Search in sources :

Example 21 with CheckBoxPreference

use of android.support.v7.preference.CheckBoxPreference in project frostwire by frostwire.

the class OtherFragment method setupHapticFeedback.

private void setupHapticFeedback() {
    final CheckBoxPreference cb = findPreference(Constants.PREF_KEY_GUI_HAPTIC_FEEDBACK_ON);
    if (cb != null) {
        cb.setOnPreferenceClickListener(preference -> {
            ConfigurationManager.instance().setBoolean(Constants.PREF_KEY_GUI_HAPTIC_FEEDBACK_ON, cb.isChecked());
            Engine.instance().getVibrator().onPreferenceChanged();
            return true;
        });
    }
}
Also used : CheckBoxPreference(android.support.v7.preference.CheckBoxPreference)

Example 22 with CheckBoxPreference

use of android.support.v7.preference.CheckBoxPreference in project frostwire by frostwire.

the class SearchEnginesPreferenceFragment method checkAllEngines.

private void checkAllEngines(boolean checked) {
    CheckBoxPreference archivePreference = null;
    for (CheckBoxPreference preference : activeSearchEnginePreferences.keySet()) {
        if (preference != null) {
            // it could already have been removed due to remote config value.
            setChecked(preference, checked, false);
            if (activeSearchEnginePreferences.get(preference).getName().equals("Archive.org")) {
                archivePreference = preference;
            }
        }
    }
    // always leave one checked.
    if (!checked && archivePreference != null) {
        setChecked(archivePreference, true, false);
        UIUtils.showShortMessage(getView(), R.string.search_preferences_one_engine_checked_always);
    }
}
Also used : CheckBoxPreference(android.support.v7.preference.CheckBoxPreference)

Example 23 with CheckBoxPreference

use of android.support.v7.preference.CheckBoxPreference in project frostwire by frostwire.

the class SearchEnginesPreferenceFragment method fillSearchEnginePreferences.

private void fillSearchEnginePreferences(Map<CheckBoxPreference, SearchEngine> active, Map<CheckBoxPreference, SearchEngine> inactive) {
    // make sure we start empty
    inactive.clear();
    active.clear();
    for (SearchEngine engine : SearchEngine.getEngines()) {
        CheckBoxPreference preference = findPreference(engine.getPreferenceKey());
        if (preference != null) {
            // it could already have been removed due to remote config value.
            if (engine.isActive()) {
                active.put(preference, engine);
            } else {
                inactive.put(preference, engine);
            }
        }
    }
}
Also used : SearchEngine(com.frostwire.android.gui.SearchEngine) CheckBoxPreference(android.support.v7.preference.CheckBoxPreference)

Example 24 with CheckBoxPreference

use of android.support.v7.preference.CheckBoxPreference in project frostwire by frostwire.

the class SearchEnginesPreferenceFragment method updateSelectAllCheckBox.

private void updateSelectAllCheckBox() {
    CheckBoxPreference cb = findPreference(PREF_KEY_SEARCH_SELECT_ALL);
    boolean allChecked = areAllEnginesChecked(activeSearchEnginePreferences, true);
    setChecked(cb, allChecked, false);
    cb.setTitle(allChecked ? R.string.deselect_all : R.string.select_all);
}
Also used : CheckBoxPreference(android.support.v7.preference.CheckBoxPreference)

Example 25 with CheckBoxPreference

use of android.support.v7.preference.CheckBoxPreference in project frostwire by frostwire.

the class TorrentPreferenceFragment method setupSeedingOptions.

private void setupSeedingOptions() {
    final CheckBoxPreference preferenceSeeding = findPreference(Constants.PREF_KEY_TORRENT_SEED_FINISHED_TORRENTS);
    final CheckBoxPreference preferenceSeedingWifiOnly = findPreference(Constants.PREF_KEY_TORRENT_SEED_FINISHED_TORRENTS_WIFI_ONLY);
    if (preferenceSeeding != null) {
        preferenceSeeding.setOnPreferenceChangeListener((preference, newValue) -> {
            boolean newVal = (Boolean) newValue;
            if (!newVal) {
                // not seeding at all
                TransferManager.instance().stopSeedingTorrents();
                UIUtils.showShortMessage(getView(), R.string.seeding_has_been_turned_off);
            }
            if (preferenceSeedingWifiOnly != null) {
                preferenceSeedingWifiOnly.setEnabled(newVal);
            }
            UXStats.instance().log(newVal ? UXAction.SHARING_SEEDING_ENABLED : UXAction.SHARING_SEEDING_DISABLED);
            return true;
        });
    }
    if (preferenceSeedingWifiOnly != null) {
        preferenceSeedingWifiOnly.setOnPreferenceChangeListener((preference, newValue) -> {
            boolean newVal = (Boolean) newValue;
            if (newVal && !NetworkManager.instance().isDataWIFIUp()) {
                // not seeding on mobile data
                TransferManager.instance().stopSeedingTorrents();
                UIUtils.showShortMessage(getView(), R.string.wifi_seeding_has_been_turned_off);
            }
            return true;
        });
    }
    if (preferenceSeeding != null && preferenceSeedingWifiOnly != null) {
        preferenceSeedingWifiOnly.setEnabled(preferenceSeeding.isChecked());
    }
}
Also used : CheckBoxPreference(android.support.v7.preference.CheckBoxPreference)

Aggregations

CheckBoxPreference (android.support.v7.preference.CheckBoxPreference)31 Preference (android.support.v7.preference.Preference)17 ListPreference (android.support.v7.preference.ListPreference)13 Intent (android.content.Intent)10 CheckBoxPreference (android.preference.CheckBoxPreference)8 Context (android.content.Context)7 SharedPreferences (android.content.SharedPreferences)7 OnPreferenceChangeListener (android.support.v7.preference.Preference.OnPreferenceChangeListener)7 Preference (android.preference.Preference)6 AlertDialog (android.support.v7.app.AlertDialog)6 PreferenceScreen (android.support.v7.preference.PreferenceScreen)5 SwitchPreferenceCompat (android.support.v7.preference.SwitchPreferenceCompat)5 Uri (android.net.Uri)4 Build (android.os.Build)4 PreferenceScreen (android.preference.PreferenceScreen)4 View (android.view.View)4 ArrayList (java.util.ArrayList)4 PackageManager (android.content.pm.PackageManager)3 Bundle (android.os.Bundle)3 ListPreference (android.preference.ListPreference)3