use of android.preference.CheckBoxPreference in project Osmand by osmandapp.
the class SettingsOsmEditingActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
((OsmandApplication) getApplication()).applyTheme(this);
super.onCreate(savedInstanceState);
getToolbar().setTitle(R.string.osm_settings);
@SuppressWarnings("deprecation") PreferenceScreen grp = getPreferenceScreen();
DialogPreference loginDialogPreference = new OsmLoginDataDialogPreference(this, null);
grp.addPreference(loginDialogPreference);
CheckBoxPreference poiEdit = createCheckBoxPreference(settings.OFFLINE_EDITION, R.string.offline_edition, R.string.offline_edition_descr);
grp.addPreference(poiEdit);
Preference pref = new Preference(this);
pref.setTitle(R.string.local_openstreetmap_settings);
pref.setSummary(R.string.local_openstreetmap_settings_descr);
pref.setKey("local_openstreetmap_points");
pref.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
OsmAndAppCustomization appCustomization = getMyApplication().getAppCustomization();
final Intent favorites = new Intent(SettingsOsmEditingActivity.this, appCustomization.getFavoritesActivity());
favorites.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
getMyApplication().getSettings().FAVORITES_TAB.set(R.string.osm_edits);
startActivity(favorites);
return true;
}
});
grp.addPreference(pref);
}
use of android.preference.CheckBoxPreference in project android_packages_apps_OmniClock by omnirom.
the class ScreensaverSettingsActivity method refresh.
private void refresh() {
ListPreference listPref = (ListPreference) findPreference(KEY_CLOCK_STYLE);
listPref.setSummary(listPref.getEntry());
listPref.setOnPreferenceChangeListener(this);
Preference pref = findPreference(KEY_NIGHT_MODE);
boolean state = ((CheckBoxPreference) pref).isChecked();
pref.setOnPreferenceChangeListener(this);
}
use of android.preference.CheckBoxPreference in project android_packages_apps_OmniClock by omnirom.
the class SettingsActivity method onPreferenceChange.
@Override
public boolean onPreferenceChange(Preference pref, Object newValue) {
if (KEY_CLOCK_STYLE.equals(pref.getKey())) {
final ListPreference listPref = (ListPreference) pref;
final int idx = listPref.findIndexOfValue((String) newValue);
listPref.setSummary(listPref.getEntries()[idx]);
} else if (KEY_HOME_TZ.equals(pref.getKey())) {
final ListPreference listPref = (ListPreference) pref;
final int idx = listPref.findIndexOfValue((String) newValue);
listPref.setSummary(listPref.getEntries()[idx]);
notifyHomeTimeZoneChanged();
} else if (KEY_AUTO_HOME_CLOCK.equals(pref.getKey())) {
boolean state = ((CheckBoxPreference) pref).isChecked();
Preference homeTimeZone = findPreference(KEY_HOME_TZ);
homeTimeZone.setEnabled(!state);
notifyHomeTimeZoneChanged();
} else if (KEY_VOLUME_BUTTONS.equals(pref.getKey())) {
final ListPreference listPref = (ListPreference) pref;
final int idx = listPref.findIndexOfValue((String) newValue);
listPref.setSummary(listPref.getEntries()[idx]);
} else if (KEY_ALARM_SNOOZE_MINUTES.equals(pref.getKey())) {
mSnoozeMinutes.setSummary(getSnoozedMinutes((Integer) newValue));
} else if (KEY_ALARM_SILENCE_AFTER.equals(pref.getKey())) {
updateSilenceAfterSummary(pref, (Integer) newValue);
} else if (KEY_ALARM_SNOOZE_COUNT.equals(pref.getKey())) {
final ListPreference listPref = (ListPreference) pref;
final int idx = listPref.findIndexOfValue((String) newValue);
listPref.setSummary(listPref.getEntries()[idx]);
} else if (KEY_FLIP_ACTION.equals(pref.getKey())) {
final ListPreference listPref = (ListPreference) pref;
final int idx = listPref.findIndexOfValue((String) newValue);
listPref.setSummary(listPref.getEntries()[idx]);
} else if (KEY_SHAKE_ACTION.equals(pref.getKey())) {
final ListPreference listPref = (ListPreference) pref;
final int idx = listPref.findIndexOfValue((String) newValue);
listPref.setSummary(listPref.getEntries()[idx]);
} else if (KEY_VOLUME_INCREASE_SPEED.equals(pref.getKey())) {
final ListPreference listPref = (ListPreference) pref;
final int idx = listPref.findIndexOfValue((String) newValue);
listPref.setSummary(listPref.getEntries()[idx]);
} else if (KEY_WEEK_START.equals(pref.getKey())) {
final ListPreference listPref = (ListPreference) pref;
final int idx = listPref.findIndexOfValue((String) newValue);
listPref.setSummary(listPref.getEntries()[idx]);
} else if (KEY_AUDIO_STREAM.equals(pref.getKey())) {
final ListPreference listPref = (ListPreference) pref;
final int idx = listPref.findIndexOfValue((String) newValue);
listPref.setSummary(listPref.getEntries()[idx]);
} else if (KEY_TIMER_ALARM_INCREASE_VOLUME_SPEED.equals(pref.getKey())) {
final ListPreference listPref = (ListPreference) pref;
final int idx = listPref.findIndexOfValue((String) newValue);
listPref.setSummary(listPref.getEntries()[idx]);
} else if (KEY_PRE_ALARM_NOTIFICATION_TIME.equals(pref.getKey())) {
final ListPreference listPref = (ListPreference) pref;
final int idx = listPref.findIndexOfValue((String) newValue);
listPref.setSummary(listPref.getEntries()[idx]);
} else if (KEY_COLOR_THEME.equals(pref.getKey())) {
final ListPreference listPref = (ListPreference) pref;
final int idx = listPref.findIndexOfValue((String) newValue);
listPref.setSummary(listPref.getEntries()[idx]);
notifyColorThemeChanged();
} else if (KEY_DEFAULT_PAGE.equals(pref.getKey())) {
final ListPreference listPref = (ListPreference) pref;
final int idx = listPref.findIndexOfValue((String) newValue);
listPref.setSummary(listPref.getEntries()[idx]);
}
return true;
}
use of android.preference.CheckBoxPreference in project sentinel-android by Samourai-Wallet.
the class SettingsActivity method onCreate.
/**
* Called when the activity is first created.
*/
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setTitle(R.string.app_name);
addPreferencesFromResource(R.xml.settings);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
Preference aboutPref = (Preference) findPreference("about");
aboutPref.setSummary("Sentinel," + " " + getResources().getString(R.string.version_name));
aboutPref.setOnPreferenceClickListener(new OnPreferenceClickListener() {
public boolean onPreferenceClick(Preference preference) {
new AlertDialog.Builder(SettingsActivity.this).setIcon(R.drawable.ic_launcher).setTitle(R.string.app_name).setMessage("Sentinel," + " " + getResources().getString(R.string.version_name)).setCancelable(false).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
;
}
}).show();
return true;
}
});
Preference explorersPref = (Preference) findPreference("explorer");
explorersPref.setOnPreferenceClickListener(new OnPreferenceClickListener() {
public boolean onPreferenceClick(Preference preference) {
getBlockExplorer();
return true;
}
});
Preference fiatPref = (Preference) findPreference("fiat");
fiatPref.setOnPreferenceClickListener(new OnPreferenceClickListener() {
public boolean onPreferenceClick(Preference preference) {
getExchange();
return true;
}
});
final CheckBoxPreference cbPref1 = (CheckBoxPreference) findPreference("pin");
final CheckBoxPreference cbPref2 = (CheckBoxPreference) findPreference("scramblePin");
final CheckBoxPreference cbPref3 = (CheckBoxPreference) findPreference("haptic");
if (!cbPref1.isChecked()) {
cbPref2.setChecked(false);
cbPref2.setEnabled(false);
cbPref3.setChecked(false);
cbPref3.setEnabled(false);
}
cbPref1.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
public boolean onPreferenceChange(Preference preference, Object newValue) {
if (cbPref1.isChecked()) {
PrefsUtil.getInstance(SettingsActivity.this).setValue(PrefsUtil.PIN_HASH, "");
cbPref2.setChecked(false);
cbPref2.setEnabled(false);
cbPref3.setChecked(false);
cbPref3.setEnabled(false);
PrefsUtil.getInstance(SettingsActivity.this).setValue(PrefsUtil.SCRAMBLE_PIN, false);
} else {
cbPref2.setEnabled(true);
cbPref3.setEnabled(true);
Intent intent = new Intent(SettingsActivity.this, PinEntryActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra("create", true);
startActivity(intent);
}
return true;
}
});
cbPref2.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
public boolean onPreferenceChange(Preference preference, Object newValue) {
if (cbPref2.isChecked()) {
PrefsUtil.getInstance(SettingsActivity.this).setValue(PrefsUtil.SCRAMBLE_PIN, false);
} else {
PrefsUtil.getInstance(SettingsActivity.this).setValue(PrefsUtil.SCRAMBLE_PIN, true);
}
return true;
}
});
cbPref3.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
public boolean onPreferenceChange(Preference preference, Object newValue) {
if (cbPref3.isChecked()) {
PrefsUtil.getInstance(SettingsActivity.this).setValue(PrefsUtil.HAPTIC_PIN, false);
} else {
PrefsUtil.getInstance(SettingsActivity.this).setValue(PrefsUtil.HAPTIC_PIN, true);
}
return true;
}
});
Preference exportPref = (Preference) findPreference("export");
exportPref.setOnPreferenceClickListener(new OnPreferenceClickListener() {
public boolean onPreferenceClick(Preference preference) {
AppUtil.getInstance(SettingsActivity.this).doBackup();
return true;
}
});
Preference restorePref = (Preference) findPreference("restore");
restorePref.setOnPreferenceClickListener(new OnPreferenceClickListener() {
public boolean onPreferenceClick(Preference preference) {
AppUtil.getInstance(SettingsActivity.this).doRestore();
return true;
}
});
}
use of android.preference.CheckBoxPreference in project PhoneProfiles by henrichg.
the class PhoneProfilesPreferencesNestedFragment method setSummary.
void setSummary(String key) {
Preference preference = prefMng.findPreference(key);
if (preference == null)
return;
PreferenceScreen preferenceCategoryNotifications = (PreferenceScreen) findPreference("categoryNotifications");
if (Build.VERSION.SDK_INT < 26) {
boolean notificationStatusBar = preferences.getBoolean(ApplicationPreferences.PREF_NOTIFICATION_STATUS_BAR, true);
boolean notificationStatusBarPermanent = preferences.getBoolean(ApplicationPreferences.PREF_NOTIFICATION_STATUS_BAR_PERMANENT, true);
if (!(notificationStatusBar && notificationStatusBarPermanent)) {
setPreferenceTitleStyle(preferenceCategoryNotifications, true, true);
if (preferenceCategoryNotifications != null)
preferenceCategoryNotifications.setSummary(getString(R.string.phone_profiles_pref_notificationStatusBarNotEnabled_summary) + " " + getString(R.string.phone_profiles_pref_notificationStatusBarRequired));
} else {
setPreferenceTitleStyle(preferenceCategoryNotifications, false, false);
if (preferenceCategoryNotifications != null)
preferenceCategoryNotifications.setSummary(R.string.empty_string);
}
if (key.equals(ApplicationPreferences.PREF_NOTIFICATION_STATUS_BAR)) {
setPreferenceTitleStyle(preference, !notificationStatusBar, !notificationStatusBar);
}
if (key.equals(ApplicationPreferences.PREF_NOTIFICATION_STATUS_BAR_PERMANENT)) {
setPreferenceTitleStyle(preference, !notificationStatusBarPermanent, !notificationStatusBarPermanent);
}
}
if ((android.os.Build.VERSION.SDK_INT >= 21) && (android.os.Build.VERSION.SDK_INT < 26)) {
if (key.equals(ApplicationPreferences.PREF_NOTIFICATION_SHOW_IN_STATUS_BAR)) {
boolean show = preferences.getBoolean(key, true);
Preference _preference = prefMng.findPreference(ApplicationPreferences.PREF_NOTIFICATION_HIDE_IN_LOCKSCREEN);
if (_preference != null)
_preference.setEnabled(show);
}
}
if (key.equals(ApplicationPreferences.PREF_APPLICATION_WIDGET_LIST_BACKGROUND_TYPE)) {
if (preferences.getBoolean(ApplicationPreferences.PREF_APPLICATION_WIDGET_LIST_BACKGROUND_TYPE, false)) {
Preference _preference = prefMng.findPreference(ApplicationPreferences.PREF_APPLICATION_WIDGET_LIST_BACKGROUND_COLOR);
if (_preference != null)
_preference.setEnabled(true);
_preference = prefMng.findPreference(ApplicationPreferences.PREF_APPLICATION_WIDGET_LIST_LIGHTNESS_B);
if (_preference != null)
_preference.setEnabled(false);
} else {
Preference _preference = prefMng.findPreference(ApplicationPreferences.PREF_APPLICATION_WIDGET_LIST_BACKGROUND_COLOR);
if (_preference != null)
_preference.setEnabled(false);
_preference = prefMng.findPreference(ApplicationPreferences.PREF_APPLICATION_WIDGET_LIST_LIGHTNESS_B);
if (_preference != null)
_preference.setEnabled(true);
}
}
if (key.equals(ApplicationPreferences.PREF_APPLICATION_WIDGET_ICON_BACKGROUND_TYPE)) {
if (preferences.getBoolean(ApplicationPreferences.PREF_APPLICATION_WIDGET_ICON_BACKGROUND_TYPE, false)) {
Preference _preference = prefMng.findPreference(ApplicationPreferences.PREF_APPLICATION_WIDGET_ICON_BACKGROUND_COLOR);
if (_preference != null)
_preference.setEnabled(true);
_preference = prefMng.findPreference(ApplicationPreferences.PREF_APPLICATION_WIDGET_ICON_LIGHTNESS_B);
if (_preference != null)
_preference.setEnabled(false);
} else {
Preference _preference = prefMng.findPreference(ApplicationPreferences.PREF_APPLICATION_WIDGET_ICON_BACKGROUND_COLOR);
if (_preference != null)
_preference.setEnabled(false);
_preference = prefMng.findPreference(ApplicationPreferences.PREF_APPLICATION_WIDGET_ICON_LIGHTNESS_B);
if (_preference != null)
_preference.setEnabled(true);
}
}
if (key.equals(ApplicationPreferences.PREF_APPLICATION_SAMSUNG_EDGE_BACKGROUND_TYPE)) {
if (preferences.getBoolean(ApplicationPreferences.PREF_APPLICATION_SAMSUNG_EDGE_BACKGROUND_TYPE, false)) {
Preference _preference = prefMng.findPreference(ApplicationPreferences.PREF_APPLICATION_SAMSUNG_EDGE_BACKGROUND_COLOR);
if (_preference != null)
_preference.setEnabled(true);
_preference = prefMng.findPreference(ApplicationPreferences.PREF_APPLICATION_SAMSUNG_EDGE_LIGHTNESS_B);
if (_preference != null)
_preference.setEnabled(false);
} else {
Preference _preference = prefMng.findPreference(ApplicationPreferences.PREF_APPLICATION_SAMSUNG_EDGE_BACKGROUND_COLOR);
if (_preference != null)
_preference.setEnabled(false);
_preference = prefMng.findPreference(ApplicationPreferences.PREF_APPLICATION_SAMSUNG_EDGE_LIGHTNESS_B);
if (_preference != null)
_preference.setEnabled(true);
}
}
// Do not bind toggles.
if (preference instanceof CheckBoxPreference || preference instanceof TwoStatePreference) {
return;
}
String stringValue = preferences.getString(key, "");
if (key.equals(ApplicationPreferences.PREF_APPLICATION_BACKGROUND_PROFILE)) {
long lProfileId;
try {
lProfileId = Long.parseLong(stringValue);
} catch (Exception e) {
lProfileId = 0;
}
ProfilePreference profilePreference = (ProfilePreference) preference;
profilePreference.setSummary(lProfileId);
} else if (preference instanceof ListPreference) {
// For list preferences, look up the correct display value in
// the preference's 'entries' list.
ListPreference listPreference = (ListPreference) preference;
int index = listPreference.findIndexOfValue(stringValue);
// Set the summary to reflect the new value.
CharSequence summary = (index >= 0) ? listPreference.getEntries()[index] : null;
if (summary != null) {
String sSummary = summary.toString();
sSummary = sSummary.replace("%", "%%");
preference.setSummary(sSummary);
} else
preference.setSummary(null);
} else /*else if (preference instanceof RingtonePreference) {
// For ringtone preferences, look up the correct display value
// using RingtoneManager.
if (TextUtils.isEmpty(stringValue)) {
// Empty values correspond to 'silent' (no ringtone).
preference.setSummary(R.string.ringtone_silent);
} else {
Ringtone ringtone = RingtoneManager.getRingtone(
preference.getContext(), Uri.parse(stringValue));
if (ringtone == null) {
// Clear the summary if there was a lookup error.
preference.setSummary(null);
} else {
// Set the summary to reflect the new ringtone display
// name.
String name = ringtone
.getTitle(preference.getContext());
preference.setSummary(name);
}
}
}*/
{
// For all other preferences, set the summary to the value's
// simple string representation.
// preference.setSummary(preference.toString());
preference.setSummary(stringValue);
}
if (key.equals(ApplicationPreferences.PREF_APPLICATION_FORCE_SET_MERGE_RINGER_NOTIFICATION_VOLUMES)) {
Preference _preference = prefMng.findPreference(ApplicationPreferences.PREF_APPLICATION_UNLINK_RINGER_NOTIFICATION_VOLUMES);
if (_preference != null) {
boolean enabled;
String value = preferences.getString(key, "0");
if (!value.equals("0"))
enabled = value.equals("1");
else
enabled = ActivateProfileHelper.getMergedRingNotificationVolumes(getActivity().getApplicationContext());
// Log.d("PhoneProfilesPreferencesNestedFragment.setSummary","enabled="+enabled);
_preference.setEnabled(enabled);
}
}
if (key.equals(ApplicationPreferences.PREF_APPLICATION_WIDGET_ICON_COLOR)) {
Preference _preference = prefMng.findPreference(ApplicationPreferences.PREF_APPLICATION_WIDGET_ICON_LIGHTNESS);
if (_preference != null) {
boolean colorful = preferences.getString(key, "0").equals("1");
_preference.setEnabled(colorful);
}
}
if (key.equals(ApplicationPreferences.PREF_APPLICATION_WIDGET_LIST_ICON_COLOR)) {
Preference _preference = prefMng.findPreference(ApplicationPreferences.PREF_APPLICATION_WIDGET_LIST_ICON_LIGHTNESS);
if (_preference != null) {
boolean colorful = preferences.getString(key, "0").equals("1");
_preference.setEnabled(colorful);
}
}
if (key.equals(ApplicationPreferences.PREF_APPLICATION_SAMSUNG_EDGE_ICON_COLOR)) {
Preference _preference = prefMng.findPreference(ApplicationPreferences.PREF_APPLICATION_SAMSUNG_EDGE_ICON_LIGHTNESS);
if (_preference != null) {
boolean colorful = preferences.getString(key, "0").equals("1");
_preference.setEnabled(colorful);
}
}
}
Aggregations