Java Code Examples for android.os.LocaleList#get()
The following examples show how to use
android.os.LocaleList#get() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DefaultAndroidEventProcessor.java From sentry-android with MIT License | 5 votes |
private TimeZone getTimeZone() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { LocaleList locales = context.getResources().getConfiguration().getLocales(); if (!locales.isEmpty()) { Locale locale = locales.get(0); return Calendar.getInstance(locale).getTimeZone(); } } return Calendar.getInstance().getTimeZone(); }
Example 2
Source File: CompatUtils.java From enterprise-samples with Apache License 2.0 | 5 votes |
/** * Retrieves the primary locale from the specified {@link Configuration}. * * @param configuration The current {@link Configuration}. * @return The primary locale. */ public static Locale getPrimaryLocale(Configuration configuration) { if (Build.VERSION.SDK_INT >= 24) { final LocaleList locales = configuration.getLocales(); if (locales.size() > 0) { return locales.get(0); } } //noinspection deprecation return configuration.locale; }
Example 3
Source File: EditorInfoCompatUtils.java From LokiBoard-Android-Keylogger with Apache License 2.0 | 5 votes |
public static Locale getPrimaryHintLocale(final EditorInfo editorInfo) { if (editorInfo == null) { return null; } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { LocaleList localeList = editorInfo.hintLocales; if (localeList != null && !localeList.isEmpty()) return localeList.get(0); } return null; }
Example 4
Source File: FormatUtils.java From EnhancedScreenshotNotification with GNU General Public License v3.0 | 5 votes |
@NonNull private static Locale chooseAvailableLocale(@NonNull LocaleList localeList) { for (int i = 0; i < localeList.size(); i++) { final Locale locale = localeList.get(i); if (sEditActionTextFormats.containsKey(locale)) { return locale; } for (Locale loc : sEditActionTextFormats.keySet()) { if (loc.getLanguage().equals(locale.getLanguage())) { return loc; } } } return Locale.ENGLISH; }
Example 5
Source File: AlphabeticIndexCompat.java From LaunchEnr with GNU General Public License v3.0 | 5 votes |
AlphabeticIndexVN(Context context) { LocaleList locales = context.getResources().getConfiguration().getLocales(); int localeCount = locales.size(); Locale primaryLocale = localeCount == 0 ? Locale.ENGLISH : locales.get(0); AlphabeticIndex indexBuilder = new AlphabeticIndex(primaryLocale); for (int i = 1; i < localeCount; i++) { indexBuilder.addLabels(locales.get(i)); } indexBuilder.addLabels(Locale.ENGLISH); mAlphabeticIndex = indexBuilder.buildImmutableIndex(); }
Example 6
Source File: EditorInfoCompatUtils.java From simple-keyboard with Apache License 2.0 | 5 votes |
public static Locale getPrimaryHintLocale(final EditorInfo editorInfo) { if (editorInfo == null) { return null; } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { LocaleList localeList = editorInfo.hintLocales; if (localeList != null && !localeList.isEmpty()) return localeList.get(0); } return null; }
Example 7
Source File: DateTimePickerDialog.java From 365browser with Apache License 2.0 | 5 votes |
private Locale getLocale() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { LocaleList locales = getConfiguration().getLocales(); if (locales.size() > 0) { return locales.get(0); } } return getConfiguration().locale; }
Example 8
Source File: CompatUtils.java From android-NfcProvisioning with Apache License 2.0 | 5 votes |
/** * Retrieves the primary locale from the specified {@link Configuration}. * * @param configuration The current {@link Configuration}. * @return The primary locale. */ public static Locale getPrimaryLocale(Configuration configuration) { if (Build.VERSION.SDK_INT >= 24) { final LocaleList locales = configuration.getLocales(); if (locales.size() > 0) { return locales.get(0); } } //noinspection deprecation return configuration.locale; }
Example 9
Source File: Singleton.java From android-galaxyzoo with GNU General Public License v3.0 | 5 votes |
private static LocaleDetails getLocaleDetails(final Context context) { final Configuration config = context.getResources().getConfiguration(); if (config == null) { return null; } Locale locale = null; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { final LocaleList locales = config.getLocales(); if (locales == null || locales.isEmpty()) { return null; } locale = locales.get(0); } else { //noinspection deprecation locale = config.locale; } if (locale == null) { return null; } final LocaleDetails result = new LocaleDetails(); result.language = locale.getLanguage(); //The Galaxy zoo files, such as ch_cn.json are lowercase, instead of having the //country code in uppercase, such as ch_CN, like normal system locales. final String country = locale.getCountry(); if (!TextUtils.isEmpty(country)) { result.countryCode = country.toLowerCase(new Locale(Utils.STRING_LANGUAGE)); } return result; }
Example 10
Source File: Configuration.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
/** * * @hide */ public static String localesToResourceQualifier(LocaleList locs) { final StringBuilder sb = new StringBuilder(); for (int i = 0; i < locs.size(); i++) { final Locale loc = locs.get(i); final int l = loc.getLanguage().length(); if (l == 0) { continue; } final int s = loc.getScript().length(); final int c = loc.getCountry().length(); final int v = loc.getVariant().length(); // We ignore locale extensions, since they are not supported by AAPT if (sb.length() != 0) { sb.append(","); } if (l == 2 && s == 0 && (c == 0 || c == 2) && v == 0) { // Traditional locale format: xx or xx-rYY sb.append(loc.getLanguage()); if (c == 2) { sb.append("-r").append(loc.getCountry()); } } else { sb.append("b+"); sb.append(loc.getLanguage()); if (s != 0) { sb.append("+"); sb.append(loc.getScript()); } if (c != 0) { sb.append("+"); sb.append(loc.getCountry()); } if (v != 0) { sb.append("+"); sb.append(loc.getVariant()); } } } return sb.toString(); }