Java Code Examples for android.preference.SwitchPreference#setSummary()

The following examples show how to use android.preference.SwitchPreference#setSummary() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TwoStatePreferenceHelper.java    From openboard with GNU General Public License v3.0 6 votes vote down vote up
static void addSwitchPreferenceBasedOnCheckBoxPreference(final CheckBoxPreference checkBox,
        final PreferenceGroup group) {
    final SwitchPreference switchPref = new SwitchPreference(checkBox.getContext());
    switchPref.setTitle(checkBox.getTitle());
    switchPref.setKey(checkBox.getKey());
    switchPref.setOrder(checkBox.getOrder());
    switchPref.setPersistent(checkBox.isPersistent());
    switchPref.setEnabled(checkBox.isEnabled());
    switchPref.setChecked(checkBox.isChecked());
    switchPref.setSummary(checkBox.getSummary());
    switchPref.setSummaryOn(checkBox.getSummaryOn());
    switchPref.setSummaryOff(checkBox.getSummaryOff());
    switchPref.setSwitchTextOn(EMPTY_TEXT);
    switchPref.setSwitchTextOff(EMPTY_TEXT);
    group.addPreference(switchPref);
    switchPref.setDependency(checkBox.getDependency());
}
 
Example 2
Source File: TwoStatePreferenceHelper.java    From Android-Keyboard with Apache License 2.0 6 votes vote down vote up
static void addSwitchPreferenceBasedOnCheckBoxPreference(final CheckBoxPreference checkBox,
        final PreferenceGroup group) {
    final SwitchPreference switchPref = new SwitchPreference(checkBox.getContext());
    switchPref.setTitle(checkBox.getTitle());
    switchPref.setKey(checkBox.getKey());
    switchPref.setOrder(checkBox.getOrder());
    switchPref.setPersistent(checkBox.isPersistent());
    switchPref.setEnabled(checkBox.isEnabled());
    switchPref.setChecked(checkBox.isChecked());
    switchPref.setSummary(checkBox.getSummary());
    switchPref.setSummaryOn(checkBox.getSummaryOn());
    switchPref.setSummaryOff(checkBox.getSummaryOff());
    switchPref.setSwitchTextOn(EMPTY_TEXT);
    switchPref.setSwitchTextOff(EMPTY_TEXT);
    group.addPreference(switchPref);
    switchPref.setDependency(checkBox.getDependency());
}
 
Example 3
Source File: TwoStatePreferenceHelper.java    From LokiBoard-Android-Keylogger with Apache License 2.0 6 votes vote down vote up
static void addSwitchPreferenceBasedOnCheckBoxPreference(final CheckBoxPreference checkBox,
        final PreferenceGroup group) {
    final SwitchPreference switchPref = new SwitchPreference(checkBox.getContext());
    switchPref.setTitle(checkBox.getTitle());
    switchPref.setKey(checkBox.getKey());
    switchPref.setOrder(checkBox.getOrder());
    switchPref.setPersistent(checkBox.isPersistent());
    switchPref.setEnabled(checkBox.isEnabled());
    switchPref.setChecked(checkBox.isChecked());
    switchPref.setSummary(checkBox.getSummary());
    switchPref.setSummaryOn(checkBox.getSummaryOn());
    switchPref.setSummaryOff(checkBox.getSummaryOff());
    switchPref.setSwitchTextOn(EMPTY_TEXT);
    switchPref.setSwitchTextOff(EMPTY_TEXT);
    group.addPreference(switchPref);
    switchPref.setDependency(checkBox.getDependency());
}
 
Example 4
Source File: TwoStatePreferenceHelper.java    From simple-keyboard with Apache License 2.0 6 votes vote down vote up
static void addSwitchPreferenceBasedOnCheckBoxPreference(final CheckBoxPreference checkBox,
        final PreferenceGroup group) {
    final SwitchPreference switchPref = new SwitchPreference(checkBox.getContext());
    switchPref.setTitle(checkBox.getTitle());
    switchPref.setKey(checkBox.getKey());
    switchPref.setOrder(checkBox.getOrder());
    switchPref.setPersistent(checkBox.isPersistent());
    switchPref.setEnabled(checkBox.isEnabled());
    switchPref.setChecked(checkBox.isChecked());
    switchPref.setSummary(checkBox.getSummary());
    switchPref.setSummaryOn(checkBox.getSummaryOn());
    switchPref.setSummaryOff(checkBox.getSummaryOff());
    switchPref.setSwitchTextOn(EMPTY_TEXT);
    switchPref.setSwitchTextOff(EMPTY_TEXT);
    group.addPreference(switchPref);
    switchPref.setDependency(checkBox.getDependency());
}
 
Example 5
Source File: TwoStatePreferenceHelper.java    From AOSP-Kayboard-7.1.2 with Apache License 2.0 6 votes vote down vote up
static void addSwitchPreferenceBasedOnCheckBoxPreference(final CheckBoxPreference checkBox,
        final PreferenceGroup group) {
    final SwitchPreference switchPref = new SwitchPreference(checkBox.getContext());
    switchPref.setTitle(checkBox.getTitle());
    switchPref.setKey(checkBox.getKey());
    switchPref.setOrder(checkBox.getOrder());
    switchPref.setPersistent(checkBox.isPersistent());
    switchPref.setEnabled(checkBox.isEnabled());
    switchPref.setChecked(checkBox.isChecked());
    switchPref.setSummary(checkBox.getSummary());
    switchPref.setSummaryOn(checkBox.getSummaryOn());
    switchPref.setSummaryOff(checkBox.getSummaryOff());
    switchPref.setSwitchTextOn(EMPTY_TEXT);
    switchPref.setSwitchTextOff(EMPTY_TEXT);
    group.addPreference(switchPref);
    switchPref.setDependency(checkBox.getDependency());
}
 
Example 6
Source File: TwoStatePreferenceHelper.java    From Indic-Keyboard with Apache License 2.0 6 votes vote down vote up
static void addSwitchPreferenceBasedOnCheckBoxPreference(final CheckBoxPreference checkBox,
        final PreferenceGroup group) {
    final SwitchPreference switchPref = new SwitchPreference(checkBox.getContext());
    switchPref.setTitle(checkBox.getTitle());
    switchPref.setKey(checkBox.getKey());
    switchPref.setOrder(checkBox.getOrder());
    switchPref.setPersistent(checkBox.isPersistent());
    switchPref.setEnabled(checkBox.isEnabled());
    switchPref.setChecked(checkBox.isChecked());
    switchPref.setSummary(checkBox.getSummary());
    switchPref.setSummaryOn(checkBox.getSummaryOn());
    switchPref.setSummaryOff(checkBox.getSummaryOff());
    switchPref.setSwitchTextOn(EMPTY_TEXT);
    switchPref.setSwitchTextOff(EMPTY_TEXT);
    group.addPreference(switchPref);
    switchPref.setDependency(checkBox.getDependency());
}
 
Example 7
Source File: SwitchAccessPreferenceActivity.java    From talkback with Apache License 2.0 5 votes vote down vote up
private void adjustPointScanPrefs() {
  if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
    // Remove point scan screen
    PreferenceCategory customizeScanningCategory =
        (PreferenceCategory) findPreference(R.string.pref_category_customize_scanning_key);
    customizeScanningCategory.removePreference(
        findPreference(R.string.pref_category_point_scan_key));
  } else {
    SwitchPreference pointScanPreference =
        (SwitchPreference) findPreference(R.string.pref_key_point_scan_enabled);
    String enableAnimationsMessage =
        ((VERSION.SDK_INT >= VERSION_CODES.O) && !ValueAnimator.areAnimatorsEnabled())
            ? getString(R.string.point_scan_enable_animations_message)
            : "";
    String pointScanPreferenceSummary =
        getString(R.string.summary_pref_point_scan, enableAnimationsMessage);
    pointScanPreference.setSummary(pointScanPreferenceSummary);
    pointScanPreference.setEnabled(
        (VERSION.SDK_INT < VERSION_CODES.O) || ValueAnimator.areAnimatorsEnabled());

    // Make sure the subtitle reflects Point scan state
    PreferenceScreen pointScanScreen =
        (PreferenceScreen) findPreference(R.string.pref_category_point_scan_key);
    if (SwitchAccessPreferenceUtils.isPointScanEnabled(getActivity())) {
      pointScanScreen.setSummary(R.string.preference_on);
    } else {
      pointScanScreen.setSummary(R.string.preference_off);
    }
    ((BaseAdapter) pointScanScreen.getRootAdapter()).notifyDataSetChanged();
  }
}