Search in sources :

Example 1 with SwitchPreference

use of android.support.v14.preference.SwitchPreference in project platform_frameworks_base by android.

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 SwitchPreference

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

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 3 with SwitchPreference

use of android.support.v14.preference.SwitchPreference 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 4 with SwitchPreference

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

the class PrivacySettings method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // Don't allow any access if this is not an admin user.
    // TODO: backup/restore currently only works with owner user b/22760572
    mEnabled = UserManager.get(getActivity()).isAdminUser();
    if (!mEnabled) {
        return;
    }
    addPreferencesFromResource(R.xml.privacy_settings);
    final PreferenceScreen screen = getPreferenceScreen();
    mBackupManager = IBackupManager.Stub.asInterface(ServiceManager.getService(Context.BACKUP_SERVICE));
    mBackup = (PreferenceScreen) screen.findPreference(BACKUP_DATA);
    mAutoRestore = (SwitchPreference) screen.findPreference(AUTO_RESTORE);
    mAutoRestore.setOnPreferenceChangeListener(preferenceChangeListener);
    mConfigure = (PreferenceScreen) screen.findPreference(CONFIGURE_ACCOUNT);
    mManageData = (PreferenceScreen) screen.findPreference(DATA_MANAGEMENT);
    Set<String> keysToRemove = new HashSet<>();
    getNonVisibleKeys(getActivity(), keysToRemove);
    final int screenPreferenceCount = screen.getPreferenceCount();
    for (int i = screenPreferenceCount - 1; i >= 0; --i) {
        Preference preference = screen.getPreference(i);
        if (keysToRemove.contains(preference.getKey())) {
            screen.removePreference(preference);
        }
    }
    updateToggles();
}
Also used : PreferenceScreen(android.support.v7.preference.PreferenceScreen) RestrictedPreference(com.android.settingslib.RestrictedPreference) Preference(android.support.v7.preference.Preference) SwitchPreference(android.support.v14.preference.SwitchPreference) HashSet(java.util.HashSet)

Example 5 with SwitchPreference

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

the class ManageDomainUrls method onRebuildComplete.

@Override
public void onRebuildComplete(ArrayList<AppEntry> apps) {
    if (getContext() == null) {
        return;
    }
    final boolean disableWebActions = Global.getInt(getContext().getContentResolver(), Global.ENABLE_EPHEMERAL_FEATURE, 1) == 0;
    if (disableWebActions) {
        mDomainAppList = getPreferenceScreen();
    } else {
        final PreferenceGroup preferenceScreen = getPreferenceScreen();
        if (preferenceScreen.getPreferenceCount() == 0) {
            // add preferences
            final PreferenceCategory webActionCategory = new PreferenceCategory(getPrefContext());
            webActionCategory.setTitle(R.string.web_action_section_title);
            preferenceScreen.addPreference(webActionCategory);
            // toggle to enable / disable Web Actions [aka Instant Apps]
            mWebAction = new SwitchPreference(getPrefContext());
            mWebAction.setTitle(R.string.web_action_enable_title);
            mWebAction.setSummary(R.string.web_action_enable_summary);
            mWebAction.setChecked(Settings.Secure.getInt(getContentResolver(), Settings.Secure.WEB_ACTION_ENABLED, 1) != 0);
            mWebAction.setOnPreferenceChangeListener(this);
            webActionCategory.addPreference(mWebAction);
            // list to manage link handling per app
            mDomainAppList = new PreferenceCategory(getPrefContext());
            mDomainAppList.setTitle(R.string.domain_url_section_title);
            preferenceScreen.addPreference(mDomainAppList);
        }
    }
    rebuildAppList(mDomainAppList, apps);
}
Also used : PreferenceCategory(android.support.v7.preference.PreferenceCategory) SwitchPreference(android.support.v14.preference.SwitchPreference) PreferenceGroup(android.support.v7.preference.PreferenceGroup)

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