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

Commit a1e47ef8 authored by Riley Jones's avatar Riley Jones Committed by Android (Google) Code Review
Browse files

Merge "Update strings again for refreshed High Contrast Text" into main

parents 58519274 6d0a04a1
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -5508,13 +5508,13 @@
    <!-- Summary for the accessibility preference to high contrast text. [CHAR LIMIT=NONE] -->
    <string name="accessibility_toggle_high_text_contrast_preference_summary">Change text color to black or white. Maximizes contrast with the background.</string>
    <!-- Title for the notification that high contrast text has been replaced. [CHAR LIMIT=NONE] -->
    <string name="accessibility_notification_high_contrast_text_title">High contrast text has been replaced</string>
    <string name="accessibility_notification_high_contrast_text_title">Improve text contrast</string>
    <!-- Text content for the notification that high contrast text has been replaced. [CHAR LIMIT=NONE] -->
    <string name="accessibility_notification_high_contrast_text_content">Try Text outlines instead. Find it in Settings.</string>
    <string name="accessibility_notification_high_contrast_text_body"><xliff:g example="Outline text" id="outline_text">%1$s</xliff:g> has replaced <xliff:g example="high contrast text" id="high_contrast_text">%2$s</xliff:g>. You can turn it on in <xliff:g example="Settings" id="settings">%3$s</xliff:g>.</string>
    <!-- Action for the notification to high contrast text. [CHAR LIMIT=35] -->
    <string name="accessibility_notification_high_contrast_text_action">Open Settings</string>
    <string name="accessibility_notification_high_contrast_text_action">Go to <xliff:g example="Settings" id="settings">%1$s</xliff:g></string>
    <!-- Title for the accessibility preference that adds an outline behind text to increase contrast and legibility. [CHAR LIMIT=35] -->
    <string name="accessibility_toggle_maximize_text_contrast_preference_title">Text outlines</string>
    <string name="accessibility_toggle_maximize_text_contrast_preference_title">Outline text</string>
    <!-- Summary for the accessibility preference to high contrast text. [CHAR LIMIT=NONE] -->
    <string name="accessibility_toggle_maximize_text_contrast_preference_summary">Add a black or white background around text to increase contrast</string>
    <!-- Title for the accessibility preference to auto update screen magnification. [CHAR LIMIT=35] -->
+16 −4
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@ import com.google.common.annotations.VisibleForTesting;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.Locale;

/**
 * Handling smooth migration to the new high contrast text appearance
@@ -132,14 +133,25 @@ public class HighContrastTextMigrationReceiver extends BroadcastReceiver {
        }
    }

    private String getNotificationContentText(Context context) {
        final String newName = context.getString(
                R.string.accessibility_toggle_maximize_text_contrast_preference_title);
        final String oldName = context.getString(
                R.string.accessibility_toggle_high_text_contrast_preference_title)
                .toLowerCase(Locale.getDefault());
        final String settingsAppName = context.getString(R.string.settings_label);
        return context.getString(
                R.string.accessibility_notification_high_contrast_text_body,
                newName, oldName, settingsAppName);
    }

    private void showNotification(Context context) {
        Notification.Builder notificationBuilder = new Notification.Builder(context,
                NOTIFICATION_CHANNEL)
                .setSmallIcon(R.drawable.ic_settings_24dp)
                .setContentTitle(context.getString(
                        R.string.accessibility_notification_high_contrast_text_title))
                .setContentText(context.getString(
                        R.string.accessibility_notification_high_contrast_text_content))
                .setContentText(getNotificationContentText(context))
                .setFlag(Notification.FLAG_NO_CLEAR, true);

        Intent settingsIntent = createHighContrastTextSettingsIntent(context);
@@ -153,8 +165,8 @@ public class HighContrastTextMigrationReceiver extends BroadcastReceiver {
                    actionIntent, PendingIntent.FLAG_IMMUTABLE);
            Notification.Action settingsAction = new Notification.Action.Builder(
                    /* icon= */ null,
                    context.getString(
                            R.string.accessibility_notification_high_contrast_text_action),
                    context.getString(R.string.accessibility_notification_high_contrast_text_action,
                            context.getString(R.string.settings_label)),
                    actionPendingIntent
            ).build();

+10 −10
Original line number Diff line number Diff line
@@ -46,9 +46,10 @@ import android.provider.Settings;
import androidx.test.core.app.ApplicationProvider;

import com.android.graphics.hwui.flags.Flags;
import com.android.settings.R;
import com.android.settings.Utils;

import com.google.common.truth.Expect;

import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@@ -65,7 +66,8 @@ import java.util.List;
/** Tests for {@link HighContrastTextMigrationReceiver}. */
@RunWith(RobolectricTestRunner.class)
public class HighContrastTextMigrationReceiverTest {

    @Rule
    public final Expect expect = Expect.create();
    @Rule
    public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
    private final Context mContext = ApplicationProvider.getApplicationContext();
@@ -230,14 +232,12 @@ public class HighContrastTextMigrationReceiverTest {
        assertThat(notification).isNotNull();

        ShadowNotification shadowNotification = Shadows.shadowOf(notification);
        assertThat(shadowNotification.getContentTitle()).isEqualTo(mContext.getString(
                R.string.accessibility_notification_high_contrast_text_title));
        assertThat(shadowNotification.getContentText()).isEqualTo(
                mContext.getString(R.string.accessibility_notification_high_contrast_text_content));

        assertThat(notification.actions.length).isEqualTo(1);
        assertThat(notification.actions[0].title.toString()).isEqualTo(
                mContext.getString(R.string.accessibility_notification_high_contrast_text_action));
        expect.that(shadowNotification.getContentTitle()).isEqualTo("Improve text contrast");
        expect.that(shadowNotification.getContentText()).isEqualTo(
                "Outline text has replaced high contrast text. You can turn it on in Settings.");

        expect.that(notification.actions.length).isEqualTo(1);
        expect.that(notification.actions[0].title.toString()).isEqualTo("Go to Settings");
    }

    private void assertPromptStateAndHctState(