@Override public void onPause() { mSettingsPackageMonitor.unregister(); mSettingsContentObserver.unregister(getContentResolver()); if (RotationPolicy.isRotationSupported(getActivity())) { RotationPolicy.unregisterRotationPolicyListener(getActivity(), mRotationPolicyListener); } super.onPause(); }
@Override public void onResume() { super.onResume(); loadInstalledServices(); updateAllPreferences(); mSettingsPackageMonitor.register(getActivity(), getActivity().getMainLooper(), false); mSettingsContentObserver.register(getContentResolver()); if (RotationPolicy.isRotationSupported(getActivity())) { RotationPolicy.registerRotationPolicyListener(getActivity(), mRotationPolicyListener); } }
@Override public List<String> getNonIndexableKeys(Context context) { CMHardwareManager hardware = CMHardwareManager.getInstance(context); ArrayList<String> result = new ArrayList<String>(); if (!context .getResources() .getBoolean(com.android.internal.R.bool.config_dreamsSupported)) { result.add(KEY_SCREEN_SAVER); } if (!hardware.isSupported(FEATURE_TAP_TO_WAKE)) { result.add(KEY_TAP_TO_WAKE); } if (!isAutomaticBrightnessAvailable(context.getResources())) { result.add(KEY_AUTO_BRIGHTNESS); } if (!isLiftToWakeAvailable(context)) { result.add(KEY_LIFT_TO_WAKE); } if (!Utils.isDozeAvailable(context)) { result.add(KEY_DOZE_FRAGMENT); } if (!RotationPolicy.isRotationLockToggleVisible(context)) { result.add(KEY_DISPLAY_ROTATION); } return result; }
@Override public void onPause() { super.onPause(); RotationPolicy.unregisterRotationPolicyListener(getActivity(), mRotationPolicyListener); // Display rotation observer getContentResolver().unregisterContentObserver(mAccelerometerRotationObserver); }
@Override public void onPause() { super.onPause(); RotationPolicy.unregisterRotationPolicyListener(getActivity(), mRotationPolicyListener); // Display rotation observer getContentResolver().unregisterContentObserver(mAccelerometerRotationObserver); if (mWifiDisplayPreference != null) { getActivity().unregisterReceiver(mReceiver); } }
@Override public void onResume() { super.onResume(); updateDisplayRotationPreferenceDescription(); if (mTapToWake != null) { mTapToWake.setChecked(mHardware.get(FEATURE_TAP_TO_WAKE)); } RotationPolicy.registerRotationPolicyListener(getActivity(), mRotationPolicyListener); final ContentResolver resolver = getContentResolver(); boolean dozeEnabled = Settings.Secure.getInt(getContentResolver(), Settings.Secure.DOZE_ENABLED, 1) != 0; if (mDozeFragement != null) { mDozeFragement.setSummary( dozeEnabled ? R.string.summary_doze_enabled : R.string.summary_doze_disabled); } // Display rotation observer resolver.registerContentObserver( Settings.System.getUriFor(Settings.System.ACCELEROMETER_ROTATION), true, mAccelerometerRotationObserver); // Default value for wake-on-plug behavior from config.xml boolean wakeUpWhenPluggedOrUnpluggedConfig = getResources().getBoolean(com.android.internal.R.bool.config_unplugTurnsOnScreen); mWakeWhenPluggedOrUnplugged.setChecked( Settings.Global.getInt( getContentResolver(), Settings.Global.WAKE_WHEN_PLUGGED_OR_UNPLUGGED, (wakeUpWhenPluggedOrUnpluggedConfig ? 1 : 0)) == 1); updateState(); }
@Override public void onResume() { super.onResume(); updateDisplayRotationPreferenceDescription(); RotationPolicy.registerRotationPolicyListener(getActivity(), mRotationPolicyListener); // Display rotation observer getContentResolver() .registerContentObserver( Settings.System.getUriFor(Settings.System.ACCELEROMETER_ROTATION), true, mAccelerometerRotationObserver); if (mWifiDisplayPreference != null) { getActivity() .registerReceiver( mReceiver, new IntentFilter(DisplayManager.ACTION_WIFI_DISPLAY_STATUS_CHANGED)); mWifiDisplayStatus = mDisplayManager.getWifiDisplayStatus(); } updateState(); }
private void updateLockScreenRotationCheckbox() { Context context = getActivity(); if (context != null) { mToggleLockScreenRotationPreference.setChecked(!RotationPolicy.isRotationLocked(context)); } }
private void initializeAllPreferences() { mServicesCategory = (PreferenceCategory) findPreference(SERVICES_CATEGORY); mSystemsCategory = (PreferenceCategory) findPreference(SYSTEM_CATEGORY); // Large text. mToggleLargeTextPreference = (SwitchPreference) findPreference(TOGGLE_LARGE_TEXT_PREFERENCE); // Text contrast. mToggleHighTextContrastPreference = (SwitchPreference) findPreference(TOGGLE_HIGH_TEXT_CONTRAST_PREFERENCE); // Display inversion. mToggleInversionPreference = (SwitchPreference) findPreference(TOGGLE_INVERSION_PREFERENCE); mToggleInversionPreference.setOnPreferenceChangeListener(this); // Power button ends calls. mTogglePowerButtonEndsCallPreference = (SwitchPreference) findPreference(TOGGLE_POWER_BUTTON_ENDS_CALL_PREFERENCE); if (!KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_POWER) || !Utils.isVoiceCapable(getActivity())) { mSystemsCategory.removePreference(mTogglePowerButtonEndsCallPreference); } // Lock screen rotation. mToggleLockScreenRotationPreference = (SwitchPreference) findPreference(TOGGLE_LOCK_SCREEN_ROTATION_PREFERENCE); if (!RotationPolicy.isRotationSupported(getActivity())) { mSystemsCategory.removePreference(mToggleLockScreenRotationPreference); } // Speak passwords. mToggleSpeakPasswordPreference = (SwitchPreference) findPreference(TOGGLE_SPEAK_PASSWORD_PREFERENCE); // Long press timeout. mSelectLongPressTimeoutPreference = (ListPreference) findPreference(SELECT_LONG_PRESS_TIMEOUT_PREFERENCE); mSelectLongPressTimeoutPreference.setOnPreferenceChangeListener(this); if (mLongPressTimeoutValuetoTitleMap.size() == 0) { String[] timeoutValues = getResources().getStringArray(R.array.long_press_timeout_selector_values); mLongPressTimeoutDefault = Integer.parseInt(timeoutValues[0]); String[] timeoutTitles = getResources().getStringArray(R.array.long_press_timeout_selector_titles); final int timeoutValueCount = timeoutValues.length; for (int i = 0; i < timeoutValueCount; i++) { mLongPressTimeoutValuetoTitleMap.put(timeoutValues[i], timeoutTitles[i]); } } // Captioning. mCaptioningPreferenceScreen = (PreferenceScreen) findPreference(CAPTIONING_PREFERENCE_SCREEN); // Display magnification. mDisplayMagnificationPreferenceScreen = (PreferenceScreen) findPreference(DISPLAY_MAGNIFICATION_PREFERENCE_SCREEN); // Display color adjustments. mDisplayDaltonizerPreferenceScreen = (PreferenceScreen) findPreference(DISPLAY_DALTONIZER_PREFERENCE_SCREEN); // Global gesture. mGlobalGesturePreferenceScreen = (PreferenceScreen) findPreference(ENABLE_ACCESSIBILITY_GESTURE_PREFERENCE_SCREEN); final int longPressOnPowerBehavior = getActivity() .getResources() .getInteger(com.android.internal.R.integer.config_longPressOnPowerBehavior); final int LONG_PRESS_POWER_GLOBAL_ACTIONS = 1; if (!KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_POWER) || longPressOnPowerBehavior != LONG_PRESS_POWER_GLOBAL_ACTIONS) { // Remove accessibility shortcut if power key is not present // nor long press power does not show global actions menu. mSystemsCategory.removePreference(mGlobalGesturePreferenceScreen); } }
private void handleLockScreenRotationPreferenceClick() { RotationPolicy.setRotationLockForAccessibility( getActivity(), !mToggleLockScreenRotationPreference.isChecked()); }