Search in sources :

Example 1 with PreferenceScreen

use of android.support.v7.preference.PreferenceScreen in project android_frameworks_base by ResurrectionRemix.

the class DemoModeFragment method onCreatePreferences.

@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
    Context context = getContext();
    mEnabledSwitch = new SwitchPreference(context);
    mEnabledSwitch.setTitle(R.string.enable_demo_mode);
    mEnabledSwitch.setOnPreferenceChangeListener(this);
    mOnSwitch = new SwitchPreference(context);
    mOnSwitch.setTitle(R.string.show_demo_mode);
    mOnSwitch.setEnabled(false);
    mOnSwitch.setOnPreferenceChangeListener(this);
    PreferenceScreen screen = getPreferenceManager().createPreferenceScreen(context);
    screen.addPreference(mEnabledSwitch);
    screen.addPreference(mOnSwitch);
    setPreferenceScreen(screen);
    updateDemoModeEnabled();
    updateDemoModeOn();
    ContentResolver contentResolver = getContext().getContentResolver();
    contentResolver.registerContentObserver(Settings.Global.getUriFor(DemoMode.DEMO_MODE_ALLOWED), false, mDemoModeObserver);
    contentResolver.registerContentObserver(Settings.Global.getUriFor(DEMO_MODE_ON), false, mDemoModeObserver);
    setHasOptionsMenu(true);
}
Also used : Context(android.content.Context) PreferenceScreen(android.support.v7.preference.PreferenceScreen) SwitchPreference(android.support.v14.preference.SwitchPreference) ContentResolver(android.content.ContentResolver)

Example 2 with PreferenceScreen

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

the class AccountPreferenceBase method addPreferencesForType.

/**
     * Gets the preferences.xml file associated with a particular account type.
     * @param accountType the type of account
     * @return a PreferenceScreen inflated from accountPreferenceId.
     */
public PreferenceScreen addPreferencesForType(final String accountType, PreferenceScreen parent) {
    PreferenceScreen prefs = null;
    if (mAuthenticatorHelper.containsAccountType(accountType)) {
        AuthenticatorDescription desc = null;
        try {
            desc = mAuthenticatorHelper.getAccountTypeDescription(accountType);
            if (desc != null && desc.accountPreferencesId != 0 && Utils.showAccount(getActivity(), accountType)) {
                // Load the context of the target package, then apply the
                // base Settings theme (no references to local resources)
                // and create a context theme wrapper so that we get the
                // correct text colors. Control colors will still be wrong,
                // but there's not much we can do about it since we can't
                // reference local color resources.
                final Context targetCtx = getActivity().createPackageContextAsUser(desc.packageName, 0, mUserHandle);
                final Theme baseTheme = getResources().newTheme();
                baseTheme.applyStyle(com.android.settings.R.style.Theme_SettingsBase, true);
                final Context themedCtx = new LocalClassLoaderContextThemeWrapper(getClass(), targetCtx, 0);
                themedCtx.getTheme().setTo(baseTheme);
                prefs = getPreferenceManager().inflateFromResource(themedCtx, desc.accountPreferencesId, parent);
            }
        } catch (PackageManager.NameNotFoundException e) {
            Log.w(TAG, "Couldn't load preferences.xml file from " + desc.packageName);
        } catch (Resources.NotFoundException e) {
            Log.w(TAG, "Couldn't load preferences.xml file from " + desc.packageName);
        }
    }
    return prefs;
}
Also used : Context(android.content.Context) AuthenticatorDescription(android.accounts.AuthenticatorDescription) PreferenceScreen(android.support.v7.preference.PreferenceScreen) PackageManager(android.content.pm.PackageManager) Theme(android.content.res.Resources.Theme) LocalClassLoaderContextThemeWrapper(com.android.settings.utils.LocalClassLoaderContextThemeWrapper) Resources(android.content.res.Resources)

Example 3 with PreferenceScreen

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

the class ScrollAnimationInterfaceSettings method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.scroll_animation_interface_settings);
    PreferenceScreen prefSet = getPreferenceScreen();
    ContentResolver resolver = getActivity().getContentResolver();
    mAnimNoScroll = (SwitchPreference) prefSet.findPreference(ANIMATION_NO_SCROLL);
    mAnimNoScroll.setChecked(Settings.System.getInt(resolver, Settings.System.ANIMATION_CONTROLS_NO_SCROLL, 0) == 1);
    mAnimNoScroll.setOnPreferenceChangeListener(this);
    float defaultScroll = Settings.System.getFloat(resolver, Settings.System.CUSTOM_SCROLL_FRICTION, ViewConfiguration.DEFAULT_SCROLL_FRICTION);
    mAnimationScroll = (SeekBarPreference) prefSet.findPreference(ANIMATION_SCROLL_FRICTION);
    mAnimationScroll.setValue((int) (defaultScroll * MULTIPLIER_SCROLL_FRICTION));
    mAnimationScroll.setOnPreferenceChangeListener(this);
    int defaultFling = Settings.System.getInt(resolver, Settings.System.CUSTOM_FLING_VELOCITY, ViewConfiguration.DEFAULT_MAXIMUM_FLING_VELOCITY);
    mAnimationFling = (SeekBarPreference) prefSet.findPreference(ANIMATION_FLING_VELOCITY);
    mAnimationFling.setValue(defaultFling);
    mAnimationFling.setOnPreferenceChangeListener(this);
    int defaultOverScroll = Settings.System.getInt(resolver, Settings.System.CUSTOM_OVERSCROLL_DISTANCE, ViewConfiguration.DEFAULT_OVERSCROLL_DISTANCE);
    mAnimationOverScroll = (SeekBarPreference) prefSet.findPreference(ANIMATION_OVERSCROLL_DISTANCE);
    mAnimationOverScroll.setValue(defaultOverScroll);
    mAnimationOverScroll.setOnPreferenceChangeListener(this);
    int defaultOverFling = Settings.System.getInt(resolver, Settings.System.CUSTOM_OVERFLING_DISTANCE, ViewConfiguration.DEFAULT_OVERFLING_DISTANCE);
    mAnimationOverFling = (SeekBarPreference) prefSet.findPreference(ANIMATION_OVERFLING_DISTANCE);
    mAnimationOverFling.setValue(defaultOverFling);
    mAnimationOverFling.setOnPreferenceChangeListener(this);
    setHasOptionsMenu(true);
}
Also used : PreferenceScreen(android.support.v7.preference.PreferenceScreen) ContentResolver(android.content.ContentResolver)

Example 4 with PreferenceScreen

use of android.support.v7.preference.PreferenceScreen 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 5 with PreferenceScreen

use of android.support.v7.preference.PreferenceScreen 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)

Aggregations

PreferenceScreen (android.support.v7.preference.PreferenceScreen)640 Preference (android.support.v7.preference.Preference)458 Context (android.content.Context)127 Test (org.junit.Test)126 SwitchPreference (android.support.v14.preference.SwitchPreference)96 PreferenceCategory (android.support.v7.preference.PreferenceCategory)82 Intent (android.content.Intent)63 PreferenceGroup (android.support.v7.preference.PreferenceGroup)58 VisibleForTesting (android.support.annotation.VisibleForTesting)55 PreferenceManager (android.support.v7.preference.PreferenceManager)54 ContentResolver (android.content.ContentResolver)53 PackageManager (android.content.pm.PackageManager)51 StorageItemPreference (com.android.settings.deviceinfo.StorageItemPreference)48 Bundle (android.os.Bundle)46 ArrayList (java.util.ArrayList)46 OnPreferenceChangeListener (android.support.v7.preference.Preference.OnPreferenceChangeListener)44 ListPreference (android.support.v7.preference.ListPreference)41 ComponentName (android.content.ComponentName)31 Resources (android.content.res.Resources)30 VolumeInfo (android.os.storage.VolumeInfo)30