android.support.v7.preference.TwoStatePreference Java Examples

The following examples show how to use android.support.v7.preference.TwoStatePreference. 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 Camera-Roll-Android-App with Apache License 2.0 5 votes vote down vote up
private void initMediaRetrieverPref(boolean storageRetriever) {
    TwoStatePreference mediaRetrieverPref =
            (TwoStatePreference) findPreference(getString(R.string.pref_key_media_retriever));

    mediaRetrieverPref.setChecked(storageRetriever);
    mediaRetrieverPref.setOnPreferenceChangeListener(this);
}
 
Example #2
Source File: SettingsActivity.java    From Camera-Roll-Android-App with Apache License 2.0 5 votes vote down vote up
private void init8BitColorPref(boolean use8BitColor) {
    TwoStatePreference use8BitColorPref =
            (TwoStatePreference) findPreference(getString(R.string.pref_key_8_bit_color));

    use8BitColorPref.setChecked(use8BitColor);
    use8BitColorPref.setOnPreferenceChangeListener(this);
}
 
Example #3
Source File: SettingsActivity.java    From Camera-Roll-Android-App with Apache License 2.0 5 votes vote down vote up
private void initCameraShortcutPref(boolean cameraShortcut) {
    TwoStatePreference cameraShortcutPref =
            (TwoStatePreference) findPreference(getString(R.string.pref_key_camera_shortcut));

    cameraShortcutPref.setChecked(cameraShortcut);
    cameraShortcutPref.setOnPreferenceChangeListener(this);
}
 
Example #4
Source File: SettingsActivity.java    From Camera-Roll-Android-App with Apache License 2.0 5 votes vote down vote up
private void initAnimationsPref(boolean showAnimations) {
    TwoStatePreference animationsPref =
            (TwoStatePreference) findPreference(getString(R.string.pref_key_animations));

    animationsPref.setChecked(showAnimations);
    animationsPref.setOnPreferenceChangeListener(this);
}
 
Example #5
Source File: SettingsActivity.java    From Camera-Roll-Android-App with Apache License 2.0 5 votes vote down vote up
private void initMaxBrightnessPref(boolean maxBrightness) {
    TwoStatePreference animationsPref =
            (TwoStatePreference) findPreference(getString(R.string.pref_key_max_brightness));

    animationsPref.setChecked(maxBrightness);
    animationsPref.setOnPreferenceChangeListener(this);
}
 
Example #6
Source File: SettingsFragment.java    From RememBirthday with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
    addPreferencesFromResource(R.xml.preferences);
    remindersDaysEditTextPreference = (EditTextPreference) findPreference(getString(R.string.pref_reminders_days_key));

    Preference openCalendar = findPreference(getString(R.string.pref_open_calendar_key));
    openCalendar.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @SuppressLint("NewApi")
        @Override
        public boolean onPreferenceClick(Preference preference) {
            IntentCall.openCalendarAt(getContext(), new Date());
            return true;
        }
    });

    accountResolver = CalendarAccount.getAccount(getContext());
    preferenceCreateCalendar = (TwoStatePreference) findPreference(getString(R.string.pref_create_calendar_key));
    preferenceCreateCalendar.setDefaultValue(false);
    preferenceCreateCalendar.setOnPreferenceClickListener(onPreferenceCalendarClick);

    preferenceSpecial = (TwoStatePreference) findPreference(getString(R.string.pref_special_service_key));
    preferenceSpecial.setDefaultValue(false);
    if (!BuildConfig.FULL_VERSION) {
        // Disable switch and show pro dialog if free version
        preferenceSpecial.setOnPreferenceClickListener(onPreferenceProFeatureClick);
    } else {
        preferenceSpecial.setOnPreferenceClickListener(onPreferenceSendSmsClick);
    }

    TwoStatePreference preferenceHideInactive = (TwoStatePreference) findPreference(getString(R.string.pref_hide_inactive_features_key));
    if (!BuildConfig.FULL_VERSION) {
        preferenceHideInactive.setOnPreferenceClickListener(onPreferenceProFeatureClick);
    }
}
 
Example #7
Source File: PreferencesUi.java    From VCL-Android with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onPreferenceTreeClick(Preference preference) {
    if (preference.getKey() == null)
        return false;
    switch (preference.getKey()){
        case "enable_headset_detection":
            ((PreferencesActivity)getActivity()).detectHeadset(((TwoStatePreference) preference).isChecked());
            return true;
        case "enable_steal_remote_control":
            PlaybackService.Client.restartService(getActivity());
            return true;
    }
    return super.onPreferenceTreeClick(preference);
}
 
Example #8
Source File: SettingsActivity.java    From RetroMusicPlayer with GNU General Public License v3.0 4 votes vote down vote up
private void invalidateSettings() {
    Preference findPreference = findPreference("changelog");
    findPreference.setOnPreferenceClickListener(preference -> {
        openUrl(Constants.TELEGRAM_CHANGE_LOG);
        return true;
    });
    findPreference = findPreference("day_dream");
    findPreference.setVisible(false);
    findPreference.setOnPreferenceClickListener(preference -> {
        Intent intent = new Intent(Settings.ACTION_DREAM_SETTINGS);
        startActivity(intent);
        return true;
    });
    findPreference = findPreference("user_info");
    findPreference.setOnPreferenceClickListener(preference -> {
        startActivity(new Intent(getContext(), UserInfoActivity.class));
        return true;
    });
    findPreference = findPreference("open_source");
    findPreference.setOnPreferenceClickListener(preference -> {
        showLicenseDialog();
        return true;
    });
    findPreference = findPreference("about");
    findPreference.setOnPreferenceClickListener(preference -> {
        startActivity(new Intent(getContext(), AboutActivity.class));
        return true;
    });
    findPreference = findPreference("app_version");
    try {
        PackageInfo packageInfo = getActivity().getPackageManager().getPackageInfo(getActivity().getPackageName(), 0);
        findPreference.setSummary(packageInfo.versionName);
    } catch (PackageManager.NameNotFoundException e) {
        e.printStackTrace();
    }
    TwoStatePreference toggleVolume = (TwoStatePreference) findPreference("toggle_volume");
    toggleVolume.setOnPreferenceChangeListener((preference, o) -> {
        Toast.makeText(getContext(), "Restart app!", Toast.LENGTH_SHORT).show();
        getActivity().recreate();
        return true;
    });
    TwoStatePreference colorAppShortcuts = (TwoStatePreference) findPreference("should_color_app_shortcuts");
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N_MR1) {
        colorAppShortcuts.setVisible(false);
    } else {
        colorAppShortcuts.setChecked(PreferenceUtil.getInstance(getActivity()).coloredAppShortcuts());
        colorAppShortcuts.setOnPreferenceChangeListener((preference, newValue) -> {
            // Save preference
            PreferenceUtil.getInstance(getActivity()).setColoredAppShortcuts((Boolean) newValue);

            // Update app shortcuts
            new DynamicShortcutManager(getActivity()).updateDynamicShortcuts();

            return true;
        });
    }

    TwoStatePreference cornerWindow = (TwoStatePreference) findPreference("corner_window");
    cornerWindow.setOnPreferenceChangeListener((preference, newValue) -> {
        Toast.makeText(getContext(), "Restart app!", Toast.LENGTH_SHORT).show();
        getActivity().recreate();
        return true;
    });
}
 
Example #9
Source File: SettingsFragment.java    From RememBirthday with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean onPreferenceClick(Preference preference) {
    ((TwoStatePreference) preference).setChecked(false);
    new ProFeatureDialogFragment().show(getFragmentManager(), "PRO_FEATURE_TAG");
    return false;
}