Merge "[Partial Screensharing] Permission Dialog VisD polish" into tm-qpr-dev

This commit is contained in:
Yalan Yiue
2022-11-24 09:42:38 +00:00
committed by Android (Google) Code Review
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" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical"> android:orientation="vertical"
android:paddingBottom="@dimen/screenrecord_options_padding_bottom">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@@ -72,7 +73,7 @@
android:gravity="center_vertical" android:gravity="center_vertical"
android:text="@string/screenrecord_taps_label" android:text="@string/screenrecord_taps_label"
android:textAppearance="?android:attr/textAppearanceMedium" android:textAppearance="?android:attr/textAppearanceMedium"
android:fontFamily="@*android:string/config_headlineFontFamily" android:fontFamily="@*android:string/config_bodyFontFamily"
android:textColor="?android:attr/textColorPrimary" android:textColor="?android:attr/textColorPrimary"
android:contentDescription="@string/screenrecord_taps_label"/> android:contentDescription="@string/screenrecord_taps_label"/>
<Switch <Switch

View File

@@ -16,7 +16,7 @@
<!-- Scrollview is necessary to fit everything in landscape layout --> <!-- Scrollview is necessary to fit everything in landscape layout -->
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" <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:id="@+id/screen_share_permission_dialog"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
@@ -32,10 +32,11 @@
android:gravity="center_horizontal"> android:gravity="center_horizontal">
<ImageView <ImageView
android:id="@+id/screen_share_dialog_icon"
android:layout_width="@dimen/screenrecord_logo_size" android:layout_width="@dimen/screenrecord_logo_size"
android:layout_height="@dimen/screenrecord_logo_size" android:layout_height="@dimen/screenrecord_logo_size"
android:src="@drawable/ic_screenrecord" android:src="@drawable/ic_media_projection_permission"
android:tint="@color/screenrecord_icon_color" android:tint="?androidprv:attr/colorAccentPrimary"
android:importantForAccessibility="no"/> android:importantForAccessibility="no"/>
<TextView <TextView
android:id="@+id/screen_share_dialog_title" android:id="@+id/screen_share_dialog_title"
@@ -43,34 +44,37 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge" android:textAppearance="?android:attr/textAppearanceLarge"
android:fontFamily="@*android:string/config_headlineFontFamily" android:fontFamily="@*android:string/config_headlineFontFamily"
android:layout_marginTop="22dp" android:layout_marginTop="@dimen/screenrecord_title_margin_top"
android:layout_marginBottom="15dp"/> android:gravity="center"/>
<Spinner <Spinner
android:id="@+id/screen_share_mode_spinner" android:id="@+id/screen_share_mode_spinner"
android:layout_width="320dp" android:layout_width="match_parent"
android:layout_height="72dp" android:layout_height="@dimen/screenrecord_spinner_height"
android:layout_marginTop="24dp" android:layout_marginTop="@dimen/screenrecord_spinner_margin"
android:layout_marginBottom="24dp" /> 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 <ViewStub
android:id="@+id/options_stub" android:id="@+id/options_stub"
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="wrap_content"/> android:layout_height="wrap_content"/>
<TextView <TextView
android:id="@+id/text_warning" android:id="@+id/text_warning"
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/screenrecord_description" android:text="@string/screenrecord_description"
android:textAppearance="?android:attr/textAppearanceSmall" android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?android:textColorSecondary" android:textColor="?android:textColorSecondary"
android:gravity="start" android:gravity="start"
android:layout_marginBottom="20dp"/> android:lineHeight="@dimen/screenrecord_warning_line_height"/>
<!-- Buttons --> <!-- Buttons -->
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal" android:orientation="horizontal"
android:layout_marginTop="36dp"> android:layout_marginTop="@dimen/screenrecord_buttons_margin_top">
<TextView <TextView
android:id="@+id/button_cancel" android:id="@+id/button_cancel"
android:layout_width="wrap_content" 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 --> <!-- Screen record dialog -->
<dimen name="screenrecord_option_padding">18dp</dimen> <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> <dimen name="screenrecord_option_icon_size">24dp</dimen>
<!-- Screen record status bar icon --> <!-- Screen record status bar icon -->
<dimen name="screenrecord_status_text_size">14sp</dimen> <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_width">21dp</dimen>
<dimen name="screenrecord_status_icon_height">17.5dp</dimen> <dimen name="screenrecord_status_icon_height">17.5dp</dimen>
<dimen name="screenrecord_status_icon_bg_radius">8dp</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 --> <!-- Keyguard user switcher -->
<dimen name="kg_user_switcher_text_size">16sp</dimen> <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.view.WindowManager
import android.widget.AdapterView import android.widget.AdapterView
import android.widget.ArrayAdapter import android.widget.ArrayAdapter
import android.widget.ImageView
import android.widget.Spinner import android.widget.Spinner
import android.widget.TextView import android.widget.TextView
import androidx.annotation.ColorRes
import androidx.annotation.DrawableRes
import androidx.annotation.LayoutRes import androidx.annotation.LayoutRes
import androidx.annotation.StringRes import androidx.annotation.StringRes
import com.android.systemui.R import com.android.systemui.R
@@ -34,7 +37,9 @@ import com.android.systemui.statusbar.phone.SystemUIDialog
open class BaseScreenSharePermissionDialog( open class BaseScreenSharePermissionDialog(
context: Context?, context: Context?,
private val screenShareOptions: List<ScreenShareOption>, 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 { ) : SystemUIDialog(context), AdapterView.OnItemSelectedListener {
private lateinit var dialogTitle: TextView private lateinit var dialogTitle: TextView
private lateinit var startButton: TextView private lateinit var startButton: TextView
@@ -53,10 +58,21 @@ open class BaseScreenSharePermissionDialog(
warning = findViewById(R.id.text_warning) warning = findViewById(R.id.text_warning)
startButton = findViewById(R.id.button_start) startButton = findViewById(R.id.button_start)
findViewById<TextView>(R.id.button_cancel).setOnClickListener { dismiss() } findViewById<TextView>(R.id.button_cancel).setOnClickListener { dismiss() }
updateIcon()
initScreenShareOptions() initScreenShareOptions()
createOptionsView(getOptionsViewLayoutId()) 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() { protected fun initScreenShareOptions() {
selectedScreenShareOption = screenShareOptions.first() selectedScreenShareOption = screenShareOptions.first()
warning.text = warningText warning.text = warningText
@@ -69,8 +85,12 @@ open class BaseScreenSharePermissionDialog(
private fun initScreenShareSpinner() { private fun initScreenShareSpinner() {
val options = screenShareOptions.map { context.getString(it.spinnerText) }.toTypedArray() val options = screenShareOptions.map { context.getString(it.spinnerText) }.toTypedArray()
val adapter = val adapter =
ArrayAdapter(context.applicationContext, android.R.layout.simple_spinner_item, options) ArrayAdapter(
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item) 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 = findViewById(R.id.screen_share_mode_spinner)
screenShareModeSpinner.adapter = adapter screenShareModeSpinner.adapter = adapter
screenShareModeSpinner.onItemSelectedListener = this screenShareModeSpinner.onItemSelectedListener = this

View File

@@ -40,15 +40,15 @@ class MediaProjectionPermissionDialog(
companion object { companion object {
private fun createOptionList(): List<ScreenShareOption> { private fun createOptionList(): List<ScreenShareOption> {
return listOf( return listOf(
ScreenShareOption(
SINGLE_APP,
R.string.media_projection_permission_dialog_option_single_app,
R.string.media_projection_permission_dialog_warning_single_app
),
ScreenShareOption( ScreenShareOption(
ENTIRE_SCREEN, ENTIRE_SCREEN,
R.string.media_projection_permission_dialog_option_entire_screen, R.string.media_projection_permission_dialog_option_entire_screen,
R.string.media_projection_permission_dialog_warning_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 dialogLaunchAnimator: DialogLaunchAnimator,
private val userContextProvider: UserContextProvider, private val userContextProvider: UserContextProvider,
private val onStartRecordingClicked: Runnable? 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 tapsSwitch: Switch
private lateinit var tapsView: View private lateinit var tapsView: View
private lateinit var audioSwitch: Switch private lateinit var audioSwitch: Switch
@@ -168,15 +175,15 @@ class ScreenRecordPermissionDialog(
private const val INTERVAL_MS: Long = 1000 private const val INTERVAL_MS: Long = 1000
private fun createOptionList(): List<ScreenShareOption> { private fun createOptionList(): List<ScreenShareOption> {
return listOf( return listOf(
ScreenShareOption(
SINGLE_APP,
R.string.screenrecord_option_single_app,
R.string.screenrecord_warning_single_app
),
ScreenShareOption( ScreenShareOption(
ENTIRE_SCREEN, ENTIRE_SCREEN,
R.string.screenrecord_option_entire_screen, R.string.screenrecord_option_entire_screen,
R.string.screenrecord_warning_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 import kotlin.annotation.Retention
@Retention(AnnotationRetention.SOURCE) @Retention(AnnotationRetention.SOURCE)
@IntDef(SINGLE_APP, ENTIRE_SCREEN) @IntDef(ENTIRE_SCREEN, SINGLE_APP)
annotation class ScreenShareMode annotation class ScreenShareMode
const val SINGLE_APP = 0 const val ENTIRE_SCREEN = 0
const val ENTIRE_SCREEN = 1 const val SINGLE_APP = 1
class ScreenShareOption( class ScreenShareOption(
@ScreenShareMode val mode: Int, @ScreenShareMode val mode: Int,