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

Commit 7a95f759 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "[Screen share] Update strings and icon for share-to-app dialog." into main

parents 86dd6eb6 201e52f0
Loading
Loading
Loading
Loading
+9 −4
Original line number Diff line number Diff line
@@ -1367,13 +1367,18 @@

    <!-- Media projection that launched from 1P/3P apps -->
    <!-- 1P/3P app media projection permission dialog title. [CHAR LIMIT=NONE] -->
    <string name="media_projection_entry_app_permission_dialog_title">Start recording or casting with <xliff:g id="app_seeking_permission" example="Meet">%s</xliff:g>?</string>
    <string name="media_projection_entry_app_permission_dialog_title">Share your screen with <xliff:g id="app_seeking_permission" example="Meet">%s</xliff:g>?</string>

    <!-- 1P/3P app media projection permission option for capturing just a single app [CHAR LIMIT=50] -->
    <string name="media_projection_entry_app_permission_dialog_option_text_single_app">Share one app</string>
    <!-- 1P/3P app media projection permission option for capturing the whole screen [CHAR LIMIT=50] -->
    <string name="media_projection_entry_app_permission_dialog_option_text_entire_screen">Share entire screen</string>
    <!-- 1P/3P app media projection permission warning for capturing the whole screen. [CHAR LIMIT=350] -->
    <string name="media_projection_entry_app_permission_dialog_warning_entire_screen">When you’re sharing, recording, or casting, <xliff:g id="app_seeking_permission" example="Meet">%s</xliff:g> has access to anything visible on your screen or played on your device. So be careful with things like passwords, payment details, messages, photos, and audio and video.</string>
    <string name="media_projection_entry_app_permission_dialog_warning_entire_screen">When you’re sharing your entire screen, anything on your screen is visible to <xliff:g id="app_seeking_permission" example="Meet">%s</xliff:g>. So be careful with things like passwords, payment details, messages, photos, and audio and video.</string>
    <!-- 1P/3P app media projection permission warning for capturing an app. [CHAR LIMIT=350] -->
    <string name="media_projection_entry_app_permission_dialog_warning_single_app">When you’re sharing, recording, or casting an app, <xliff:g id="app_seeking_permission" example="Meet">%s</xliff:g> 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>
    <string name="media_projection_entry_app_permission_dialog_warning_single_app">When you’re sharing an app, anything shown or played in that app is visible to <xliff:g id="app_seeking_permission" example="Meet">%s</xliff:g>. So be careful with things like passwords, payment details, messages, photos, and audio and video.</string>
    <!-- 1P/3P apps media projection permission button to continue with app selection or recording [CHAR LIMIT=60] -->
    <string name="media_projection_entry_app_permission_dialog_continue">Start</string>
    <string name="media_projection_entry_app_permission_dialog_continue_entire_screen">Share screen</string>
    <!-- 1P/3P apps disabled the single app projection option. [CHAR LIMIT=NONE] -->
    <string name="media_projection_entry_app_permission_dialog_single_app_disabled"><xliff:g id="app_name" example="Meet">%1$s</xliff:g> has disabled this option</string>

+11 −4
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@ class ShareToAppPermissionDialogDelegate(
        appName,
        hostUid,
        mediaProjectionMetricsLogger,
        dialogIconDrawable = R.drawable.ic_present_to_all,
    ) {
    override fun onCreate(dialog: AlertDialog, savedInstanceState: Bundle?) {
        super.onCreate(dialog, savedInstanceState)
@@ -83,22 +84,28 @@ class ShareToAppPermissionDialogDelegate(
                listOf(
                    ScreenShareOption(
                        mode = SINGLE_APP,
                        spinnerText = R.string.screen_share_permission_dialog_option_single_app,
                        spinnerText =
                            R.string
                                .media_projection_entry_app_permission_dialog_option_text_single_app,
                        warningText =
                            R.string
                                .media_projection_entry_app_permission_dialog_warning_single_app,
                        startButtonText =
                            R.string.media_projection_entry_app_permission_dialog_continue,
                            R.string
                                .media_projection_entry_generic_permission_dialog_continue_single_app,
                        spinnerDisabledText = singleAppDisabledText,
                    ),
                    ScreenShareOption(
                        mode = ENTIRE_SCREEN,
                        spinnerText = R.string.screen_share_permission_dialog_option_entire_screen,
                        spinnerText =
                            R.string
                                .media_projection_entry_app_permission_dialog_option_text_entire_screen,
                        warningText =
                            R.string
                                .media_projection_entry_app_permission_dialog_warning_entire_screen,
                        startButtonText =
                            R.string.media_projection_entry_app_permission_dialog_continue,
                            R.string
                                .media_projection_entry_app_permission_dialog_continue_entire_screen,
                    )
                )
            return if (singleAppDisabledText != null) {
+41 −2
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import com.android.systemui.mediaprojection.MediaProjectionMetricsLogger
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
@@ -44,8 +45,10 @@ class ShareToAppPermissionDialogDelegateTest : SysuiTestCase() {

    private val appName = "Test App"

    private val resIdSingleApp = R.string.screen_share_permission_dialog_option_single_app
    private val resIdFullScreen = R.string.screen_share_permission_dialog_option_entire_screen
    private val resIdSingleApp =
        R.string.media_projection_entry_app_permission_dialog_option_text_single_app
    private val resIdFullScreen =
        R.string.media_projection_entry_app_permission_dialog_option_text_entire_screen
    private val resIdSingleAppDisabled =
        R.string.media_projection_entry_app_permission_dialog_single_app_disabled

@@ -115,6 +118,36 @@ class ShareToAppPermissionDialogDelegateTest : SysuiTestCase() {
        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_app_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,
@@ -142,4 +175,10 @@ class ShareToAppPermissionDialogDelegateTest : SysuiTestCase() {
        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)
    }
}