diff options
author | Babak <babakbo@google.com> | 2020-09-17 16:32:09 -0700 |
---|---|---|
committer | Babak <babakbo@google.com> | 2020-09-17 16:39:03 -0700 |
commit | c7420e9c97b111ddc4dea956c76ec3fad2f2b47e (patch) | |
tree | 1153f5f437f3c8454733c2fc7d581ddf12ed1b07 | |
parent | 275aac97a7111af3749f1fbe601c14616f3e690a (diff) | |
download | Messenger-android-11.0.0_r30.tar.gz |
Fix group message title when switching to RTL languagesandroid-11.0.0_r37android-11.0.0_r36android-11.0.0_r35android-11.0.0_r34android-11.0.0_r33android-11.0.0_r32android-11.0.0_r30android11-qpr2-releaseandroid11-qpr1-c-release
Generated titles should not be reused after changing the locale.
Because:
1 - Change of locale means none of the separators used are valid
anymore. For example a string like "name, name2, name3" cannot be used
in a language that does not use "," as a separator.
2 - All the text direction markers should be reassessed when the locale
changes. Please note that TextDirectionHeuristics.LOCALE translates
to either RLM or LRM based on the current locale. The generated string
should not be used in another locale with a different text direction.
Bug: 159221409
Bug: 161947401
Test: Manual
Change-Id: I725f23a306ff97889d08879c44a38c94f128d326
-rw-r--r-- | src/com/android/car/messenger/MessageNotificationDelegate.java | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/com/android/car/messenger/MessageNotificationDelegate.java b/src/com/android/car/messenger/MessageNotificationDelegate.java index 8541c5d..5fa6db0 100644 --- a/src/com/android/car/messenger/MessageNotificationDelegate.java +++ b/src/com/android/car/messenger/MessageNotificationDelegate.java @@ -59,6 +59,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Set; import java.util.concurrent.CompletableFuture; @@ -75,6 +76,7 @@ public class MessageNotificationDelegate extends BaseNotificationDelegate implem /** Tracks whether a projection application is active in the foreground. **/ private ProjectionStateListener mProjectionStateListener; private CompletableFuture<Void> mPhoneNumberInfoFuture; + private Locale mGeneratedGroupConversationTitlesLocale; private static int mBitmapSize; private static float mCornerRadiusPercent; private static boolean mShouldLoadExistingMessages; @@ -396,6 +398,13 @@ public class MessageNotificationDelegate extends BaseNotificationDelegate implem */ private void setGroupConversationTitle(ConversationKey conversationKey) { ConversationNotificationInfo notificationInfo = mNotificationInfos.get(conversationKey); + Locale locale = Locale.getDefault(); + + // Do not reuse the old titles if locale has changed. The new locale might need different + // formatting or text direction. + if (locale != mGeneratedGroupConversationTitlesLocale) { + mGeneratedGroupConversationTitles.clear(); + } if (!notificationInfo.isGroupConvo() || mGeneratedGroupConversationTitles.contains(conversationKey)) { return; @@ -416,7 +425,10 @@ public class MessageNotificationDelegate extends BaseNotificationDelegate implem notificationInfo.setConvoTitle(Utils.constructGroupConversationTitle(names, mContext.getString(R.string.name_separator), mNotificationConversationTitleLength)); - if (allNamesLoaded) mGeneratedGroupConversationTitles.add(conversationKey); + if (allNamesLoaded) { + mGeneratedGroupConversationTitlesLocale = locale; + mGeneratedGroupConversationTitles.add(conversationKey); + } } private void loadPhoneNumberInfo(@Nullable String phoneNumber, |