Java Code Examples for net.gsantner.opoc.util.ContextUtils#getBuildConfigValue()

The following examples show how to use net.gsantner.opoc.util.ContextUtils#getBuildConfigValue() . 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: LanguagePreferenceCompat.java    From memetastic with GNU General Public License v3.0 5 votes vote down vote up
private void loadLangs(Context context, @Nullable AttributeSet attrs) {
    setDefaultValue(SYSTEM_LANGUAGE_CODE);

    // Fetch readable details
    ContextUtils contextUtils = new ContextUtils(context);
    List<String> languages = new ArrayList<>();
    Object bcof = contextUtils.getBuildConfigValue("DETECTED_ANDROID_LOCALES");
    if (bcof instanceof String[]) {
        for (String langId : (String[]) bcof) {
            Locale locale = contextUtils.getLocaleByAndroidCode(langId);
            languages.add(summarizeLocale(locale, langId) + ";" + langId);
        }
    }

    // Sort languages naturally
    Collections.sort(languages);

    // Show in UI
    String[] entries = new String[languages.size() + 2];
    String[] entryval = new String[languages.size() + 2];
    for (int i = 0; i < languages.size(); i++) {
        entries[i + 2] = languages.get(i).split(";")[0];
        entryval[i + 2] = languages.get(i).split(";")[1];
    }
    entryval[0] = SYSTEM_LANGUAGE_CODE;
    entries[0] = _systemLanguageName + " » " + summarizeLocale(ConfigurationCompat.getLocales(Resources.getSystem().getConfiguration()).get(0), "");
    entryval[1] = _defaultLanguageCode;
    entries[1] = summarizeLocale(contextUtils.getLocaleByAndroidCode(_defaultLanguageCode), _defaultLanguageCode);

    setEntries(entries);
    setEntryValues(entryval);
}
 
Example 2
Source File: LanguagePreferenceCompat.java    From openlauncher with Apache License 2.0 5 votes vote down vote up
private void loadLangs(Context context, @Nullable AttributeSet attrs) {
    setDefaultValue(SYSTEM_LANGUAGE_CODE);

    // Fetch readable details
    ContextUtils contextUtils = new ContextUtils(context);
    List<String> languages = new ArrayList<>();
    Object bcof = contextUtils.getBuildConfigValue("DETECTED_ANDROID_LOCALES");
    if (bcof instanceof String[]) {
        for (String langId : (String[]) bcof) {
            Locale locale = contextUtils.getLocaleByAndroidCode(langId);
            languages.add(summarizeLocale(locale, langId) + ";" + langId);
        }
    }

    // Sort languages naturally
    Collections.sort(languages);

    // Show in UI
    String[] entries = new String[languages.size() + 2];
    String[] entryval = new String[languages.size() + 2];
    for (int i = 0; i < languages.size(); i++) {
        entries[i + 2] = languages.get(i).split(";")[0];
        entryval[i + 2] = languages.get(i).split(";")[1];
    }
    entryval[0] = SYSTEM_LANGUAGE_CODE;
    entries[0] = _systemLanguageName + " » " + summarizeLocale(ConfigurationCompat.getLocales(Resources.getSystem().getConfiguration()).get(0), "");
    entryval[1] = _defaultLanguageCode;
    entries[1] = summarizeLocale(contextUtils.getLocaleByAndroidCode(_defaultLanguageCode), _defaultLanguageCode);

    setEntries(entries);
    setEntryValues(entryval);
}
 
Example 3
Source File: LanguagePreferenceCompat.java    From Stringlate with MIT License 5 votes vote down vote up
private void loadLangs(Context context, @Nullable AttributeSet attrs) {
    setDefaultValue(SYSTEM_LANGUAGE_CODE);

    // Fetch readable details
    ContextUtils contextUtils = new ContextUtils(context);
    List<String> languages = new ArrayList<>();
    Object bcof = contextUtils.getBuildConfigValue("DETECTED_ANDROID_LOCALES");
    if (bcof instanceof String[]) {
        for (String langId : (String[]) bcof) {
            Locale locale = contextUtils.getLocaleByAndroidCode(langId);
            languages.add(summarizeLocale(locale, langId) + ";" + langId);
        }
    }

    // Sort languages naturally
    Collections.sort(languages);

    // Show in UI
    String[] entries = new String[languages.size() + 2];
    String[] entryval = new String[languages.size() + 2];
    for (int i = 0; i < languages.size(); i++) {
        entries[i + 2] = languages.get(i).split(";")[0];
        entryval[i + 2] = languages.get(i).split(";")[1];
    }
    entryval[0] = SYSTEM_LANGUAGE_CODE;
    entries[0] = _systemLanguageName + " » " + summarizeLocale(context.getResources().getConfiguration().locale, "");
    entryval[1] = _defaultLanguageCode;
    entries[1] = summarizeLocale(contextUtils.getLocaleByAndroidCode(_defaultLanguageCode), _defaultLanguageCode);

    setEntries(entries);
    setEntryValues(entryval);
}
 
Example 4
Source File: LanguagePreferenceCompat.java    From kimai-android with MIT License 5 votes vote down vote up
private void loadLangs(Context context, @Nullable AttributeSet attrs) {
    setDefaultValue(SYSTEM_LANGUAGE_CODE);

    // Fetch readable details
    ContextUtils contextUtils = new ContextUtils(context);
    List<String> languages = new ArrayList<>();
    Object bcof = contextUtils.getBuildConfigValue("DETECTED_ANDROID_LOCALES");
    if (bcof instanceof String[]) {
        for (String langId : (String[]) bcof) {
            Locale locale = contextUtils.getLocaleByAndroidCode(langId);
            languages.add(summarizeLocale(locale, langId) + ";" + langId);
        }
    }

    // Sort languages naturally
    Collections.sort(languages);

    // Show in UI
    String[] entries = new String[languages.size() + 2];
    String[] entryval = new String[languages.size() + 2];
    for (int i = 0; i < languages.size(); i++) {
        entries[i + 2] = languages.get(i).split(";")[0];
        entryval[i + 2] = languages.get(i).split(";")[1];
    }
    entryval[0] = SYSTEM_LANGUAGE_CODE;
    entries[0] = _systemLanguageName + " » " + summarizeLocale(ConfigurationCompat.getLocales(Resources.getSystem().getConfiguration()).get(0), "");
    entryval[1] = _defaultLanguageCode;
    entries[1] = summarizeLocale(contextUtils.getLocaleByAndroidCode(_defaultLanguageCode), _defaultLanguageCode);

    setEntries(entries);
    setEntryValues(entryval);
}