Merge "[Partial Screensharing] Permission Dialog VisD polish" into tm-qpr-dev
diff --git a/packages/SystemUI/res/drawable/screenrecord_options_spinner_popup_background.xml b/packages/SystemUI/res/drawable/screenrecord_options_spinner_popup_background.xml
new file mode 100644
index 0000000..9a02296
--- /dev/null
+++ b/packages/SystemUI/res/drawable/screenrecord_options_spinner_popup_background.xml
@@ -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>
\ No newline at end of file
diff --git a/packages/SystemUI/res/drawable/screenshare_options_spinner_background.xml b/packages/SystemUI/res/drawable/screenshare_options_spinner_background.xml
new file mode 100644
index 0000000..34e7d0a
--- /dev/null
+++ b/packages/SystemUI/res/drawable/screenshare_options_spinner_background.xml
@@ -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>
\ No newline at end of file
diff --git a/packages/SystemUI/res/layout/screen_record_options.xml b/packages/SystemUI/res/layout/screen_record_options.xml
index d6c9e98..3f0eea9 100644
--- a/packages/SystemUI/res/layout/screen_record_options.xml
+++ b/packages/SystemUI/res/layout/screen_record_options.xml
@@ -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
diff --git a/packages/SystemUI/res/layout/screen_share_dialog.xml b/packages/SystemUI/res/layout/screen_share_dialog.xml
index ac46cdb..bd71989 100644
--- a/packages/SystemUI/res/layout/screen_share_dialog.xml
+++ b/packages/SystemUI/res/layout/screen_share_dialog.xml
@@ -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"
diff --git a/packages/SystemUI/res/layout/screen_share_dialog_spinner_item_text.xml b/packages/SystemUI/res/layout/screen_share_dialog_spinner_item_text.xml
new file mode 100644
index 0000000..66c2155
--- /dev/null
+++ b/packages/SystemUI/res/layout/screen_share_dialog_spinner_item_text.xml
@@ -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"/>
\ No newline at end of file
diff --git a/packages/SystemUI/res/layout/screen_share_dialog_spinner_text.xml b/packages/SystemUI/res/layout/screen_share_dialog_spinner_text.xml
new file mode 100644
index 0000000..4cc4cba
--- /dev/null
+++ b/packages/SystemUI/res/layout/screen_share_dialog_spinner_text.xml
@@ -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"/>
\ No newline at end of file
diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml
index f223eb7..2a0e64a 100644
--- a/packages/SystemUI/res/values/dimens.xml
+++ b/packages/SystemUI/res/values/dimens.xml
@@ -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>
diff --git a/packages/SystemUI/src/com/android/systemui/screenrecord/BaseScreenSharePermissionDialog.kt b/packages/SystemUI/src/com/android/systemui/screenrecord/BaseScreenSharePermissionDialog.kt
index f4d59a8..db0052a 100644
--- a/packages/SystemUI/src/com/android/systemui/screenrecord/BaseScreenSharePermissionDialog.kt
+++ b/packages/SystemUI/src/com/android/systemui/screenrecord/BaseScreenSharePermissionDialog.kt
@@ -23,8 +23,11 @@
 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 @@
 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 @@
         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 @@
     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
diff --git a/packages/SystemUI/src/com/android/systemui/screenrecord/MediaProjectionPermissionDialog.kt b/packages/SystemUI/src/com/android/systemui/screenrecord/MediaProjectionPermissionDialog.kt
index 15b0bc4..e56ab99 100644
--- a/packages/SystemUI/src/com/android/systemui/screenrecord/MediaProjectionPermissionDialog.kt
+++ b/packages/SystemUI/src/com/android/systemui/screenrecord/MediaProjectionPermissionDialog.kt
@@ -41,14 +41,14 @@
         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
                 )
             )
         }
diff --git a/packages/SystemUI/src/com/android/systemui/screenrecord/ScreenRecordPermissionDialog.kt b/packages/SystemUI/src/com/android/systemui/screenrecord/ScreenRecordPermissionDialog.kt
index 19bb15a..44b18ec 100644
--- a/packages/SystemUI/src/com/android/systemui/screenrecord/ScreenRecordPermissionDialog.kt
+++ b/packages/SystemUI/src/com/android/systemui/screenrecord/ScreenRecordPermissionDialog.kt
@@ -46,7 +46,14 @@
     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
@@ -169,14 +176,14 @@
         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
                 )
             )
         }
diff --git a/packages/SystemUI/src/com/android/systemui/screenrecord/ScreenShareOption.kt b/packages/SystemUI/src/com/android/systemui/screenrecord/ScreenShareOption.kt
index 914d29a..3d39fd8 100644
--- a/packages/SystemUI/src/com/android/systemui/screenrecord/ScreenShareOption.kt
+++ b/packages/SystemUI/src/com/android/systemui/screenrecord/ScreenShareOption.kt
@@ -20,11 +20,11 @@
 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,