List of usage examples for android.preference CheckBoxPreference setOnPreferenceClickListener
public void setOnPreferenceClickListener(OnPreferenceClickListener onPreferenceClickListener)
From source file:net.basilwang.StaticAttachmentActivity.java
@Override public void onPreferenceAttached(PreferenceScreen root, int xmlId) { if (root == null) return; // for whatever reason in very rare cases this is null if (xmlId == R.xml.preferencesfragment) { PreferenceCategory logonPreference; PreferenceScreen logonAddPreference; PreferenceScreen aboutusPreference; PreferenceScreen shareonweiboPreference; // PreferenceScreen ruguozhaiPreference; // The filelds we have deleted // CheckBoxPreference weekViewCheckboxPreference; // CheckBoxPreference scoreCheckboxPreference; CheckBoxPreference adCheckboxPreference; logonAddPreference = (PreferenceScreen) root .findPreference(LOGON_ADD_PREFERENCES); if (logonAddPreference != null) { logonAddPreference.setOnPreferenceClickListener(this); }/*from www. jav a 2 s . com*/ logonPreference = (PreferenceCategory) root .findPreference(LOGON_PREFERENCES); aboutusPreference = (PreferenceScreen) root .findPreference(ABOUT_US); shareonweiboPreference = (PreferenceScreen) root .findPreference(SHAREONWEIBO); // ruguozhaiPreference = (PreferenceScreen) root // .findPreference(RU_GUO_ZHAI); adCheckboxPreference = (CheckBoxPreference) root .findPreference(CLOSE_AD); // weekViewCheckboxPreference = (CheckBoxPreference) root // .findPreference(WEEKVIEW_ENABLED); // 2012-09-26 basilwang if weekview already enabled, we set // WeekViewCheckboxPreference enable status is false // if (Preferences.isWeekViewUnlocked(this)) { // weekViewCheckboxPreference.setChecked(true); // weekViewCheckboxPreference.setEnabled(false); // } else { // weekViewCheckboxPreference.setChecked(false); // weekViewCheckboxPreference.setEnabled(true); // } if (Preferences.isAdClosed(this)) { adCheckboxPreference.setChecked(true); adCheckboxPreference.setEnabled(false); } else { adCheckboxPreference.setChecked(false); adCheckboxPreference.setEnabled(true); } aboutusPreference.setOnPreferenceClickListener(this); shareonweiboPreference.setOnPreferenceClickListener(this); // ruguozhaiPreference.setOnPreferenceClickListener(this); // weekViewCheckboxPreference.setOnPreferenceClickListener(this); adCheckboxPreference.setOnPreferenceClickListener(this); YoumiOffersManager.init(this, "2fc95b356bb979ae", "8b94f727980f7158"); YoumiOffersManager.checkStatus(StaticAttachmentActivity.this, StaticAttachmentActivity.this); reloadData(logonPreference, logonAddPreference, root.getPreferenceManager()); } }
From source file:com.aware.Aware_Preferences.java
/** * ESM module settings UI/*www .j av a 2 s . c om*/ */ 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 a v a2s .c om */ 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
/** * Screen module settings UI//from w ww .java2 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 ww . j a v a2s . co 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 ww w .j av a 2 s. c o m */ 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
/** * Light module settings UI//from w w w . j av a 2 s .co m */ private void light() { final PreferenceScreen light_pref = (PreferenceScreen) findPreference("light"); Sensor temp = mSensorMgr.getDefaultSensor(Sensor.TYPE_LIGHT); if (temp != null) { light_pref.setSummary( light_pref.getSummary().toString().replace("*", " - Power: " + temp.getPower() + " mA")); } else { light_pref.setSummary(light_pref.getSummary().toString().replace("*", "")); } final CheckBoxPreference light = (CheckBoxPreference) findPreference(Aware_Preferences.STATUS_LIGHT); light.setChecked(Aware.getSetting(getApplicationContext(), Aware_Preferences.STATUS_LIGHT).equals("true")); light.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { if (mSensorMgr.getDefaultSensor(Sensor.TYPE_LIGHT) == null) { showDialog(DIALOG_ERROR_MISSING_SENSOR); light.setChecked(false); Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_LIGHT, false); return false; } Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_LIGHT, light.isChecked()); if (light.isChecked()) { framework.startLight(); } else { framework.stopLight(); } return true; } }); final EditTextPreference frequency_light = (EditTextPreference) findPreference( Aware_Preferences.FREQUENCY_LIGHT); if (Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_LIGHT).length() > 0) { frequency_light.setSummary( Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_LIGHT) + " microseconds"); } frequency_light.setText(Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_LIGHT)); frequency_light.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { Aware.setSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_LIGHT, (String) newValue); frequency_light.setSummary((String) newValue + " microseconds"); framework.startLight(); return true; } }); }
From source file:com.aware.Aware_Preferences.java
/** * TimeZone module settings UI//from w w w. j a v a 2s. c om */ 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; } }); }
From source file:com.aware.Aware_Preferences.java
/** * Telephony module settings UI//from www . ja va 2 s. c om */ private void telephony() { final CheckBoxPreference telephony = (CheckBoxPreference) findPreference( Aware_Preferences.STATUS_TELEPHONY); telephony.setChecked( Aware.getSetting(getApplicationContext(), Aware_Preferences.STATUS_TELEPHONY).equals("true")); telephony.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_TELEPHONY, telephony.isChecked()); if (telephony.isChecked()) { framework.startTelephony(); } else { framework.stopTelephony(); } return true; } }); }
From source file:com.aware.Aware_Preferences.java
/** * Gravity module settings UI/*from w w w . j av a 2 s. c om*/ */ private void gravity() { final PreferenceScreen grav_pref = (PreferenceScreen) findPreference("gravity"); Sensor temp = mSensorMgr.getDefaultSensor(Sensor.TYPE_GRAVITY); if (temp != null) { grav_pref.setSummary( grav_pref.getSummary().toString().replace("*", " - Power: " + temp.getPower() + " mA")); } else { grav_pref.setSummary(grav_pref.getSummary().toString().replace("*", "")); } final CheckBoxPreference gravity = (CheckBoxPreference) findPreference(Aware_Preferences.STATUS_GRAVITY); gravity.setChecked( Aware.getSetting(getApplicationContext(), Aware_Preferences.STATUS_GRAVITY).equals("true")); gravity.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { if (mSensorMgr.getDefaultSensor(Sensor.TYPE_GRAVITY) == null) { showDialog(DIALOG_ERROR_MISSING_SENSOR); gravity.setChecked(false); Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_GRAVITY, false); return false; } Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_GRAVITY, gravity.isChecked()); if (gravity.isChecked()) { framework.startGravity(); } else { framework.stopGravity(); } return true; } }); final EditTextPreference frequency_gravity = (EditTextPreference) findPreference( Aware_Preferences.FREQUENCY_GRAVITY); if (Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_GRAVITY).length() > 0) { frequency_gravity .setSummary(Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_GRAVITY) + " microseconds"); } frequency_gravity.setText(Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_GRAVITY)); frequency_gravity.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { Aware.setSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_GRAVITY, (String) newValue); frequency_gravity.setSummary((String) newValue + " microseconds"); framework.startGravity(); return true; } }); }