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