List of usage examples for android.preference CheckBoxPreference setSummary
public void setSummary(CharSequence summary)
From source file:nya.miku.wishmaster.api.AbstractChanModule.java
/** * ( ?/ ) ? ?-?/* www . j av a2 s . c o m*/ * @param group , ??? */ protected void addProxyPreferences(PreferenceGroup group) { final Context context = group.getContext(); PreferenceCategory proxyCat = new PreferenceCategory(context); //? ? ? proxyCat.setTitle(R.string.pref_cat_proxy); group.addPreference(proxyCat); CheckBoxPreference useProxyPref = new CheckBoxPreference(context); //? "? ? " useProxyPref.setTitle(R.string.pref_use_proxy); useProxyPref.setSummary(R.string.pref_use_proxy_summary); useProxyPref.setKey(getSharedKey(PREF_KEY_USE_PROXY)); useProxyPref.setDefaultValue(false); useProxyPref.setOnPreferenceChangeListener(updateHttpListener); proxyCat.addPreference(useProxyPref); EditTextPreference proxyHostPref = new EditTextPreference(context); // ? ?-? proxyHostPref.setTitle(R.string.pref_proxy_host); proxyHostPref.setDialogTitle(R.string.pref_proxy_host); proxyHostPref.setSummary(R.string.pref_proxy_host_summary); proxyHostPref.setKey(getSharedKey(PREF_KEY_PROXY_HOST)); proxyHostPref.setDefaultValue(DEFAULT_PROXY_HOST); proxyHostPref.getEditText().setSingleLine(); proxyHostPref.getEditText().setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI); proxyHostPref.setOnPreferenceChangeListener(updateHttpListener); proxyCat.addPreference(proxyHostPref); proxyHostPref.setDependency(getSharedKey(PREF_KEY_USE_PROXY)); EditTextPreference proxyHostPort = new EditTextPreference(context); // ?-? proxyHostPort.setTitle(R.string.pref_proxy_port); proxyHostPort.setDialogTitle(R.string.pref_proxy_port); proxyHostPort.setSummary(R.string.pref_proxy_port_summary); proxyHostPort.setKey(getSharedKey(PREF_KEY_PROXY_PORT)); proxyHostPort.setDefaultValue(DEFAULT_PROXY_PORT); proxyHostPort.getEditText().setSingleLine(); proxyHostPort.getEditText().setInputType(InputType.TYPE_CLASS_NUMBER); proxyHostPort.setOnPreferenceChangeListener(updateHttpListener); proxyCat.addPreference(proxyHostPort); proxyHostPort.setDependency(getSharedKey(PREF_KEY_USE_PROXY)); }
From source file:nya.miku.wishmaster.chans.incah.InachModule.java
@Override public void addPreferencesOnScreen(PreferenceGroup preferenceGroup) { Context context = preferenceGroup.getContext(); CheckBoxPreference ajaxPref = new CheckBoxPreference(context); ajaxPref.setTitle(R.string.inach_prefs_ajax_update); ajaxPref.setSummary(R.string.inach_prefs_ajax_update_summary); ajaxPref.setKey(getSharedKey(PREF_AJAX_UPDATE)); ajaxPref.setDefaultValue(true);/*from w ww . j a va2s .co m*/ preferenceGroup.addPreference(ajaxPref); super.addPreferencesOnScreen(preferenceGroup); }
From source file:de.j4velin.wifiAutoOff.Preferences.java
@Override public void onResume() { super.onResume(); final CheckBoxPreference no_network_off = (CheckBoxPreference) findPreference("off_no_network"); no_network_off.setSummary(getString(R.string.for_at_least, PreferenceManager .getDefaultSharedPreferences(this).getInt("no_network_timeout", Receiver.TIMEOUT_NO_NETWORK))); handler.postDelayed(signalUpdater, 1000); IntentFilter ifilter = new IntentFilter(WifiManager.NETWORK_STATE_CHANGED_ACTION); ifilter.addAction(WifiManager.WIFI_STATE_CHANGED_ACTION); registerReceiver(stateChangedReceiver, ifilter); }
From source file:com.nttec.everychan.chans.dvach.DvachModule.java
@Override public void addPreferencesOnScreen(PreferenceGroup preferenceGroup) { Context context = preferenceGroup.getContext(); addPasswordPreference(preferenceGroup); CheckBoxPreference onionPref = new LazyPreferences.CheckBoxPreference(context); onionPref.setTitle(R.string.pref_use_onion); onionPref.setSummary(R.string.pref_use_onion_summary); onionPref.setKey(getSharedKey(PREF_KEY_USE_ONION)); onionPref.setDefaultValue(false);// w w w . ja v a 2 s .c o m onionPref.setDisableDependentsState(true); preferenceGroup.addPreference(onionPref); EditTextPreference domainPref = new EditTextPreference(context); domainPref.setTitle(R.string.pref_domain); domainPref.setDialogTitle(R.string.pref_domain); domainPref.setSummary(resources.getString(R.string.pref_domain_summary, DOMAINS_HINT)); domainPref.setKey(getSharedKey(PREF_KEY_DOMAIN)); domainPref.getEditText().setHint(DEFAULT_DOMAIN); domainPref.getEditText().setSingleLine(); domainPref.getEditText().setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI); preferenceGroup.addPreference(domainPref); domainPref.setDependency(getSharedKey(PREF_KEY_USE_ONION)); addProxyPreferences(preferenceGroup); }
From source file:com.nttec.everychan.chans.infinity.InfinityModule.java
@Override public void addPreferencesOnScreen(PreferenceGroup preferenceGroup) { Context context = preferenceGroup.getContext(); addPasswordPreference(preferenceGroup); CheckBoxPreference httpsPref = addHttpsPreference(preferenceGroup, true); CheckBoxPreference onionPref = new LazyPreferences.CheckBoxPreference(context); onionPref.setTitle(R.string.pref_use_onion); onionPref.setSummary(R.string.pref_use_onion_summary); onionPref.setKey(getSharedKey(PREF_KEY_USE_ONION)); onionPref.setDefaultValue(false);/*from w ww. j a va2s . co m*/ onionPref.setDisableDependentsState(true); preferenceGroup.addPreference(onionPref); httpsPref.setDependency(getSharedKey(PREF_KEY_USE_ONION)); addProxyPreferences(preferenceGroup); }
From source file:net.freifunk.android.discover.SettingsActivity.java
@Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.pref_data_sync); // get data via the key ArrayList<NodeMap> nodeMapArrayList = new ArrayList<NodeMap>(MapMaster.getInstance().getMaps().values()); PreferenceCategory communities = (PreferenceCategory) findPreference("communities"); // sort by Name Collections.sort(nodeMapArrayList, new NodeMapComparator()); if (nodeMapArrayList != null && communities != null) { for (final NodeMap nm : nodeMapArrayList) { PreferenceScreen communityPreferenceScreen = getPreferenceManager() .createPreferenceScreen(SettingsActivity.this); communityPreferenceScreen.setTitle(nm.getMapName()); communityPreferenceScreen.setKey(nm.getMapName()); final CheckBoxPreference deactivateCommunityPreference = new CheckBoxPreference( SettingsActivity.this); // TODO: move Strings to resources deactivateCommunityPreference.setTitle("Community aktiv"); deactivateCommunityPreference .setSummary("deaktivieren, falls Community nicht auf der Karte angezeigt werden soll"); deactivateCommunityPreference.setKey("community_deactivate_" + nm.getMapName()); deactivateCommunityPreference.setChecked(nm.isActive()); deactivateCommunityPreference .setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { Database db = Database.getInstance(null); boolean newActive = newValue.toString().equals("true") ? true : false; nm.setActive(newActive); db.addNodeMap(nm); // reload if set to active if (newActive) { nm.loadNodes(); } else { nm.updateNodes(); }//from w w w . ja v a2 s.c o m return true; } }); EditTextPreference editCommunityPreference = new EditTextPreference(SettingsActivity.this); // TODO: move Strings to resources editCommunityPreference.setTitle("URL bearbeiten"); editCommunityPreference.setSummary("aendern, falls eine andere Quelle genutzt werden soll."); editCommunityPreference.setKey("community_edit_" + nm.getMapName()); editCommunityPreference.setText(nm.getMapUrl()); editCommunityPreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { Database db = Database.getInstance(null); // remove old nodes from map nm.setActive(false); EventBus.getInstance().post(new NodeResult(NodeResult.NodeResultType.UPDATE_NODES, nm)); // we should probably do this async as well db.deleteAllNodesForMap(nm); // load new nodes NodeMap newMap = new NodeMap(nm.getMapName(), (String) newValue, true); db.addNodeMap(newMap); //HashMap<String, NodeMap> nodeResult = new HashMap<String, NodeMap>(1); //nodeResult.put(nm.getMapName(), nm); newMap.updateNodes(); //EventBus.getInstance().post(new NodeResult(NodeResult.NodeResultType.LOAD_NODES, nm)); //EventBus.getInstance().post(new NodeResult(NodeResult.NodeResultType.UPDATE_MAP, nodeResult)); return true; } }); communityPreferenceScreen.addPreference(deactivateCommunityPreference); communityPreferenceScreen.addPreference(editCommunityPreference); communities.addPreference(communityPreferenceScreen); } } setupActionBar(); }
From source file:fi.iki.murgo.irssinotifier.SettingsActivity.java
private void handleIcb() { CheckBoxPreference showIcbIconPreference = (CheckBoxPreference) findPreference("IcbEnabled"); if (!IntentSniffer.isPackageAvailable(this, IrssiConnectbotLauncher.PACKAGE_IRSSICONNECTBOT)) { PreferenceCategory icbCategory = (PreferenceCategory) findPreference("IcbCategory"); icbCategory.setEnabled(false);/*from w w w. j a va 2 s .co m*/ showIcbIconPreference.setChecked(false); showIcbIconPreference.setSummary("Install Irssi ConnectBot to show it in the action bar"); } else { showIcbIconPreference.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { IrssiNotifierActivity.refreshIsNeeded(); return true; } }); Preference icbHostPref = findPreference("IcbHost"); Preferences prefs = new Preferences(this); String hostName = prefs.getIcbHostName(); String summary = "Select which Irssi ConnectBot host to open when pressing the ICB icon"; if (hostName != null) summary += ". Currently selected host: " + hostName; icbHostPref.setSummary(summary); icbHostPref.setOnPreferenceClickListener(new OnPreferenceClickListener() { public boolean onPreferenceClick(Preference preference) { Intent i = new Intent("android.intent.action.PICK"); i.setClassName(IrssiConnectbotLauncher.PACKAGE_IRSSICONNECTBOT, IrssiConnectbotLauncher.PACKAGE_IRSSICONNECTBOT + ".HostListActivity"); startActivityForResult(i, ICB_HOST_REQUEST_CODE); return true; } }); } }
From source file:com.nttec.everychan.chans.horochan.HorochanModule.java
@Override public void addPreferencesOnScreen(PreferenceGroup preferenceGroup) { Context context = preferenceGroup.getContext(); addOnlyNewPostsPreference(preferenceGroup, true); CheckBoxPreference fallbackRecaptchaPref = new LazyPreferences.CheckBoxPreference(context); // recaptcha fallback fallbackRecaptchaPref.setTitle(R.string.fourchan_prefs_new_recaptcha_fallback); fallbackRecaptchaPref.setSummary(R.string.fourchan_prefs_new_recaptcha_fallback_summary); fallbackRecaptchaPref.setKey(getSharedKey(PREF_KEY_RECAPTCHA_FALLBACK)); fallbackRecaptchaPref.setDefaultValue(false); preferenceGroup.addPreference(fallbackRecaptchaPref); addHttpsPreference(preferenceGroup, true); //https addCloudflareRecaptchaFallbackPreference(preferenceGroup); addProxyPreferences(preferenceGroup); }
From source file:de.j4velin.wifiAutoOff.Preferences.java
@SuppressWarnings("deprecation") @Override//from ww w . j av a 2s . com public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.preferences); if (BuildConfig.DEBUG && PermissionChecker.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PermissionChecker.PERMISSION_GRANTED) { requestPermissions(new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE }, 0); } status = (StatusPreference) findPreference("status"); status.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(final Preference preference) { WifiManager wm = (WifiManager) getSystemService(Context.WIFI_SERVICE); boolean connected = ((ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE)) .getNetworkInfo(ConnectivityManager.TYPE_WIFI).isConnected(); if (wm.isWifiEnabled() && !connected) { try { startActivity(new Intent(WifiManager.ACTION_PICK_WIFI_NETWORK) .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)); } catch (Exception e) { Toast.makeText(Preferences.this, R.string.settings_not_found_, Toast.LENGTH_SHORT).show(); } } else if (!wm.isWifiEnabled()) { wm.setWifiEnabled(true); } else { try { startActivity( new Intent(Settings.ACTION_WIFI_SETTINGS).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)); } catch (Exception e) { Toast.makeText(Preferences.this, R.string.settings_not_found_, Toast.LENGTH_SHORT).show(); } } return true; } }); final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); final CheckBoxPreference screen_off = (CheckBoxPreference) findPreference("off_screen_off"); screen_off.setSummary( getString(R.string.for_at_least, prefs.getInt("screen_off_timeout", Receiver.TIMEOUT_SCREEN_OFF))); if (!keepWiFiOn(this)) { screen_off.setChecked(false); } screen_off.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(final Preference preference, final Object newValue) { if ((Boolean) newValue) { if (!keepWiFiOn(Preferences.this)) { new AlertDialog.Builder(Preferences.this).setMessage(R.string.sleep_policy) .setPositiveButton(R.string.adv_wifi_settings, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { try { startActivity(new Intent(Settings.ACTION_WIFI_IP_SETTINGS) .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)); } catch (Exception e) { Toast.makeText(Preferences.this, R.string.settings_not_found_, Toast.LENGTH_SHORT).show(); } } }).setNegativeButton(android.R.string.cancel, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }).create().show(); return false; } if (android.os.Build.VERSION.SDK_INT >= 11) { APILevel11Wrapper.showNumberPicker(Preferences.this, prefs, screen_off, R.string.for_at_least, 1, 60, getString(R.string.minutes_before_turning_off_wifi_), "screen_off_timeout", Receiver.TIMEOUT_SCREEN_OFF, false); } else { showPre11NumberPicker(Preferences.this, prefs, screen_off, R.string.for_at_least, 1, 60, getString(R.string.minutes_before_turning_off_wifi_), "screen_off_timeout", Receiver.TIMEOUT_SCREEN_OFF, false); } } return true; } }); findPreference("off_no_network").setOnPreferenceChangeListener(new OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(final Preference preference, final Object newValue) { if ((Boolean) newValue) { if (android.os.Build.VERSION.SDK_INT >= 11) { APILevel11Wrapper.showNumberPicker(Preferences.this, prefs, preference, R.string.for_at_least, 1, 60, getString(R.string.minutes_before_turning_off_wifi_), "no_network_timeout", Receiver.TIMEOUT_NO_NETWORK, false); } else { showPre11NumberPicker(Preferences.this, prefs, preference, R.string.for_at_least, 1, 60, getString(R.string.minutes_before_turning_off_wifi_), "no_network_timeout", Receiver.TIMEOUT_NO_NETWORK, false); } } return true; } }); final CheckBoxPreference on_at = (CheckBoxPreference) findPreference("on_at"); on_at.setTitle(getString(R.string.at_summary, prefs.getString("on_at_time", Receiver.ON_AT_TIME))); on_at.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(final Preference preference, final Object newValue) { if ((Boolean) newValue) { String[] time = prefs.getString("on_at_time", Receiver.ON_AT_TIME).split(":"); final TimePickerDialog dialog = new TimePickerDialog(Preferences.this, new OnTimeSetListener() { @Override public void onTimeSet(TimePicker view, int hourOfDay, int minute) { prefs.edit().putString("on_at_time", hourOfDay + ":" + (minute < 10 ? "0" + minute : minute)).commit(); on_at.setTitle(getString(R.string.at_summary, hourOfDay + ":" + (minute < 10 ? "0" + minute : minute))); } }, Integer.parseInt(time[0]), Integer.parseInt(time[1]), true); dialog.setOnCancelListener(new OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { on_at.setChecked(false); } }); dialog.setTitle(getString(R.string.turn_wifi_on_at_)); dialog.show(); } return true; } }); final CheckBoxPreference off_at = (CheckBoxPreference) findPreference("off_at"); off_at.setTitle(getString(R.string.at_summary, prefs.getString("off_at_time", Receiver.OFF_AT_TIME))); off_at.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(final Preference preference, final Object newValue) { if ((Boolean) newValue) { String[] time = prefs.getString("off_at_time", Receiver.OFF_AT_TIME).split(":"); final TimePickerDialog dialog = new TimePickerDialog(Preferences.this, new OnTimeSetListener() { @Override public void onTimeSet(TimePicker view, int hourOfDay, int minute) { prefs.edit().putString("off_at_time", hourOfDay + ":" + (minute < 10 ? "0" + minute : minute)).commit(); off_at.setTitle(getString(R.string.at_summary, hourOfDay + ":" + (minute < 10 ? "0" + minute : minute))); } }, Integer.parseInt(time[0]), Integer.parseInt(time[1]), true); dialog.setOnCancelListener(new OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { off_at.setChecked(false); } }); dialog.setTitle(getString(R.string.turn_wifi_off_at_)); dialog.show(); } return true; } }); final Preference on_every = findPreference("on_every"); final String[] time_names = getResources().getStringArray(R.array.time_names); // default 2 hours on_every.setTitle(getString(R.string.every_summary, prefs.getString("on_every_str", time_names[4]))); on_every.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(final Preference preference, final Object newValue) { if ((Boolean) newValue) { AlertDialog.Builder builder = new AlertDialog.Builder(Preferences.this); builder.setTitle(R.string.turn_wifi_on_every).setItems(time_names, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { prefs.edit().putInt("on_every_time_min", time_values[which]) .putString("on_every_str", time_names[which]).commit(); on_every.setTitle(getString(R.string.every_summary, time_names[which])); } }); builder.create().show(); } return true; } }); Preference locations = findPreference("locations"); if (BuildConfig.FLAVOR.equals("play")) { if (getPackageManager().hasSystemFeature(PackageManager.FEATURE_LOCATION_NETWORK)) { locations.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(final Preference preference) { startActivity(new Intent(Preferences.this, Locations.class)); return true; } }); } else { locations.setEnabled(false); } } else { locations.setSummary("Not available in F-Droid version"); locations.setEnabled(false); } final Preference power = findPreference("power_connected"); power.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(final Preference preference, final Object newValue) { if ((boolean) newValue) { Intent battery = registerReceiver(null, new IntentFilter(Intent.ACTION_BATTERY_CHANGED)); if (battery != null && battery.getIntExtra(BatteryManager.EXTRA_PLUGGED, 0) > 0) { // already connected to external power prefs.edit().putBoolean("ignore_screen_off", true).commit(); } } else { prefs.edit().putBoolean("ignore_screen_off", false).commit(); } return true; } }); }