android.support.v4.os.ConfigurationCompat Java Examples

The following examples show how to use android.support.v4.os.ConfigurationCompat. 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: UserModel.java    From openwebnet-android with MIT License 6 votes vote down vote up
private Builder(FirebaseUser firebaseUser) {
    this.userId = firebaseUser.getUid();
    this.email = firebaseUser.getEmail();
    this.name = firebaseUser.getDisplayName();
    this.phoneNumber = firebaseUser.getPhoneNumber();
    this.photoUrl = firebaseUser.getPhotoUrl() == null ? null : firebaseUser.getPhotoUrl().toString();

    // https://stackoverflow.com/questions/4212320/get-the-current-language-in-device
    this.iso3Language = Locale.getDefault().getISO3Language();
    this.iso3Country = Locale.getDefault().getISO3Country();
    this.locale = ConfigurationCompat.getLocales(Resources.getSystem().getConfiguration()).toLanguageTags();

    this.createdAt = firebaseUser.getMetadata() != null ?
        new Date(firebaseUser.getMetadata().getCreationTimestamp()) : new Date();
    this.modifiedAt = new Date();
}
 
Example #2
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 #3
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 #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);
}