Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 22a5dfe1 authored by Caitlin Shkuratov's avatar Caitlin Shkuratov Committed by Android (Google) Code Review
Browse files

Merge "[Screen share] Make start button text be option-specific." into main

parents 275624f6 ebdf56f7
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -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] -->
+10 −5
Original line number Diff line number Diff line
@@ -95,13 +95,16 @@ abstract class BaseMediaProjectionPermissionDialogDelegate<T : AlertDialog>(

    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 @@ abstract class BaseMediaProjectionPermissionDialogDelegate<T : AlertDialog>(

    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 @@ abstract class BaseMediaProjectionPermissionDialogDelegate<T : AlertDialog>(
        dialogTitle.text = title
    }

    protected fun setStartButtonText(@StringRes stringId: Int) {
        startButton.setText(stringId)
    }

    protected fun setStartButtonOnClickListener(listener: View.OnClickListener?) {
        startButton.setOnClickListener { view ->
            shouldLogCancel = false
+2 −1
Original line number Diff line number Diff line
@@ -26,9 +26,10 @@ annotation class ScreenShareMode
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,
)
+4 −1
Original line number Diff line number Diff line
@@ -53,7 +53,6 @@ class ShareToAppPermissionDialogDelegate(
        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 @@ class ShareToAppPermissionDialogDelegate(
                        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 @@ class ShareToAppPermissionDialogDelegate(
                        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) {
+6 −1
Original line number Diff line number Diff line
@@ -52,7 +52,6 @@ class SystemCastPermissionDialogDelegate(
        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 @@ class SystemCastPermissionDialogDelegate(
                        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 @@ class SystemCastPermissionDialogDelegate(
                        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) {
Loading