use of android.support.v14.preference.SwitchPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class GestureAnywhereSettings method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.gesture_anywhere);
mEnabledPref = (SwitchPreference) findPreference(KEY_ENABLED);
mEnabledPref.setChecked((Settings.System.getInt(getContentResolver(), Settings.System.GESTURE_ANYWHERE_ENABLED, 0) == 1));
mEnabledPref.setOnPreferenceChangeListener(this);
PreferenceScreen prefSet = getPreferenceScreen();
mPositionPref = (ListPreference) prefSet.findPreference(KEY_POSITION);
mPositionPref.setOnPreferenceChangeListener(this);
int position = Settings.System.getInt(getContentResolver(), Settings.System.GESTURE_ANYWHERE_POSITION, Gravity.LEFT);
mPositionPref.setValue(String.valueOf(position));
mTriggerWidthPref = (SeekBarPreference) findPreference(KEY_TRIGGER_WIDTH);
mTriggerWidthPref.setValue(Settings.System.getInt(getContentResolver(), Settings.System.GESTURE_ANYWHERE_TRIGGER_WIDTH, 20));
mTriggerWidthPref.setOnPreferenceChangeListener(this);
mTriggerTopPref = (SeekBarPreference) findPreference(KEY_TRIGGER_TOP);
mTriggerTopPref.setValue(Settings.System.getInt(getContentResolver(), Settings.System.GESTURE_ANYWHERE_TRIGGER_TOP, 0));
mTriggerTopPref.setOnPreferenceChangeListener(this);
mTriggerBottomPref = (SeekBarPreference) findPreference(KEY_TRIGGER_BOTTOM);
mTriggerBottomPref.setValue(Settings.System.getInt(getContentResolver(), Settings.System.GESTURE_ANYWHERE_TRIGGER_HEIGHT, 100));
mTriggerBottomPref.setOnPreferenceChangeListener(this);
Preference pref = findPreference(KEY_GESTURES);
pref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
startActivity(new Intent(getActivity(), GestureAnywhereBuilderActivity.class));
return true;
}
});
}
use of android.support.v14.preference.SwitchPreference in project android_frameworks_base by AOSPA.
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);
}
use of android.support.v14.preference.SwitchPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class ScanningSettings method initPreferences.
private void initPreferences() {
final SwitchPreference wifiScanAlwaysAvailable = (SwitchPreference) findPreference(KEY_WIFI_SCAN_ALWAYS_AVAILABLE);
wifiScanAlwaysAvailable.setChecked(Global.getInt(getContentResolver(), Global.WIFI_SCAN_ALWAYS_AVAILABLE, 0) == 1);
final SwitchPreference bleScanAlwaysAvailable = (SwitchPreference) findPreference(KEY_BLUETOOTH_SCAN_ALWAYS_AVAILABLE);
bleScanAlwaysAvailable.setChecked(Global.getInt(getContentResolver(), Global.BLE_SCAN_ALWAYS_AVAILABLE, 0) == 1);
}
use of android.support.v14.preference.SwitchPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class AppRestrictionsFragment method onRestrictionsReceived.
private void onRestrictionsReceived(AppRestrictionsPreference preference, ArrayList<RestrictionEntry> restrictions) {
// Remove any earlier restrictions
removeRestrictionsForApp(preference);
// Non-custom-activity case - expand the restrictions in-place
int count = 1;
for (RestrictionEntry entry : restrictions) {
Preference p = null;
switch(entry.getType()) {
case RestrictionEntry.TYPE_BOOLEAN:
p = new SwitchPreference(getPrefContext());
p.setTitle(entry.getTitle());
p.setSummary(entry.getDescription());
((SwitchPreference) p).setChecked(entry.getSelectedState());
break;
case RestrictionEntry.TYPE_CHOICE:
case RestrictionEntry.TYPE_CHOICE_LEVEL:
p = new ListPreference(getPrefContext());
p.setTitle(entry.getTitle());
String value = entry.getSelectedString();
if (value == null) {
value = entry.getDescription();
}
p.setSummary(findInArray(entry.getChoiceEntries(), entry.getChoiceValues(), value));
((ListPreference) p).setEntryValues(entry.getChoiceValues());
((ListPreference) p).setEntries(entry.getChoiceEntries());
((ListPreference) p).setValue(value);
((ListPreference) p).setDialogTitle(entry.getTitle());
break;
case RestrictionEntry.TYPE_MULTI_SELECT:
p = new MultiSelectListPreference(getPrefContext());
p.setTitle(entry.getTitle());
((MultiSelectListPreference) p).setEntryValues(entry.getChoiceValues());
((MultiSelectListPreference) p).setEntries(entry.getChoiceEntries());
HashSet<String> set = new HashSet<>();
Collections.addAll(set, entry.getAllSelectedStrings());
((MultiSelectListPreference) p).setValues(set);
((MultiSelectListPreference) p).setDialogTitle(entry.getTitle());
break;
case RestrictionEntry.TYPE_NULL:
default:
}
if (p != null) {
p.setPersistent(false);
p.setOrder(preference.getOrder() + count);
// Store the restrictions key string as a key for the preference
p.setKey(preference.getKey().substring(PKG_PREFIX.length()) + DELIMITER + entry.getKey());
mAppList.addPreference(p);
p.setOnPreferenceChangeListener(AppRestrictionsFragment.this);
p.setIcon(R.drawable.empty_icon);
preference.mChildren.add(p);
count++;
}
}
preference.setRestrictions(restrictions);
if (// No visible restrictions
count == 1 && preference.isImmutable() && preference.isChecked()) {
// Special case of required app with no visible restrictions. Remove it
mAppList.removePreference(preference);
}
}
use of android.support.v14.preference.SwitchPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class DevelopmentSettings method onCreate.
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
mWindowManager = IWindowManager.Stub.asInterface(ServiceManager.getService("window"));
mBackupManager = IBackupManager.Stub.asInterface(ServiceManager.getService(Context.BACKUP_SERVICE));
mWebViewUpdateService = IWebViewUpdateService.Stub.asInterface(ServiceManager.getService("webviewupdate"));
mOemUnlockManager = (PersistentDataBlockManager) getActivity().getSystemService(Context.PERSISTENT_DATA_BLOCK_SERVICE);
mTelephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
mDpm = (DevicePolicyManager) getActivity().getSystemService(Context.DEVICE_POLICY_SERVICE);
mUm = (UserManager) getSystemService(Context.USER_SERVICE);
mWifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
setIfOnlyAvailableForAdmins(true);
if (isUiRestricted() || !Utils.isDeviceProvisioned(getActivity())) {
// Block access to developer options if the user is not the owner, if user policy
// restricts it, or if the device has not been provisioned
mUnavailable = true;
setPreferenceScreen(new PreferenceScreen(getPrefContext(), null));
return;
}
addPreferencesFromResource(R.xml.development_prefs);
final PreferenceGroup debugDebuggingCategory = (PreferenceGroup) findPreference(DEBUG_DEBUGGING_CATEGORY_KEY);
mEnableAdb = findAndInitSwitchPref(ENABLE_ADB);
mAdbAlwaysNotify = findAndInitSwitchPref(ADB_ALWAYS_NOTIFY);
mAdbOverNetwork = findAndInitSwitchPref(ADB_TCPIP);
mClearAdbKeys = findPreference(CLEAR_ADB_KEYS);
if (!SystemProperties.getBoolean("ro.adb.secure", false)) {
if (debugDebuggingCategory != null) {
debugDebuggingCategory.removePreference(mClearAdbKeys);
}
}
mAllPrefs.add(mClearAdbKeys);
mEnableTerminal = findAndInitSwitchPref(ENABLE_TERMINAL);
if (!isPackageInstalled(getActivity(), TERMINAL_APP_PACKAGE)) {
debugDebuggingCategory.removePreference(mEnableTerminal);
mEnableTerminal = null;
}
mBugreport = findPreference(BUGREPORT);
mBugreportInPower = findAndInitSwitchPref(BUGREPORT_IN_POWER_KEY);
mKeepScreenOn = (RestrictedSwitchPreference) findAndInitSwitchPref(KEEP_SCREEN_ON);
mBtHciSnoopLog = findAndInitSwitchPref(BT_HCI_SNOOP_LOG);
mEnableOemUnlock = (RestrictedSwitchPreference) findAndInitSwitchPref(ENABLE_OEM_UNLOCK);
if (!showEnableOemUnlockPreference()) {
removePreference(mEnableOemUnlock);
mEnableOemUnlock = null;
}
mDebugViewAttributes = findAndInitSwitchPref(DEBUG_VIEW_ATTRIBUTES);
mForceAllowOnExternal = findAndInitSwitchPref(FORCE_ALLOW_ON_EXTERNAL_KEY);
mPassword = (PreferenceScreen) findPreference(LOCAL_BACKUP_PASSWORD);
mAllPrefs.add(mPassword);
mForceAuthorizeSubstratumPackages = findAndInitSwitchPref(FORCE_AUTHORIZE_SUBSTRATUM_PACKAGES);
if (!mUm.isAdminUser()) {
disableForUser(mEnableAdb);
disableForUser(mClearAdbKeys);
disableForUser(mEnableTerminal);
disableForUser(mPassword);
disableForUser(mForceAuthorizeSubstratumPackages);
}
mDebugAppPref = findPreference(DEBUG_APP_KEY);
mAllPrefs.add(mDebugAppPref);
mWaitForDebugger = findAndInitSwitchPref(WAIT_FOR_DEBUGGER_KEY);
mMockLocationAppPref = findPreference(MOCK_LOCATION_APP_KEY);
mAllPrefs.add(mMockLocationAppPref);
mVerifyAppsOverUsb = findAndInitSwitchPref(VERIFY_APPS_OVER_USB_KEY);
if (!showVerifierSetting()) {
if (debugDebuggingCategory != null) {
debugDebuggingCategory.removePreference(mVerifyAppsOverUsb);
} else {
mVerifyAppsOverUsb.setEnabled(false);
}
}
mStrictMode = findAndInitSwitchPref(STRICT_MODE_KEY);
mPointerLocation = findAndInitSwitchPref(POINTER_LOCATION_KEY);
mShowTouches = findAndInitSwitchPref(SHOW_TOUCHES_KEY);
mShowScreenUpdates = findAndInitSwitchPref(SHOW_SCREEN_UPDATES_KEY);
mDisableOverlays = findAndInitSwitchPref(DISABLE_OVERLAYS_KEY);
mShowCpuInfo = findAndInitSwitchPref(SHOW_CPU_INFO_KEY);
mForceHardwareUi = findAndInitSwitchPref(FORCE_HARDWARE_UI_KEY);
mForceMsaa = findAndInitSwitchPref(FORCE_MSAA_KEY);
mTrackFrameTime = addListPreference(TRACK_FRAME_TIME_KEY);
mShowNonRectClip = addListPreference(SHOW_NON_RECTANGULAR_CLIP_KEY);
mShowHwScreenUpdates = findAndInitSwitchPref(SHOW_HW_SCREEN_UPDATES_KEY);
mShowHwLayersUpdates = findAndInitSwitchPref(SHOW_HW_LAYERS_UPDATES_KEY);
mDebugLayout = findAndInitSwitchPref(DEBUG_LAYOUT_KEY);
mForceRtlLayout = findAndInitSwitchPref(FORCE_RTL_LAYOUT_KEY);
mDebugHwOverdraw = addListPreference(DEBUG_HW_OVERDRAW_KEY);
mWifiDisplayCertification = findAndInitSwitchPref(WIFI_DISPLAY_CERTIFICATION_KEY);
mWifiVerboseLogging = findAndInitSwitchPref(WIFI_VERBOSE_LOGGING_KEY);
mWifiAggressiveHandover = findAndInitSwitchPref(WIFI_AGGRESSIVE_HANDOVER_KEY);
mWifiAllowScansWithTraffic = findAndInitSwitchPref(WIFI_ALLOW_SCAN_WITH_TRAFFIC_KEY);
mMobileDataAlwaysOn = findAndInitSwitchPref(MOBILE_DATA_ALWAYS_ON);
mLogdSize = addListPreference(SELECT_LOGD_SIZE_KEY);
if ("1".equals(SystemProperties.get("ro.debuggable", "0"))) {
mLogpersist = addListPreference(SELECT_LOGPERSIST_KEY);
} else {
mLogpersist = (ListPreference) findPreference(SELECT_LOGPERSIST_KEY);
if (mLogpersist != null) {
mLogpersist.setEnabled(false);
if (debugDebuggingCategory != null) {
debugDebuggingCategory.removePreference(mLogpersist);
}
}
mLogpersist = null;
}
mUsbConfiguration = addListPreference(USB_CONFIGURATION_KEY);
mWebViewProvider = addListPreference(WEBVIEW_PROVIDER_KEY);
mWebViewMultiprocess = findAndInitSwitchPref(WEBVIEW_MULTIPROCESS_KEY);
mBluetoothDisableAbsVolume = findAndInitSwitchPref(BLUETOOTH_DISABLE_ABSOLUTE_VOLUME_KEY);
mOverlayDisplayDevices = addListPreference(OVERLAY_DISPLAY_DEVICES_KEY);
mSimulateColorSpace = addListPreference(SIMULATE_COLOR_SPACE);
mUSBAudio = findAndInitSwitchPref(USB_AUDIO_KEY);
mForceResizable = findAndInitSwitchPref(FORCE_RESIZABLE_KEY);
mWindowAnimationScale = findAndInitAnimationScalePreference(WINDOW_ANIMATION_SCALE_KEY);
mTransitionAnimationScale = findAndInitAnimationScalePreference(TRANSITION_ANIMATION_SCALE_KEY);
mAnimatorDurationScale = findAndInitAnimationScalePreference(ANIMATOR_DURATION_SCALE_KEY);
mImmediatelyDestroyActivities = (SwitchPreference) findPreference(IMMEDIATELY_DESTROY_ACTIVITIES_KEY);
mAllPrefs.add(mImmediatelyDestroyActivities);
mResetSwitchPrefs.add(mImmediatelyDestroyActivities);
mAppProcessLimit = addListPreference(APP_PROCESS_LIMIT_KEY);
mShowAllANRs = (SwitchPreference) findPreference(SHOW_ALL_ANRS_KEY);
mAllPrefs.add(mShowAllANRs);
mResetSwitchPrefs.add(mShowAllANRs);
Preference hdcpChecking = findPreference(HDCP_CHECKING_KEY);
if (hdcpChecking != null) {
mAllPrefs.add(hdcpChecking);
removePreferenceForProduction(hdcpChecking);
}
PreferenceScreen convertFbePreference = (PreferenceScreen) findPreference(KEY_CONVERT_FBE);
try {
IBinder service = ServiceManager.getService("mount");
IMountService mountService = IMountService.Stub.asInterface(service);
if (!mountService.isConvertibleToFBE()) {
removePreference(KEY_CONVERT_FBE);
} else if ("file".equals(SystemProperties.get("ro.crypto.type", "none"))) {
convertFbePreference.setEnabled(false);
convertFbePreference.setSummary(getResources().getString(R.string.convert_to_file_encryption_done));
}
} catch (RemoteException e) {
removePreference(KEY_CONVERT_FBE);
}
mOtaDisableAutomaticUpdate = findAndInitSwitchPref(OTA_DISABLE_AUTOMATIC_UPDATE_KEY);
if (!SystemProperties.getBoolean("ro.build.ab_update", false)) {
removePreference(mOtaDisableAutomaticUpdate);
mOtaDisableAutomaticUpdate = null;
}
mColorModePreference = (ColorModePreference) findPreference(KEY_COLOR_MODE);
mColorModePreference.updateCurrentAndSupported();
if (mColorModePreference.getColorModeCount() < 2) {
removePreference(KEY_COLOR_MODE);
mColorModePreference = null;
}
updateWebViewProviderOptions();
mColorTemperaturePreference = (SwitchPreference) findPreference(COLOR_TEMPERATURE_KEY);
if (getResources().getBoolean(R.bool.config_enableColorTemperature)) {
mAllPrefs.add(mColorTemperaturePreference);
mResetSwitchPrefs.add(mColorTemperaturePreference);
} else {
removePreference(COLOR_TEMPERATURE_KEY);
mColorTemperaturePreference = null;
}
mRootAccess = (ListPreference) findPreference(ROOT_ACCESS_KEY);
mRootAccess.setOnPreferenceChangeListener(this);
mRootAppops = (Preference) findPreference(ROOT_APPOPS_KEY);
mRootAppops.setOnPreferenceClickListener(this);
if (!removeRootOptionsIfRequired()) {
if (FileUtils.fileExists("/system/xbin/su")) {
mRootAccess.setEntries(R.array.root_access_entries);
mRootAccess.setEntryValues(R.array.root_access_values);
} else {
mRootAccess.setEntries(R.array.root_access_entries_adb);
mRootAccess.setEntryValues(R.array.root_access_values_adb);
}
mAllPrefs.add(mRootAccess);
mAllPrefs.add(mRootAppops);
}
mDevelopmentTools = (PreferenceScreen) findPreference(DEVELOPMENT_TOOLS);
mAllPrefs.add(mDevelopmentTools);
}
Aggregations