diff --git a/res/values/strings.xml b/res/values/strings.xml index af5ecc16198..4e770ee193a 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -5508,13 +5508,13 @@ Change text color to black or white. Maximizes contrast with the background. - High contrast text has been replaced + Improve text contrast - Try Text outlines instead. Find it in Settings. + %1$s has replaced %2$s. You can turn it on in %3$s. - Open Settings + Go to %1$s - Text outlines + Outline text Add a black or white background around text to increase contrast diff --git a/src/com/android/settings/accessibility/HighContrastTextMigrationReceiver.java b/src/com/android/settings/accessibility/HighContrastTextMigrationReceiver.java index fbe192191f1..bf5b8871544 100644 --- a/src/com/android/settings/accessibility/HighContrastTextMigrationReceiver.java +++ b/src/com/android/settings/accessibility/HighContrastTextMigrationReceiver.java @@ -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(); diff --git a/tests/robotests/src/com/android/settings/accessibility/HighContrastTextMigrationReceiverTest.java b/tests/robotests/src/com/android/settings/accessibility/HighContrastTextMigrationReceiverTest.java index b0864aa1073..98c2c239b00 100644 --- a/tests/robotests/src/com/android/settings/accessibility/HighContrastTextMigrationReceiverTest.java +++ b/tests/robotests/src/com/android/settings/accessibility/HighContrastTextMigrationReceiverTest.java @@ -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)); + 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."); - 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(notification.actions.length).isEqualTo(1); + expect.that(notification.actions[0].title.toString()).isEqualTo("Go to Settings"); } private void assertPromptStateAndHctState(