Merge "[Partial Screensharing] Permission Dialog VisD polish" into tm-qpr-dev am: 0daf00ed1d

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/20520331

Change-Id: I18656747dfe2cf33217a921c7c1dd6489968efbc
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Yalan Yiue
2022-11-24 10:11:01 +00:00
committed by Automerger Merge Worker
11 changed files with 186 additions and 33 deletions

View File

@@ -0,0 +1,21 @@
<!--
~ Copyright (C) 2022 The Android Open Source Project
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
android:shape="rectangle">
<corners android:radius="@dimen/screenrecord_spinner_background_radius"/>
<solid android:color="?androidprv:attr/colorAccentSecondary" />
</shape>

View File

@@ -0,0 +1,35 @@
<!--
~ Copyright (C) 2022 The Android Open Source Project
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
android:paddingMode="stack">
<item>
<shape android:shape="rectangle">
<corners android:radius="@dimen/screenrecord_spinner_background_radius" />
<stroke
android:width="1dp"
android:color="?androidprv:attr/textColorTertiary" />
<solid android:color="@android:color/transparent"/>
</shape>
</item>
<item
android:drawable="@drawable/ic_ksh_key_down"
android:gravity="end|center_vertical"
android:textColor="?androidprv:attr/textColorPrimary"
android:width="@dimen/screenrecord_spinner_arrow_size"
android:height="@dimen/screenrecord_spinner_arrow_size"
android:end="20dp" />
</layer-list>

View File

@@ -16,7 +16,8 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
android:orientation="vertical"
android:paddingBottom="@dimen/screenrecord_options_padding_bottom">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
@@ -72,7 +73,7 @@
android:gravity="center_vertical"
android:text="@string/screenrecord_taps_label"
android:textAppearance="?android:attr/textAppearanceMedium"
android:fontFamily="@*android:string/config_headlineFontFamily"
android:fontFamily="@*android:string/config_bodyFontFamily"
android:textColor="?android:attr/textColorPrimary"
android:contentDescription="@string/screenrecord_taps_label"/>
<Switch

View File

@@ -16,7 +16,7 @@
<!-- Scrollview is necessary to fit everything in landscape layout -->
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
android:id="@+id/screen_share_permission_dialog"
android:layout_width="match_parent"
android:layout_height="match_parent">
@@ -32,10 +32,11 @@
android:gravity="center_horizontal">
<ImageView
android:id="@+id/screen_share_dialog_icon"
android:layout_width="@dimen/screenrecord_logo_size"
android:layout_height="@dimen/screenrecord_logo_size"
android:src="@drawable/ic_screenrecord"
android:tint="@color/screenrecord_icon_color"
android:src="@drawable/ic_media_projection_permission"
android:tint="?androidprv:attr/colorAccentPrimary"
android:importantForAccessibility="no"/>
<TextView
android:id="@+id/screen_share_dialog_title"
@@ -43,34 +44,37 @@
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:fontFamily="@*android:string/config_headlineFontFamily"
android:layout_marginTop="22dp"
android:layout_marginBottom="15dp"/>
android:layout_marginTop="@dimen/screenrecord_title_margin_top"
android:gravity="center"/>
<Spinner
android:id="@+id/screen_share_mode_spinner"
android:layout_width="320dp"
android:layout_height="72dp"
android:layout_marginTop="24dp"
android:layout_marginBottom="24dp" />
android:layout_width="match_parent"
android:layout_height="@dimen/screenrecord_spinner_height"
android:layout_marginTop="@dimen/screenrecord_spinner_margin"
android:layout_marginBottom="@dimen/screenrecord_spinner_margin"
android:gravity="center_vertical"
android:background="@drawable/screenshare_options_spinner_background"
android:popupBackground="@drawable/screenrecord_options_spinner_popup_background"/>
<ViewStub
android:id="@+id/options_stub"
android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<TextView
android:id="@+id/text_warning"
android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/screenrecord_description"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?android:textColorSecondary"
android:gravity="start"
android:layout_marginBottom="20dp"/>
android:lineHeight="@dimen/screenrecord_warning_line_height"/>
<!-- Buttons -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="36dp">
android:layout_marginTop="@dimen/screenrecord_buttons_margin_top">
<TextView
android:id="@+id/button_cancel"
android:layout_width="wrap_content"

View File

@@ -0,0 +1,27 @@
<!--
Copyright (C) 2022 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
android:id="@android:id/text1"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="?androidprv:attr/textColorOnAccent"
android:singleLine="true"
android:layout_width="match_parent"
android:layout_height="@dimen/screenrecord_spinner_height"
android:gravity="center_vertical"
android:ellipsize="marquee"
android:paddingStart="@dimen/screenrecord_spinner_text_padding_start"
android:paddingEnd="@dimen/screenrecord_spinner_text_padding_end"/>

View File

@@ -0,0 +1,26 @@
<!--
Copyright (C) 2022 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:textAppearance="?android:attr/textAppearanceMedium"
android:fontFamily="@*android:string/config_bodyFontFamily"
android:textColor="?android:textColorPrimary"
android:singleLine="true"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:ellipsize="marquee"
android:paddingStart="@dimen/screenrecord_spinner_text_padding_start"
android:paddingEnd="@dimen/screenrecord_spinner_text_padding_end"/>

View File

@@ -1167,7 +1167,7 @@
<!-- Screen record dialog -->
<dimen name="screenrecord_option_padding">18dp</dimen>
<dimen name="screenrecord_logo_size">26dp</dimen>
<dimen name="screenrecord_logo_size">30dp</dimen>
<dimen name="screenrecord_option_icon_size">24dp</dimen>
<!-- Screen record status bar icon -->
<dimen name="screenrecord_status_text_size">14sp</dimen>
@@ -1175,6 +1175,18 @@
<dimen name="screenrecord_status_icon_width">21dp</dimen>
<dimen name="screenrecord_status_icon_height">17.5dp</dimen>
<dimen name="screenrecord_status_icon_bg_radius">8dp</dimen>
<!-- Screen record spinner -->
<dimen name="screenrecord_spinner_height">72dp</dimen>
<dimen name="screenrecord_spinner_margin">24dp</dimen>
<dimen name="screenrecord_spinner_text_padding_start">20dp</dimen>
<dimen name="screenrecord_spinner_text_padding_end">80dp</dimen>
<dimen name="screenrecord_spinner_arrow_size">24dp</dimen>
<dimen name="screenrecord_spinner_background_radius">28dp</dimen>
<dimen name="screenrecord_title_margin_top">20dp</dimen>
<dimen name="screenrecord_warning_line_height">20dp</dimen>
<dimen name="screenrecord_options_padding_bottom">16dp</dimen>
<dimen name="screenrecord_buttons_margin_top">20dp</dimen>
<!-- Keyguard user switcher -->
<dimen name="kg_user_switcher_text_size">16sp</dimen>

View File

@@ -23,8 +23,11 @@ import android.view.ViewStub
import android.view.WindowManager
import android.widget.AdapterView
import android.widget.ArrayAdapter
import android.widget.ImageView
import android.widget.Spinner
import android.widget.TextView
import androidx.annotation.ColorRes
import androidx.annotation.DrawableRes
import androidx.annotation.LayoutRes
import androidx.annotation.StringRes
import com.android.systemui.R
@@ -34,7 +37,9 @@ import com.android.systemui.statusbar.phone.SystemUIDialog
open class BaseScreenSharePermissionDialog(
context: Context?,
private val screenShareOptions: List<ScreenShareOption>,
private val appName: String?
private val appName: String?,
@DrawableRes private val dialogIconDrawable: Int? = null,
@ColorRes private val dialogIconTint: Int? = null
) : SystemUIDialog(context), AdapterView.OnItemSelectedListener {
private lateinit var dialogTitle: TextView
private lateinit var startButton: TextView
@@ -53,10 +58,21 @@ open class BaseScreenSharePermissionDialog(
warning = findViewById(R.id.text_warning)
startButton = findViewById(R.id.button_start)
findViewById<TextView>(R.id.button_cancel).setOnClickListener { dismiss() }
updateIcon()
initScreenShareOptions()
createOptionsView(getOptionsViewLayoutId())
}
private fun updateIcon() {
val icon = findViewById<ImageView>(R.id.screen_share_dialog_icon)
if (dialogIconTint != null) {
icon.setColorFilter(context.getColor(dialogIconTint))
}
if (dialogIconDrawable != null) {
icon.setImageDrawable(context.getDrawable(dialogIconDrawable))
}
}
protected fun initScreenShareOptions() {
selectedScreenShareOption = screenShareOptions.first()
warning.text = warningText
@@ -69,8 +85,12 @@ open class BaseScreenSharePermissionDialog(
private fun initScreenShareSpinner() {
val options = screenShareOptions.map { context.getString(it.spinnerText) }.toTypedArray()
val adapter =
ArrayAdapter(context.applicationContext, android.R.layout.simple_spinner_item, options)
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
ArrayAdapter(
context.applicationContext,
R.layout.screen_share_dialog_spinner_text,
options
)
adapter.setDropDownViewResource(R.layout.screen_share_dialog_spinner_item_text)
screenShareModeSpinner = findViewById(R.id.screen_share_mode_spinner)
screenShareModeSpinner.adapter = adapter
screenShareModeSpinner.onItemSelectedListener = this

View File

@@ -40,15 +40,15 @@ class MediaProjectionPermissionDialog(
companion object {
private fun createOptionList(): List<ScreenShareOption> {
return listOf(
ScreenShareOption(
SINGLE_APP,
R.string.media_projection_permission_dialog_option_single_app,
R.string.media_projection_permission_dialog_warning_single_app
),
ScreenShareOption(
ENTIRE_SCREEN,
R.string.media_projection_permission_dialog_option_entire_screen,
R.string.media_projection_permission_dialog_warning_entire_screen
),
ScreenShareOption(
SINGLE_APP,
R.string.media_projection_permission_dialog_option_single_app,
R.string.media_projection_permission_dialog_warning_single_app
)
)
}

View File

@@ -46,7 +46,14 @@ class ScreenRecordPermissionDialog(
private val dialogLaunchAnimator: DialogLaunchAnimator,
private val userContextProvider: UserContextProvider,
private val onStartRecordingClicked: Runnable?
) : BaseScreenSharePermissionDialog(context, createOptionList(), null) {
) :
BaseScreenSharePermissionDialog(
context,
createOptionList(),
null,
R.drawable.ic_screenrecord,
R.color.screenrecord_icon_color
) {
private lateinit var tapsSwitch: Switch
private lateinit var tapsView: View
private lateinit var audioSwitch: Switch
@@ -168,15 +175,15 @@ class ScreenRecordPermissionDialog(
private const val INTERVAL_MS: Long = 1000
private fun createOptionList(): List<ScreenShareOption> {
return listOf(
ScreenShareOption(
SINGLE_APP,
R.string.screenrecord_option_single_app,
R.string.screenrecord_warning_single_app
),
ScreenShareOption(
ENTIRE_SCREEN,
R.string.screenrecord_option_entire_screen,
R.string.screenrecord_warning_entire_screen
),
ScreenShareOption(
SINGLE_APP,
R.string.screenrecord_option_single_app,
R.string.screenrecord_warning_single_app
)
)
}

View File

@@ -20,11 +20,11 @@ import androidx.annotation.StringRes
import kotlin.annotation.Retention
@Retention(AnnotationRetention.SOURCE)
@IntDef(SINGLE_APP, ENTIRE_SCREEN)
@IntDef(ENTIRE_SCREEN, SINGLE_APP)
annotation class ScreenShareMode
const val SINGLE_APP = 0
const val ENTIRE_SCREEN = 1
const val ENTIRE_SCREEN = 0
const val SINGLE_APP = 1
class ScreenShareOption(
@ScreenShareMode val mode: Int,