fune/mobile/android/base/java/org/mozilla/gecko/LocaleManager.java
Makoto Kato 9bba600ffc Bug 1420332 - Use system locale when system default is selected for browser locale. r=snorp
This is a regression by bug 1337078.  When user selects system default for
Browser language, "locale" pref is empty.  So BrowserLocaleManager.getLocale
always returns null.  So, current locale is always en-US in Gecko code.

So we should return system locale when "locale" pref is empty.

Also, ReadSystemLocales expects language tag string for locale.  Since
Locale.toString doesn't return language tag, so we should convert to it.

MozReview-Commit-ID: 3NhAkuA4HaH

--HG--
extra : rebase_source : 98e7c928e852391abe11b1b7ba19cc61d4924cea
2017-11-27 10:55:25 +09:00

40 lines
1.6 KiB
Java

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.gecko;
import java.util.Locale;
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;
/**
* Implement this interface to provide Fennec's locale switching functionality.
*
* The LocaleManager is responsible for persisting and applying selected locales,
* and correcting configurations after Android has changed them.
*/
public interface LocaleManager {
void initialize(Context context);
Locale getCurrentLocale(Context context);
Locale getDefaultSystemLocale();
boolean isMirroringSystemLocale(Context context);
String getAndApplyPersistedLocale(Context context);
void correctLocale(Context context, Resources resources, Configuration newConfig);
void updateConfiguration(Context context, Locale locale);
String setSelectedLocale(Context context, String localeCode);
boolean systemLocaleDidChange();
void resetToSystemLocale(Context context);
/**
* Call this in your onConfigurationChanged handler. This method is expected
* to do the appropriate thing: if the user has selected a locale, it
* corrects the incoming configuration; if not, it signals the new locale to
* use.
*/
Locale onSystemConfigurationChanged(Context context, Resources resources, Configuration configuration, Locale currentActivityLocale);
String getFallbackLocaleTag();
}