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

Commit c67b64fd authored by Mihai Nita's avatar Mihai Nita Committed by Roozbeh Pournader
Browse files

Flag all the locales of the default region as suggested

This was done by the SetupWizard to suggest the default locale
before the SIM was detected.
It is also handy for devices without SIM (tablets).

Bug: 26784450
Bug: 26882058
Bug: 26939651
Change-Id: Ia1d3b2ef4756121cf6ca13d5d7280215df060a8f
parent ab9651b9
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;
    }