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

Commit 15db7cdf authored by Julia Reynolds's avatar Julia Reynolds
Browse files

Don't be clever with strings

The app ops strings were not translating well, leading to
crashes in some languages

Test: atest SystemUITests
Change-Id: Iee18504217c5c13543ad130f502695e3919d7ddf
Fixes: 77640411
parent f738feb7
Loading
Loading
Loading
Loading
+14 −15
Original line number Diff line number Diff line
@@ -1567,21 +1567,20 @@
    <!-- Notification: Control panel: Label that displays when the app's notifications cannot be blocked. -->
    <string name="notification_unblockable_desc">These notifications can\'t be turned off</string>

    <string name="notification_appops_camera_active">camera</string>

    <string name="notification_appops_microphone_active">microphone</string>

    <string name="notification_appops_overlay_active">displaying over other apps on your screen</string>

    <plurals name="notification_appops">
        <item quantity="one">This app is <xliff:g id="performing activity" example="using the camera">%1$s</xliff:g>.</item>
        <item quantity="other">This app is <xliff:g id="performing activity" example="using the camera">%1$s</xliff:g> and <xliff:g id="performing activity" example="using the microphone">%2$s</xliff:g>.</item>
    </plurals>

    <plurals name="notification_using">
        <item quantity="one">using the <xliff:g id="performing activity" example="camera">%1$s</xliff:g></item>
        <item quantity="other">using the <xliff:g id="performing activity" example="camera">%1$s</xliff:g> and <xliff:g id="performing activity" example="microphone">%2$s</xliff:g></item>
    </plurals>
    <!-- Notification Inline controls: describes what the app is doing in the background [CHAR_LIMIT=NONE] -->
    <string name="appops_camera">This app is using the camera.</string>
    <!-- Notification Inline controls: describes what the app is doing in the background [CHAR_LIMIT=NONE] -->
    <string name="appops_microphone">This app is using the microphone.</string>
    <!-- Notification Inline controls: describes what the app is doing in the background [CHAR_LIMIT=NONE] -->
    <string name="appops_overlay">This app is displaying over other apps on your screen.</string>
    <!-- Notification Inline controls: describes what the app is doing in the background [CHAR_LIMIT=NONE] -->
    <string name="appops_camera_mic">This app is using the microphone and camera.</string>
    <!-- Notification Inline controls: describes what the app is doing in the background [CHAR_LIMIT=NONE] -->
    <string name="appops_camera_overlay">This app is displaying over other apps on your screen and using the camera.</string>
    <!-- Notification Inline controls: describes what the app is doing in the background [CHAR_LIMIT=NONE] -->
    <string name="appops_mic_overlay">This app is displaying over other apps on your screen and using the microphone.</string>
    <!-- Notification Inline controls: describes what the app is doing in the background [CHAR_LIMIT=NONE] -->
    <string name="appops_camera_mic_overlay">This app is displaying over other apps on your screen and using the microphone and camera.</string>

    <string name="notification_appops_settings">Settings</string>
    <string name="notification_appops_ok">OK</string>
+21 −32
Original line number Diff line number Diff line
@@ -109,7 +109,7 @@ public class AppOpsInfo extends LinearLayout implements NotificationGuts.GutsCon

    private void bindPrompt() {
        final TextView prompt = findViewById(R.id.prompt);
        prompt.setText(getPromptString());
        prompt.setText(getPrompt());
    }

    private void bindButtons() {
@@ -121,41 +121,30 @@ public class AppOpsInfo extends LinearLayout implements NotificationGuts.GutsCon
        ok.setOnClickListener(mOnOk);
    }

    private String getPromptString() {
        String cameraString =
                mContext.getResources().getString(R.string.notification_appops_camera_active);
        String micString =
                mContext.getResources().getString(R.string.notification_appops_microphone_active);
        String overlayString =
                mContext.getResources().getString(R.string.notification_appops_overlay_active);
        String using = null;
        String promptString;
        if (mAppOps.contains(AppOpsManager.OP_CAMERA)
                && mAppOps.contains(AppOpsManager.OP_RECORD_AUDIO)) {
            using = mContext.getResources().getQuantityString(
                    R.plurals.notification_using, 2, micString, cameraString);
        } else if (mAppOps.contains(AppOpsManager.OP_CAMERA)) {
            using = mContext.getResources().getQuantityString(
                    R.plurals.notification_using, 1, cameraString);
    private String getPrompt() {
        if (mAppOps == null || mAppOps.size() == 0) {
            return "";
        } else if (mAppOps.size() == 1) {
            if (mAppOps.contains(AppOpsManager.OP_CAMERA)) {
                return mContext.getString(R.string.appops_camera);
            } else if (mAppOps.contains(AppOpsManager.OP_RECORD_AUDIO)) {
            using = mContext.getResources().getQuantityString(
                    R.plurals.notification_using, 1, micString);
                return mContext.getString(R.string.appops_microphone);
            } else {
                return mContext.getString(R.string.appops_overlay);
            }

        if (mAppOps.contains(AppOpsManager.OP_SYSTEM_ALERT_WINDOW)) {
            if (using != null) {
                promptString = mContext.getResources().getQuantityString(
                        R.plurals.notification_appops, 2, overlayString, using);
        } else if (mAppOps.size() == 2) {
            if (mAppOps.contains(AppOpsManager.OP_CAMERA)) {
                if (mAppOps.contains(AppOpsManager.OP_RECORD_AUDIO)) {
                    return mContext.getString(R.string.appops_camera_mic);
                } else {
                promptString = mContext.getResources().getQuantityString(
                        R.plurals.notification_appops, 1, overlayString);
                    return mContext.getString(R.string.appops_camera_overlay);
                }
            } else {
            promptString = mContext.getResources().getQuantityString(
                    R.plurals.notification_appops, 1, using);
                return mContext.getString(R.string.appops_mic_overlay);
            }
        } else {
            return mContext.getString(R.string.appops_camera_mic_overlay);
        }

        return promptString;
    }

    @Override