use of android.preference.CheckBoxPreference in project Android-IMSI-Catcher-Detector by CellularPrivacy.
the class SettingsFragment method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preferences);
final String gps_key = getResources().getString(R.string.pref_enable_gps_key);
locationManager = (LocationManager) getActivity().getSystemService(Context.LOCATION_SERVICE);
gpsPref = (CheckBoxPreference) findPreference(gps_key);
gpsPref.setDefaultValue(locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER));
gpsPref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
Intent gpsSettings = new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS);
startActivityForResult(gpsSettings, 1);
if (locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
gpsPref.setChecked(true);
return true;
}
gpsPref.setChecked(false);
return false;
}
});
gpsPref.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
if (locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
Log.e("pref", "changed to " + newValue);
preference.setDefaultValue(newValue);
return true;
}
preference.setDefaultValue(newValue);
return false;
}
});
}
use of android.preference.CheckBoxPreference in project Android-IMSI-Catcher-Detector by CellularPrivacy.
the class PrefFragment method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preferences);
final String gps_key = getResources().getString(R.string.pref_enable_gps_key);
locationManager = (LocationManager) getActivity().getSystemService(Context.LOCATION_SERVICE);
gpsPref = (CheckBoxPreference) findPreference(gps_key);
gpsPref.setDefaultValue(locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER));
gpsPref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
Intent gpsSettings = new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS);
startActivityForResult(gpsSettings, 1);
if (locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
gpsPref.setChecked(true);
return true;
}
gpsPref.setChecked(false);
return false;
}
});
gpsPref.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
if (locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
Log.e("pref", "changed to " + newValue);
preference.setDefaultValue(newValue);
return true;
}
preference.setDefaultValue(newValue);
return false;
}
});
}
use of android.preference.CheckBoxPreference in project android_packages_apps_DSPManager by CyanogenMod.
the class WM8994 method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.wm8994_preferences);
PreferenceScreen prefSet = getPreferenceScreen();
for (int i = 0; i < OPTION_CONTROLS.length; i++) {
String fileName = OPTION_CONTROLS[i][0];
mPreferences[i] = (CheckBoxPreference) prefSet.findPreference(OPTION_CONTROLS[i][1]);
if (Utils.fileExists(fileName)) {
mPreferences[i].setChecked(PREF_ENABLED.equals(Utils.readOneLine(fileName)));
mPreferences[i].setOnPreferenceChangeListener(this);
} else {
mPreferences[i].setSummary(R.string.pref_unavailable);
mPreferences[i].setEnabled(false);
}
}
if (Utils.fileExists(HeadsetAmplifierPreference.FILE_PATH)) {
prefSet.findPreference("headphone_amp").setOnPreferenceChangeListener(this);
} else {
Preference category = prefSet.findPreference("wm8994_headphone_amp_category");
prefSet.removePreference(category);
}
if (Utils.fileExists(MIC_REC_PRESET[0][0])) {
prefSet.findPreference(MIC_REC_PRESET[0][1]).setOnPreferenceChangeListener(this);
} else {
Preference category = prefSet.findPreference("wm8994_microphone_recording_category");
prefSet.removePreference(category);
}
Preference bassBoostPreset = prefSet.findPreference(BASS_BOOST_PRESET_PREF);
Preference bassBoostGainRange = prefSet.findPreference(BASS_BOOST_GAIN_RANGE_PREF);
if (Utils.fileExists(BASS_BOOST_ENABLE_FILE)) {
bassBoostPreset.setOnPreferenceChangeListener(this);
bassBoostGainRange.setOnPreferenceChangeListener(this);
} else {
PreferenceCategory bassBoostCategory = (PreferenceCategory) prefSet.findPreference("wm8994_signal_processing_category");
bassBoostCategory.removePreference(bassBoostPreset);
bassBoostCategory.removePreference(bassBoostGainRange);
}
}
use of android.preference.CheckBoxPreference in project double-espresso by JakeWharton.
the class PreferenceMatchersTest method testWithSummary.
public void testWithSummary() {
CheckBoxPreference pref = new CheckBoxPreference(getInstrumentation().getContext());
pref.setSummary(R.string.something);
assertThat(pref, withSummary(R.string.something));
assertThat(pref, not(withSummary(R.string.other_string)));
assertThat(pref, withSummaryText("Hello World"));
assertThat(pref, not(withSummaryText(("Hello Mars"))));
assertThat(pref, withSummaryText(is("Hello World")));
}
use of android.preference.CheckBoxPreference in project double-espresso by JakeWharton.
the class PreferenceMatchersTest method testWithTitle.
public void testWithTitle() {
CheckBoxPreference pref = new CheckBoxPreference(getInstrumentation().getContext());
pref.setTitle(R.string.other_string);
assertThat(pref, withTitle(R.string.other_string));
assertThat(pref, not(withTitle(R.string.something)));
assertThat(pref, withTitleText("Goodbye!!"));
assertThat(pref, not(withTitleText(("Hello Mars"))));
assertThat(pref, withTitleText(is("Goodbye!!")));
}
Aggregations