Update strings again for refreshed High Contrast Text
Deletes the old string resource and uses a new resource because the old translated strings do not have formatting placeholders. Eventually the old translated strings will be automatically deleted and the new string with placeholder will be translated. Also uses placeholders for referencing other strings so that we guarantee that the strings are consistent across this notification and the actual preference in Settings. Bug: 384791485 Test: see bug screenshots Flag: com.android.graphics.hwui.flags.high_contrast_text_small_text_rect Change-Id: I89a9ee4b3755b20f4e090df5b4cccb7ce47a961c
This commit is contained in:
@@ -5504,13 +5504,13 @@
|
|||||||
<!-- Summary for the accessibility preference to high contrast text. [CHAR LIMIT=NONE] -->
|
<!-- 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>
|
<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] -->
|
<!-- 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] -->
|
<!-- 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] -->
|
<!-- 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] -->
|
<!-- 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] -->
|
<!-- 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>
|
<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] -->
|
<!-- Title for the accessibility preference to auto update screen magnification. [CHAR LIMIT=35] -->
|
||||||
|
@@ -43,6 +43,7 @@ import com.google.common.annotations.VisibleForTesting;
|
|||||||
|
|
||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handling smooth migration to the new high contrast text appearance
|
* Handling smooth migration to the new high contrast text appearance
|
||||||
@@ -128,14 +129,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) {
|
private void showNotification(Context context) {
|
||||||
Notification.Builder notificationBuilder = new Notification.Builder(context,
|
Notification.Builder notificationBuilder = new Notification.Builder(context,
|
||||||
NOTIFICATION_CHANNEL)
|
NOTIFICATION_CHANNEL)
|
||||||
.setSmallIcon(R.drawable.ic_settings_24dp)
|
.setSmallIcon(R.drawable.ic_settings_24dp)
|
||||||
.setContentTitle(context.getString(
|
.setContentTitle(context.getString(
|
||||||
R.string.accessibility_notification_high_contrast_text_title))
|
R.string.accessibility_notification_high_contrast_text_title))
|
||||||
.setContentText(context.getString(
|
.setContentText(getNotificationContentText(context))
|
||||||
R.string.accessibility_notification_high_contrast_text_content))
|
|
||||||
.setFlag(Notification.FLAG_NO_CLEAR, true);
|
.setFlag(Notification.FLAG_NO_CLEAR, true);
|
||||||
|
|
||||||
Intent settingsIntent = createHighContrastTextSettingsIntent(context);
|
Intent settingsIntent = createHighContrastTextSettingsIntent(context);
|
||||||
@@ -149,8 +161,8 @@ public class HighContrastTextMigrationReceiver extends BroadcastReceiver {
|
|||||||
actionIntent, PendingIntent.FLAG_IMMUTABLE);
|
actionIntent, PendingIntent.FLAG_IMMUTABLE);
|
||||||
Notification.Action settingsAction = new Notification.Action.Builder(
|
Notification.Action settingsAction = new Notification.Action.Builder(
|
||||||
/* icon= */ null,
|
/* icon= */ null,
|
||||||
context.getString(
|
context.getString(R.string.accessibility_notification_high_contrast_text_action,
|
||||||
R.string.accessibility_notification_high_contrast_text_action),
|
context.getString(R.string.settings_label)),
|
||||||
actionPendingIntent
|
actionPendingIntent
|
||||||
).build();
|
).build();
|
||||||
|
|
||||||
|
@@ -46,9 +46,10 @@ import android.provider.Settings;
|
|||||||
import androidx.test.core.app.ApplicationProvider;
|
import androidx.test.core.app.ApplicationProvider;
|
||||||
|
|
||||||
import com.android.graphics.hwui.flags.Flags;
|
import com.android.graphics.hwui.flags.Flags;
|
||||||
import com.android.settings.R;
|
|
||||||
import com.android.settings.Utils;
|
import com.android.settings.Utils;
|
||||||
|
|
||||||
|
import com.google.common.truth.Expect;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -65,7 +66,8 @@ import java.util.List;
|
|||||||
/** Tests for {@link HighContrastTextMigrationReceiver}. */
|
/** Tests for {@link HighContrastTextMigrationReceiver}. */
|
||||||
@RunWith(RobolectricTestRunner.class)
|
@RunWith(RobolectricTestRunner.class)
|
||||||
public class HighContrastTextMigrationReceiverTest {
|
public class HighContrastTextMigrationReceiverTest {
|
||||||
|
@Rule
|
||||||
|
public final Expect expect = Expect.create();
|
||||||
@Rule
|
@Rule
|
||||||
public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
|
public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
|
||||||
private final Context mContext = ApplicationProvider.getApplicationContext();
|
private final Context mContext = ApplicationProvider.getApplicationContext();
|
||||||
@@ -230,14 +232,12 @@ public class HighContrastTextMigrationReceiverTest {
|
|||||||
assertThat(notification).isNotNull();
|
assertThat(notification).isNotNull();
|
||||||
|
|
||||||
ShadowNotification shadowNotification = Shadows.shadowOf(notification);
|
ShadowNotification shadowNotification = Shadows.shadowOf(notification);
|
||||||
assertThat(shadowNotification.getContentTitle()).isEqualTo(mContext.getString(
|
expect.that(shadowNotification.getContentTitle()).isEqualTo("Improve text contrast");
|
||||||
R.string.accessibility_notification_high_contrast_text_title));
|
expect.that(shadowNotification.getContentText()).isEqualTo(
|
||||||
assertThat(shadowNotification.getContentText()).isEqualTo(
|
"Outline text has replaced high contrast text. You can turn it on in Settings.");
|
||||||
mContext.getString(R.string.accessibility_notification_high_contrast_text_content));
|
|
||||||
|
|
||||||
assertThat(notification.actions.length).isEqualTo(1);
|
expect.that(notification.actions.length).isEqualTo(1);
|
||||||
assertThat(notification.actions[0].title.toString()).isEqualTo(
|
expect.that(notification.actions[0].title.toString()).isEqualTo("Go to Settings");
|
||||||
mContext.getString(R.string.accessibility_notification_high_contrast_text_action));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertPromptStateAndHctState(
|
private void assertPromptStateAndHctState(
|
||||||
|
Reference in New Issue
Block a user