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"));
}
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();
}
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());
}
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;
}
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);
}
}
Aggregations