From 3f8d62fbf170f8260afa69400dba3872eab2555e Mon Sep 17 00:00:00 2001 From: Lauren Winston Date: Thu, 6 Oct 2022 23:33:45 +0000 Subject: [PATCH] Revert "Add toggles for two Software Cursor settings: keyboard shift and trigger" This reverts commit 28b4b34f926c1a43bd280b63cac96800b1ad8771. Reason for revert: Software Cursor is not launching in Android U Test: manual Change-Id: I213cf64ca94fce51883a30a9d6b734b4ed874dad --- res/values/strings.xml | 7 - res/xml/accessibility_cursor_settings.xml | 10 -- ...rsorKeyboardShiftPreferenceController.java | 78 ------------ ...ursorTriggerHintsPreferenceController.java | 76 ----------- ...KeyboardShiftPreferenceControllerTest.java | 120 ------------------ ...rTriggerHintsPreferenceControllerTest.java | 120 ------------------ 6 files changed, 411 deletions(-) delete mode 100644 src/com/android/settings/accessibility/SoftwareCursorKeyboardShiftPreferenceController.java delete mode 100644 src/com/android/settings/accessibility/SoftwareCursorTriggerHintsPreferenceController.java delete mode 100644 tests/unit/src/com/android/settings/accessibility/SoftwareCursorKeyboardShiftPreferenceControllerTest.java delete mode 100644 tests/unit/src/com/android/settings/accessibility/SoftwareCursorTriggerHintsPreferenceControllerTest.java diff --git a/res/values/strings.xml b/res/values/strings.xml index 3c79253141b..b569f27e80a 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -11909,13 +11909,6 @@ QR code isn\u0027t a valid format - - - - Gesture detection area hints - - Shift gesture detection region above keyboard - diff --git a/res/xml/accessibility_cursor_settings.xml b/res/xml/accessibility_cursor_settings.xml index 1d23051ebbd..6bc50bb58ae 100644 --- a/res/xml/accessibility_cursor_settings.xml +++ b/res/xml/accessibility_cursor_settings.xml @@ -22,14 +22,4 @@ android:key="screen_software_cursor_preference_switch" android:title="@string/accessibility_screen_software_cursor_title" settings:controller="com.android.settings.accessibility.SoftwareCursorTogglePreferenceController"/> - - - - diff --git a/src/com/android/settings/accessibility/SoftwareCursorKeyboardShiftPreferenceController.java b/src/com/android/settings/accessibility/SoftwareCursorKeyboardShiftPreferenceController.java deleted file mode 100644 index 6ff49a3a853..00000000000 --- a/src/com/android/settings/accessibility/SoftwareCursorKeyboardShiftPreferenceController.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (C) 2022 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 static com.android.settings.accessibility.AccessibilityUtil.State.OFF; -import static com.android.settings.accessibility.AccessibilityUtil.State.ON; - -import android.content.ContentResolver; -import android.content.Context; -import android.provider.Settings; - -import androidx.preference.PreferenceScreen; -import androidx.preference.SwitchPreference; - -import com.android.settings.R; -import com.android.settings.core.TogglePreferenceController; - -/** Controller class for the Software Cursor keyboard shift setting. */ -public class SoftwareCursorKeyboardShiftPreferenceController extends - TogglePreferenceController { - - private static final String SETTINGS_VALUE = - Settings.Secure.ACCESSIBILITY_SOFTWARE_CURSOR_KEYBOARD_SHIFT_ENABLED; - - private final ContentResolver mContentResolver; - - - public SoftwareCursorKeyboardShiftPreferenceController(Context context, String preferenceKey) { - super(context, preferenceKey); - mContentResolver = context.getContentResolver(); - } - - @Override - public boolean isChecked() { - return Settings.Secure.getInt(mContentResolver, SETTINGS_VALUE, OFF) == ON; - } - - @Override - public boolean setChecked(boolean isChecked) { - Settings.Secure.putInt(mContentResolver, SETTINGS_VALUE, isChecked ? ON : OFF); - return true; - } - - @Override - public int getAvailabilityStatus() { - return AVAILABLE; - } - - @Override - public int getSliceHighlightMenuRes() { - return R.string.menu_key_accessibility; - } - - @Override - public void displayPreference(PreferenceScreen screen) { - super.displayPreference(screen); - - SwitchPreference preference = screen.findPreference(getPreferenceKey()); - if (preference != null) { - preference.setOnPreferenceChangeListener(this); - preference.setChecked(isChecked()); - } - } -} diff --git a/src/com/android/settings/accessibility/SoftwareCursorTriggerHintsPreferenceController.java b/src/com/android/settings/accessibility/SoftwareCursorTriggerHintsPreferenceController.java deleted file mode 100644 index bd6e1470ac0..00000000000 --- a/src/com/android/settings/accessibility/SoftwareCursorTriggerHintsPreferenceController.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (C) 2022 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 static com.android.settings.accessibility.AccessibilityUtil.State.OFF; -import static com.android.settings.accessibility.AccessibilityUtil.State.ON; - -import android.content.ContentResolver; -import android.content.Context; -import android.provider.Settings; - -import androidx.preference.PreferenceScreen; -import androidx.preference.SwitchPreference; - -import com.android.settings.R; -import com.android.settings.core.TogglePreferenceController; - -/** Controller class that control accessibility software cursor trigger hints settings. */ -public class SoftwareCursorTriggerHintsPreferenceController extends TogglePreferenceController { - - private static final String SETTINGS_VALUE = - Settings.Secure.ACCESSIBILITY_SOFTWARE_CURSOR_TRIGGER_HINTS_ENABLED; - - private final ContentResolver mContentResolver; - - public SoftwareCursorTriggerHintsPreferenceController(Context context, String preferenceKey) { - super(context, preferenceKey); - mContentResolver = context.getContentResolver(); - } - - @Override - public boolean isChecked() { - return Settings.Secure.getInt(mContentResolver, SETTINGS_VALUE, OFF) == ON; - } - - @Override - public boolean setChecked(boolean isChecked) { - Settings.Secure.putInt(mContentResolver, SETTINGS_VALUE, isChecked ? ON : OFF); - return true; - } - - @Override - public int getSliceHighlightMenuRes() { - return R.string.menu_key_accessibility; - } - - @Override - public int getAvailabilityStatus() { - return AVAILABLE; - } - - @Override - public void displayPreference(PreferenceScreen screen) { - super.displayPreference(screen); - - SwitchPreference preference = screen.findPreference(getPreferenceKey()); - if (preference != null) { - preference.setOnPreferenceChangeListener(this); - preference.setChecked(isChecked()); - } - } -} diff --git a/tests/unit/src/com/android/settings/accessibility/SoftwareCursorKeyboardShiftPreferenceControllerTest.java b/tests/unit/src/com/android/settings/accessibility/SoftwareCursorKeyboardShiftPreferenceControllerTest.java deleted file mode 100644 index 2df291ab9bd..00000000000 --- a/tests/unit/src/com/android/settings/accessibility/SoftwareCursorKeyboardShiftPreferenceControllerTest.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright (C) 2022 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 static com.android.settings.accessibility.AccessibilityUtil.State.OFF; -import static com.android.settings.accessibility.AccessibilityUtil.State.ON; - -import static com.google.common.truth.Truth.assertThat; - -import android.content.Context; -import android.os.Looper; -import android.provider.Settings; - -import androidx.preference.PreferenceManager; -import androidx.preference.PreferenceScreen; -import androidx.preference.SwitchPreference; -import androidx.test.core.app.ApplicationProvider; -import androidx.test.ext.junit.runners.AndroidJUnit4; - -import com.android.settings.core.BasePreferenceController; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; - -/** Tests for {@link SoftwareCursorKeyboardShiftPreferenceController}. */ -@RunWith(AndroidJUnit4.class) -public class SoftwareCursorKeyboardShiftPreferenceControllerTest { - - private PreferenceScreen mScreen; - private final Context mContext = ApplicationProvider.getApplicationContext(); - private SoftwareCursorKeyboardShiftPreferenceController mController; - private SwitchPreference mSwitchPreference; - - @Before - public void setUp() { - if (Looper.myLooper() == null) { - Looper.prepare(); - } - mController = new SoftwareCursorKeyboardShiftPreferenceController(mContext, - "cursor_trigger_keyboard_shift_enabled"); - mSwitchPreference = new SwitchPreference(mContext); - mSwitchPreference.setKey(mController.getPreferenceKey()); - PreferenceManager preferenceManager = new PreferenceManager(mContext); - mScreen = preferenceManager.createPreferenceScreen(mContext); - mScreen.addPreference(mSwitchPreference); - } - - @After - public void tearDown() { - Settings.Secure.putInt(mContext.getContentResolver(), - Settings.Secure.ACCESSIBILITY_SOFTWARE_CURSOR_KEYBOARD_SHIFT_ENABLED, OFF); - } - - @Test - public void getAvailabilityStatus_shouldReturnAvailable() { - assertThat(mController.getAvailabilityStatus()) - .isEqualTo(BasePreferenceController.AVAILABLE); - } - - @Test - public void performClick_cursorEnabled_shouldSetSettingDisabled() { - mController.setChecked(true); - mController.displayPreference(mScreen); - - mSwitchPreference.performClick(); - - assertThat(mSwitchPreference.isChecked()).isFalse(); - assertThat(isKeyboardShiftEnabled()).isFalse(); - } - - @Test - public void performClick_cursorDisabled_shouldSetSettingEnabled() { - mController.setChecked(false); - mController.displayPreference(mScreen); - - mSwitchPreference.performClick(); - - assertThat(mSwitchPreference.isChecked()).isTrue(); - assertThat(isKeyboardShiftEnabled()).isTrue(); - } - - @Test - public void setChecked_switchChecked_shouldSetSettingEnabled() { - mController.displayPreference(mScreen); - - mController.setChecked(/* isChecked= */ true); - - assertThat(isKeyboardShiftEnabled()).isTrue(); - } - - @Test - public void setChecked_switchUnchecked_shouldSetSettingDisabled() { - mController.displayPreference(mScreen); - - mController.setChecked(/* isChecked= */ false); - - assertThat(isKeyboardShiftEnabled()).isFalse(); - } - - private boolean isKeyboardShiftEnabled() { - return Settings.Secure.getInt(mContext.getContentResolver(), - Settings.Secure.ACCESSIBILITY_SOFTWARE_CURSOR_KEYBOARD_SHIFT_ENABLED, OFF) == ON; - } -} diff --git a/tests/unit/src/com/android/settings/accessibility/SoftwareCursorTriggerHintsPreferenceControllerTest.java b/tests/unit/src/com/android/settings/accessibility/SoftwareCursorTriggerHintsPreferenceControllerTest.java deleted file mode 100644 index 73c118fa12d..00000000000 --- a/tests/unit/src/com/android/settings/accessibility/SoftwareCursorTriggerHintsPreferenceControllerTest.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright (C) 2022 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 static com.android.settings.accessibility.AccessibilityUtil.State.OFF; -import static com.android.settings.accessibility.AccessibilityUtil.State.ON; - -import static com.google.common.truth.Truth.assertThat; - -import android.content.Context; -import android.os.Looper; -import android.provider.Settings; - -import androidx.preference.PreferenceManager; -import androidx.preference.PreferenceScreen; -import androidx.preference.SwitchPreference; -import androidx.test.core.app.ApplicationProvider; -import androidx.test.ext.junit.runners.AndroidJUnit4; - -import com.android.settings.core.BasePreferenceController; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; - -/** Tests for {@link SoftwareCursorTriggerHintsPreferenceController}. */ -@RunWith(AndroidJUnit4.class) -public class SoftwareCursorTriggerHintsPreferenceControllerTest { - - private PreferenceScreen mScreen; - private final Context mContext = ApplicationProvider.getApplicationContext(); - private SoftwareCursorTriggerHintsPreferenceController mController; - private SwitchPreference mSwitchPreference; - - @Before - public void setUp() { - if (Looper.myLooper() == null) { - Looper.prepare(); - } - mController = new SoftwareCursorTriggerHintsPreferenceController(mContext, - "cursor_trigger_hints_enabled"); - mSwitchPreference = new SwitchPreference(mContext); - mSwitchPreference.setKey(mController.getPreferenceKey()); - PreferenceManager preferenceManager = new PreferenceManager(mContext); - mScreen = preferenceManager.createPreferenceScreen(mContext); - mScreen.addPreference(mSwitchPreference); - } - - @After - public void tearDown() { - Settings.Secure.putInt(mContext.getContentResolver(), - Settings.Secure.ACCESSIBILITY_SOFTWARE_CURSOR_TRIGGER_HINTS_ENABLED, OFF); - } - - @Test - public void getAvailabilityStatus_shouldReturnAvailable() { - assertThat(mController.getAvailabilityStatus()) - .isEqualTo(BasePreferenceController.AVAILABLE); - } - - @Test - public void performClick_cursorEnabled_shouldSetSettingDisabled() { - mController.setChecked(true); - mController.displayPreference(mScreen); - - mSwitchPreference.performClick(); - - assertThat(mSwitchPreference.isChecked()).isFalse(); - assertThat(areTriggerHintsEnabled()).isFalse(); - } - - @Test - public void performClick_cursorDisabled_shouldSetSettingEnabled() { - mController.setChecked(false); - mController.displayPreference(mScreen); - - mSwitchPreference.performClick(); - - assertThat(mSwitchPreference.isChecked()).isTrue(); - assertThat(areTriggerHintsEnabled()).isTrue(); - } - - @Test - public void setChecked_switchChecked_shouldSetSettingEnabled() { - mController.displayPreference(mScreen); - - mController.setChecked(/* isChecked= */ true); - - assertThat(areTriggerHintsEnabled()).isTrue(); - } - - @Test - public void setChecked_switchUnchecked_shouldSetSettingDisabled() { - mController.displayPreference(mScreen); - - mController.setChecked(/* isChecked= */ false); - - assertThat(areTriggerHintsEnabled()).isFalse(); - } - - private boolean areTriggerHintsEnabled() { - return Settings.Secure.getInt(mContext.getContentResolver(), - Settings.Secure.ACCESSIBILITY_SOFTWARE_CURSOR_TRIGGER_HINTS_ENABLED, OFF) == ON; - } -}