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

Commit af629623 authored by Mihai Nita's avatar Mihai Nita Committed by android-build-merger
Browse files

Flag all the locales of the default region as suggested am: c67b64fd

am: 608a7394

* commit '608a7394':
  Flag all the locales of the default region as suggested
parents 69f3e8a3 608a7394
Loading
Loading
Loading
Loading
+26 −0
Original line number Diff line number Diff line
@@ -104,6 +104,9 @@ public class LocaleStore {
        }

        private boolean isSuggestionOfType(int suggestionMask) {
            if (!mIsTranslated) { // Never suggest an untranslated locale
                return false;
            }
            return (mSuggestionFlags & suggestionMask) == suggestionMask;
        }

@@ -207,6 +210,27 @@ public class LocaleStore {
        }
    }

    /*
     * Show all the languages supported for a country in the suggested list.
     * This is also handy for devices without SIM (tablets).
     */
    private static void addSuggestedLocalesForRegion(Locale locale) {
        if (locale == null) {
            return;
        }
        final String country = locale.getCountry();
        if (country.isEmpty()) {
            return;
        }

        for (LocaleInfo li : sLocaleCache.values()) {
            if (country.equals(li.getLocale().getCountry())) {
                // We don't need to differentiate between manual and SIM suggestions
                li.mSuggestionFlags |= LocaleInfo.SUGGESTION_TYPE_SIM;
            }
        }
    }

    public static void fillCache(Context context) {
        if (sFullyInitialized) {
            return;
@@ -256,6 +280,8 @@ public class LocaleStore {
            li.setTranslated(localizedLocales.contains(li.getLangScriptKey()));
        }

        addSuggestedLocalesForRegion(Locale.getDefault());

        sFullyInitialized = true;
    }