diff options
-rw-r--r-- | AndroidManifest.xml | 15 | ||||
-rw-r--r-- | res/xml/accessibility_inversion_settings.xml | 25 | ||||
-rw-r--r-- | res/xml/accessibility_settings.xml | 8 | ||||
-rw-r--r-- | src/com/android/settings/SettingsActivity.java | 1 | ||||
-rw-r--r-- | src/com/android/settings/accessibility/AccessibilitySettings.java | 51 | ||||
-rw-r--r-- | src/com/android/settings/accessibility/ToggleInversionPreferenceFragment.java | 95 |
6 files changed, 35 insertions, 160 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml index b9f87d1..a0563b4 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -961,21 +961,6 @@ android:resource="@id/accessibility_settings" /> </activity> - <activity android:name="Settings$AccessibilityInversionSettingsActivity" - android:label="@string/accessibility_display_inversion_preference_title" - android:taskAffinity="com.android.settings" - android:parentActivityName="Settings$AccessibilitySettingsActivity"> - <intent-filter> - <action android:name="android.intent.action.MAIN" /> - <action android:name="com.android.settings.ACCESSIBILITY_INVERSION_SETTINGS" /> - <category android:name="android.intent.category.DEFAULT" /> - </intent-filter> - <meta-data android:name="com.android.settings.FRAGMENT_CLASS" - android:value="com.android.settings.accessibility.ToggleInversionPreferenceFragment" /> - <meta-data android:name="com.android.settings.TOP_LEVEL_HEADER_ID" - android:resource="@id/accessibility_settings" /> - </activity> - <activity android:name="Settings$AccessibilityDaltonizerSettingsActivity" android:label="@string/accessibility_display_daltonizer_preference_title" android:taskAffinity="com.android.settings" diff --git a/res/xml/accessibility_inversion_settings.xml b/res/xml/accessibility_inversion_settings.xml deleted file mode 100644 index 6aa3869..0000000 --- a/res/xml/accessibility_inversion_settings.xml +++ /dev/null @@ -1,25 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (C) 2013 The Android Open Source Project - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. ---> - -<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" - android:title="@string/accessibility_display_inversion_preference_title" > - - <CheckBoxPreference - android:key="enable_quick_setting" - android:persistent="false" - android:title="@string/enable_quick_setting" /> - -</PreferenceScreen> diff --git a/res/xml/accessibility_settings.xml b/res/xml/accessibility_settings.xml index 414affa..14129da 100644 --- a/res/xml/accessibility_settings.xml +++ b/res/xml/accessibility_settings.xml @@ -82,10 +82,10 @@ <PreferenceCategory android:key="display_category" android:title="@string/accessibility_display_title" > - <PreferenceScreen - android:fragment="com.android.settings.accessibility.ToggleInversionPreferenceFragment" - android:key="inversion_preference_screen" - android:title="@string/accessibility_display_inversion_preference_title" /> + <SwitchPreference + android:key="toggle_inversion_preference" + android:title="@string/accessibility_display_inversion_preference_title" + android:persistent="false" /> <PreferenceScreen android:fragment="com.android.settings.accessibility.ToggleDaltonizerPreferenceFragment" android:key="daltonizer_preference_screen" diff --git a/src/com/android/settings/SettingsActivity.java b/src/com/android/settings/SettingsActivity.java index b227c6b..751d478 100644 --- a/src/com/android/settings/SettingsActivity.java +++ b/src/com/android/settings/SettingsActivity.java @@ -253,7 +253,6 @@ public class SettingsActivity extends Activity DeviceAdminSettings.class.getName(), AccessibilitySettings.class.getName(), CaptionPropertiesFragment.class.getName(), - com.android.settings.accessibility.ToggleInversionPreferenceFragment.class.getName(), com.android.settings.accessibility.ToggleDaltonizerPreferenceFragment.class.getName(), TextToSpeechSettings.class.getName(), Memory.class.getName(), diff --git a/src/com/android/settings/accessibility/AccessibilitySettings.java b/src/com/android/settings/accessibility/AccessibilitySettings.java index d3f0466..36025a6 100644 --- a/src/com/android/settings/accessibility/AccessibilitySettings.java +++ b/src/com/android/settings/accessibility/AccessibilitySettings.java @@ -33,6 +33,7 @@ import android.preference.ListPreference; import android.preference.Preference; import android.preference.PreferenceCategory; import android.preference.PreferenceScreen; +import android.preference.SwitchPreference; import android.provider.SearchIndexableResource; import android.provider.Settings; import android.text.TextUtils; @@ -80,6 +81,8 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements "toggle_large_text_preference"; private static final String TOGGLE_HIGH_TEXT_CONTRAST_PREFERENCE = "toggle_high_text_contrast_preference"; + private static final String TOGGLE_INVERSION_PREFERENCE = + "toggle_inversion_preference"; private static final String TOGGLE_POWER_BUTTON_ENDS_CALL_PREFERENCE = "toggle_power_button_ends_call_preference"; private static final String TOGGLE_LOCK_SCREEN_ROTATION_PREFERENCE = @@ -94,10 +97,6 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements "captioning_preference_screen"; private static final String DISPLAY_MAGNIFICATION_PREFERENCE_SCREEN = "screen_magnification_preference_screen"; - private static final String DISPLAY_CONTRAST_PREFERENCE_SCREEN = - "contrast_preference_screen"; - private static final String DISPLAY_INVERSION_PREFERENCE_SCREEN = - "inversion_preference_screen"; private static final String DISPLAY_DALTONIZER_PREFERENCE_SCREEN = "daltonizer_preference_screen"; @@ -193,9 +192,8 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements private PreferenceScreen mCaptioningPreferenceScreen; private PreferenceScreen mDisplayMagnificationPreferenceScreen; private PreferenceScreen mGlobalGesturePreferenceScreen; - private PreferenceScreen mDisplayInversionPreferenceScreen; - private PreferenceScreen mDisplayContrastPreferenceScreen; private PreferenceScreen mDisplayDaltonizerPreferenceScreen; + private SwitchPreference mToggleInversionPreference; private int mLongPressTimeoutDefault; @@ -233,17 +231,28 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements @Override public boolean onPreferenceChange(Preference preference, Object newValue) { - if (preference == mSelectLongPressTimeoutPreference) { - String stringValue = (String) newValue; - Settings.Secure.putInt(getContentResolver(), - Settings.Secure.LONG_PRESS_TIMEOUT, Integer.parseInt(stringValue)); - mSelectLongPressTimeoutPreference.setSummary( - mLongPressTimeoutValuetoTitleMap.get(stringValue)); + if (mSelectLongPressTimeoutPreference == preference) { + handleLongPressTimeoutPreferenceChange((String) newValue); + return true; + } else if (mToggleInversionPreference == preference) { + handleToggleInversionPreferenceChange((Boolean) newValue); return true; } return false; } + private void handleLongPressTimeoutPreferenceChange(String stringValue) { + Settings.Secure.putInt(getContentResolver(), + Settings.Secure.LONG_PRESS_TIMEOUT, Integer.parseInt(stringValue)); + mSelectLongPressTimeoutPreference.setSummary( + mLongPressTimeoutValuetoTitleMap.get(stringValue)); + } + + private void handleToggleInversionPreferenceChange(boolean checked) { + Settings.Secure.putInt(getContentResolver(), + Settings.Secure.ACCESSIBILITY_DISPLAY_INVERSION_ENABLED, (checked ? 1 : 0)); + } + @Override public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) { if (mToggleLargeTextPreference == preference) { @@ -262,7 +271,7 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements handleToggleSpeakPasswordPreferenceClick(); return true; } else if (mGlobalGesturePreferenceScreen == preference) { - handleTogglEnableAccessibilityGesturePreferenceClick(); + handleToggleEnableAccessibilityGesturePreferenceClick(); return true; } else if (mDisplayMagnificationPreferenceScreen == preference) { handleDisplayMagnificationPreferenceScreenClick(); @@ -305,7 +314,7 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements mToggleSpeakPasswordPreference.isChecked() ? 1 : 0); } - private void handleTogglEnableAccessibilityGesturePreferenceClick() { + private void handleToggleEnableAccessibilityGesturePreferenceClick() { Bundle extras = mGlobalGesturePreferenceScreen.getExtras(); extras.putString(EXTRA_TITLE, getString( R.string.accessibility_global_gesture_preference_title)); @@ -341,6 +350,10 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements mToggleHighTextContrastPreference = (CheckBoxPreference) findPreference(TOGGLE_HIGH_TEXT_CONTRAST_PREFERENCE); + // Display inversion. + mToggleInversionPreference = (SwitchPreference) findPreference(TOGGLE_INVERSION_PREFERENCE); + mToggleInversionPreference.setOnPreferenceChangeListener(this); + // Power button ends calls. mTogglePowerButtonEndsCallPreference = (CheckBoxPreference) findPreference(TOGGLE_POWER_BUTTON_ENDS_CALL_PREFERENCE); @@ -385,10 +398,6 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements DISPLAY_MAGNIFICATION_PREFERENCE_SCREEN); // Display color adjustments. - mDisplayContrastPreferenceScreen = (PreferenceScreen) findPreference( - DISPLAY_CONTRAST_PREFERENCE_SCREEN); - mDisplayInversionPreferenceScreen = (PreferenceScreen) findPreference( - DISPLAY_INVERSION_PREFERENCE_SCREEN); mDisplayDaltonizerPreferenceScreen = (PreferenceScreen) findPreference( DISPLAY_DALTONIZER_PREFERENCE_SCREEN); @@ -513,6 +522,10 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements Settings.Secure.getInt(getContentResolver(), Settings.Secure.ACCESSIBILITY_HIGH_TEXT_CONTRAST_ENABLED, 0) == 1); + // If the quick setting is enabled, the preference MUST be enabled. + mToggleInversionPreference.setChecked(Settings.Secure.getInt(getContentResolver(), + Settings.Secure.ACCESSIBILITY_DISPLAY_INVERSION_ENABLED, 0) == 1); + // Power button ends calls. if (KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_POWER) && Utils.isVoiceCapable(getActivity())) { @@ -543,8 +556,6 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements mCaptioningPreferenceScreen); updateFeatureSummary(Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED, mDisplayMagnificationPreferenceScreen); - updateFeatureSummary(Settings.Secure.ACCESSIBILITY_DISPLAY_INVERSION_ENABLED, - mDisplayInversionPreferenceScreen); updateFeatureSummary(Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED, mDisplayDaltonizerPreferenceScreen); diff --git a/src/com/android/settings/accessibility/ToggleInversionPreferenceFragment.java b/src/com/android/settings/accessibility/ToggleInversionPreferenceFragment.java deleted file mode 100644 index a7bc0b3..0000000 --- a/src/com/android/settings/accessibility/ToggleInversionPreferenceFragment.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (C) 2013 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.settings.accessibility; - -import android.os.Bundle; -import android.preference.CheckBoxPreference; -import android.preference.Preference; -import android.provider.Settings; -import android.view.View; - -import android.widget.Switch; -import com.android.settings.R; -import com.android.settings.widget.SwitchBar; - -public class ToggleInversionPreferenceFragment extends ToggleFeaturePreferenceFragment - implements Preference.OnPreferenceChangeListener, SwitchBar.OnSwitchChangeListener { - private static final String ENABLED = Settings.Secure.ACCESSIBILITY_DISPLAY_INVERSION_ENABLED; - private static final String QUICK_SETTING_ENABLED = - Settings.Secure.ACCESSIBILITY_DISPLAY_INVERSION_QUICK_SETTING_ENABLED; - - private CheckBoxPreference mEnableQuickSetting; - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - addPreferencesFromResource(R.xml.accessibility_inversion_settings); - - mEnableQuickSetting = (CheckBoxPreference) findPreference("enable_quick_setting"); - - initPreferences(); - } - - @Override - protected void onPreferenceToggled(String preferenceKey, boolean enabled) { - Settings.Secure.putInt(getContentResolver(), ENABLED, enabled ? 1 : 0); - } - - @Override - public boolean onPreferenceChange(Preference preference, Object newValue) { - if (preference == mEnableQuickSetting) { - Settings.Secure.putInt( - getContentResolver(), QUICK_SETTING_ENABLED, ((Boolean) newValue) ? 1 : 0); - } - - return true; - } - - @Override - public void onViewCreated(View view, Bundle savedInstanceState) { - super.onViewCreated(view, savedInstanceState); - - setTitle(getString(R.string.accessibility_display_inversion_preference_title)); - } - - @Override - protected void onInstallSwitchBarToggleSwitch() { - super.onInstallSwitchBarToggleSwitch(); - - mSwitchBar.setCheckedInternal( - Settings.Secure.getInt(getContentResolver(), ENABLED, 0) == 1); - mSwitchBar.addOnSwitchChangeListener(this); - } - - @Override - protected void onRemoveSwitchBarToggleSwitch() { - super.onRemoveSwitchBarToggleSwitch(); - mSwitchBar.removeOnSwitchChangeListener(this); - } - - private void initPreferences() { - mEnableQuickSetting.setChecked( - Settings.Secure.getInt(getContentResolver(), QUICK_SETTING_ENABLED, 0) == 1); - mEnableQuickSetting.setOnPreferenceChangeListener(this); - } - - @Override - public void onSwitchChanged(Switch switchView, boolean isChecked) { - onPreferenceToggled(mPreferenceKey, isChecked); - } -} |