[Screen share] Make start button text be option-specific.
With the new dialog UX, the start button text is different depending on
whether "single app" or "entire screen" is selected. This CL makes that
text be set when an option is created, and also updates the cast dialog
to use different text in the two cases. (Record and share updates will
be in a future CL.)
Bug: 352327853
Flag: NONE string changes
Test: Cast screen to other device -> verify start button text is "Next"
when selecting single app option, but "Cast screen" when selecting
entire screen option
Test: Screen record -> verify start button text stays the same
Test: Share to app -> verify start button text stays the same
Test: atest SystemCastPermissionDialogDelegateTest
Change-Id: Ie4bbe23826f0862beda73d69536f9a74e84e1983
diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml
index 19eebf5..dd4ede4 100644
--- a/packages/SystemUI/res/values/strings.xml
+++ b/packages/SystemUI/res/values/strings.xml
@@ -1389,7 +1389,7 @@
<!-- System casting media projection permission warning for capturing a single app when SysUI casting requests it. [CHAR LIMIT=350] -->
<string name="media_projection_entry_cast_permission_dialog_warning_single_app">When you’re casting an app, anything shown or played in that app is visible. So be careful with things like passwords, payment details, messages, photos, and audio and video.</string>
<!-- System casting media projection permission button to continue for SysUI casting. [CHAR LIMIT=60] -->
- <string name="media_projection_entry_cast_permission_dialog_continue">Start casting</string>
+ <string name="media_projection_entry_cast_permission_dialog_continue_entire_screen">Cast screen</string>
<!-- Other sharing (not recording nor casting) that launched by SysUI (currently not in use) -->
<!-- System sharing media projection permission dialog title. [CHAR LIMIT=100] -->
@@ -1400,6 +1400,8 @@
<string name="media_projection_entry_generic_permission_dialog_warning_single_app">When you’re sharing, recording, or casting an app, Android has access to anything shown or played on that app. So be careful with things like passwords, payment details, messages, photos, and audio and video.</string>
<!-- System sharing media projection permission button to continue. [CHAR LIMIT=60] -->
<string name="media_projection_entry_generic_permission_dialog_continue">Start</string>
+ <!-- System sharing media projection permission button to continue to the next step. [CHAR LIMIT=60] -->
+ <string name="media_projection_entry_generic_permission_dialog_continue_single_app">Next</string>
<!-- Task switcher notification -->
<!-- Task switcher notification text. [CHAR LIMIT=100] -->
diff --git a/packages/SystemUI/src/com/android/systemui/mediaprojection/permission/BaseMediaProjectionPermissionDialogDelegate.kt b/packages/SystemUI/src/com/android/systemui/mediaprojection/permission/BaseMediaProjectionPermissionDialogDelegate.kt
index 83f694b..cdf8f06 100644
--- a/packages/SystemUI/src/com/android/systemui/mediaprojection/permission/BaseMediaProjectionPermissionDialogDelegate.kt
+++ b/packages/SystemUI/src/com/android/systemui/mediaprojection/permission/BaseMediaProjectionPermissionDialogDelegate.kt
@@ -95,13 +95,16 @@
private fun initScreenShareOptions() {
selectedScreenShareOption = screenShareOptions.first { it.mode == defaultSelectedMode }
- warning.text = warningText
+ setOptionSpecificFields()
initScreenShareSpinner()
}
private val warningText: String
get() = dialog.context.getString(selectedScreenShareOption.warningText, appName)
+ private val startButtonText: String
+ get() = dialog.context.getString(selectedScreenShareOption.startButtonText)
+
private fun initScreenShareSpinner() {
val adapter = OptionsAdapter(dialog.context.applicationContext, screenShareOptions)
screenShareModeSpinner = dialog.requireViewById(R.id.screen_share_mode_options)
@@ -126,7 +129,13 @@
override fun onItemSelected(adapterView: AdapterView<*>?, view: View, pos: Int, id: Long) {
selectedScreenShareOption = screenShareOptions[pos]
+ setOptionSpecificFields()
+ }
+
+ /** Sets fields on the dialog that change based on which option is selected. */
+ private fun setOptionSpecificFields() {
warning.text = warningText
+ startButton.text = startButtonText
}
override fun onNothingSelected(parent: AdapterView<*>?) {}
@@ -137,10 +146,6 @@
dialogTitle.text = title
}
- protected fun setStartButtonText(@StringRes stringId: Int) {
- startButton.setText(stringId)
- }
-
protected fun setStartButtonOnClickListener(listener: View.OnClickListener?) {
startButton.setOnClickListener { view ->
shouldLogCancel = false
diff --git a/packages/SystemUI/src/com/android/systemui/mediaprojection/permission/ScreenShareOption.kt b/packages/SystemUI/src/com/android/systemui/mediaprojection/permission/ScreenShareOption.kt
index 9bd5783..ab92173 100644
--- a/packages/SystemUI/src/com/android/systemui/mediaprojection/permission/ScreenShareOption.kt
+++ b/packages/SystemUI/src/com/android/systemui/mediaprojection/permission/ScreenShareOption.kt
@@ -26,9 +26,10 @@
const val SINGLE_APP = 0
const val ENTIRE_SCREEN = 1
-class ScreenShareOption(
+data class ScreenShareOption(
@ScreenShareMode val mode: Int,
@StringRes val spinnerText: Int,
@StringRes val warningText: Int,
+ @StringRes val startButtonText: Int,
val spinnerDisabledText: String? = null,
)
diff --git a/packages/SystemUI/src/com/android/systemui/mediaprojection/permission/ShareToAppPermissionDialogDelegate.kt b/packages/SystemUI/src/com/android/systemui/mediaprojection/permission/ShareToAppPermissionDialogDelegate.kt
index 5a2d88c..8bf2202 100644
--- a/packages/SystemUI/src/com/android/systemui/mediaprojection/permission/ShareToAppPermissionDialogDelegate.kt
+++ b/packages/SystemUI/src/com/android/systemui/mediaprojection/permission/ShareToAppPermissionDialogDelegate.kt
@@ -53,7 +53,6 @@
super.onCreate(dialog, savedInstanceState)
// TODO(b/270018943): Handle the case of System sharing (not recording nor casting)
setDialogTitle(R.string.media_projection_entry_app_permission_dialog_title)
- setStartButtonText(R.string.media_projection_entry_app_permission_dialog_continue)
setStartButtonOnClickListener {
// Note that it is important to run this callback before dismissing, so that the
// callback can disable the dialog exit animation if it wants to.
@@ -88,6 +87,8 @@
warningText =
R.string
.media_projection_entry_app_permission_dialog_warning_single_app,
+ startButtonText =
+ R.string.media_projection_entry_app_permission_dialog_continue,
spinnerDisabledText = singleAppDisabledText,
),
ScreenShareOption(
@@ -96,6 +97,8 @@
warningText =
R.string
.media_projection_entry_app_permission_dialog_warning_entire_screen,
+ startButtonText =
+ R.string.media_projection_entry_app_permission_dialog_continue,
)
)
return if (singleAppDisabledText != null) {
diff --git a/packages/SystemUI/src/com/android/systemui/mediaprojection/permission/SystemCastPermissionDialogDelegate.kt b/packages/SystemUI/src/com/android/systemui/mediaprojection/permission/SystemCastPermissionDialogDelegate.kt
index 1ac3ccd..a19fb96 100644
--- a/packages/SystemUI/src/com/android/systemui/mediaprojection/permission/SystemCastPermissionDialogDelegate.kt
+++ b/packages/SystemUI/src/com/android/systemui/mediaprojection/permission/SystemCastPermissionDialogDelegate.kt
@@ -52,7 +52,6 @@
super.onCreate(dialog, savedInstanceState)
// TODO(b/270018943): Handle the case of System sharing (not recording nor casting)
setDialogTitle(R.string.media_projection_entry_cast_permission_dialog_title)
- setStartButtonText(R.string.media_projection_entry_cast_permission_dialog_continue)
setStartButtonOnClickListener {
// Note that it is important to run this callback before dismissing, so that the
// callback can disable the dialog exit animation if it wants to.
@@ -89,6 +88,9 @@
warningText =
R.string
.media_projection_entry_cast_permission_dialog_warning_single_app,
+ startButtonText =
+ R.string
+ .media_projection_entry_generic_permission_dialog_continue_single_app,
spinnerDisabledText = singleAppDisabledText,
),
ScreenShareOption(
@@ -99,6 +101,9 @@
warningText =
R.string
.media_projection_entry_cast_permission_dialog_warning_entire_screen,
+ startButtonText =
+ R.string
+ .media_projection_entry_cast_permission_dialog_continue_entire_screen,
)
)
return if (singleAppDisabledText != null) {
diff --git a/packages/SystemUI/src/com/android/systemui/screenrecord/ScreenRecordPermissionDialogDelegate.kt b/packages/SystemUI/src/com/android/systemui/screenrecord/ScreenRecordPermissionDialogDelegate.kt
index ab6067c..b54bf6c 100644
--- a/packages/SystemUI/src/com/android/systemui/screenrecord/ScreenRecordPermissionDialogDelegate.kt
+++ b/packages/SystemUI/src/com/android/systemui/screenrecord/ScreenRecordPermissionDialogDelegate.kt
@@ -125,7 +125,6 @@
super<BaseMediaProjectionPermissionDialogDelegate>.onCreate(dialog, savedInstanceState)
setDialogTitle(R.string.screenrecord_permission_dialog_title)
dialog.setTitle(R.string.screenrecord_title)
- setStartButtonText(R.string.screenrecord_permission_dialog_continue)
setStartButtonOnClickListener { v: View? ->
onStartRecordingClicked?.run()
if (selectedScreenShareOption.mode == ENTIRE_SCREEN) {
@@ -272,12 +271,14 @@
ScreenShareOption(
SINGLE_APP,
R.string.screen_share_permission_dialog_option_single_app,
- R.string.screenrecord_permission_dialog_warning_single_app
+ R.string.screenrecord_permission_dialog_warning_single_app,
+ startButtonText = R.string.screenrecord_permission_dialog_continue,
),
ScreenShareOption(
ENTIRE_SCREEN,
R.string.screen_share_permission_dialog_option_entire_screen,
- R.string.screenrecord_permission_dialog_warning_entire_screen
+ R.string.screenrecord_permission_dialog_warning_entire_screen,
+ startButtonText = R.string.screenrecord_permission_dialog_continue,
)
)
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/mediaprojection/permission/SystemCastPermissionDialogDelegateTest.kt b/packages/SystemUI/tests/src/com/android/systemui/mediaprojection/permission/SystemCastPermissionDialogDelegateTest.kt
index 59602dc..6495b66 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/mediaprojection/permission/SystemCastPermissionDialogDelegateTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/mediaprojection/permission/SystemCastPermissionDialogDelegateTest.kt
@@ -29,6 +29,7 @@
import com.android.systemui.res.R
import com.android.systemui.statusbar.phone.AlertDialogWithDelegate
import com.android.systemui.statusbar.phone.SystemUIDialog
+import com.google.common.truth.Truth.assertThat
import kotlin.test.assertEquals
import org.junit.After
import org.junit.Test
@@ -117,6 +118,36 @@
assertEquals(context.getString(resIdFullScreen), secondOptionText)
}
+ @Test
+ fun startButtonText_entireScreenSelected() {
+ setUpAndShowDialog()
+ onSpinnerItemSelected(ENTIRE_SCREEN)
+
+ val startButtonText = dialog.requireViewById<TextView>(android.R.id.button1).text
+
+ assertThat(startButtonText)
+ .isEqualTo(
+ context.getString(
+ R.string.media_projection_entry_cast_permission_dialog_continue_entire_screen
+ )
+ )
+ }
+
+ @Test
+ fun startButtonText_singleAppSelected() {
+ setUpAndShowDialog()
+ onSpinnerItemSelected(SINGLE_APP)
+
+ val startButtonText = dialog.requireViewById<TextView>(android.R.id.button1).text
+
+ assertThat(startButtonText)
+ .isEqualTo(
+ context.getString(
+ R.string.media_projection_entry_generic_permission_dialog_continue_single_app
+ )
+ )
+ }
+
private fun setUpAndShowDialog(
mediaProjectionConfig: MediaProjectionConfig? = null,
overrideDisableSingleAppOption: Boolean = false,
@@ -144,4 +175,10 @@
delegate.onCreate(dialog, savedInstanceState = null)
dialog.show()
}
+
+ private fun onSpinnerItemSelected(position: Int) {
+ val spinner = dialog.requireViewById<Spinner>(R.id.screen_share_mode_options)
+ checkNotNull(spinner.onItemSelectedListener)
+ .onItemSelected(spinner, mock(), position, /* id= */ 0)
+ }
}