Search in sources :

Example 1 with SwitchPreference

use of android.preference.SwitchPreference in project cw-omnibus by commonsguy.

the class SettingsFragment method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.settings);
    pm = getActivity().getPackageManager();
    SwitchPreference enabled = (SwitchPreference) findPreference("enabled");
    enabled.setOnPreferenceChangeListener(this);
    populateWhitelist((MultiSelectListPreference) findPreference("whitelist"));
}
Also used : SwitchPreference(android.preference.SwitchPreference)

Example 2 with SwitchPreference

use of android.preference.SwitchPreference in project android_packages_inputmethods_LatinIME by CyanogenMod.

the class CorrectionSettingsFragment method onCreate.

@Override
public void onCreate(final Bundle icicle) {
    super.onCreate(icicle);
    addPreferencesFromResource(R.xml.prefs_screen_correction);
    final Context context = getActivity();
    final PackageManager pm = context.getPackageManager();
    final Preference dictionaryLink = findPreference(Settings.PREF_CONFIGURE_DICTIONARIES_KEY);
    final Intent intent = dictionaryLink.getIntent();
    intent.setClassName(context.getPackageName(), DictionarySettingsActivity.class.getName());
    final int number = pm.queryIntentActivities(intent, 0).size();
    if (0 >= number) {
        removePreference(Settings.PREF_CONFIGURE_DICTIONARIES_KEY);
    }
    final Preference editPersonalDictionary = findPreference(Settings.PREF_EDIT_PERSONAL_DICTIONARY);
    final Intent editPersonalDictionaryIntent = editPersonalDictionary.getIntent();
    final ResolveInfo ri = USE_INTERNAL_PERSONAL_DICTIONARY_SETTINGS ? null : pm.resolveActivity(editPersonalDictionaryIntent, PackageManager.MATCH_DEFAULT_ONLY);
    if (ri == null) {
        overwriteUserDictionaryPreference(editPersonalDictionary);
    }
    mUseContactsPreference = (SwitchPreference) findPreference(Settings.PREF_KEY_USE_CONTACTS_DICT);
    turnOffUseContactsIfNoPermission();
}
Also used : Context(android.content.Context) ResolveInfo(android.content.pm.ResolveInfo) PackageManager(android.content.pm.PackageManager) Preference(android.preference.Preference) SwitchPreference(android.preference.SwitchPreference) DictionarySettingsActivity(com.android.inputmethod.dictionarypack.DictionarySettingsActivity) Intent(android.content.Intent)

Example 3 with SwitchPreference

use of android.preference.SwitchPreference in project android_packages_inputmethods_LatinIME by CyanogenMod.

the class TwoStatePreferenceHelper method addSwitchPreferenceBasedOnCheckBoxPreference.

static void addSwitchPreferenceBasedOnCheckBoxPreference(final CheckBoxPreference checkBox, final PreferenceGroup group) {
    final SwitchPreference switchPref = new SwitchPreference(checkBox.getContext());
    switchPref.setTitle(checkBox.getTitle());
    switchPref.setKey(checkBox.getKey());
    switchPref.setOrder(checkBox.getOrder());
    switchPref.setPersistent(checkBox.isPersistent());
    switchPref.setEnabled(checkBox.isEnabled());
    switchPref.setChecked(checkBox.isChecked());
    switchPref.setSummary(checkBox.getSummary());
    switchPref.setSummaryOn(checkBox.getSummaryOn());
    switchPref.setSummaryOff(checkBox.getSummaryOff());
    switchPref.setSwitchTextOn(EMPTY_TEXT);
    switchPref.setSwitchTextOff(EMPTY_TEXT);
    group.addPreference(switchPref);
    switchPref.setDependency(checkBox.getDependency());
}
Also used : SwitchPreference(android.preference.SwitchPreference)

Example 4 with SwitchPreference

use of android.preference.SwitchPreference in project AndroidChromium by JackyAndroid.

the class SyncCustomizationFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mProfileSyncService = ProfileSyncService.get();
    assert mProfileSyncService != null;
    mIsBackendInitialized = mProfileSyncService.isBackendInitialized();
    mIsPassphraseRequired = mIsBackendInitialized && mProfileSyncService.isPassphraseRequiredForDecryption();
    getActivity().setTitle(R.string.sign_in_sync);
    View view = super.onCreateView(inflater, container, savedInstanceState);
    addPreferencesFromResource(R.xml.sync_customization_preferences);
    mSyncEverything = (SwitchPreference) findPreference(PREFERENCE_SYNC_EVERYTHING);
    mSyncAutofill = (CheckBoxPreference) findPreference(PREFERENCE_SYNC_AUTOFILL);
    mSyncBookmarks = (CheckBoxPreference) findPreference(PREFERENCE_SYNC_BOOKMARKS);
    mSyncOmnibox = (CheckBoxPreference) findPreference(PREFERENCE_SYNC_OMNIBOX);
    mSyncPasswords = (CheckBoxPreference) findPreference(PREFERENCE_SYNC_PASSWORDS);
    mSyncRecentTabs = (CheckBoxPreference) findPreference(PREFERENCE_SYNC_RECENT_TABS);
    mSyncSettings = (CheckBoxPreference) findPreference(PREFERENCE_SYNC_SETTINGS);
    mPaymentsIntegration = (CheckBoxPreference) findPreference(PREFERENCE_PAYMENTS_INTEGRATION);
    mSyncEncryption = findPreference(PREFERENCE_ENCRYPTION);
    mSyncEncryption.setOnPreferenceClickListener(this);
    mManageSyncData = findPreference(PREFERENCE_SYNC_MANAGE_DATA);
    mManageSyncData.setOnPreferenceClickListener(this);
    mSyncErrorCard = findPreference(PREFERENCE_SYNC_ERROR_CARD);
    mSyncErrorCard.setOnPreferenceClickListener(this);
    mAllTypes = new CheckBoxPreference[] { mSyncAutofill, mSyncBookmarks, mSyncOmnibox, mSyncPasswords, mSyncRecentTabs, mSyncSettings, mPaymentsIntegration };
    mSyncEverything.setOnPreferenceChangeListener(this);
    for (CheckBoxPreference type : mAllTypes) {
        type.setOnPreferenceChangeListener(this);
    }
    mSyncSwitchPreference = (ChromeSwitchPreference) findPreference(PREF_SYNC_SWITCH);
    mSyncSwitchPreference.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {

        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            assert canDisableSync();
            if ((boolean) newValue) {
                mProfileSyncService.requestStart();
            } else {
                stopSync();
            }
            // Must be done asynchronously because the switch state isn't updated
            // until after this function exits.
            new Handler().post(new Runnable() {

                @Override
                public void run() {
                    updateSyncStateFromSwitch();
                }
            });
            return true;
        }
    });
    mSyncedAccountPreference = (SyncedAccountPreference) findPreference(PREFERENCE_SYNC_ACCOUNT_LIST);
    mSyncedAccountPreference.setOnPreferenceChangeListener(new SyncAccountSwitcher(getActivity(), mSyncedAccountPreference));
    return view;
}
Also used : SyncAccountSwitcher(org.chromium.chrome.browser.sync.SyncAccountSwitcher) CheckBoxPreference(android.preference.CheckBoxPreference) ChromeSwitchPreference(org.chromium.chrome.browser.preferences.ChromeSwitchPreference) CheckBoxPreference(android.preference.CheckBoxPreference) Preference(android.preference.Preference) SyncedAccountPreference(org.chromium.chrome.browser.preferences.SyncedAccountPreference) SwitchPreference(android.preference.SwitchPreference) Handler(android.os.Handler) OnPreferenceChangeListener(android.preference.Preference.OnPreferenceChangeListener) View(android.view.View)

Example 5 with SwitchPreference

use of android.preference.SwitchPreference in project WordPress-Android by wordpress-mobile.

the class AppSettingsActivity method onStart.

@Override
public void onStart() {
    super.onStart();
    Preference togglePref = mAppSettingsFragment.findPreference(getString(org.wordpress.passcodelock.R.string.pref_key_passcode_toggle));
    Preference changePref = mAppSettingsFragment.findPreference(getString(org.wordpress.passcodelock.R.string.pref_key_change_passcode));
    if (togglePref != null && changePref != null) {
        mPasscodePreferenceFragment.setPreferences(togglePref, changePref);
        ((SwitchPreference) togglePref).setChecked(AppLockManager.getInstance().getAppLock().isPasswordLocked());
        //here they've changed the PIN lock settings, so let's rebuild notifications if they have
        //quick actions
        GCMMessageService.rebuildAndUpdateNotifsOnSystemBarForRemainingNote(this);
    }
}
Also used : Preference(android.preference.Preference) SwitchPreference(android.preference.SwitchPreference) SwitchPreference(android.preference.SwitchPreference)

Aggregations

SwitchPreference (android.preference.SwitchPreference)5 Preference (android.preference.Preference)3 Context (android.content.Context)1 Intent (android.content.Intent)1 PackageManager (android.content.pm.PackageManager)1 ResolveInfo (android.content.pm.ResolveInfo)1 Handler (android.os.Handler)1 CheckBoxPreference (android.preference.CheckBoxPreference)1 OnPreferenceChangeListener (android.preference.Preference.OnPreferenceChangeListener)1 View (android.view.View)1 DictionarySettingsActivity (com.android.inputmethod.dictionarypack.DictionarySettingsActivity)1 ChromeSwitchPreference (org.chromium.chrome.browser.preferences.ChromeSwitchPreference)1 SyncedAccountPreference (org.chromium.chrome.browser.preferences.SyncedAccountPreference)1 SyncAccountSwitcher (org.chromium.chrome.browser.sync.SyncAccountSwitcher)1