List of usage examples for android.preference CheckBoxPreference isChecked
public boolean isChecked()
From source file:com.aware.Aware_Preferences.java
/** * MQTT module settings UI// w w w .jav a2s . co m */ private void mqtt() { final CheckBoxPreference mqtt = (CheckBoxPreference) findPreference(Aware_Preferences.STATUS_MQTT); mqtt.setChecked(Aware.getSetting(getApplicationContext(), Aware_Preferences.STATUS_MQTT).equals("true")); mqtt.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { if (Aware.getSetting(getApplicationContext(), Aware_Preferences.MQTT_SERVER).length() == 0) { showDialog(DIALOG_ERROR_MISSING_PARAMETERS); mqtt.setChecked(false); Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_MQTT, false); return false; } else { Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_MQTT, mqtt.isChecked()); if (mqtt.isChecked()) { framework.startMQTT(); } else { framework.stopMQTT(); } return true; } } }); final EditTextPreference mqttServer = (EditTextPreference) findPreference(Aware_Preferences.MQTT_SERVER); mqttServer.setText(Aware.getSetting(getApplicationContext(), Aware_Preferences.MQTT_SERVER)); if (Aware.getSetting(getApplicationContext(), Aware_Preferences.MQTT_SERVER).length() > 0) { mqttServer.setSummary( "Server: " + Aware.getSetting(getApplicationContext(), Aware_Preferences.MQTT_SERVER)); } mqttServer.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { Aware.setSetting(getApplicationContext(), Aware_Preferences.MQTT_SERVER, (String) newValue); mqttServer.setSummary("Server: " + (String) newValue); return true; } }); final EditTextPreference mqttPort = (EditTextPreference) findPreference(Aware_Preferences.MQTT_PORT); if (Aware.getSetting(getApplicationContext(), Aware_Preferences.MQTT_PORT).length() > 0) { mqttPort.setSummary(Aware.getSetting(getApplicationContext(), Aware_Preferences.MQTT_PORT)); } mqttPort.setText(Aware.getSetting(getApplicationContext(), Aware_Preferences.MQTT_PORT)); mqttPort.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { Aware.setSetting(getApplicationContext(), Aware_Preferences.MQTT_PORT, (String) newValue); return true; } }); final EditTextPreference mqttUsername = (EditTextPreference) findPreference( Aware_Preferences.MQTT_USERNAME); if (Aware.getSetting(getApplicationContext(), Aware_Preferences.MQTT_USERNAME).length() > 0) { mqttUsername.setSummary(Aware.getSetting(getApplicationContext(), Aware_Preferences.MQTT_USERNAME)); } mqttUsername.setText(Aware.getSetting(getApplicationContext(), Aware_Preferences.MQTT_USERNAME)); mqttUsername.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { Aware.setSetting(getApplicationContext(), Aware_Preferences.MQTT_USERNAME, (String) newValue); return true; } }); final EditTextPreference mqttPassword = (EditTextPreference) findPreference( Aware_Preferences.MQTT_PASSWORD); mqttPassword.setText(Aware.getSetting(getApplicationContext(), Aware_Preferences.MQTT_PASSWORD)); mqttPassword.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { Aware.setSetting(getApplicationContext(), Aware_Preferences.MQTT_PASSWORD, (String) newValue); return true; } }); final EditTextPreference mqttKeepAlive = (EditTextPreference) findPreference( Aware_Preferences.MQTT_KEEP_ALIVE); if (Aware.getSetting(getApplicationContext(), Aware_Preferences.MQTT_KEEP_ALIVE).length() > 0) { mqttKeepAlive.setSummary( Aware.getSetting(getApplicationContext(), Aware_Preferences.MQTT_KEEP_ALIVE) + " seconds"); } mqttKeepAlive.setText(Aware.getSetting(getApplicationContext(), Aware_Preferences.MQTT_KEEP_ALIVE)); mqttKeepAlive.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { Aware.setSetting(getApplicationContext(), Aware_Preferences.MQTT_KEEP_ALIVE, (String) newValue); mqttKeepAlive.setSummary((String) newValue + " seconds"); return true; } }); final EditTextPreference mqttQoS = (EditTextPreference) findPreference(Aware_Preferences.MQTT_QOS); mqttQoS.setText(Aware.getSetting(getApplicationContext(), Aware_Preferences.MQTT_QOS)); mqttQoS.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { Aware.setSetting(getApplicationContext(), Aware_Preferences.MQTT_QOS, (String) newValue); return true; } }); final EditTextPreference mqttProtocol = (EditTextPreference) findPreference( Aware_Preferences.MQTT_PROTOCOL); mqttProtocol.setText(Aware.getSetting(getApplicationContext(), Aware_Preferences.MQTT_PROTOCOL)); mqttProtocol.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { Aware.setSetting(getApplicationContext(), Aware_Preferences.MQTT_PROTOCOL, (String) newValue); return true; } }); }
From source file:com.aware.Aware_Preferences.java
/** * Temperature module settings UI/*w ww. j a va2 s . com*/ */ private void temperature() { final PreferenceScreen temp_pref = (PreferenceScreen) findPreference("temperature"); Sensor temp = mSensorMgr.getDefaultSensor(Sensor.TYPE_TEMPERATURE); if (temp != null) { temp_pref.setSummary( temp_pref.getSummary().toString().replace("*", " - Power: " + temp.getPower() + " mA")); } else { temp_pref.setSummary(temp_pref.getSummary().toString().replace("*", "")); } final CheckBoxPreference temperature = (CheckBoxPreference) findPreference( Aware_Preferences.STATUS_TEMPERATURE); temperature.setChecked( Aware.getSetting(getApplicationContext(), Aware_Preferences.STATUS_TEMPERATURE).equals("true")); temperature.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { if (mSensorMgr.getDefaultSensor(Sensor.TYPE_TEMPERATURE) == null) { showDialog(DIALOG_ERROR_MISSING_SENSOR); temperature.setChecked(false); Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_TEMPERATURE, false); return false; } Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_TEMPERATURE, temperature.isChecked()); if (temperature.isChecked()) { framework.startTemperature(); } else { framework.stopTemperature(); } return true; } }); final EditTextPreference frequency_temperature = (EditTextPreference) findPreference( Aware_Preferences.FREQUENCY_TEMPERATURE); frequency_temperature .setText(Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_TEMPERATURE)); if (Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_TEMPERATURE).length() > 0) { frequency_temperature .setSummary(Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_TEMPERATURE) + " microseconds"); } frequency_temperature.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { Aware.setSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_TEMPERATURE, (String) newValue); frequency_temperature.setSummary((String) newValue + " microseconds"); framework.startTemperature(); return true; } }); }
From source file:com.aware.Aware_Preferences.java
/** * Bluetooth module settings UI/*from w w w . jav a 2 s . com*/ */ private void bluetooth() { final CheckBoxPreference bluetooth = (CheckBoxPreference) findPreference( Aware_Preferences.STATUS_BLUETOOTH); bluetooth.setChecked( Aware.getSetting(getApplicationContext(), Aware_Preferences.STATUS_BLUETOOTH).equals("true")); bluetooth.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { BluetoothAdapter btAdapter = BluetoothAdapter.getDefaultAdapter(); if (btAdapter == null) { showDialog(DIALOG_ERROR_MISSING_SENSOR); bluetooth.setChecked(false); Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_BLUETOOTH, false); return false; } Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_BLUETOOTH, bluetooth.isChecked()); if (bluetooth.isChecked()) { framework.startBluetooth(); } else { framework.stopBluetooth(); } return true; } }); final EditTextPreference bluetoothInterval = (EditTextPreference) findPreference( Aware_Preferences.FREQUENCY_BLUETOOTH); if (Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_BLUETOOTH).length() > 0) { bluetoothInterval.setSummary( Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_BLUETOOTH) + " seconds"); } bluetoothInterval.setText(Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_BLUETOOTH)); bluetoothInterval.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { Aware.setSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_BLUETOOTH, (String) newValue); bluetoothInterval.setSummary((String) newValue + " seconds"); framework.startBluetooth(); return true; } }); }
From source file:com.aware.Aware_Preferences.java
/** * Magnetometer module settings UI//from w ww . ja v a2 s . com */ private void magnetometer() { final PreferenceScreen magno_pref = (PreferenceScreen) findPreference("magnetometer"); Sensor temp = mSensorMgr.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD); if (temp != null) { magno_pref.setSummary( magno_pref.getSummary().toString().replace("*", " - Power: " + temp.getPower() + " mA")); } else { magno_pref.setSummary(magno_pref.getSummary().toString().replace("*", "")); } final CheckBoxPreference magnetometer = (CheckBoxPreference) findPreference( Aware_Preferences.STATUS_MAGNETOMETER); magnetometer.setChecked( Aware.getSetting(getApplicationContext(), Aware_Preferences.STATUS_MAGNETOMETER).equals("true")); magnetometer.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { if (mSensorMgr.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD) == null) { showDialog(DIALOG_ERROR_MISSING_SENSOR); magnetometer.setChecked(false); Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_MAGNETOMETER, false); return false; } Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_MAGNETOMETER, magnetometer.isChecked()); if (magnetometer.isChecked()) { framework.startMagnetometer(); } else { framework.stopMagnetometer(); } return true; } }); final EditTextPreference frequency_magnetometer = (EditTextPreference) findPreference( Aware_Preferences.FREQUENCY_MAGNETOMETER); if (Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_MAGNETOMETER).length() > 0) { frequency_magnetometer .setSummary(Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_MAGNETOMETER) + " microseconds"); } frequency_magnetometer .setText(Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_MAGNETOMETER)); frequency_magnetometer.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { Aware.setSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_MAGNETOMETER, (String) newValue); frequency_magnetometer.setSummary((String) newValue + " microseconds"); framework.startMagnetometer(); return true; } }); }
From source file:com.aware.Aware_Preferences.java
/** * Accelerometer module settings UI/*from w w w . ja va 2 s.c o m*/ */ private void accelerometer() { final PreferenceScreen accel_pref = (PreferenceScreen) findPreference("accelerometer"); Sensor temp = mSensorMgr.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); if (temp != null) { accel_pref.setSummary( accel_pref.getSummary().toString().replace("*", " - Power: " + temp.getPower() + " mA")); } else { accel_pref.setSummary(accel_pref.getSummary().toString().replace("*", "")); } final CheckBoxPreference accelerometer = (CheckBoxPreference) findPreference( Aware_Preferences.STATUS_ACCELEROMETER); accelerometer.setChecked( Aware.getSetting(getApplicationContext(), Aware_Preferences.STATUS_ACCELEROMETER).equals("true")); accelerometer.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { if (mSensorMgr.getDefaultSensor(Sensor.TYPE_ACCELEROMETER) == null) { showDialog(DIALOG_ERROR_MISSING_SENSOR); accelerometer.setChecked(false); Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_ACCELEROMETER, false); return false; } Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_ACCELEROMETER, accelerometer.isChecked()); if (accelerometer.isChecked()) { framework.startAccelerometer(); } else { framework.stopAccelerometer(); } return true; } }); final EditTextPreference frequency_accelerometer = (EditTextPreference) findPreference( Aware_Preferences.FREQUENCY_ACCELEROMETER); if (Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_ACCELEROMETER).length() > 0) { frequency_accelerometer .setSummary(Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_ACCELEROMETER) + " microseconds"); } frequency_accelerometer .setText(Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_ACCELEROMETER)); frequency_accelerometer.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { Aware.setSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_ACCELEROMETER, (String) newValue); frequency_accelerometer.setSummary((String) newValue + " microseconds"); framework.startAccelerometer(); return true; } }); }
From source file:com.aware.Aware_Preferences.java
/** * Linear Accelerometer module settings UI *///from www .ja va 2 s . c om private void linear_accelerometer() { final PreferenceScreen linear_pref = (PreferenceScreen) findPreference("linear_accelerometer"); Sensor temp = mSensorMgr.getDefaultSensor(Sensor.TYPE_LINEAR_ACCELERATION); if (temp != null) { linear_pref.setSummary( linear_pref.getSummary().toString().replace("*", " - Power: " + temp.getPower() + " mA")); } else { linear_pref.setSummary(linear_pref.getSummary().toString().replace("*", "")); } final CheckBoxPreference linear_accelerometer = (CheckBoxPreference) findPreference( Aware_Preferences.STATUS_LINEAR_ACCELEROMETER); linear_accelerometer.setChecked(Aware .getSetting(getApplicationContext(), Aware_Preferences.STATUS_LINEAR_ACCELEROMETER).equals("true")); linear_accelerometer.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { if (mSensorMgr.getDefaultSensor(Sensor.TYPE_LINEAR_ACCELERATION) == null) { showDialog(DIALOG_ERROR_MISSING_SENSOR); linear_accelerometer.setChecked(false); Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_LINEAR_ACCELEROMETER, false); return false; } Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_LINEAR_ACCELEROMETER, linear_accelerometer.isChecked()); if (linear_accelerometer.isChecked()) { framework.startLinearAccelerometer(); } else { framework.stopLinearAccelerometer(); } return true; } }); final EditTextPreference frequency_linear_accelerometer = (EditTextPreference) findPreference( Aware_Preferences.FREQUENCY_LINEAR_ACCELEROMETER); if (Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_LINEAR_ACCELEROMETER) .length() > 0) { frequency_linear_accelerometer.setSummary( Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_LINEAR_ACCELEROMETER) + " microseconds"); } frequency_linear_accelerometer.setText( Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_LINEAR_ACCELEROMETER)); frequency_linear_accelerometer.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { Aware.setSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_LINEAR_ACCELEROMETER, (String) newValue); frequency_linear_accelerometer.setSummary((String) newValue + " microseconds"); framework.startLinearAccelerometer(); return true; } }); }
From source file:com.aware.Aware_Preferences.java
/** * Webservices module settings UI/*w w w . j a v a 2 s .com*/ */ private void webservices() { final CheckBoxPreference webservice = (CheckBoxPreference) findPreference( Aware_Preferences.STATUS_WEBSERVICE); webservice.setChecked( Aware.getSetting(getApplicationContext(), Aware_Preferences.STATUS_WEBSERVICE).equals("true")); webservice.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { if (Aware.getSetting(getApplicationContext(), Aware_Preferences.WEBSERVICE_SERVER).length() == 0) { showDialog(DIALOG_ERROR_MISSING_PARAMETERS); Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_WEBSERVICE, false); webservice.setChecked(false); return false; } else { Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_WEBSERVICE, webservice.isChecked()); if (webservice.isChecked() && Aware.getSetting(getApplicationContext(), WEBSERVICE_SERVER).length() > 0) { //setup and send data Intent study_config = new Intent(getApplicationContext(), StudyConfig.class); study_config.putExtra("study_url", Aware.getSetting(getApplicationContext(), WEBSERVICE_SERVER)); startService(study_config); } return true; } } }); final EditTextPreference webservice_server = (EditTextPreference) findPreference( Aware_Preferences.WEBSERVICE_SERVER); webservice_server.setText(Aware.getSetting(getApplicationContext(), Aware_Preferences.WEBSERVICE_SERVER)); if (Aware.getSetting(getApplicationContext(), Aware_Preferences.WEBSERVICE_SERVER).length() > 0) { webservice_server.setSummary( "Server: " + Aware.getSetting(getApplicationContext(), Aware_Preferences.WEBSERVICE_SERVER)); } webservice_server.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { Aware.setSetting(getApplicationContext(), Aware_Preferences.WEBSERVICE_SERVER, (String) newValue); webservice_server.setSummary("Server: " + (String) newValue); return true; } }); final CheckBoxPreference webservice_wifi_only = (CheckBoxPreference) findPreference( Aware_Preferences.WEBSERVICE_WIFI_ONLY); webservice_wifi_only.setChecked( Aware.getSetting(getApplicationContext(), Aware_Preferences.WEBSERVICE_WIFI_ONLY).equals("true")); webservice_wifi_only.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { Aware.setSetting(getApplicationContext(), Aware_Preferences.WEBSERVICE_WIFI_ONLY, webservice_wifi_only.isChecked()); return true; } }); final EditTextPreference frequency_webservice = (EditTextPreference) findPreference( Aware_Preferences.FREQUENCY_WEBSERVICE); if (Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_WEBSERVICE).length() > 0) { frequency_webservice.setSummary( Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_WEBSERVICE) + " minutes"); } frequency_webservice .setText(Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_WEBSERVICE)); frequency_webservice.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { Aware.setSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_WEBSERVICE, (String) newValue); frequency_webservice.setSummary((String) newValue + " minutes"); return true; } }); final ListPreference clean_old_data = (ListPreference) findPreference(FREQUENCY_CLEAN_OLD_DATA); if (Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_CLEAN_OLD_DATA).length() > 0) { String freq = Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_CLEAN_OLD_DATA); if (freq.equals("0")) { clean_old_data.setSummary("Never"); } else if (freq.equals("1")) { clean_old_data.setSummary("Weekly"); } else if (freq.equals("2")) { clean_old_data.setSummary("Monthly"); } } clean_old_data.setDefaultValue(Aware.getSetting(getApplicationContext(), FREQUENCY_CLEAN_OLD_DATA)); clean_old_data.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { Aware.setSetting(getApplicationContext(), FREQUENCY_CLEAN_OLD_DATA, (String) newValue); if (((String) newValue).equals("0")) { clean_old_data.setSummary("Never"); } else if (((String) newValue).equals("1")) { clean_old_data.setSummary("Weekly"); } else if (((String) newValue).equals("2")) { clean_old_data.setSummary("Monthly"); } return true; } }); }
From source file:com.aware.Aware_Preferences.java
/** * Location module settings UI//from w ww. j a va2 s .co m */ private void locations() { final CheckBoxPreference location_gps = (CheckBoxPreference) findPreference( Aware_Preferences.STATUS_LOCATION_GPS); location_gps.setChecked( Aware.getSetting(getApplicationContext(), Aware_Preferences.STATUS_LOCATION_GPS).equals("true")); location_gps.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { LocationManager localMng = (LocationManager) getSystemService(LOCATION_SERVICE); List<String> providers = localMng.getAllProviders(); if (!providers.contains(LocationManager.GPS_PROVIDER)) { showDialog(DIALOG_ERROR_MISSING_SENSOR); location_gps.setChecked(false); Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_LOCATION_GPS, false); return false; } Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_LOCATION_GPS, location_gps.isChecked()); if (location_gps.isChecked()) { framework.startLocations(); } else { framework.stopLocations(); } return true; } }); final CheckBoxPreference location_network = (CheckBoxPreference) findPreference( Aware_Preferences.STATUS_LOCATION_NETWORK); location_network.setChecked(Aware .getSetting(getApplicationContext(), Aware_Preferences.STATUS_LOCATION_NETWORK).equals("true")); location_network.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { LocationManager localMng = (LocationManager) getSystemService(LOCATION_SERVICE); List<String> providers = localMng.getAllProviders(); if (!providers.contains(LocationManager.NETWORK_PROVIDER)) { showDialog(DIALOG_ERROR_MISSING_SENSOR); location_gps.setChecked(false); Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_LOCATION_NETWORK, false); return false; } Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_LOCATION_NETWORK, location_network.isChecked()); if (location_network.isChecked()) { framework.startLocations(); } else { framework.stopLocations(); } return true; } }); final EditTextPreference gpsInterval = (EditTextPreference) findPreference( Aware_Preferences.FREQUENCY_LOCATION_GPS); if (Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_LOCATION_GPS).length() > 0) { gpsInterval .setSummary(Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_LOCATION_GPS) + " seconds"); } gpsInterval.setText(Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_LOCATION_GPS)); gpsInterval.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { Aware.setSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_LOCATION_GPS, (String) newValue); gpsInterval.setSummary((String) newValue + " seconds"); framework.startLocations(); return true; } }); final EditTextPreference networkInterval = (EditTextPreference) findPreference( Aware_Preferences.FREQUENCY_LOCATION_NETWORK); if (Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_LOCATION_NETWORK).length() > 0) { networkInterval.setSummary( Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_LOCATION_NETWORK) + " seconds"); } networkInterval .setText(Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_LOCATION_NETWORK)); networkInterval.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { Aware.setSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_LOCATION_NETWORK, (String) newValue); networkInterval.setSummary((String) newValue + " seconds"); framework.startLocations(); return true; } }); final EditTextPreference gpsAccuracy = (EditTextPreference) findPreference( Aware_Preferences.MIN_LOCATION_GPS_ACCURACY); if (Aware.getSetting(getApplicationContext(), Aware_Preferences.MIN_LOCATION_GPS_ACCURACY).length() > 0) { gpsAccuracy.setSummary( Aware.getSetting(getApplicationContext(), Aware_Preferences.MIN_LOCATION_GPS_ACCURACY) + " meters"); } gpsAccuracy.setText(Aware.getSetting(getApplicationContext(), Aware_Preferences.MIN_LOCATION_GPS_ACCURACY)); gpsAccuracy.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { Aware.setSetting(getApplicationContext(), Aware_Preferences.MIN_LOCATION_GPS_ACCURACY, (String) newValue); gpsAccuracy.setSummary((String) newValue + " meters"); framework.startLocations(); return true; } }); final EditTextPreference networkAccuracy = (EditTextPreference) findPreference( Aware_Preferences.MIN_LOCATION_NETWORK_ACCURACY); if (Aware.getSetting(getApplicationContext(), Aware_Preferences.MIN_LOCATION_NETWORK_ACCURACY) .length() > 0) { networkAccuracy.setSummary( Aware.getSetting(getApplicationContext(), Aware_Preferences.MIN_LOCATION_NETWORK_ACCURACY) + " meters"); } networkAccuracy.setText( Aware.getSetting(getApplicationContext(), Aware_Preferences.MIN_LOCATION_NETWORK_ACCURACY)); networkAccuracy.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { Aware.setSetting(getApplicationContext(), Aware_Preferences.MIN_LOCATION_NETWORK_ACCURACY, (String) newValue); networkAccuracy.setSummary((String) newValue + " meters"); framework.startLocations(); return true; } }); final EditTextPreference expirateTime = (EditTextPreference) findPreference( Aware_Preferences.LOCATION_EXPIRATION_TIME); if (Aware.getSetting(getApplicationContext(), Aware_Preferences.LOCATION_EXPIRATION_TIME).length() > 0) { expirateTime.setSummary( Aware.getSetting(getApplicationContext(), Aware_Preferences.LOCATION_EXPIRATION_TIME) + " seconds"); } expirateTime.setText(Aware.getSetting(getApplicationContext(), Aware_Preferences.LOCATION_EXPIRATION_TIME)); expirateTime.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { Aware.setSetting(getApplicationContext(), Aware_Preferences.LOCATION_EXPIRATION_TIME, (String) newValue); expirateTime.setSummary((String) newValue + " seconds"); framework.startLocations(); return true; } }); }
From source file:im.vector.fragments.VectorSettingsPreferencesFragment.java
/** * Build the cryptography preference section. * * @param aMyDeviceInfo the device info/* w ww . ja v a2 s. c om*/ */ private void refreshCryptographyPreference(final DeviceInfo aMyDeviceInfo) { final String userId = mSession.getMyUserId(); final String deviceId = mSession.getCredentials().deviceId; VectorCustomActionEditTextPreference cryptoInfoTextPreference; // device name if ((null != aMyDeviceInfo) && !TextUtils.isEmpty(aMyDeviceInfo.display_name)) { cryptoInfoTextPreference = (VectorCustomActionEditTextPreference) findPreference( PreferencesManager.SETTINGS_ENCRYPTION_INFORMATION_DEVICE_NAME_PREFERENCE_KEY); if (null != cryptoInfoTextPreference) { cryptoInfoTextPreference.setSummary(aMyDeviceInfo.display_name); cryptoInfoTextPreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { displayDeviceRenameDialog(aMyDeviceInfo); return true; } }); cryptoInfoTextPreference.setOnPreferenceLongClickListener( new VectorCustomActionEditTextPreference.OnPreferenceLongClickListener() { @Override public boolean onPreferenceLongClick(Preference preference) { VectorUtils.copyToClipboard(getActivity(), aMyDeviceInfo.display_name); return true; } }); } } // crypto section: device ID if (!TextUtils.isEmpty(deviceId)) { cryptoInfoTextPreference = (VectorCustomActionEditTextPreference) findPreference( PreferencesManager.SETTINGS_ENCRYPTION_INFORMATION_DEVICE_ID_PREFERENCE_KEY); if (null != cryptoInfoTextPreference) { cryptoInfoTextPreference.setSummary(deviceId); cryptoInfoTextPreference.setOnPreferenceLongClickListener( new VectorCustomActionEditTextPreference.OnPreferenceLongClickListener() { @Override public boolean onPreferenceLongClick(Preference preference) { VectorUtils.copyToClipboard(getActivity(), deviceId); return true; } }); } VectorCustomActionEditTextPreference exportPref = (VectorCustomActionEditTextPreference) findPreference( PreferencesManager.SETTINGS_ENCRYPTION_EXPORT_E2E_ROOM_KEYS_PREFERENCE_KEY); exportPref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { exportKeys(); return true; } }); VectorCustomActionEditTextPreference importPref = (VectorCustomActionEditTextPreference) findPreference( PreferencesManager.SETTINGS_ENCRYPTION_IMPORT_E2E_ROOM_KEYS_PREFERENCE_KEY); importPref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { importKeys(); return true; } }); } // crypto section: device key (fingerprint) if (!TextUtils.isEmpty(deviceId) && !TextUtils.isEmpty(userId)) { mSession.getCrypto().getDeviceInfo(userId, deviceId, new SimpleApiCallback<MXDeviceInfo>() { @Override public void onSuccess(final MXDeviceInfo deviceInfo) { if ((null != deviceInfo) && !TextUtils.isEmpty(deviceInfo.fingerprint()) && (null != getActivity())) { VectorCustomActionEditTextPreference cryptoInfoTextPreference = (VectorCustomActionEditTextPreference) findPreference( PreferencesManager.SETTINGS_ENCRYPTION_INFORMATION_DEVICE_KEY_PREFERENCE_KEY); if (null != cryptoInfoTextPreference) { cryptoInfoTextPreference.setSummary(deviceInfo.fingerprint()); cryptoInfoTextPreference.setOnPreferenceLongClickListener( new VectorCustomActionEditTextPreference.OnPreferenceLongClickListener() { @Override public boolean onPreferenceLongClick(Preference preference) { VectorUtils.copyToClipboard(getActivity(), deviceInfo.fingerprint()); return true; } }); } } } }); } // encrypt to unverified devices final CheckBoxPreference sendToUnverifiedDevicesPref = (CheckBoxPreference) findPreference( PreferencesManager.SETTINGS_ENCRYPTION_NEVER_SENT_TO_PREFERENCE_KEY); if (null != sendToUnverifiedDevicesPref) { sendToUnverifiedDevicesPref.setChecked(false); mSession.getCrypto().getGlobalBlacklistUnverifiedDevices(new SimpleApiCallback<Boolean>() { @Override public void onSuccess(Boolean status) { sendToUnverifiedDevicesPref.setChecked(status); } }); sendToUnverifiedDevicesPref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { mSession.getCrypto().getGlobalBlacklistUnverifiedDevices(new SimpleApiCallback<Boolean>() { @Override public void onSuccess(Boolean status) { if (sendToUnverifiedDevicesPref.isChecked() != status) { mSession.getCrypto().setGlobalBlacklistUnverifiedDevices( sendToUnverifiedDevicesPref.isChecked(), new SimpleApiCallback<Void>() { @Override public void onSuccess(Void info) { } }); } } }); return true; } }); } }
From source file:com.googlecode.mindbell.MindBellPreferences.java
@SuppressWarnings("deprecation") // deprecation is because MindBell is not fragment-based @Override/*from w w w.j av a 2s .co m*/ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // check settings, delete any settings that are not valid final PrefsAccessor prefs = ContextAccessor.getInstance(this).getPrefs(); // Load the preferences from an XML resource addPreferencesFromResource(R.xml.preferences_1); addPreferencesFromResource(R.xml.preferences_2); // notifications depend on SDK addPreferencesFromResource(R.xml.preferences_3); final CheckBoxPreference preferenceUseAudioStreamVolumeSetting = (CheckBoxPreference) getPreferenceScreen() .findPreference(getText(R.string.keyUseAudioStreamVolumeSetting)); final CheckBoxPreference preferenceStatus = (CheckBoxPreference) getPreferenceScreen() .findPreference(getText(R.string.keyStatus)); final CheckBoxPreference preferenceShow = (CheckBoxPreference) getPreferenceScreen() .findPreference(getText(R.string.keyShow)); final CheckBoxPreference preferenceSound = (CheckBoxPreference) getPreferenceScreen() .findPreference(getText(R.string.keySound)); final Preference preferenceReminderSoundLength = (Preference) getPreferenceScreen() .findPreference(getText(R.string.keyReminderSoundLength)); final ListPreferenceWithSummaryFix preferenceReminderBell = (ListPreferenceWithSummaryFix) getPreferenceScreen() .findPreference(getText(R.string.keyReminderBell)); final MediaVolumePreference preferenceVolume = (MediaVolumePreference) getPreferenceScreen() .findPreference(getText(R.string.keyVolume)); final RingtonePreference preferenceRingtone = (RingtonePreference) getPreferenceScreen() .findPreference(getText(R.string.keyRingtone)); final CheckBoxPreference preferenceVibrate = (CheckBoxPreference) getPreferenceScreen() .findPreference(getText(R.string.keyVibrate)); final ListPreferenceWithSummaryFix preferencePattern = (ListPreferenceWithSummaryFix) getPreferenceScreen() .findPreference(getText(R.string.keyPattern)); final CheckBoxPreference preferenceMuteOffHook = (CheckBoxPreference) getPreferenceScreen() .findPreference(getText(R.string.keyMuteOffHook)); final MinutesIntervalPickerPreference preferenceFrequency = (MinutesIntervalPickerPreference) getPreferenceScreen() .findPreference(getText(R.string.keyFrequency)); final CheckBoxPreference preferenceRandomize = (CheckBoxPreference) getPreferenceScreen() .findPreference(getText(R.string.keyRandomize)); final ListPreferenceWithSummaryFix preferenceNormalize = (ListPreferenceWithSummaryFix) getPreferenceScreen() .findPreference(getText(R.string.keyNormalize)); final MultiSelectListPreferenceWithSummary preferenceActiveOnDaysOfWeek = (MultiSelectListPreferenceWithSummary) getPreferenceScreen() .findPreference(getText(R.string.keyActiveOnDaysOfWeek)); final MediaVolumePreference preferenceMeditationVolume = (MediaVolumePreference) getPreferenceScreen() .findPreference(getText(R.string.keyMeditationVolume)); final CheckBoxPreference preferenceUseWorkaroundBell = (CheckBoxPreference) getPreferenceScreen() .findPreference(getText(R.string.keyUseWorkaroundBell)); final Preference preferenceFAQ = (Preference) getPreferenceScreen() .findPreference(getText(R.string.keyFAQ)); final Preference preferenceBatterySettings = (Preference) getPreferenceScreen() .findPreference(getText(R.string.keyBatterySettings)); final Preference preferenceSendMail = (Preference) getPreferenceScreen() .findPreference(getText(R.string.keySendMail)); preferenceUseAudioStreamVolumeSetting.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { public boolean onPreferenceChange(Preference preference, Object newValue) { boolean isChecked = (Boolean) newValue; if (!isChecked && prefs.mustUseAudioStreamVolumeSetting()) { Toast.makeText(MindBellPreferences.this, R.string.mustUseAudioStreamSetting, Toast.LENGTH_SHORT) .show(); return false; } else { preferenceVolume.setEnabled(preferenceSound.isChecked() && !isChecked); preferenceMeditationVolume.setEnabled(!isChecked); return true; } } }); preferenceStatus.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { public boolean onPreferenceChange(Preference preference, Object newValue) { return mediateMuteOffHookAndStatus(preferenceMuteOffHook, newValue, REQUEST_CODE_STATUS); } }); preferenceShow.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { public boolean onPreferenceChange(Preference preference, Object newValue) { return mediateShowAndSoundAndVibrate(preferenceSound, preferenceVibrate, newValue); } }); preferenceSound.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { public boolean onPreferenceChange(Preference preference, Object newValue) { if (mediateShowAndSoundAndVibrate(preferenceShow, preferenceVibrate, newValue) && mediateSoundDurationRelatedSettings(preferenceFrequency, preferenceUseWorkaroundBell, preferenceReminderBell, preferenceRingtoneValue, newValue)) { boolean isChecked = (Boolean) newValue; preferenceReminderBell.setEnabled(isChecked); preferenceRingtone.setEnabled( isChecked && !PrefsAccessor.isUseStandardBell(preferenceReminderBell.getValue())); preferenceVolume.setEnabled(!preferenceUseAudioStreamVolumeSetting.isChecked() && isChecked); return true; } else { return false; } } }); preferenceReminderSoundLength.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { onPreferenceReminderSoundLength(preferenceUseWorkaroundBell.isChecked(), preferenceReminderBell.getValue(), preferenceRingtoneValue); return true; } }); preferenceReminderBell.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { public boolean onPreferenceChange(Preference preference, Object newValue) { String reminderBell = (String) newValue; boolean isChecked = PrefsAccessor.isUseStandardBell(reminderBell); if (PrefsAccessor.isUseStandardBell(reminderBell) || ContextCompat.checkSelfPermission(MindBellPreferences.this, Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) { if (mediateSoundDurationRelatedSettings(preferenceFrequency, preferenceUseWorkaroundBell, reminderBell, preferenceRingtoneValue, preferenceSound)) { // Allow setting this option to "off" if permission is granted preferenceRingtone.setEnabled(preferenceSound.isChecked() && !isChecked); // Weird, but ringtone cannot be retrieved from RingtonePreference, only from SharedPreference setPreferenceVolumeSoundUri(preferenceVolume, reminderBell, preferenceUseWorkaroundBell.isChecked(), preferenceRingtoneValue); return true; } else { return false; } } else { // Ask for permission if this option shall be set to "off" but permission is missing ActivityCompat.requestPermissions(MindBellPreferences.this, new String[] { Manifest.permission.READ_EXTERNAL_STORAGE }, REQUEST_CODE_RINGTONE); // As the permission request is asynchronous we have to deny setting this option (to "off") return false; } } }); preferenceRingtone.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { public boolean onPreferenceChange(Preference preference, Object newValue) { String newRingtoneValue = (String) newValue; if (validatePreferenceRingtone(newRingtoneValue) && mediateSoundDurationRelatedSettings(preferenceFrequency, preferenceUseWorkaroundBell, preferenceReminderBell, newRingtoneValue, preferenceSound)) { setPreferenceRingtoneSummary(preferenceRingtone, newRingtoneValue); setPreferenceVolumeSoundUri(preferenceVolume, preferenceReminderBell.getValue(), preferenceUseWorkaroundBell.isChecked(), newRingtoneValue); preferenceRingtoneValue = newRingtoneValue; return true; } else { return false; } } }); preferenceVibrate.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { public boolean onPreferenceChange(Preference preference, Object newValue) { return mediateShowAndSoundAndVibrate(preferenceShow, preferenceSound, newValue); } }); preferencePattern.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { public boolean onPreferenceChange(Preference preference, Object newValue) { Vibrator vibrator = (Vibrator) MindBellPreferences.this.getSystemService(Context.VIBRATOR_SERVICE); vibrator.vibrate(PrefsAccessor.getVibrationPattern((String) newValue), -1); return true; } }); preferenceMuteOffHook.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { public boolean onPreferenceChange(Preference preference, Object newValue) { return mediateMuteOffHookAndStatus(preferenceStatus, newValue, REQUEST_CODE_MUTE_OFF_HOOK); } }); preferenceRandomize.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { public boolean onPreferenceChange(Preference preference, Object newValue) { if ((Boolean) newValue) { // if interval deviation is selected, normalize is disabled on screen but it must be disabled in preferences, // too. Otherwise the following scenario could happen: set interval 1 h, de-select randomize, set normalize to // hh:00, select randomize, set interval 2 h, de-select randomize again ... hh:00 would be left in normalize // erroneously. preferenceNormalize.setValue(PrefsAccessor.NORMALIZE_NONE); } return true; } }); preferenceFrequency.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { public boolean onPreferenceChange(Preference preference, Object newValue) { if (!mediateSoundDurationRelatedSettings(newValue, preferenceUseWorkaroundBell, preferenceReminderBell, preferenceRingtoneValue, preferenceSound)) { return false; } else if (preferenceRandomize.isChecked()) { // if interval varies randomly, ringing on the minute is disabled and set to "no" anyway return true; } else if (isFrequencyDividesAnHour(new TimeOfDay((String) newValue))) { // if frequency is factor of an hour, ringing on the minute may be requested preferenceNormalize.setEnabled(true); } else { // if frequency is NOT factor of an hour, ringing on the minute may NOT be set if (preferenceNormalize.isEnabled() && isNormalize(preferenceNormalize.getValue())) { Toast.makeText(MindBellPreferences.this, R.string.frequencyDoesNotFitIntoAnHour, Toast.LENGTH_SHORT).show(); return false; } else { preferenceNormalize.setEnabled(false); } } return true; } }); preferenceNormalize.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { public boolean onPreferenceChange(Preference preference, Object newValue) { if (!isNormalize((String) newValue)) { // if normalize - ringing on the minute - is not wanted, it's fine, no more to check here return true; } else if (isFrequencyDividesAnHour(preferenceFrequency.getTime())) { // if frequency is factor of an hour, requesting ringing on the minute is allowed return true; } else { // if frequency is NOT factor of an hour, ringing on the minute may NOT be set Toast.makeText(MindBellPreferences.this, R.string.frequencyDoesNotFitIntoAnHour, Toast.LENGTH_SHORT).show(); return false; } } }); preferenceActiveOnDaysOfWeek.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { public boolean onPreferenceChange(Preference preference, Object newValues) { if (((Set<?>) newValues).isEmpty()) { Toast.makeText(MindBellPreferences.this, R.string.atLeastOneActiveDayNeeded, Toast.LENGTH_SHORT) .show(); return false; } return true; } }); preferenceFAQ.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { Uri faqUri = Uri.parse(getText(R.string.faq_url).toString()); Intent browserIntent = new Intent(Intent.ACTION_VIEW, faqUri); startActivity(browserIntent); return true; } }); preferenceBatterySettings.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { onPreferenceClickBatterySettings(); return true; } }); preferenceUseWorkaroundBell.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { public boolean onPreferenceChange(Preference preference, Object newValue) { if (mediateSoundDurationRelatedSettings(preferenceFrequency, newValue, preferenceReminderBell, preferenceRingtoneValue, preferenceSound)) { boolean isChecked = (Boolean) newValue; setPreferenceVolumeSoundUri(preferenceVolume, preferenceReminderBell.getValue(), isChecked, preferenceRingtoneValue); return true; } else { return false; } } }); preferenceSendMail.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { new AlertDialog.Builder(MindBellPreferences.this) // .setTitle(R.string.prefsSendMail) // .setMessage(R.string.mailInfo1) // .setIcon(R.mipmap.ic_launcher) // .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { onClickReallySendInfo(); } }) // .setNegativeButton(android.R.string.cancel, null) // .show(); return true; } }); // As no PreferenceChangeListener is called without change *BY USER*, some settings have to be made explicitly preferenceVolume .setEnabled(preferenceSound.isChecked() && !preferenceUseAudioStreamVolumeSetting.isChecked()); preferenceMeditationVolume.setEnabled(!preferenceUseAudioStreamVolumeSetting.isChecked()); preferenceReminderBell.setEnabled(preferenceSound.isChecked()); preferenceRingtone.setEnabled( preferenceSound.isChecked() && !PrefsAccessor.isUseStandardBell(preferenceReminderBell.getValue())); preferenceRingtoneValue = prefs.getRingtone(); // cannot be retrieved from preference setPreferenceRingtoneSummary(preferenceRingtone, preferenceRingtoneValue); setPreferenceVolumeSoundUri(preferenceVolume, preferenceReminderBell.getValue(), preferenceUseWorkaroundBell.isChecked(), preferenceRingtoneValue); }