Search in sources :

Example 26 with SwitchPreference

use of android.support.v14.preference.SwitchPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class InputMethodAndLanguageSettings method updateGameControllers.

private void updateGameControllers() {
    if (haveInputDeviceWithVibrator()) {
        getPreferenceScreen().addPreference(mGameControllerCategory);
        SwitchPreference pref = (SwitchPreference) mGameControllerCategory.findPreference("vibrate_input_devices");
        pref.setChecked(System.getInt(getContentResolver(), Settings.System.VIBRATE_INPUT_DEVICES, 1) > 0);
    } else {
        getPreferenceScreen().removePreference(mGameControllerCategory);
    }
}
Also used : SwitchPreference(android.support.v14.preference.SwitchPreference)

Example 27 with SwitchPreference

use of android.support.v14.preference.SwitchPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class ZenAccessSettings method reloadList.

private void reloadList() {
    final PreferenceScreen screen = getPreferenceScreen();
    screen.removeAll();
    final ArrayList<ApplicationInfo> apps = new ArrayList<>();
    final ArraySet<String> requesting = mNoMan.getPackagesRequestingNotificationPolicyAccess();
    if (!requesting.isEmpty()) {
        final List<ApplicationInfo> installed = mPkgMan.getInstalledApplications(0);
        if (installed != null) {
            for (ApplicationInfo app : installed) {
                if (requesting.contains(app.packageName)) {
                    apps.add(app);
                }
            }
        }
    }
    ArraySet<String> autoApproved = getEnabledNotificationListeners();
    requesting.addAll(autoApproved);
    Collections.sort(apps, new PackageItemInfo.DisplayNameComparator(mPkgMan));
    for (ApplicationInfo app : apps) {
        final String pkg = app.packageName;
        final CharSequence label = app.loadLabel(mPkgMan);
        final SwitchPreference pref = new SwitchPreference(getPrefContext());
        pref.setPersistent(false);
        pref.setIcon(app.loadIcon(mPkgMan));
        pref.setTitle(label);
        pref.setChecked(hasAccess(pkg));
        if (autoApproved.contains(pkg)) {
            pref.setEnabled(false);
            pref.setSummary(getString(R.string.zen_access_disabled_package_warning));
        }
        pref.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {

            @Override
            public boolean onPreferenceChange(Preference preference, Object newValue) {
                final boolean access = (Boolean) newValue;
                if (access) {
                    new ScaryWarningDialogFragment().setPkgInfo(pkg, label).show(getFragmentManager(), "dialog");
                } else {
                    new FriendlyWarningDialogFragment().setPkgInfo(pkg, label).show(getFragmentManager(), "dialog");
                }
                return false;
            }
        });
        screen.addPreference(pref);
    }
}
Also used : PreferenceScreen(android.support.v7.preference.PreferenceScreen) SwitchPreference(android.support.v14.preference.SwitchPreference) ArrayList(java.util.ArrayList) ApplicationInfo(android.content.pm.ApplicationInfo) OnPreferenceChangeListener(android.support.v7.preference.Preference.OnPreferenceChangeListener) Preference(android.support.v7.preference.Preference) SwitchPreference(android.support.v14.preference.SwitchPreference) PackageItemInfo(android.content.pm.PackageItemInfo)

Example 28 with SwitchPreference

use of android.support.v14.preference.SwitchPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class DateTimeSettings method onResume.

@Override
public void onResume() {
    super.onResume();
    ((SwitchPreference) mTime24Pref).setChecked(is24Hour());
    // Register for time ticks and other reasons for time change
    IntentFilter filter = new IntentFilter();
    filter.addAction(Intent.ACTION_TIME_TICK);
    filter.addAction(Intent.ACTION_TIME_CHANGED);
    filter.addAction(Intent.ACTION_TIMEZONE_CHANGED);
    getActivity().registerReceiver(mIntentReceiver, filter, null, null);
    updateTimeAndDateDisplay(getActivity());
}
Also used : IntentFilter(android.content.IntentFilter) RestrictedSwitchPreference(com.android.settingslib.RestrictedSwitchPreference) SwitchPreference(android.support.v14.preference.SwitchPreference)

Example 29 with SwitchPreference

use of android.support.v14.preference.SwitchPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class ManagedServiceSettings method updateList.

private void updateList(List<ServiceInfo> services) {
    final PreferenceScreen screen = getPreferenceScreen();
    screen.removeAll();
    Collections.sort(services, new PackageItemInfo.DisplayNameComparator(mPM));
    for (ServiceInfo service : services) {
        final ComponentName cn = new ComponentName(service.packageName, service.name);
        final String title = service.loadLabel(mPM).toString();
        final SwitchPreference pref = new SwitchPreference(getPrefContext());
        pref.setPersistent(false);
        pref.setIcon(service.loadIcon(mPM));
        pref.setTitle(title);
        pref.setChecked(mServiceListing.isEnabled(cn));
        pref.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {

            @Override
            public boolean onPreferenceChange(Preference preference, Object newValue) {
                final boolean enable = (boolean) newValue;
                return setEnabled(cn, title, enable);
            }
        });
        screen.addPreference(pref);
    }
}
Also used : ServiceInfo(android.content.pm.ServiceInfo) PreferenceScreen(android.support.v7.preference.PreferenceScreen) SwitchPreference(android.support.v14.preference.SwitchPreference) Preference(android.support.v7.preference.Preference) SwitchPreference(android.support.v14.preference.SwitchPreference) PackageItemInfo(android.content.pm.PackageItemInfo) ComponentName(android.content.ComponentName) OnPreferenceChangeListener(android.support.v7.preference.Preference.OnPreferenceChangeListener)

Example 30 with SwitchPreference

use of android.support.v14.preference.SwitchPreference in project android_frameworks_base by crdroidandroid.

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)

Aggregations

SwitchPreference (android.support.v14.preference.SwitchPreference)30 Preference (android.support.v7.preference.Preference)16 PreferenceScreen (android.support.v7.preference.PreferenceScreen)16 Context (android.content.Context)8 ContentResolver (android.content.ContentResolver)7 ListPreference (android.support.v7.preference.ListPreference)7 OnPreferenceChangeListener (android.support.v7.preference.Preference.OnPreferenceChangeListener)6 PreferenceCategory (android.support.v7.preference.PreferenceCategory)5 RestrictedSwitchPreference (com.android.settingslib.RestrictedSwitchPreference)5 RestrictedPreference (com.android.settingslib.RestrictedPreference)4 Activity (android.app.Activity)3 Intent (android.content.Intent)3 PreferenceGroup (android.support.v7.preference.PreferenceGroup)3 PackageItemInfo (android.content.pm.PackageItemInfo)2 Settings (android.provider.Settings)2 DropDownPreference (android.support.v7.preference.DropDownPreference)2 OnPreferenceClickListener (android.support.v7.preference.Preference.OnPreferenceClickListener)2 ArrayList (java.util.ArrayList)2 FragmentManager (android.app.FragmentManager)1 UiModeManager (android.app.UiModeManager)1