List of usage examples for android.preference CheckBoxPreference isChecked
public boolean isChecked()
From source file:com.p3authentication.preferences.Prefs.java
@SuppressWarnings("deprecation") @Override/*ww w . j a v a2 s .c o m*/ public void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); getActionBar().setDisplayHomeAsUpEnabled(true); addPreferencesFromResource(R.xml.pref); AccessPin = (EditTextPreference) getPreferenceManager().findPreference("KeypadKey"); final Preference ResetPreference = getPreferenceManager().findPreference("reset_data"); final Preference EULAPreference = getPreferenceManager().findPreference("eula"); final Preference AboutUsPreference = getPreferenceManager().findPreference("about_us"); final Preference UnlockAppsPreference = getPreferenceManager().findPreference("unlock_apps"); final Preference TouchTolerance = getPreferenceManager().findPreference("touch_tolerance"); final Preference RedownloadImage = getPreferenceManager().findPreference("redownload_images"); final Preference RateApp = getPreferenceManager().findPreference("rate_app"); final CheckBoxPreference GhostStatusPref = (CheckBoxPreference) getPreferenceManager() .findPreference("GhostStatus"); final CheckBoxPreference StartServicePref = (CheckBoxPreference) getPreferenceManager() .findPreference("startup_service"); final ListPreference patterntype = (ListPreference) getPreferenceManager().findPreference("PatternType"); final ListPreference PatternStealth = (ListPreference) getPreferenceManager() .findPreference("PatternStealth"); if (patterntype.getValue().toString().equals("No Pattern")) { PatternStealth.setEnabled(false); } else { PatternStealth.setEnabled(true); } if (GhostStatusPref.isChecked()) { AccessPin.setEnabled(true); } else { AccessPin.setEnabled(false); } AccessPin.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { // TODO Auto-generated method stub if (newValue.toString().trim().equals("")) { Toast.makeText(Prefs.this, "Your Custom PIN cannot be empty.", Toast.LENGTH_LONG).show(); return false; } else if (newValue.toString().length() < 5) { Toast.makeText(Prefs.this, "Your Custom PIN must be atleast 5 Digits.", Toast.LENGTH_LONG) .show(); return false; } Toast.makeText(Prefs.this, "Your Custom PIN is set.", Toast.LENGTH_LONG).show(); return true; } }); GhostStatusPref.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { if (newValue.toString().equals("true")) { hideLauncherIcon(); Toast.makeText(Prefs.this, "P3 hidden from App Menu", Toast.LENGTH_SHORT).show(); } else { showLauncherIcon(); Toast.makeText(Prefs.this, "P3 visible on App Menu", Toast.LENGTH_SHORT).show(); } return true; } }); StartServicePref.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { if (newValue.toString().equals("true")) { ComponentName receiver = new ComponentName(Prefs.this, Startup.class); PackageManager pm = getPackageManager(); pm.setComponentEnabledSetting(receiver, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP); } else { ComponentName receiver = new ComponentName(Prefs.this, Startup.class); PackageManager pm = getPackageManager(); pm.setComponentEnabledSetting(receiver, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); } return true; } }); patterntype.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { // TODO Auto-generated method stub if (!newValue.toString().equals("No Pattern")) { PatternStealth.setEnabled(true); } else { PatternStealth.setEnabled(false); } return true; } }); ResetPreference.setOnPreferenceClickListener(this); UnlockAppsPreference.setOnPreferenceClickListener(this); TouchTolerance.setOnPreferenceClickListener(this); RedownloadImage.setOnPreferenceClickListener(this); RateApp.setOnPreferenceClickListener(this); AboutUsPreference.setOnPreferenceClickListener(this); EULAPreference.setOnPreferenceClickListener(this); }
From source file:org.linphone.SettingsFragment.java
private void initNetworkSettings() { initMediaEncryptionPreference(/*from w w w . j a v a 2s. c om*/ (ListPreference) findPreference(getString(R.string.pref_media_encryption_key))); ((CheckBoxPreference) findPreference(getString(R.string.pref_wifi_only_key))) .setChecked(mPrefs.isWifiOnlyEnabled()); // Disable UPnP if ICE si enabled, or disable ICE if UPnP is enabled CheckBoxPreference ice = (CheckBoxPreference) findPreference(getString(R.string.pref_ice_enable_key)); CheckBoxPreference upnp = (CheckBoxPreference) findPreference(getString(R.string.pref_upnp_enable_key)); ice.setChecked(mPrefs.isIceEnabled()); if (mPrefs.isIceEnabled()) { upnp.setEnabled(false); } else { upnp.setChecked(mPrefs.isUpnpEnabled()); if (mPrefs.isUpnpEnabled()) { ice.setEnabled(false); } } CheckBoxPreference randomPort = (CheckBoxPreference) findPreference( getString(R.string.pref_transport_use_random_ports_key)); randomPort.setChecked(mPrefs.isUsingRandomPort()); // Disable sip port choice if port is random EditTextPreference sipPort = (EditTextPreference) findPreference(getString(R.string.pref_sip_port_key)); sipPort.setEnabled(!randomPort.isChecked()); sipPort.setSummary(mPrefs.getSipPort()); sipPort.setText(mPrefs.getSipPort()); EditTextPreference stun = (EditTextPreference) findPreference(getString(R.string.pref_stun_server_key)); stun.setSummary(mPrefs.getStunServer()); stun.setText(mPrefs.getStunServer()); ((CheckBoxPreference) findPreference(getString(R.string.pref_push_notification_key))) .setChecked(mPrefs.isPushNotificationEnabled()); ((CheckBoxPreference) findPreference(getString(R.string.pref_ipv6_key))).setChecked(mPrefs.isUsingIpv6()); }
From source file:com.brewcrewfoo.performance.fragments.MemSettings.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setHasOptionsMenu(true);//from w ww. j a v a 2s . c o m mPreferences = PreferenceManager.getDefaultSharedPreferences(getActivity()); mPreferences.registerOnSharedPreferenceChangeListener(this); addPreferencesFromResource(R.layout.mem_settings); values = Helpers.readOneLine(MINFREE_PATH).split(","); mForegroundApp = findPreference(OOM_FOREGROUND_APP); mVisibleApp = findPreference(OOM_VISIBLE_APP); mSecondaryServer = findPreference(OOM_SECONDARY_SERVER); mHiddenApp = findPreference(OOM_HIDDEN_APP); mContentProviders = findPreference(OOM_CONTENT_PROVIDERS); mEmptyApp = findPreference(OOM_EMPTY_APP); mPresets = (ListPreference) findPreference("oom_presets"); Map<String, String> oom = new LinkedHashMap<String, String>(); final String s = mPreferences.getString(MINFREE_DEFAULT, ""); if (!s.equals("")) { oom.put(getResources().getString(R.string.oom_default), s); } for (int i = 0; i < getResources().getStringArray(R.array.oom_values).length; i++) { oom.put(getResources().getStringArray(R.array.oom_values)[i], ventries[i].toString()); } mPresets.setEntryValues(oom.values().toArray(new CharSequence[oom.size()])); mPresets.setEntries(oom.keySet().toArray(new CharSequence[oom.size()])); mPresets.setValue(Helpers.readOneLine(MINFREE_PATH)); updateOOM(values); mUserON = (CheckBoxPreference) findPreference(PREF_USER_PROC); mSysON = (CheckBoxPreference) findPreference(PREF_SYS_PROC); mUserNames = findPreference(PREF_USER_NAMES); mSysNames = findPreference(PREF_SYS_NAMES); mKSM = (CheckBoxPreference) findPreference(PREF_RUN_KSM); mKSMsettings = findPreference("ksm_settings"); mZRAMsettings = findPreference("zram_settings"); CheckBoxPreference mZRAMboot = (CheckBoxPreference) findPreference("zram_boot"); String names = ""; if (!new File(USER_PROC_PATH).exists()) { PreferenceCategory hideCat = (PreferenceCategory) findPreference("notkill_user_proc"); getPreferenceScreen().removePreference(hideCat); } else { mUserON.setChecked(Helpers.readOneLine(USER_PROC_PATH).equals("1")); names = Helpers.readOneLine(USER_PROC_NAMES_PATH); if (names == null) names = ""; mPreferences.edit().putString(PREF_USER_NAMES, names).apply(); } if (!new File(SYS_PROC_PATH).exists()) { PreferenceCategory hideCat = (PreferenceCategory) findPreference("notkill_sys_proc"); getPreferenceScreen().removePreference(hideCat); } else { mSysON.setChecked(Helpers.readOneLine(SYS_PROC_PATH).equals("1")); names = Helpers.readOneLine(USER_SYS_NAMES_PATH); if (names == null) names = ""; mPreferences.edit().putString(PREF_SYS_NAMES, names).apply(); } if (!new File(UKSM_RUN_PATH + "/run").exists() && !new File(KSM_RUN_PATH + "/run").exists()) { PreferenceCategory hideCat = (PreferenceCategory) findPreference("ksm"); getPreferenceScreen().removePreference(hideCat); } else { if (new File(UKSM_RUN_PATH + "/run").exists()) { ksm = 1; ksmpath = UKSM_RUN_PATH; mKSMsettings.setSummary(R.string.uksm); } else { ksm = 0; ksmpath = KSM_RUN_PATH; mKSMsettings.setSummary(null); } mKSM.setChecked(Helpers.readOneLine(ksmpath + "/run").equals("1")); //mKSMsettings.setSummary(getString(R.string.ksm_pagtoscan)+" "+Helpers.readOneLine(KSM_PAGESTOSCAN_PATH[ksm])+" | "+getString(R.string.ksm_sleep)+" "+Helpers.readOneLine(KSM_SLEEP_PATH[ksm])); } ispm = (Helpers.binExist("pm") != null); if (!Helpers.isZRAM()) { PreferenceCategory hideCat = (PreferenceCategory) findPreference("zram"); getPreferenceScreen().removePreference(hideCat); } else { int percent = 0; if (swap > 0) { percent = Math.round(swap * 100 / maxdisk); curdisk = Math.round(maxdisk * percent / 100); if (mZRAMboot.isChecked()) mPreferences.edit().putInt(PREF_ZRAM, curdisk).apply(); } else { curdisk = mPreferences.getInt(PREF_ZRAM, Math.round(maxdisk * 18 / 100)); percent = Math.round(curdisk * 100 / maxdisk); } mZRAMsettings.setSummary(getString(R.string.ps_zram) + " | " + getString(R.string.zram_disk_size, Helpers.ReadableByteCount(curdisk * 1024 * 1024)) + " (" + String.valueOf(percent) + "%)"); } }
From source file:com.aware.Aware_Preferences.java
/** * ESM module settings UI//from w ww .ja va2s. c o m */ private void esm() { final CheckBoxPreference esm = (CheckBoxPreference) findPreference(Aware_Preferences.STATUS_ESM); esm.setChecked(Aware.getSetting(getApplicationContext(), Aware_Preferences.STATUS_ESM).equals("true")); esm.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_ESM, esm.isChecked()); if (esm.isChecked()) { framework.startESM(); } else { framework.stopESM(); } return true; } }); }
From source file:com.aware.Aware_Preferences.java
/** * WiFi module settings UI//from w ww .j av a2s . c o m */ private void wifi() { final CheckBoxPreference wifi = (CheckBoxPreference) findPreference(Aware_Preferences.STATUS_WIFI); wifi.setChecked(Aware.getSetting(getApplicationContext(), Aware_Preferences.STATUS_WIFI).equals("true")); wifi.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_WIFI, wifi.isChecked()); if (wifi.isChecked()) { framework.startWiFi(); } else { framework.stopWiFi(); } return true; } }); final EditTextPreference wifiInterval = (EditTextPreference) findPreference( Aware_Preferences.FREQUENCY_WIFI); if (Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_WIFI).length() > 0) { wifiInterval.setSummary( Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_WIFI) + " seconds"); } wifiInterval.setText(Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_WIFI)); wifiInterval.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { Aware.setSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_WIFI, (String) newValue); wifiInterval.setSummary((String) newValue + " seconds"); framework.startWiFi(); return true; } }); }
From source file:com.aware.Aware_Preferences.java
/** * Developer UI options/*from w w w . ja v a 2 s .c o m*/ * - Debug flag * - Debug tag * - AWARE updates * - Device ID */ private void developerOptions() { final CheckBoxPreference debug_flag = (CheckBoxPreference) findPreference(Aware_Preferences.DEBUG_FLAG); debug_flag .setChecked(Aware.getSetting(getApplicationContext(), Aware_Preferences.DEBUG_FLAG).equals("true")); debug_flag.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { Aware.DEBUG = debug_flag.isChecked(); Aware.setSetting(getApplicationContext(), Aware_Preferences.DEBUG_FLAG, debug_flag.isChecked()); return true; } }); final EditTextPreference debug_tag = (EditTextPreference) findPreference(Aware_Preferences.DEBUG_TAG); debug_tag.setText(Aware.getSetting(getApplicationContext(), Aware_Preferences.DEBUG_TAG)); debug_tag.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { Aware.TAG = (String) newValue; Aware.setSetting(getApplicationContext(), Aware_Preferences.DEBUG_TAG, (String) newValue); return true; } }); final CheckBoxPreference auto_update = (CheckBoxPreference) findPreference( Aware_Preferences.AWARE_AUTO_UPDATE); auto_update.setChecked( Aware.getSetting(getApplicationContext(), Aware_Preferences.AWARE_AUTO_UPDATE).equals("true")); PackageInfo awareInfo = null; try { awareInfo = getPackageManager().getPackageInfo(getPackageName(), PackageManager.GET_ACTIVITIES); } catch (NameNotFoundException e) { e.printStackTrace(); } auto_update.setSummary("Current version is " + ((awareInfo != null) ? awareInfo.versionCode : "???")); auto_update.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { Aware.setSetting(getApplicationContext(), Aware_Preferences.AWARE_AUTO_UPDATE, auto_update.isChecked()); return true; } }); final CheckBoxPreference debug_db_slow = (CheckBoxPreference) findPreference( Aware_Preferences.DEBUG_DB_SLOW); debug_db_slow.setChecked( Aware.getSetting(getApplicationContext(), Aware_Preferences.DEBUG_DB_SLOW).equals("true")); debug_db_slow.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { Aware.setSetting(getApplicationContext(), Aware_Preferences.DEBUG_DB_SLOW, debug_db_slow.isChecked()); return true; } }); final EditTextPreference device_id = (EditTextPreference) findPreference(Aware_Preferences.DEVICE_ID); device_id.setSummary("UUID: " + Aware.getSetting(getApplicationContext(), DEVICE_ID)); device_id.setText(Aware.getSetting(getApplicationContext(), Aware_Preferences.DEVICE_ID)); device_id.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { Aware.setSetting(getApplicationContext(), Aware_Preferences.DEVICE_ID, (String) newValue); device_id.setSummary( "UUID: " + Aware.getSetting(getApplicationContext(), Aware_Preferences.DEVICE_ID)); return true; } }); }
From source file:com.aware.Aware_Preferences.java
/** * Screen module settings UI/*from w w w . ja v a 2 s.co m*/ */ private void screen() { final CheckBoxPreference screen = (CheckBoxPreference) findPreference(Aware_Preferences.STATUS_SCREEN); screen.setChecked( Aware.getSetting(getApplicationContext(), Aware_Preferences.STATUS_SCREEN).equals("true")); screen.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_SCREEN, screen.isChecked()); if (screen.isChecked()) { framework.startScreen(); } else { framework.stopScreen(); } return true; } }); }
From source file:com.aware.Aware_Preferences.java
/** * Battery module settings UI/*from w w w . j a v a2 s . c o m*/ */ private void battery() { final CheckBoxPreference battery = (CheckBoxPreference) findPreference(Aware_Preferences.STATUS_BATTERY); battery.setChecked( Aware.getSetting(getApplicationContext(), Aware_Preferences.STATUS_BATTERY).equals("true")); battery.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_BATTERY, battery.isChecked()); if (battery.isChecked()) { framework.startBattery(); } else { framework.stopBattery(); } return true; } }); }
From source file:com.aware.Aware_Preferences.java
/** * Communication module settings UI/*from w ww. jav a 2s .c om*/ */ private void communication() { final CheckBoxPreference calls = (CheckBoxPreference) findPreference(Aware_Preferences.STATUS_CALLS); calls.setChecked(Aware.getSetting(getApplicationContext(), Aware_Preferences.STATUS_CALLS).equals("true")); calls.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_CALLS, calls.isChecked()); if (calls.isChecked()) { framework.startCommunication(); } else { framework.stopCommunication(); } return true; } }); final CheckBoxPreference messages = (CheckBoxPreference) findPreference(Aware_Preferences.STATUS_MESSAGES); messages.setChecked( Aware.getSetting(getApplicationContext(), Aware_Preferences.STATUS_MESSAGES).equals("true")); messages.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_MESSAGES, messages.isChecked()); if (messages.isChecked()) { framework.startCommunication(); } else { framework.stopCommunication(); } return true; } }); final CheckBoxPreference communication = (CheckBoxPreference) findPreference( Aware_Preferences.STATUS_COMMUNICATION_EVENTS); communication.setChecked(Aware .getSetting(getApplicationContext(), Aware_Preferences.STATUS_COMMUNICATION_EVENTS).equals("true")); communication.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_COMMUNICATION_EVENTS, communication.isChecked()); if (communication.isChecked()) { framework.startCommunication(); } else { framework.stopCommunication(); } return true; } }); }
From source file:com.aware.Aware_Preferences.java
/** * TimeZone module settings UI//w w w . ja v a 2 s . c o m */ private void timeZone() { final CheckBoxPreference timeZone = (CheckBoxPreference) findPreference(Aware_Preferences.STATUS_TIMEZONE); timeZone.setChecked( Aware.getSetting(getApplicationContext(), Aware_Preferences.STATUS_TIMEZONE).equals("true")); timeZone.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_TIMEZONE, timeZone.isChecked()); if (timeZone.isChecked()) { framework.startTimeZone(); } else { framework.stopTimeZone(); } return true; } }); final EditTextPreference frequencyTimeZone = (EditTextPreference) findPreference( Aware_Preferences.FREQUENCY_TIMEZONE); if (Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_TIMEZONE).length() > 0) { frequencyTimeZone.setSummary( Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_TIMEZONE) + " seconds"); } frequencyTimeZone.setText(Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_TIMEZONE)); frequencyTimeZone.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { Aware.setSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_TIMEZONE, (String) newValue); frequencyTimeZone.setSummary((String) newValue + " seconds"); framework.startTimeZone(); return true; } }); }