import android.view.accessibility.AccessibilityManager;
import com.android.internal.content.PackageMonitor;
import com.android.internal.logging.MetricsLogger;
-import com.android.internal.view.RotationPolicy;
-import com.android.internal.view.RotationPolicy.RotationPolicyListener;
import com.android.settings.DialogCreatable;
import com.android.settings.R;
import com.android.settings.SettingsPreferenceFragment;
"toggle_high_text_contrast_preference";
private static final String TOGGLE_INVERSION_PREFERENCE =
"toggle_inversion_preference";
- private static final String TOGGLE_LOCK_SCREEN_ROTATION_PREFERENCE =
- "toggle_lock_screen_rotation_preference";
private static final String TOGGLE_SPEAK_PASSWORD_PREFERENCE =
"toggle_speak_password_preference";
private static final String SELECT_LONG_PRESS_TIMEOUT_PREFERENCE =
}
};
- private final RotationPolicyListener mRotationPolicyListener = new RotationPolicyListener() {
- @Override
- public void onChange() {
- updateLockScreenRotationCheckbox();
- }
- };
-
// Preference controls.
private PreferenceCategory mServicesCategory;
private PreferenceCategory mSystemsCategory;
private SwitchPreference mToggleLargeTextPreference;
private SwitchPreference mToggleHighTextContrastPreference;
- private SwitchPreference mToggleLockScreenRotationPreference;
private SwitchPreference mToggleSpeakPasswordPreference;
private ListPreference mSelectLongPressTimeoutPreference;
private Preference mNoServicesMessagePreference;
mSettingsPackageMonitor.register(getActivity(), getActivity().getMainLooper(), false);
mSettingsContentObserver.register(getContentResolver());
- if (RotationPolicy.isRotationSupported(getActivity())) {
- RotationPolicy.registerRotationPolicyListener(getActivity(),
- mRotationPolicyListener);
- }
}
@Override
public void onPause() {
mSettingsPackageMonitor.unregister();
mSettingsContentObserver.unregister(getContentResolver());
- if (RotationPolicy.isRotationSupported(getActivity())) {
- RotationPolicy.unregisterRotationPolicyListener(getActivity(),
- mRotationPolicyListener);
- }
super.onPause();
}
} else if (mToggleHighTextContrastPreference == preference) {
handleToggleTextContrastPreferenceClick();
return true;
- } else if (mToggleLockScreenRotationPreference == preference) {
- handleLockScreenRotationPreferenceClick();
- return true;
} else if (mToggleSpeakPasswordPreference == preference) {
handleToggleSpeakPasswordPreferenceClick();
return true;
(mToggleHighTextContrastPreference.isChecked() ? 1 : 0));
}
- private void handleLockScreenRotationPreferenceClick() {
- RotationPolicy.setRotationLockForAccessibility(getActivity(),
- !mToggleLockScreenRotationPreference.isChecked());
- }
-
private void handleToggleSpeakPasswordPreferenceClick() {
Settings.Secure.putInt(getContentResolver(),
Settings.Secure.ACCESSIBILITY_SPEAK_PASSWORD,
mToggleInversionPreference = (SwitchPreference) findPreference(TOGGLE_INVERSION_PREFERENCE);
mToggleInversionPreference.setOnPreferenceChangeListener(this);
- // 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);
mToggleInversionPreference.setChecked(Settings.Secure.getInt(getContentResolver(),
Settings.Secure.ACCESSIBILITY_DISPLAY_INVERSION_ENABLED, 0) == 1);
- // Auto-rotate screen
- updateLockScreenRotationCheckbox();
-
// Speak passwords.
final boolean speakPasswordEnabled = Settings.Secure.getInt(getContentResolver(),
Settings.Secure.ACCESSIBILITY_SPEAK_PASSWORD, 0) != 0;
: R.string.accessibility_feature_state_off);
}
- private void updateLockScreenRotationCheckbox() {
- Context context = getActivity();
- if (context != null) {
- mToggleLockScreenRotationPreference.setChecked(
- !RotationPolicy.isRotationLocked(context));
- }
- }
-
private void loadInstalledServices() {
Set<ComponentName> installedServices = sInstalledServices;
installedServices.clear();