Search in sources :

Example 36 with CheckBoxPreference

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;
        }
    });
}
Also used : Preference(android.preference.Preference) CheckBoxPreference(android.preference.CheckBoxPreference) Intent(android.content.Intent)

Example 37 with CheckBoxPreference

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;
        }
    });
}
Also used : Preference(android.preference.Preference) CheckBoxPreference(android.preference.CheckBoxPreference) Intent(android.content.Intent)

Example 38 with CheckBoxPreference

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);
    }
}
Also used : PreferenceScreen(android.preference.PreferenceScreen) CheckBoxPreference(android.preference.CheckBoxPreference) BassBoostPreference(com.bel.android.dspmanager.preference.BassBoostPreference) Preference(android.preference.Preference) HeadsetAmplifierPreference(com.bel.android.dspmanager.preference.HeadsetAmplifierPreference) PreferenceCategory(android.preference.PreferenceCategory)

Example 39 with CheckBoxPreference

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")));
}
Also used : CheckBoxPreference(android.preference.CheckBoxPreference)

Example 40 with CheckBoxPreference

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!!")));
}
Also used : CheckBoxPreference(android.preference.CheckBoxPreference)

Aggregations

CheckBoxPreference (android.preference.CheckBoxPreference)49 Preference (android.preference.Preference)31 ListPreference (android.preference.ListPreference)20 PreferenceScreen (android.preference.PreferenceScreen)11 SharedPreferences (android.content.SharedPreferences)10 EditTextPreference (android.preference.EditTextPreference)10 PreferenceCategory (android.preference.PreferenceCategory)9 Intent (android.content.Intent)8 ArrayList (java.util.ArrayList)8 OnPreferenceClickListener (android.preference.Preference.OnPreferenceClickListener)6 Uri (android.net.Uri)5 View (android.view.View)5 OnPreferenceChangeListener (android.preference.Preference.OnPreferenceChangeListener)4 PreferenceManager (android.preference.PreferenceManager)4 DialogInterface (android.content.DialogInterface)3 PackageInfo (android.content.pm.PackageInfo)3 Resources (android.content.res.Resources)3 Build (android.os.Build)3 Bundle (android.os.Bundle)3 SwitchPreference (android.preference.SwitchPreference)3