android.preference.Preference.OnPreferenceChangeListener Java Examples

The following examples show how to use android.preference.Preference.OnPreferenceChangeListener. 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: SettingsActivity.java    From nxt-remote-control with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.settings);
    CheckBoxPreference cb_speed = (CheckBoxPreference) findPreference("PREF_REG_SPEED");
    cb_sync = (CheckBoxPreference) findPreference("PREF_REG_SYNC");
    
    cb_speed.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
        
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            if (!((Boolean) newValue).booleanValue()) {
                cb_sync.setChecked(false);
            }
            return true;
        }
    });
}
 
Example #2
Source File: FetchingPrefFragment.java    From Onosendai with Apache License 2.0 6 votes vote down vote up
private void addBatLevel (final String key, final CharSequence title, final CharSequence defVal, final OnPreferenceChangeListener changeListener) {
	final ListPreference pref = new ListPreference(getActivity());
	pref.setKey(key);
	pref.setTitle(title);
	pref.setEntries(CollectionHelper.map(BATTERY_LEVELS, new Function<CharSequence, CharSequence>() {
		@Override
		public CharSequence exec (final CharSequence input) {
			return input + "%";
		}
	}, new ArrayList<CharSequence>()).toArray(new CharSequence[BATTERY_LEVELS.length]));
	pref.setEntryValues(BATTERY_LEVELS);
	pref.setSummary("%s");
	pref.setDefaultValue(defVal);
	pref.setOnPreferenceChangeListener(changeListener);
	getPreferenceScreen().addPreference(pref);
}
 
Example #3
Source File: PreferencesDecorator.java    From document-viewer with GNU General Public License v3.0 6 votes vote down vote up
protected void decorateListPreference(final ListPreference listPrefs) {
    final CharSequence summary = listPrefs.getSummary();
    summaries.put(listPrefs.getKey(), summary);

    final String value = listPrefs.getValue();

    setListPreferenceSummary(listPrefs, value);

    addListener(listPrefs, new OnPreferenceChangeListener() {

        @Override
        public boolean onPreferenceChange(final Preference preference, final Object newValue) {
            setListPreferenceSummary(listPrefs, (String) newValue);
            return true;
        }
    });
}
 
Example #4
Source File: PreferencesDecorator.java    From document-viewer with GNU General Public License v3.0 6 votes vote down vote up
protected void decorateSeekPreference(final SeekBarPreference textPrefs) {
    final CharSequence summary = textPrefs.getSummary();
    summaries.put(textPrefs.getKey(), summary);

    final int value = textPrefs.getValue();

    setPreferenceSummary(textPrefs, "" + value);

    addListener(textPrefs, new OnPreferenceChangeListener() {

        @Override
        public boolean onPreferenceChange(final Preference preference, final Object newValue) {
            setPreferenceSummary(textPrefs, (String) newValue);
            return true;
        }
    });
}
 
Example #5
Source File: PreferencesDecorator.java    From document-viewer with GNU General Public License v3.0 6 votes vote down vote up
protected void decorateEditPreference(final EditTextPreference textPrefs) {
    final CharSequence summary = textPrefs.getSummary();
    summaries.put(textPrefs.getKey(), summary);

    final String value = textPrefs.getText();

    setPreferenceSummary(textPrefs, value);

    addListener(textPrefs, new OnPreferenceChangeListener() {

        @Override
        public boolean onPreferenceChange(final Preference preference, final Object newValue) {
            setPreferenceSummary(textPrefs, (String) newValue);
            return true;
        }
    });
}
 
Example #6
Source File: PreferencesDecorator.java    From document-viewer with GNU General Public License v3.0 6 votes vote down vote up
public void decorateBrowserSettings() {
    final boolean isTablet = IUIManager.instance.isTabletUi(parent.getActivity()) && !AndroidVersion.lessThan3x;
    enableSettings(isTablet, SHOW_REMOVABLE_MEDIA.key, SHOW_SCANNING_MEDIA.key);

    addListener(CACHE_LOCATION.key, new OnPreferenceChangeListener() {

        @Override
        public boolean onPreferenceChange(final Preference preference, final Object newValue) {
            final CacheLocation newLocation = EnumUtils.getByResValue(CacheLocation.class,
                    LengthUtils.toString(newValue), null);
            if (newLocation != null) {
                CacheManager.moveCacheLocation(preference.getContext(), newLocation);
            }
            return true;
        }
    });
}
 
Example #7
Source File: LXMyApp.java    From android_library_libxposed with Apache License 2.0 6 votes vote down vote up
public static void setTransferOnPreferenceChangeListener(
		final String action, Preference p,
		final OnPreferenceChangeListener l) {
	p.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {

		@Override
		public boolean onPreferenceChange(Preference preference,
				Object newValue) {

			transferPreferences(action, preference, newValue);

			if (l != null)
				return l.onPreferenceChange(preference, newValue);

			return true;
		}
	});
}
 
Example #8
Source File: SettingsActivity.java    From MaterialPreferenceLibrary with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(final Bundle savedInstanceState) {
    final String themePrefKey = getString(R.string.pref_theme), defaultTheme = getResources().getString(R.string.pref_theme_default);
    final String theme = PreferenceManager.getDefaultSharedPreferences(this).getString(themePrefKey, defaultTheme);
    switch (theme) {
        case "dark":
            setTheme(R.style.AppTheme_Dark);
            break;
        case "light":
            setTheme(R.style.AppTheme_Light);
            break;
    }
    super.onCreate(savedInstanceState);
    ListPreference themeListPreference = (ListPreference) findPreference(getString(R.string.pref_theme));
    themeListPreference.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(final Preference preference, final Object newValue) {
            restartActivity(SettingsActivity.this);
            return true;
        }
    });
    handleActionBarMenu();

}
 
Example #9
Source File: EventPreferencesScreen.java    From PhoneProfilesPlus with Apache License 2.0 6 votes vote down vote up
@Override
void checkPreferences(PreferenceManager prefMng, Context context)
{
    final Preference eventTypePreference = prefMng.findPreference(PREF_EVENT_SCREEN_EVENT_TYPE);
    final PreferenceManager _prefMng = prefMng;

    if (eventTypePreference != null) {
        eventTypePreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
            @Override
            public boolean onPreferenceChange(Preference preference, Object newValue) {
                String sNewValue = (String) newValue;
                int iNewValue;
                if (sNewValue.isEmpty())
                    iNewValue = 100;
                else
                    iNewValue = Integer.parseInt(sNewValue);

                setWhenUnlockedTitle(_prefMng, iNewValue);

                return true;
            }
        });
    }
}
 
Example #10
Source File: AutofillAndPaymentsPreferences.java    From 365browser with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    PreferenceUtils.addPreferencesFromResource(this, R.xml.autofill_and_payments_preferences);
    getActivity().setTitle(R.string.prefs_autofill_and_payments);

    ChromeSwitchPreference autofillSwitch =
            (ChromeSwitchPreference) findPreference(PREF_AUTOFILL_SWITCH);
    autofillSwitch.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            PersonalDataManager.setAutofillEnabled((boolean) newValue);
            return true;
        }
    });

    if (ChromeFeatureList.isEnabled(ChromeFeatureList.ANDROID_PAYMENT_APPS)) {
        Preference pref = new Preference(getActivity());
        pref.setTitle(getActivity().getString(R.string.payment_apps_title));
        pref.setFragment(AndroidPaymentAppsFragment.class.getCanonicalName());
        pref.setShouldDisableView(true);
        pref.setKey(PREF_ANDROID_PAYMENT_APPS);
        getPreferenceScreen().addPreference(pref);
    }
}
 
Example #11
Source File: PhysicalWebPreferenceFragment.java    From 365browser with Apache License 2.0 6 votes vote down vote up
private void initPhysicalWebSwitch() {
    ChromeSwitchPreference physicalWebSwitch =
            (ChromeSwitchPreference) findPreference(PREF_PHYSICAL_WEB_SWITCH);

    physicalWebSwitch.setChecked(
            PrivacyPreferencesManager.getInstance().isPhysicalWebEnabled());

    physicalWebSwitch.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            boolean enabled = (boolean) newValue;
            if (enabled) {
                PhysicalWebUma.onPrefsFeatureEnabled();
                ensureLocationPermission();
            } else {
                PhysicalWebUma.onPrefsFeatureDisabled();
            }
            PrivacyPreferencesManager.getInstance().setPhysicalWebEnabled(enabled);
            return true;
        }
    });
}
 
Example #12
Source File: DoNotTrackPreference.java    From 365browser with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.do_not_track_preferences);
    getActivity().setTitle(R.string.do_not_track_title);

    ChromeSwitchPreference doNotTrackSwitch =
            (ChromeSwitchPreference) findPreference(PREF_DO_NOT_TRACK_SWITCH);

    boolean isDoNotTrackEnabled = PrefServiceBridge.getInstance().isDoNotTrackEnabled();
    doNotTrackSwitch.setChecked(isDoNotTrackEnabled);

    doNotTrackSwitch.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            PrefServiceBridge.getInstance().setDoNotTrackEnabled((boolean) newValue);
            return true;
        }
    });
}
 
Example #13
Source File: HomepagePreferences.java    From 365browser with Apache License 2.0 6 votes vote down vote up
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    mHomepageManager = HomepageManager.getInstance(getActivity());
    getActivity().setTitle(R.string.options_homepage_title);
    addPreferencesFromResource(R.xml.homepage_preferences);

    mHomepageSwitch = (ChromeSwitchPreference) findPreference(PREF_HOMEPAGE_SWITCH);
    boolean isHomepageEnabled = mHomepageManager.getPrefHomepageEnabled();
    mHomepageSwitch.setChecked(isHomepageEnabled);
    mHomepageSwitch.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            mHomepageManager.setPrefHomepageEnabled((boolean) newValue);
            return true;
        }
    });

    mHomepageEdit = findPreference(PREF_HOMEPAGE_EDIT);
    updateCurrentHomepageUrl();
}
 
Example #14
Source File: AbstractSettingsActivity.java    From mytracks with Apache License 2.0 6 votes vote down vote up
/**
 * Configures a list preference.
 * 
 * @param listPreference the list preference
 * @param summary the summary array
 * @param options the options array
 * @param values the values array
 * @param value the value
 * @param listener optional listener
 */
protected void configureListPreference(ListPreference listPreference, final String[] summary,
    final String[] options, final String[] values, String value,
    final OnPreferenceChangeListener listener) {
  listPreference.setEntryValues(values);
  listPreference.setEntries(options);
  listPreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
      @Override
    public boolean onPreferenceChange(Preference pref, Object newValue) {
      updatePreferenceSummary(pref, summary, values, (String) newValue);
      if (listener != null) {
        listener.onPreferenceChange(pref, newValue);
      }
      return true;
    }
  });
  updatePreferenceSummary(listPreference, summary, values, value);
  if (listener != null) {
    listener.onPreferenceChange(listPreference, value);
  }
}
 
Example #15
Source File: MapSettingsActivity.java    From mytracks with Apache License 2.0 6 votes vote down vote up
/**
 * Configures the track color mode preference.
 */
@SuppressWarnings("deprecation")
private void configTrackColorModePerference() {
  ListPreference preference = (ListPreference) findPreference(
      getString(R.string.track_color_mode_key));
  OnPreferenceChangeListener listener = new OnPreferenceChangeListener() {
      @Override
    public boolean onPreferenceChange(Preference pref, Object newValue) {
      updateUiByTrackColorMode((String) newValue);
      return true;
    }
  };
  String value = PreferencesUtils.getString(
      this, R.string.track_color_mode_key, PreferencesUtils.TRACK_COLOR_MODE_DEFAULT);
  String[] values = getResources().getStringArray(R.array.track_color_mode_values);
  String[] options = getResources().getStringArray(R.array.track_color_mode_options);
  String[] summary = getResources().getStringArray(R.array.track_color_mode_summary);
  configureListPreference(preference, summary, options, values, value, listener);
}
 
Example #16
Source File: SensorSettingsActivity.java    From mytracks with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("deprecation")
private void configSensorType(boolean hasAntSupport) {
  ListPreference preference = (ListPreference) findPreference(
      getString(R.string.sensor_type_key));
  String value = PreferencesUtils.getString(
      this, R.string.sensor_type_key, PreferencesUtils.SENSOR_TYPE_DEFAULT);
  String[] options = getResources().getStringArray(
      hasAntSupport ? R.array.sensor_type_all_options : R.array.sensor_type_bluetooth_options);
  String[] values = getResources().getStringArray(
      hasAntSupport ? R.array.sensor_type_all_values : R.array.sensor_type_bluetooth_values);

  if (!hasAntSupport && value.equals(R.string.sensor_type_value_ant)) {
    value = PreferencesUtils.SENSOR_TYPE_DEFAULT;
    PreferencesUtils.setString(this, R.string.sensor_type_key, value);
  }

  OnPreferenceChangeListener listener = new OnPreferenceChangeListener() {
      @Override
    public boolean onPreferenceChange(Preference pref, Object newValue) {
      updateUiBySensorType((String) newValue);
      return true;
    }
  };
  configureListPreference(preference, options, options, values, value, listener);
}
 
Example #17
Source File: DoNotTrackPreference.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.do_not_track_preferences);
    getActivity().setTitle(R.string.do_not_track_title);

    ChromeSwitchPreference doNotTrackSwitch =
            (ChromeSwitchPreference) findPreference(PREF_DO_NOT_TRACK_SWITCH);

    boolean isDoNotTrackEnabled = PrefServiceBridge.getInstance().isDoNotTrackEnabled();
    doNotTrackSwitch.setChecked(isDoNotTrackEnabled);

    doNotTrackSwitch.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            PrefServiceBridge.getInstance().setDoNotTrackEnabled((boolean) newValue);
            return true;
        }
    });
}
 
Example #18
Source File: HomepagePreferences.java    From delion with Apache License 2.0 6 votes vote down vote up
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    mHomepageManager = HomepageManager.getInstance(getActivity());
    getActivity().setTitle(R.string.options_homepage_title);
    addPreferencesFromResource(R.xml.homepage_preferences);

    mHomepageSwitch = (ChromeSwitchPreference) findPreference(PREF_HOMEPAGE_SWITCH);
    boolean isHomepageEnabled = mHomepageManager.getPrefHomepageEnabled();
    mHomepageSwitch.setChecked(isHomepageEnabled);
    mHomepageSwitch.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            mHomepageManager.setPrefHomepageEnabled((boolean) newValue);
            return true;
        }
    });

    mHomepageEdit = findPreference(PREF_HOMEPAGE_EDIT);
    updateCurrentHomepageUrl();
}
 
Example #19
Source File: DoNotTrackPreference.java    From delion with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.do_not_track_preferences);
    getActivity().setTitle(R.string.do_not_track_title);

    ChromeSwitchPreference doNotTrackSwitch =
            (ChromeSwitchPreference) findPreference(PREF_DO_NOT_TRACK_SWITCH);

    boolean isDoNotTrackEnabled = PrefServiceBridge.getInstance().isDoNotTrackEnabled();
    doNotTrackSwitch.setChecked(isDoNotTrackEnabled);

    doNotTrackSwitch.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            PrefServiceBridge.getInstance().setDoNotTrackEnabled((boolean) newValue);
            return true;
        }
    });
}
 
Example #20
Source File: PhysicalWebPreferenceFragment.java    From delion with Apache License 2.0 6 votes vote down vote up
private void initPhysicalWebSwitch() {
    ChromeSwitchPreference physicalWebSwitch =
            (ChromeSwitchPreference) findPreference(PREF_PHYSICAL_WEB_SWITCH);

    physicalWebSwitch.setChecked(
            PrivacyPreferencesManager.getInstance().isPhysicalWebEnabled());

    physicalWebSwitch.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            boolean enabled = (boolean) newValue;
            if (enabled) {
                PhysicalWebUma.onPrefsFeatureEnabled(getActivity());
                ensureLocationPermission();
            } else {
                PhysicalWebUma.onPrefsFeatureDisabled(getActivity());
            }
            PrivacyPreferencesManager.getInstance().setPhysicalWebEnabled(enabled);
            return true;
        }
    });
}
 
Example #21
Source File: AutofillPreferences.java    From delion with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.autofill_preferences);
    getActivity().setTitle(R.string.prefs_autofill);

    ChromeSwitchPreference autofillSwitch =
            (ChromeSwitchPreference) findPreference(PREF_AUTOFILL_SWITCH);
    autofillSwitch.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            PersonalDataManager.setAutofillEnabled((boolean) newValue);
            return true;
        }
    });

    setPreferenceCategoryIcons();
}
 
Example #22
Source File: HomepagePreferences.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    mHomepageManager = HomepageManager.getInstance(getActivity());
    getActivity().setTitle(R.string.options_homepage_title);
    addPreferencesFromResource(R.xml.homepage_preferences);

    mHomepageSwitch = (ChromeSwitchPreference) findPreference(PREF_HOMEPAGE_SWITCH);
    boolean isHomepageEnabled = mHomepageManager.getPrefHomepageEnabled();
    mHomepageSwitch.setChecked(isHomepageEnabled);
    mHomepageSwitch.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            mHomepageManager.setPrefHomepageEnabled((boolean) newValue);
            return true;
        }
    });

    mHomepageEdit = findPreference(PREF_HOMEPAGE_EDIT);
    updateCurrentHomepageUrl();
}
 
Example #23
Source File: PhysicalWebPreferenceFragment.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
private void initPhysicalWebSwitch() {
    ChromeSwitchPreference physicalWebSwitch =
            (ChromeSwitchPreference) findPreference(PREF_PHYSICAL_WEB_SWITCH);

    physicalWebSwitch.setChecked(
            PrivacyPreferencesManager.getInstance().isPhysicalWebEnabled());

    physicalWebSwitch.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            boolean enabled = (boolean) newValue;
            if (enabled) {
                PhysicalWebUma.onPrefsFeatureEnabled(getActivity());
                ensureLocationPermission();
            } else {
                PhysicalWebUma.onPrefsFeatureDisabled(getActivity());
            }
            PrivacyPreferencesManager.getInstance().setPhysicalWebEnabled(enabled);
            return true;
        }
    });
}
 
Example #24
Source File: AutofillPreferences.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.autofill_preferences);
    getActivity().setTitle(R.string.prefs_autofill);

    ChromeSwitchPreference autofillSwitch =
            (ChromeSwitchPreference) findPreference(PREF_AUTOFILL_SWITCH);
    autofillSwitch.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            PersonalDataManager.setAutofillEnabled((boolean) newValue);
            return true;
        }
    });

    setPreferenceCategoryIcons();
}
 
Example #25
Source File: StatsSettingsActivity.java    From mytracks with Apache License 2.0 6 votes vote down vote up
/**
 * Configures the preferred units list preference.
 */
private void configUnitsListPreference() {
  @SuppressWarnings("deprecation")
  ListPreference listPreference = (ListPreference) findPreference(
      getString(R.string.stats_units_key));
  OnPreferenceChangeListener listener = new OnPreferenceChangeListener() {

      @Override
    public boolean onPreferenceChange(Preference pref, Object newValue) {
      boolean metricUnits = PreferencesUtils.STATS_UNITS_DEFAULT.equals((String) newValue);
      configRateListPreference(metricUnits);
      return true;
    }
  };
  String value = PreferencesUtils.getString(
      this, R.string.stats_units_key, PreferencesUtils.STATS_UNITS_DEFAULT);
  String[] values = getResources().getStringArray(R.array.stats_units_values);
  String[] options = getResources().getStringArray(R.array.stats_units_options);
  configureListPreference(listPreference, options, options, values, value, listener);
}
 
Example #26
Source File: PreferencesDecorator.java    From document-viewer with GNU General Public License v3.0 5 votes vote down vote up
protected void addListener(final Preference pref, final OnPreferenceChangeListener l) {
    final String key = pref.getKey();
    CompositeListener cl = listeners.get(key);
    if (cl == null) {
        cl = new CompositeListener();
        pref.setOnPreferenceChangeListener(cl);
        listeners.put(key, cl);
    }
    cl.add(l);
}
 
Example #27
Source File: InLineActivity.java    From wear-os-samples with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // Load the preferences from an XML resource
    addPreferencesFromResource(R.xml.prefs_in_line_progress);

    mDeterminantSwitchPref =
            (SwitchPreference)
                    findPreference(getString(R.string.key_pref_determinant_switch));
    mDeterminantSwitchPref.setChecked(true);

    mCircledImageViewPref =
            (CircledImageViewPreference)
                    findPreference(getString(R.string.key_pref_circled_image_view));

    mPreferenceScreen =
            (PreferenceScreen) findPreference(getString(R.string.key_pref_progress_screen));

    mProgressBarPreference = new ProgressBarPreference(getContext());
    mProgressBarPreference.setTitle("@string/indeterminant_progress");

    mDeterminantSwitchPref.setOnPreferenceChangeListener(
            new OnPreferenceChangeListener() {
                @Override
                public boolean onPreferenceChange(Preference preference, Object newValue) {
                    mDeterminantSwitchPref.setChecked(!mDeterminantSwitchPref.isChecked());
                    if (mDeterminantSwitchPref.isChecked()) {
                        mCircledImageViewPref.cancelCountDownTimer();
                        mCircledImageViewPref.setStartCircledImageView();
                        mPreferenceScreen.removePreference(mProgressBarPreference);
                        mPreferenceScreen.addPreference(mCircledImageViewPref);
                    } else {
                        mPreferenceScreen.removePreference(mCircledImageViewPref);
                        mPreferenceScreen.addPreference(mProgressBarPreference);
                    }
                    return true;
                }
            });
}
 
Example #28
Source File: SettingsHolder.java    From mobile-manager-tool with MIT License 5 votes vote down vote up
private void initChangeWidgetTheme(){
	ListPreference listPreference = (ListPreference)findPreference(WIDGET_STYLE);
    listPreference.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            MusicUtils.notifyWidgets(ApolloService.META_CHANGED);
            return true;
        }
    });
}
 
Example #29
Source File: PreferencesDecorator.java    From document-viewer with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean onPreferenceChange(final Preference preference, final Object newValue) {
    for (final OnPreferenceChangeListener l : listeners) {
        if (!l.onPreferenceChange(preference, newValue)) {
            return false;
        }
    }
    return true;
}
 
Example #30
Source File: NotificationsActivity.java    From wear-os-samples with Apache License 2.0 5 votes vote down vote up
public void initAvatar(SwitchPreference switchPref) {
    switchPref.setChecked(true);
    mAvatarOn = switchPref.isChecked();
    switchPref.setOnPreferenceChangeListener(
            new OnPreferenceChangeListener() {
                @Override
                public boolean onPreferenceChange(Preference preference, Object newValue) {
                    mAvatarOn = (Boolean) newValue;
                    return true;
                }
            });
}