Search in sources :

Example 46 with PreferenceScreen

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

the class LockscreenShortcutFragment method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.lockscreen_shortcut_fragment);
    PreferenceScreen prefSet = getPreferenceScreen();
    mLockscreenShortcutsLongpress = (SwitchPreference) findPreference(PREF_LOCKSCREEN_SHORTCUTS_LONGPRESS);
    mLockscreenShortcutsLongpress.setChecked(Settings.System.getInt(getContentResolver(), Settings.System.LOCKSCREEN_SHORTCUTS_LONGPRESS, 1) == 1);
    mLockscreenShortcutsLongpress.setOnPreferenceChangeListener(this);
    setHasOptionsMenu(false);
}
Also used : PreferenceScreen(android.support.v7.preference.PreferenceScreen)

Example 47 with PreferenceScreen

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

the class LockClockFonts method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.lock_clock_fonts);
    final ContentResolver resolver = getActivity().getContentResolver();
    PreferenceScreen prefs = getPreferenceScreen();
    mLockClockFonts = (ListPreference) findPreference(LOCK_CLOCK_FONTS);
    mLockClockFonts.setValue(String.valueOf(Settings.System.getInt(getContentResolver(), Settings.System.LOCK_CLOCK_FONTS, 0)));
    mLockClockFonts.setSummary(mLockClockFonts.getEntry());
    mLockClockFonts.setOnPreferenceChangeListener(this);
    mDateFonts = (ListPreference) findPreference(LOCK_DATE_FONTS);
    mDateFonts.setValue(String.valueOf(Settings.System.getInt(resolver, Settings.System.LOCK_DATE_FONTS, 8)));
    mDateFonts.setSummary(mDateFonts.getEntry());
    mDateFonts.setOnPreferenceChangeListener(this);
}
Also used : PreferenceScreen(android.support.v7.preference.PreferenceScreen) ContentResolver(android.content.ContentResolver)

Example 48 with PreferenceScreen

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

the class GestureAnywhereSettings method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.gesture_anywhere);
    mEnabledPref = (SwitchPreference) findPreference(KEY_ENABLED);
    mEnabledPref.setChecked((Settings.System.getInt(getContentResolver(), Settings.System.GESTURE_ANYWHERE_ENABLED, 0) == 1));
    mEnabledPref.setOnPreferenceChangeListener(this);
    PreferenceScreen prefSet = getPreferenceScreen();
    mPositionPref = (ListPreference) prefSet.findPreference(KEY_POSITION);
    mPositionPref.setOnPreferenceChangeListener(this);
    int position = Settings.System.getInt(getContentResolver(), Settings.System.GESTURE_ANYWHERE_POSITION, Gravity.LEFT);
    mPositionPref.setValue(String.valueOf(position));
    mTriggerWidthPref = (SeekBarPreference) findPreference(KEY_TRIGGER_WIDTH);
    mTriggerWidthPref.setValue(Settings.System.getInt(getContentResolver(), Settings.System.GESTURE_ANYWHERE_TRIGGER_WIDTH, 20));
    mTriggerWidthPref.setOnPreferenceChangeListener(this);
    mTriggerTopPref = (SeekBarPreference) findPreference(KEY_TRIGGER_TOP);
    mTriggerTopPref.setValue(Settings.System.getInt(getContentResolver(), Settings.System.GESTURE_ANYWHERE_TRIGGER_TOP, 0));
    mTriggerTopPref.setOnPreferenceChangeListener(this);
    mTriggerBottomPref = (SeekBarPreference) findPreference(KEY_TRIGGER_BOTTOM);
    mTriggerBottomPref.setValue(Settings.System.getInt(getContentResolver(), Settings.System.GESTURE_ANYWHERE_TRIGGER_HEIGHT, 100));
    mTriggerBottomPref.setOnPreferenceChangeListener(this);
    Preference pref = findPreference(KEY_GESTURES);
    pref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {

        @Override
        public boolean onPreferenceClick(Preference preference) {
            startActivity(new Intent(getActivity(), GestureAnywhereBuilderActivity.class));
            return true;
        }
    });
}
Also used : PreferenceScreen(android.support.v7.preference.PreferenceScreen) SeekBarPreference(com.android.settings.rr.SeekBarPreference) ListPreference(android.support.v7.preference.ListPreference) Preference(android.support.v7.preference.Preference) SwitchPreference(android.support.v14.preference.SwitchPreference) Intent(android.content.Intent)

Example 49 with PreferenceScreen

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

the class Utils method getNonIndexable.

public static List<String> getNonIndexable(int xml, Context context) {
    if (Looper.myLooper() == null) {
        // Hack to make sure Preferences can initialize.  Prefs expect a looper, but
        // don't actually use it for the basic stuff here.
        Looper.prepare();
    }
    final List<String> ret = new ArrayList<>();
    PreferenceManager manager = new PreferenceManager(context);
    PreferenceScreen screen = manager.inflateFromResource(context, xml, null);
    checkPrefs(screen, ret);
    return ret;
}
Also used : PreferenceScreen(android.support.v7.preference.PreferenceScreen) ArrayList(java.util.ArrayList) SpannableString(android.text.SpannableString) PreferenceManager(android.support.v7.preference.PreferenceManager)

Example 50 with PreferenceScreen

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

the class ManageAccountsSettings method updatePreferenceIntents.

/**
     * Filters through the preference list provided by GoogleLoginService.
     *
     * This method removes all the invalid intent from the list, adds account name as extra into the
     * intent, and hack the location settings to start it as a fragment.
     */
private void updatePreferenceIntents(PreferenceScreen prefs) {
    final PackageManager pm = getActivity().getPackageManager();
    for (int i = 0; i < prefs.getPreferenceCount(); ) {
        Preference pref = prefs.getPreference(i);
        Intent intent = pref.getIntent();
        if (intent != null) {
            // preference click event here directly.
            if (intent.getAction().equals(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS)) {
                // The OnPreferenceClickListener overrides the click event completely. No intent
                // will get fired.
                pref.setOnPreferenceClickListener(new FragmentStarter(LocationSettings.class.getName(), R.string.location_settings_title));
            } else {
                ResolveInfo ri = pm.resolveActivityAsUser(intent, PackageManager.MATCH_DEFAULT_ONLY, mUserHandle.getIdentifier());
                if (ri == null) {
                    prefs.removePreference(pref);
                    continue;
                } else {
                    intent.putExtra(ACCOUNT_KEY, mFirstAccount);
                    intent.setFlags(intent.getFlags() | Intent.FLAG_ACTIVITY_NEW_TASK);
                    pref.setOnPreferenceClickListener(new OnPreferenceClickListener() {

                        @Override
                        public boolean onPreferenceClick(Preference preference) {
                            Intent prefIntent = preference.getIntent();
                            /*
                                 * Check the intent to see if it resolves to a exported=false
                                 * activity that doesn't share a uid with the authenticator.
                                 *
                                 * Otherwise the intent is considered unsafe in that it will be
                                 * exploiting the fact that settings has system privileges.
                                 */
                            if (isSafeIntent(pm, prefIntent)) {
                                getActivity().startActivityAsUser(prefIntent, mUserHandle);
                            } else {
                                Log.e(TAG, "Refusing to launch authenticator intent because" + "it exploits Settings permissions: " + prefIntent);
                            }
                            return true;
                        }
                    });
                }
            }
        }
        i++;
    }
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) OnPreferenceClickListener(android.support.v7.preference.Preference.OnPreferenceClickListener) PackageManager(android.content.pm.PackageManager) AccountPreference(com.android.settings.AccountPreference) Preference(android.support.v7.preference.Preference) Intent(android.content.Intent)

Aggregations

PreferenceScreen (android.support.v7.preference.PreferenceScreen)107 Preference (android.support.v7.preference.Preference)38 ContentResolver (android.content.ContentResolver)33 SwitchPreference (android.support.v14.preference.SwitchPreference)21 Context (android.content.Context)18 Resources (android.content.res.Resources)15 PreferenceCategory (android.support.v7.preference.PreferenceCategory)12 Intent (android.content.Intent)11 OnPreferenceChangeListener (android.support.v7.preference.Preference.OnPreferenceChangeListener)7 PreferenceGroup (android.support.v7.preference.PreferenceGroup)7 ArrayList (java.util.ArrayList)7 PackageManager (android.content.pm.PackageManager)6 ListPreference (android.support.v7.preference.ListPreference)6 OnPreferenceClickListener (android.support.v7.preference.Preference.OnPreferenceClickListener)6 Activity (android.app.Activity)5 PreferenceManager (android.support.v7.preference.PreferenceManager)5 InputMethodInfo (android.view.inputmethod.InputMethodInfo)4 InputMethodSubtype (android.view.inputmethod.InputMethodSubtype)4 ComponentName (android.content.ComponentName)3 IntentFilter (android.content.IntentFilter)3