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

Commit 9fe1c121 authored by Roozbeh Pournader's avatar Roozbeh Pournader
Browse files

Special-case English for DateTime and Time key listeners

Because English time patterns use uppercase letters by default (and a
comma to separate date and time when both are represented), we were
concluding they need internationalized input. Although they
literally do, let's keep the world simple and assume they don't need
internationalized input.

Compared to Nougat, we will now accept uppercase AM and PM and comma
for English if the IME allows them, we just continue to not signal
that an internationalized layout is needed.

Test: CTS tests pass
Bug: https://code.google.com/p/android/issues/detail?id=2626
Bug: https://code.google.com/p/android/issues/detail?id=82993
Bug: 8319249
Bug: 33276673
Bug: 34394455
Bug: 37079150
Change-Id: I82bfde323ba49ae1a27ff5c2e729063b7d81dcc8
parent b2bb3bf2
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -68,7 +68,7 @@ public class DateTimeKeyListener extends NumberKeyListener
        final LinkedHashSet<Character> chars = new LinkedHashSet<>();
        // First add the digits. Then, add all the character in AM and PM markers. Finally, add all
        // the non-pattern characters seen in the patterns for "yMdhms" and "yMdHms".
        boolean success = NumberKeyListener.addDigits(chars, locale)
        final boolean success = NumberKeyListener.addDigits(chars, locale)
                          && NumberKeyListener.addAmPmChars(chars, locale)
                          && NumberKeyListener.addFormatCharsFromSkeleton(
                              chars, locale, SKELETON_12HOUR, SYMBOLS_TO_IGNORE)
@@ -76,7 +76,14 @@ public class DateTimeKeyListener extends NumberKeyListener
                              chars, locale, SKELETON_24HOUR, SYMBOLS_TO_IGNORE);
        if (success) {
            mCharacters = NumberKeyListener.collectionToArray(chars);
            if (locale != null && "en".equals(locale.getLanguage())) {
                // For backward compatibility reasons, assume we don't need advanced input for
                // English locales, although English locales literally also need a comma and perhaps
                // uppercase letters for AM and PM.
                mNeedsAdvancedInput = false;
            } else {
                mNeedsAdvancedInput = !ArrayUtils.containsAll(CHARACTERS, mCharacters);
            }
        } else {
            mCharacters = CHARACTERS;
            mNeedsAdvancedInput = false;
+9 −2
Original line number Diff line number Diff line
@@ -68,7 +68,7 @@ public class TimeKeyListener extends NumberKeyListener
        final LinkedHashSet<Character> chars = new LinkedHashSet<>();
        // First add the digits. Then, add all the character in AM and PM markers. Finally, add all
        // the non-pattern characters seen in the patterns for "hms" and "Hms".
        boolean success = NumberKeyListener.addDigits(chars, locale)
        final boolean success = NumberKeyListener.addDigits(chars, locale)
                          && NumberKeyListener.addAmPmChars(chars, locale)
                          && NumberKeyListener.addFormatCharsFromSkeleton(
                              chars, locale, SKELETON_12HOUR, SYMBOLS_TO_IGNORE)
@@ -76,7 +76,14 @@ public class TimeKeyListener extends NumberKeyListener
                              chars, locale, SKELETON_24HOUR, SYMBOLS_TO_IGNORE);
        if (success) {
            mCharacters = NumberKeyListener.collectionToArray(chars);
            if (locale != null && "en".equals(locale.getLanguage())) {
                // For backward compatibility reasons, assume we don't need advanced input for
                // English locales, although English locales may need uppercase letters for
                // AM and PM.
                mNeedsAdvancedInput = false;
            } else {
                mNeedsAdvancedInput = !ArrayUtils.containsAll(CHARACTERS, mCharacters);
            }
        } else {
            mCharacters = CHARACTERS;
            mNeedsAdvancedInput = false;