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

The following examples show how to use android.preference.SwitchPreference#setChecked() . 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 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 2
Source File: SettingsFragment.java    From Interessant with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.settings);

    cacheWithWifi = (SwitchPreference) findPreference("cache_with_wifi");
    cacheWithWifi.setOnPreferenceChangeListener(this);
    boolean checked = PreferenceManager.getBooleanValue(context, CACHE_KEY, true);
    cacheWithWifi.setChecked(checked);

    clearVideoCache  = findPreference("clear_video_cache");
    clearVideoCache.setOnPreferenceClickListener(this);

    float videoFileSize = calculateCacheFileSize("video-cache", true);

    clearVideoCache.setSummary(String.format(Locale.CHINESE, "%.2fMb", videoFileSize));

    clearPhotoCache = findPreference("clear_photo_cache");
    clearPhotoCache.setOnPreferenceClickListener(this);

    float photoFileSize = calculateCacheFileSize("image_manager_disk_cache", false);
    photoFileSize += calculateCacheFileSize("picasso-cache", false);

    clearPhotoCache.setSummary(String.format(Locale.CHINESE, "%.2fMb", photoFileSize));

}
 
Example 3
Source File: SettingFragment.java    From PicKing with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.preference_screen);

    colsDetail = (int) SPUtils.get(getActivity(), AppConfig.cols_detail, 0);
    RadioPreference cols = (RadioPreference) findPreference(AppConfig.cols_detail);
    cols.setSummary("当前显示列数: " + (colsDetail + 1) + "\n图册页加载图片一般较大,同时显示多列对设备性能要求较高,请酌情选择");

    EditTextPreference downloadPath = (EditTextPreference) findPreference(getResources().getString(R.string.download_path));
    downloadPath.setSummary((String) SPUtils.get(getActivity(), AppConfig.download_path, AppConfig.DOWNLOAD_PATH));

    noMedia = new File((String) SPUtils.get(getActivity(), AppConfig.download_path, AppConfig.DOWNLOAD_PATH) + File.separatorChar + ".nomedia");
    SwitchPreference noMediaSwitch = (SwitchPreference) findPreference(AppConfig.hide_pic);
    if (noMedia.exists())
        noMediaSwitch.setChecked(true);
    else
        noMediaSwitch.setChecked(false);

    Fresco.getImagePipelineFactory().getMainFileCache().trimToMinimum();
    float size = (float) Fresco.getImagePipelineFactory().getMainFileCache().getSize() / ByteConstants.MB;
    cacheSize = (EditTextPreference) findPreference(getResources().getString(R.string.cache_size));
    cacheSize.setSummary(String.format("已使用 %.2f MB", size));
}
 
Example 4
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 5
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 6
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 7
Source File: PBPreferenceFragment.java    From client-android with GNU General Public License v2.0 6 votes vote down vote up
private void startOrStopService(final SharedPreferences preferences) {
    boolean userDidStart = preferences.getBoolean(PBConstants.PREF_SERVICE_RUNNING, false);
    Log.i(LOG_TAG, "PREF_SERVICE_RUNNING = " + userDidStart);

    if (userDidStart) {
        if (validatePreferences()) {
            checkPermissions(PBConstants.PERM_ORIGIN_SERVICE);
        } else {
            final SwitchPreference switchPreference = (SwitchPreference) findPreference(PBConstants.PREF_SERVICE_RUNNING);
            switchPreference.setChecked(false);
        }
    } else if (isPhotoBackupServiceRunning() && currentService != null) {
        Log.i(LOG_TAG, "stop PhotoBackup service");
        getActivity().unbindService(serviceConnection);
        getActivity().invalidateOptionsMenu();
        isBoundToService = false;
        currentService.stopSelf();
        currentService = null;
        updatePreferences();
    }
}
 
Example 8
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 9
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;
                }
            });
}
 
Example 10
Source File: PBPreferenceFragment.java    From client-android with GNU General Public License v2.0 5 votes vote down vote up
private void initPreferences() {
    ((PBActivity) getActivity()).setActionBar();

    // switch on if service is running
    final SwitchPreference switchPreference = (SwitchPreference) findPreference(PBConstants.PREF_SERVICE_RUNNING);
    switchPreference.setChecked(isPhotoBackupServiceRunning());

    // initiate preferences summaries
    setSummaries();
}
 
Example 11
Source File: DebugSettingsFragment.java    From Xndroid with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    BrowserApp.getAppComponent().inject(this);
    addPreferencesFromResource(R.xml.preference_debug);

    mSwitchLeakCanary = (SwitchPreference) findPreference(LEAK_CANARY);
    mSwitchLeakCanary.setChecked(mPreferenceManager.getUseLeakCanary());
    mSwitchLeakCanary.setOnPreferenceChangeListener(this);
}
 
Example 12
Source File: InputSettingsFragment.java    From wearmouse with Apache License 2.0 5 votes vote down vote up
private void initBooleanPref(@SettingKey final String key) {
    final SwitchPreference pref = (SwitchPreference) findPreference(key);
    pref.setChecked(settings.getBoolean(key));
    pref.setOnPreferenceChangeListener(
            (p, newVal) -> {
                settings.setBoolean(p.getKey(), ((Boolean) newVal));
                return true;
            });
}
 
Example 13
Source File: AdBlockSettings.java    From Cornowser with MIT License 5 votes vote down vote up
private void initAdBlockEnable() {
    final SwitchPreference pref = (SwitchPreference) findPreference("adblock_enable");

    pref.setChecked(CornBrowser.getBrowserStorage().isAdBlockEnabled());

    pref.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            CornBrowser.getBrowserStorage().saveEnableAdBlock((boolean)newValue);
            pref.setChecked((boolean)newValue);
            if((boolean)newValue) doUpdateAdBlock();
            return false;
        }
    });
}
 
Example 14
Source File: SudokuBoardCustomThemePreferenceGroup.java    From opensudoku with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    if (position == parent.getCount() - 1) {
        showCreateFromSingleColorDialog();
    } else if (position == parent.getCount() - 2) {
        showCopyFromExistingThemeDialog();
    } else if (position == 0) {
        SwitchPreference preference = (SwitchPreference) getPreference(position);
        preference.setChecked(!preference.isChecked());
    } else {
        ((ColorPickerPreference) getPreference(position)).onPreferenceClick(null);
    }
}
 
Example 15
Source File: AdBlockSettings.java    From Cornowser with MIT License 5 votes vote down vote up
private void initAdBlockWaitForPref() {
    final SwitchPreference pref = (SwitchPreference) findPreference("adblock_waitfor");

    pref.setChecked(CornBrowser.getBrowserStorage().isWaitForAdBlockEnabled());

    pref.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            CornBrowser.getBrowserStorage().saveWaitForAdBlock((boolean)newValue);
            pref.setChecked((boolean)newValue);
            return false;
        }
    });
}
 
Example 16
Source File: DebugSettingsFragment.java    From JumpGo with Mozilla Public License 2.0 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    BrowserApp.getAppComponent().inject(this);
    addPreferencesFromResource(R.xml.preference_debug);

    mSwitchLeakCanary = (SwitchPreference) findPreference(LEAK_CANARY);
    mSwitchLeakCanary.setChecked(mPreferenceManager.getUseLeakCanary());
    mSwitchLeakCanary.setOnPreferenceChangeListener(this);
}
 
Example 17
Source File: GeneralPreferenceFragment.java    From redgram-for-reddit with GNU General Public License v3.0 5 votes vote down vote up
private void toggleOver18Dependants(boolean flag){
    SwitchPreference labelPref = (SwitchPreference) getPreferenceManager().findPreference(SettingsActivity.general_label_nsfw);
    if(labelPref.isChecked() != flag){
        labelPref.setChecked(flag);
    }
    SwitchPreference prevPref = (SwitchPreference) getPreferenceManager().findPreference(SettingsActivity.general_preview_nsfw);
    if(prevPref.isChecked() != flag){
        prevPref.setChecked(flag);
    }
}
 
Example 18
Source File: AppsWidgetSettings.java    From Hangar with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onCreate(final Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.layout.apps_widget_settings);
    int defaultAppsNo = APPS_WIDGET_DEFAULT_APPSNO;
    int defaultAppsNoLs = APPS_WIDGET_DEFAULT_APPSNO_LS;

    SharedPreferences mPrefs = prefs.prefsGet();

    apps_by_widget_size_preference = (SwitchPreference)findPreference(Settings.APPS_BY_WIDGET_SIZE_PREFERENCE);
    apps_by_widget_size_preference.setChecked(mPrefs.getBoolean(Settings.APPS_BY_WIDGET_SIZE_PREFERENCE, Settings.APPS_BY_WIDGET_SIZE_DEFAULT));
    apps_by_widget_size_preference.setOnPreferenceChangeListener(changeListener);

    background_color_preference = (ColorPickerPreference) findPreference(Settings.BACKGROUND_COLOR_PREFERENCE);
    int intColor = mPrefs.getInt(Settings.BACKGROUND_COLOR_PREFERENCE, Settings.BACKGROUND_COLOR_DEFAULT);
    String hexColor = String.format("#%08x", (intColor));
    background_color_preference.setSummary(hexColor);
    background_color_preference.setOnPreferenceChangeListener(changeListener);

    appnos_preference = (UpdatingListPreference)findPreference(Settings.STATS_WIDGET_APPSNO_PREFERENCE);
    appnos_preference.setValue(mPrefs.getString(extras == null ? Settings.STATS_WIDGET_APPSNO_PREFERENCE : Integer.toString(defaultAppsNo),
            Integer.toString(defaultAppsNo)));
    appnos_preference.setOnPreferenceChangeListener(changeListener);
    if (apps_by_widget_size_preference.isChecked()) {
        appnos_preference.setSummary(R.string.automatic_appsno);
    }

    appnos_ls_preference = (UpdatingListPreference)findPreference(Settings.STATS_WIDGET_APPSNO_LS_PREFERENCE);
    appnos_ls_preference.setValue(mPrefs.getString(extras == null ? Settings.STATS_WIDGET_APPSNO_LS_PREFERENCE : Integer.toString(defaultAppsNoLs),
            Integer.toString(defaultAppsNoLs)));
    appnos_ls_preference.setOnPreferenceChangeListener(changeListener);
    if (apps_by_widget_size_preference.isChecked()) {
        appnos_ls_preference.setSummary(R.string.automatic_appsno);
    }

    weighted_recents_preference = (CheckBoxPreference)findPreference(Settings.WEIGHTED_RECENTS_PREFERENCE);
    weighted_recents_preference.setChecked(mPrefs.getBoolean(Settings.WEIGHTED_RECENTS_PREFERENCE, Settings.WEIGHTED_RECENTS_DEFAULT));
    weighted_recents_preference.setOnPreferenceChangeListener(changeListener);

    weight_priority_preference = (UpdatingListPreference)findPreference(Settings.WEIGHT_PRIORITY_PREFERENCE);
    weight_priority_preference.setValue(mPrefs.getString(Settings.WEIGHT_PRIORITY_PREFERENCE, Integer.toString(Settings.WEIGHT_PRIORITY_DEFAULT)));
    weight_priority_preference.setOnPreferenceChangeListener(changeListener);

    colorize_preference = (CheckBoxPreference)findPreference(Settings.COLORIZE_PREFERENCE);
    colorize_preference.setChecked(mPrefs.getBoolean(Settings.COLORIZE_PREFERENCE, Settings.COLORIZE_DEFAULT));
    colorize_preference.setOnPreferenceChangeListener(changeListener);

    ignore_pinned_preference = (CheckBoxPreference)findPreference(Settings.IGNORE_PINNED_PREFERENCE);
    ignore_pinned_preference.setChecked(mPrefs.getBoolean(Settings.IGNORE_PINNED_PREFERENCE, Settings.IGNORE_PINNED_DEFAULT));
    ignore_pinned_preference.setOnPreferenceChangeListener(changeListener);

    icon_color_preference = (ColorPickerPreference) findPreference(Settings.ICON_COLOR_PREFERENCE);
    int intColor2 = mPrefs.getInt(Settings.ICON_COLOR_PREFERENCE, Settings.ICON_COLOR_DEFAULT);
    String hexColor2 = String.format("#%08x", (intColor2));
    icon_color_preference.setSummary(hexColor2);
    icon_color_preference.setOnPreferenceChangeListener(changeListener);

    rounded_corners_preference = (CheckBoxPreference)findPreference(Settings.ROUNDED_CORNERS_PREFERENCE);
    rounded_corners_preference.setChecked(mPrefs.getBoolean(Settings.ROUNDED_CORNERS_PREFERENCE, Settings.ROUNDED_CORNERS_DEFAULT));
    rounded_corners_preference.setOnPreferenceChangeListener(changeListener);

    icon_size_preference = (UpdatingListPreference)findPreference(Settings.ICON_SIZE_PREFERENCE);
    icon_size_preference.setValue(mPrefs.getString(Settings.ICON_SIZE_PREFERENCE, Integer.toString(Settings.ICON_SIZE_DEFAULT)));
    icon_size_preference.setOnPreferenceChangeListener(changeListener);

    alignment_preference = (UpdatingListPreference)findPreference(Settings.ALIGNMENT_PREFERENCE);
    alignment_preference.setValue(mPrefs.getString(Settings.ALIGNMENT_PREFERENCE,
            Integer.toString(Settings.ALIGNMENT_DEFAULT)));
    alignment_preference.setOnPreferenceChangeListener(changeListener);
}
 
Example 19
Source File: SettingsMain.java    From ExpressHelper with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onCreate(Bundle savedInstance) {
	super.onCreate(savedInstance);
	addPreferencesFromResource(R.xml.pref_main);

	mSets = Settings.getInstance(getActivity().getApplicationContext());

	getActivity().setTitle(R.string.title_settings);

	pref_version = findPreference("application_version");
	pref_weibo = findPreference("sina_weibo");
	pref_os_license = findPreference("open_source_license");
	pref_api_provider = findPreference("api_provider");
	pref_github = findPreference("github_repo");
	pref_token_choose = (MaterialListPreference) findPreference("api_token_choose");
	pref_token_custom = findPreference("api_token_custom");
	pref_swipe_back = (SwitchPreference) findPreference("swipe_back");
	pref_notification_interval = (MaterialListPreference) findPreference("notification_interval");
	pref_do_not_disturb = (SwitchPreference) findPreference("do_not_disturb");
	pref_disable_animation = (SwitchPreference) findPreference("disable_animation");
	pref_navigation_tint = (SwitchPreference) findPreference("navigation_tint");

	String version = "Unknown";
	try {
		version = getActivity().getPackageManager().getPackageInfo(getActivity().getPackageName(), 0).versionName;
		version += " (" + getActivity().getPackageManager().getPackageInfo(getActivity().getPackageName(), 0).versionCode + ")";
	} catch (Exception e) {
		// Keep the default value
	}
	pref_version.setSummary(version);
	pref_swipe_back.setChecked(mSets.getBoolean(Settings.KEY_SWIPE_BACK, true));
	pref_token_custom.setDefaultValue(mSets.getInt(Settings.KEY_TOKEN_CHOOSE, 0));
	pref_token_custom.setEnabled(mSets.getInt(Settings.KEY_TOKEN_CHOOSE, 0) == 2);
	pref_do_not_disturb.setChecked(mSets.getBoolean(Settings.KEY_NOTIFICATION_DO_NOT_DISTURB, true));
	pref_disable_animation.setChecked(mSets.getBoolean(Settings.KEY_DISABLE_ANIMATION, false));
	if (Build.VERSION.SDK_INT < 21) {
		pref_navigation_tint.setEnabled(false);
		pref_navigation_tint.setChecked(false);
	} else {
		pref_navigation_tint.setChecked(mSets.getBoolean(Settings.KEY_NAVIGATION_TINT, true));
	}

	String[] values = getResources().getStringArray(R.array.item_token_list_values);
	int index, target = mSets.getInt(Settings.KEY_TOKEN_CHOOSE, 0);
	for (index = 0; index < values.length; index++) {
		if (values[index].equals(String.valueOf(target))) break;
	}
	pref_token_choose.setSummary(
			getResources().getStringArray(R.array.item_token_list)
			[index]
	);
	String[] values1 = getResources().getStringArray(R.array.notification_interval_item);
	int index1, target1 = mSets.getInt(Settings.KEY_NOTIFICATION_INTERVAL, 0);
	for (index1 = 0; index1 < values.length; index1++) {
		if (values1[index1].equals(String.valueOf(target1))) break;
	}
	pref_notification_interval.setSummary(
			getResources().getStringArray(R.array.notification_interval)
					[index1]
	);

	pref_weibo.setOnPreferenceClickListener(this);
	pref_os_license.setOnPreferenceClickListener(this);
	pref_api_provider.setOnPreferenceClickListener(this);
	pref_github.setOnPreferenceClickListener(this);
	pref_token_custom.setOnPreferenceClickListener(this);
	pref_token_choose.setOnPreferenceChangeListener(this);
	pref_swipe_back.setOnPreferenceChangeListener(this);
	pref_notification_interval.setOnPreferenceChangeListener(this);
	pref_do_not_disturb.setOnPreferenceChangeListener(this);
	pref_disable_animation.setOnPreferenceChangeListener(this);
	pref_navigation_tint.setOnPreferenceChangeListener(this);
}
 
Example 20
Source File: StatsWidgetSettings.java    From Hangar with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onCreate(final Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.layout.stats_widget_settings);
    int defaultAppsNo = WIDGET_3X3_DEFAULT_APPSNO;
    int defaultAppsNoLs = WIDGET_3X3_DEFAULT_APPSNO_LS;

    SharedPreferences mPrefs = prefs.prefsGet();

    divider_preference = (CheckBoxPreference)findPreference(Settings.DIVIDER_PREFERENCE);
    divider_preference.setChecked(mPrefs.getBoolean(Settings.DIVIDER_PREFERENCE, Settings.DIVIDER_DEFAULT));
    divider_preference.setOnPreferenceChangeListener(changeListener);

    rounded_corners_preference = (CheckBoxPreference)findPreference(Settings.ROUNDED_CORNERS_PREFERENCE);
    rounded_corners_preference.setChecked(mPrefs.getBoolean(Settings.ROUNDED_CORNERS_PREFERENCE, Settings.ROUNDED_CORNERS_DEFAULT));
    rounded_corners_preference.setOnPreferenceChangeListener(changeListener);

    apps_by_widget_size_preference = (SwitchPreference)findPreference(Settings.APPS_BY_WIDGET_SIZE_PREFERENCE);
    apps_by_widget_size_preference.setChecked(mPrefs.getBoolean(Settings.APPS_BY_WIDGET_SIZE_PREFERENCE, Settings.APPS_BY_WIDGET_SIZE_DEFAULT));
    apps_by_widget_size_preference.setOnPreferenceChangeListener(changeListener);

    background_color_preference = (ColorPickerPreference) findPreference(Settings.BACKGROUND_COLOR_PREFERENCE);
    int intColor = mPrefs.getInt(Settings.BACKGROUND_COLOR_PREFERENCE, Settings.BACKGROUND_COLOR_DEFAULT);
    String hexColor = String.format("#%08x", (intColor));
    background_color_preference.setSummary(hexColor);
    background_color_preference.setOnPreferenceChangeListener(changeListener);

    appnos_preference = (UpdatingListPreference)findPreference(Settings.STATS_WIDGET_APPSNO_PREFERENCE);
    appnos_preference.setValue(mPrefs.getString(extras == null ? Settings.STATS_WIDGET_APPSNO_PREFERENCE : Integer.toString(defaultAppsNo),
            Integer.toString(defaultAppsNo)));
    appnos_preference.setOnPreferenceChangeListener(changeListener);
    if (apps_by_widget_size_preference.isChecked()) {
        appnos_preference.setSummary(R.string.automatic_appsno);
    }

    appnos_ls_preference = (UpdatingListPreference)findPreference(Settings.STATS_WIDGET_APPSNO_LS_PREFERENCE);
    appnos_ls_preference.setValue(mPrefs.getString(extras == null ? Settings.STATS_WIDGET_APPSNO_LS_PREFERENCE : Integer.toString(defaultAppsNoLs),
            Integer.toString(defaultAppsNoLs)));
    appnos_ls_preference.setOnPreferenceChangeListener(changeListener);
    if (apps_by_widget_size_preference.isChecked()) {
        appnos_ls_preference.setSummary(R.string.automatic_appsno);
    }

    alignment_preference = (UpdatingListPreference)findPreference(Settings.ALIGNMENT_PREFERENCE);
    alignment_preference.setValue(mPrefs.getString(Settings.ALIGNMENT_PREFERENCE,
            Integer.toString(Settings.ALIGNMENT_DEFAULT)));
    alignment_preference.setOnPreferenceChangeListener(changeListener);
}