Search in sources :

Example 1 with Languages

use of org.fdroid.fdroid.Languages in project fdroidclient by f-droid.

the class PreferencesFragment method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.preferences);
    useTorCheckPref = (CheckBoxPreference) findPreference(Preferences.PREF_USE_TOR);
    enableProxyCheckPref = (CheckBoxPreference) findPreference(Preferences.PREF_ENABLE_PROXY);
    updateAutoDownloadPref = findPreference(Preferences.PREF_AUTO_DOWNLOAD_INSTALL_UPDATES);
    updatePrivilegedExtensionPref = findPreference(Preferences.PREF_UNINSTALL_PRIVILEGED_APP);
    AppCompatListPreference languagePref = (AppCompatListPreference) findPreference(Preferences.PREF_LANGUAGE);
    if (Build.VERSION.SDK_INT >= 24) {
        PreferenceCategory category = (PreferenceCategory) findPreference("pref_category_display");
        category.removePreference(languagePref);
    } else {
        Languages languages = Languages.get(getActivity());
        languagePref.setDefaultValue(Languages.USE_SYSTEM_DEFAULT);
        languagePref.setEntries(languages.getAllNames());
        languagePref.setEntryValues(languages.getSupportedLocales());
    }
}
Also used : PreferenceCategory(android.preference.PreferenceCategory) Languages(org.fdroid.fdroid.Languages) AppCompatListPreference(com.geecko.QuickLyric.view.AppCompatListPreference)

Example 2 with Languages

use of org.fdroid.fdroid.Languages in project fdroidclient by f-droid.

the class PreferencesFragment method onCreatePreferences.

@Override
public void onCreatePreferences(Bundle bundle, String s) {
    Preferences preferences = Preferences.get();
    preferences.migrateOldPreferences();
    addPreferencesFromResource(R.xml.preferences);
    otherPrefGroup = (PreferenceGroup) findPreference("pref_category_other");
    Preference aboutPreference = findPreference("pref_about");
    if (aboutPreference != null) {
        aboutPreference.setOnPreferenceClickListener(aboutPrefClickedListener);
    }
    keepInstallHistoryPref = (CheckBoxPreference) findPreference(Preferences.PREF_KEEP_INSTALL_HISTORY);
    sendToFDroidMetricsPref = findPreference(Preferences.PREF_SEND_TO_FDROID_METRICS);
    sendToFDroidMetricsPref.setEnabled(keepInstallHistoryPref.isChecked());
    installHistoryPref = findPreference("installHistory");
    installHistoryPref.setVisible(keepInstallHistoryPref.isChecked());
    if (preferences.isSendingToFDroidMetrics()) {
        installHistoryPref.setTitle(R.string.install_history_and_metrics);
    } else {
        installHistoryPref.setTitle(R.string.install_history);
    }
    useTorCheckPref = (SwitchPreferenceCompat) findPreference(Preferences.PREF_USE_TOR);
    useTorCheckPref.setOnPreferenceChangeListener(useTorChangedListener);
    enableProxyCheckPref = (SwitchPreferenceCompat) findPreference(Preferences.PREF_ENABLE_PROXY);
    enableProxyCheckPref.setOnPreferenceChangeListener(proxyEnabledChangedListener);
    updateAutoDownloadPref = findPreference(Preferences.PREF_AUTO_DOWNLOAD_INSTALL_UPDATES);
    overWifiSeekBar = (LiveSeekBarPreference) findPreference(Preferences.PREF_OVER_WIFI);
    overWifiPrevious = overWifiSeekBar.getValue();
    overWifiSeekBar.setSeekBarLiveUpdater(new LiveSeekBarPreference.SeekBarLiveUpdater() {

        @Override
        public String seekBarUpdated(int position) {
            return getNetworkSeekBarSummary(position);
        }
    });
    overDataSeekBar = (LiveSeekBarPreference) findPreference(Preferences.PREF_OVER_DATA);
    overDataPrevious = overDataSeekBar.getValue();
    overDataSeekBar.setSeekBarLiveUpdater(new LiveSeekBarPreference.SeekBarLiveUpdater() {

        @Override
        public String seekBarUpdated(int position) {
            return getNetworkSeekBarSummary(position);
        }
    });
    updateIntervalSeekBar = (LiveSeekBarPreference) findPreference(Preferences.PREF_UPDATE_INTERVAL);
    updateIntervalPrevious = updateIntervalSeekBar.getValue();
    updateIntervalSeekBar.setSeekBarLiveUpdater(new LiveSeekBarPreference.SeekBarLiveUpdater() {

        @Override
        public String seekBarUpdated(int position) {
            return getString(UPDATE_INTERVAL_NAMES[position]);
        }
    });
    ListPreference languagePref = (ListPreference) findPreference(Preferences.PREF_LANGUAGE);
    if (Build.VERSION.SDK_INT >= 24) {
        PreferenceCategory category = (PreferenceCategory) findPreference("pref_category_display");
        category.removePreference(languagePref);
    } else {
        Languages languages = Languages.get((AppCompatActivity) getActivity());
        languagePref.setDefaultValue(Languages.USE_SYSTEM_DEFAULT);
        languagePref.setEntries(languages.getAllNames());
        languagePref.setEntryValues(languages.getSupportedLocales());
    }
    if (getActivity().getPackageManager().hasSystemFeature(PackageManager.FEATURE_TOUCHSCREEN)) {
        PreferenceCategory category = (PreferenceCategory) findPreference("pref_category_appcompatibility");
        category.removePreference(findPreference(Preferences.PREF_FORCE_TOUCH_APPS));
    }
    topScroller = new LinearSmoothScroller(getActivity()) {

        @Override
        protected int getVerticalSnapPreference() {
            return SNAP_TO_START;
        }
    };
}
Also used : CheckBoxPreference(androidx.preference.CheckBoxPreference) SeekBarPreference(androidx.preference.SeekBarPreference) EditTextPreference(androidx.preference.EditTextPreference) Preference(androidx.preference.Preference) ListPreference(androidx.preference.ListPreference) PreferenceCategory(androidx.preference.PreferenceCategory) LinearSmoothScroller(androidx.recyclerview.widget.LinearSmoothScroller) Languages(org.fdroid.fdroid.Languages) ListPreference(androidx.preference.ListPreference) Preferences(org.fdroid.fdroid.Preferences) SharedPreferences(android.content.SharedPreferences)

Aggregations

Languages (org.fdroid.fdroid.Languages)2 SharedPreferences (android.content.SharedPreferences)1 PreferenceCategory (android.preference.PreferenceCategory)1 CheckBoxPreference (androidx.preference.CheckBoxPreference)1 EditTextPreference (androidx.preference.EditTextPreference)1 ListPreference (androidx.preference.ListPreference)1 Preference (androidx.preference.Preference)1 PreferenceCategory (androidx.preference.PreferenceCategory)1 SeekBarPreference (androidx.preference.SeekBarPreference)1 LinearSmoothScroller (androidx.recyclerview.widget.LinearSmoothScroller)1 AppCompatListPreference (com.geecko.QuickLyric.view.AppCompatListPreference)1 Preferences (org.fdroid.fdroid.Preferences)1