Search in sources :

Example 1 with ListPreference

use of android.support.v7.preference.ListPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class QsAnimations method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.rr_qs_animations);
    mContext = getActivity().getApplicationContext();
    mContentRes = getActivity().getContentResolver();
    final Resources res = getResources();
    PreferenceScreen prefs = getPreferenceScreen();
    ContentResolver resolver = getActivity().getContentResolver();
    mTileAnimationStyle = (ListPreference) findPreference(PREF_TILE_ANIM_STYLE);
    int tileAnimationStyle = Settings.System.getIntForUser(getContentResolver(), Settings.System.ANIM_TILE_STYLE, 0, UserHandle.USER_CURRENT);
    mTileAnimationStyle.setValue(String.valueOf(tileAnimationStyle));
    updateTileAnimationStyleSummary(tileAnimationStyle);
    updateAnimTileStyle(tileAnimationStyle);
    mTileAnimationStyle.setOnPreferenceChangeListener(this);
    mTileAnimationDuration = (ListPreference) findPreference(PREF_TILE_ANIM_DURATION);
    int tileAnimationDuration = Settings.System.getIntForUser(getContentResolver(), Settings.System.ANIM_TILE_DURATION, 2000, UserHandle.USER_CURRENT);
    mTileAnimationDuration.setValue(String.valueOf(tileAnimationDuration));
    updateTileAnimationDurationSummary(tileAnimationDuration);
    mTileAnimationDuration.setOnPreferenceChangeListener(this);
    mTileAnimationInterpolator = (ListPreference) findPreference(PREF_TILE_ANIM_INTERPOLATOR);
    int tileAnimationInterpolator = Settings.System.getIntForUser(getContentResolver(), Settings.System.ANIM_TILE_INTERPOLATOR, 0, UserHandle.USER_CURRENT);
    mTileAnimationInterpolator.setValue(String.valueOf(tileAnimationInterpolator));
    updateTileAnimationInterpolatorSummary(tileAnimationInterpolator);
    mTileAnimationInterpolator.setOnPreferenceChangeListener(this);
}
Also used : PreferenceScreen(android.support.v7.preference.PreferenceScreen) Resources(android.content.res.Resources) ContentResolver(android.content.ContentResolver)

Example 2 with ListPreference

use of android.support.v7.preference.ListPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class RecentsStyles method onCreate.

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    addPreferencesFromResource(R.xml.recent_styles);
    ContentResolver resolver = getActivity().getContentResolver();
    PreferenceScreen prefSet = getPreferenceScreen();
    int intColor;
    String hexColor;
    mfabColor = (ColorPickerPreference) prefSet.findPreference(FAB_COLOR);
    mfabColor.setOnPreferenceChangeListener(this);
    intColor = Settings.System.getInt(getContentResolver(), Settings.System.FAB_BUTTON_COLOR, DEFAULT_BG_FAB);
    hexColor = String.format("#%08x", (0xff21272b & intColor));
    mfabColor.setSummary(hexColor);
    mfabColor.setNewPreviewColor(intColor);
    mClearStyle = (ListPreference) prefSet.findPreference(RECENTS_STYLE);
    mClearStyle.setValue(String.valueOf(Settings.System.getInt(getContentResolver(), Settings.System.CLEAR_RECENTS_STYLE, 0)));
    mClearStyle.setSummary(mClearStyle.getEntry());
    mClearStyle.setOnPreferenceChangeListener(this);
    mFabanimation = (ListPreference) prefSet.findPreference(FAB_ANIM_STYLE);
    mFabanimation.setValue(String.valueOf(Settings.System.getInt(getContentResolver(), Settings.System.FAB_ANIMATION_STYLE, 0)));
    mFabanimation.setSummary(mFabanimation.getEntry());
    mFabanimation.setOnPreferenceChangeListener(this);
    mMemTextColor = (ColorPickerPreference) prefSet.findPreference(MEM_TEXT_COLOR);
    mMemTextColor.setOnPreferenceChangeListener(this);
    intColor = Settings.System.getInt(getContentResolver(), Settings.System.MEM_TEXT_COLOR, DEFAULT);
    hexColor = String.format("#%08x", (0xffffffff & intColor));
    mMemTextColor.setSummary(hexColor);
    mMemTextColor.setNewPreviewColor(intColor);
    mMemBarColor = (ColorPickerPreference) prefSet.findPreference(MEMBAR_COLOR);
    mMemBarColor.setOnPreferenceChangeListener(this);
    intColor = Settings.System.getInt(getContentResolver(), Settings.System.MEM_BAR_COLOR, DEFAULT_BG_MEM_BAR);
    hexColor = String.format("#%08x", (0xff009688 & intColor));
    mMemBarColor.setSummary(hexColor);
    mMemBarColor.setNewPreviewColor(intColor);
    mClearButtonColor = (ColorPickerPreference) prefSet.findPreference(CLEAR_BUTTON_COLOR);
    mClearButtonColor.setOnPreferenceChangeListener(this);
    intColor = Settings.System.getInt(getContentResolver(), Settings.System.CLEAR_BUTTON_COLOR, getResources().getColor(R.color.floating_action_button_touch_tint));
    hexColor = String.format("#%08x", (0xff4285f4 & intColor));
    mClearButtonColor.setSummary(hexColor);
    mClearButtonColor.setNewPreviewColor(intColor);
    mClockColor = (ColorPickerPreference) prefSet.findPreference(RECENTS_CLOCK_COLOR);
    mClockColor.setOnPreferenceChangeListener(this);
    intColor = Settings.System.getInt(getContentResolver(), Settings.System.RECENTS_CLOCK_COLOR, DEFAULT);
    hexColor = String.format("#%08x", (0xffffffff & intColor));
    mClockColor.setSummary(hexColor);
    mClockColor.setNewPreviewColor(intColor);
    mDateColor = (ColorPickerPreference) prefSet.findPreference(RECENTS_DATE_COLOR);
    mDateColor.setOnPreferenceChangeListener(this);
    intColor = Settings.System.getInt(getContentResolver(), Settings.System.RECENTS_DATE_COLOR, DEFAULT);
    hexColor = String.format("#%08x", (0xffffffff & intColor));
    mDateColor.setSummary(hexColor);
    mDateColor.setNewPreviewColor(intColor);
    setHasOptionsMenu(true);
}
Also used : PreferenceScreen(android.support.v7.preference.PreferenceScreen) ContentResolver(android.content.ContentResolver)

Example 3 with ListPreference

use of android.support.v7.preference.ListPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class TtsEngineSettingsFragment method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.tts_engine_settings);
    mEnginesHelper = new TtsEngines(getActivity());
    final PreferenceScreen root = getPreferenceScreen();
    mLocalePreference = (ListPreference) root.findPreference(KEY_ENGINE_LOCALE);
    mLocalePreference.setOnPreferenceChangeListener(this);
    mEngineSettingsPreference = root.findPreference(KEY_ENGINE_SETTINGS);
    mEngineSettingsPreference.setOnPreferenceClickListener(this);
    mInstallVoicesPreference = root.findPreference(KEY_INSTALL_DATA);
    mInstallVoicesPreference.setOnPreferenceClickListener(this);
    root.setTitle(getEngineLabel());
    root.setKey(getEngineName());
    mEngineSettingsPreference.setTitle(getResources().getString(R.string.tts_engine_settings_title, getEngineLabel()));
    mEngineSettingsIntent = mEnginesHelper.getSettingsIntent(getEngineName());
    if (mEngineSettingsIntent == null) {
        mEngineSettingsPreference.setEnabled(false);
    }
    mInstallVoicesPreference.setEnabled(false);
    if (savedInstanceState == null) {
        mLocalePreference.setEnabled(false);
        mLocalePreference.setEntries(new CharSequence[0]);
        mLocalePreference.setEntryValues(new CharSequence[0]);
    } else {
        // Repopulate mLocalePreference with saved state. Will be updated later with
        // up-to-date values when checkTtsData() calls back with results.
        final CharSequence[] entries = savedInstanceState.getCharSequenceArray(STATE_KEY_LOCALE_ENTRIES);
        final CharSequence[] entryValues = savedInstanceState.getCharSequenceArray(STATE_KEY_LOCALE_ENTRY_VALUES);
        final CharSequence value = savedInstanceState.getCharSequence(STATE_KEY_LOCALE_VALUE);
        mLocalePreference.setEntries(entries);
        mLocalePreference.setEntryValues(entryValues);
        mLocalePreference.setValue(value != null ? value.toString() : null);
        mLocalePreference.setEnabled(entries.length > 0);
    }
    mVoiceDataDetails = getArguments().getParcelable(TtsEnginePreference.FRAGMENT_ARGS_VOICES);
    mTts = new TextToSpeech(getActivity().getApplicationContext(), mTtsInitListener, getEngineName());
    // Check if data packs changed
    checkTtsData();
    getActivity().registerReceiver(mLanguagesChangedReceiver, new IntentFilter(TextToSpeech.Engine.ACTION_TTS_DATA_INSTALLED));
}
Also used : IntentFilter(android.content.IntentFilter) PreferenceScreen(android.support.v7.preference.PreferenceScreen) TtsEngines(android.speech.tts.TtsEngines) TextToSpeech(android.speech.tts.TextToSpeech)

Example 4 with ListPreference

use of android.support.v7.preference.ListPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class ApplicationSettings method onCreate.

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    addPreferencesFromResource(R.xml.application_settings);
    mToggleAdvancedSettings = (CheckBoxPreference) findPreference(KEY_TOGGLE_ADVANCED_SETTINGS);
    mToggleAdvancedSettings.setChecked(isAdvancedSettingsEnabled());
    getPreferenceScreen().removePreference(mToggleAdvancedSettings);
    // not ready for prime time yet
    if (false) {
        getPreferenceScreen().removePreference(mInstallLocation);
    }
    mInstallLocation = (ListPreference) findPreference(KEY_APP_INSTALL_LOCATION);
    // Is app default install location set?
    boolean userSetInstLocation = (Settings.Global.getInt(getContentResolver(), Settings.Global.SET_INSTALL_LOCATION, 0) != 0);
    if (!userSetInstLocation) {
        getPreferenceScreen().removePreference(mInstallLocation);
    } else {
        mInstallLocation.setValue(getAppInstallLocation());
        mInstallLocation.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {

            public boolean onPreferenceChange(Preference preference, Object newValue) {
                String value = (String) newValue;
                handleUpdateAppInstallLocation(value);
                return false;
            }
        });
    }
}
Also used : Preference(android.support.v7.preference.Preference) CheckBoxPreference(android.support.v7.preference.CheckBoxPreference) ListPreference(android.support.v7.preference.ListPreference) OnPreferenceChangeListener(android.support.v7.preference.Preference.OnPreferenceChangeListener)

Example 5 with ListPreference

use of android.support.v7.preference.ListPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class VolumeSteps method updateVolumeStepPrefs.

private void updateVolumeStepPrefs(Preference pref, int steps) {
    if (pref == null || !(pref instanceof ListPreference)) {
        return;
    }
    final ListPreference listPref = (ListPreference) pref;
    listPref.setSummary(String.valueOf(steps));
    listPref.setValue(String.valueOf(steps));
}
Also used : ListPreference(android.support.v7.preference.ListPreference)

Aggregations

ListPreference (android.support.v7.preference.ListPreference)124 Preference (android.support.v7.preference.Preference)54 PreferenceScreen (android.support.v7.preference.PreferenceScreen)36 SwitchPreference (android.support.v14.preference.SwitchPreference)33 ContentResolver (android.content.ContentResolver)25 PreferenceCategory (android.support.v7.preference.PreferenceCategory)22 OnPreferenceChangeListener (android.support.v7.preference.Preference.OnPreferenceChangeListener)18 MultiSelectListPreference (android.support.v14.preference.MultiSelectListPreference)14 Intent (android.content.Intent)13 PackageInfo (android.content.pm.PackageInfo)13 RestrictionEntry (android.content.RestrictionEntry)12 OverlayInfo (android.content.om.OverlayInfo)12 ApplicationInfo (android.content.pm.ApplicationInfo)12 Resources (android.content.res.Resources)12 SmallTest (android.support.test.filters.SmallTest)12 CheckBoxPreference (android.support.v7.preference.CheckBoxPreference)12 HashSet (java.util.HashSet)12 Test (org.junit.Test)12 Matchers.anyString (org.mockito.Matchers.anyString)12 View (android.view.View)9