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:
Daniel Norman
2025-01-28 16:47:29 -08:00
parent 6e12194015
commit 6d0a04a171
3 changed files with 29 additions and 17 deletions

View File

@@ -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
@@ -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) {
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);
@@ -149,8 +161,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();