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;
});
}
}
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);
}
}
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);
}
}
}
}
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);
}
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());
}
}
Aggregations