Revert "Add toggles for two Software Cursor settings: keyboard shift and trigger"

This reverts commit 28b4b34f92.

Reason for revert: Software Cursor is not launching in Android U

Test: manual

Change-Id: I213cf64ca94fce51883a30a9d6b734b4ed874dad
This commit is contained in:
Lauren Winston
2022-10-06 23:33:45 +00:00
parent c8e077368f
commit 3f8d62fbf1
6 changed files with 0 additions and 411 deletions

View File

@@ -11909,13 +11909,6 @@
<!-- [CHAR LIMIT=NONE] Hint for QR code process failure -->
<string name="bt_le_audio_qr_code_is_not_valid_format">QR code isn\u0027t a valid format</string>
<!-- Accessibility Software Cursor -->
<!-- [CHAR LIMIT=NONE] Title for Accessibility Software Cursor setting for trigger hints. -->
<string name="software_cursor_trigger_hints_enabled_title" translatable="false">Gesture detection area hints</string>
<!-- [CHAR LIMIT=NONE] Title for Accessibility Software Cursor setting for keyboard shift. -->
<string name="software_cursor_trigger_keyboard_shift_enabled_title" translatable="false">Shift gesture detection region above keyboard</string>
<!-- Mobile Bundled Apps Transparency Metadata-->
<!-- [CHAR_LIMIT=NONE] Label for mobile bundled apps screen -->

View File

@@ -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"/>
<SwitchPreference
android:key="cursor_trigger_hints_enabled"
android:title="@string/software_cursor_trigger_hints_enabled_title"
settings:controller="com.android.settings.accessibility.SoftwareCursorTriggerHintsPreferenceController"/>
<SwitchPreference
android:key="cursor_trigger_keyboard_shift_enabled"
android:title="@string/software_cursor_trigger_keyboard_shift_enabled_title"
settings:controller="com.android.settings.accessibility.SoftwareCursorKeyboardShiftPreferenceController"/>
</PreferenceScreen>

View File

@@ -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());
}
}
}

View File

@@ -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());
}
}
}

View File

@@ -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;
}
}

View File

@@ -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;
}
}