Add a11y setting for disabling touchpad system gestures
Screenshots: * The new setting: http://shortn/_9JL6nMS3cR * The disabled "Learn touchpad gestures" button and accompanying footer when the setting is off: http://shortn/_FTcNTQAGYj Test: disable the setting, check three- and four-finger swipes on the touchpad stop working; re-enable, check they work again Test: check the toggle and heading both hide correctly when flag is off or no touchpad is connected Test: check the "Learn touchpad gestures" button is disabled with an explanation when gestures are disabled Bug: 353947750 Bug: 374965372 Flag: com.android.hardware.input.touchpad_system_gesture_disable Change-Id: Ie7a6ea4e9ddd34710d07f78ab96598207aac4228
This commit is contained in:
@@ -4681,6 +4681,9 @@
|
||||
<string name="pointer_stroke_style_name_none">None</string>
|
||||
<!-- Title for the button to trigger the 'touch gesture' education. [CHAR LIMIT=35] -->
|
||||
<string name="trackpad_touch_gesture">Learn touchpad gestures</string>
|
||||
<!-- TODO(b/353947750): finalize this string and mark it translatable. -->
|
||||
<!-- Notice displayed at the end of the touchpad settings page when the user has disabled system navigation gestures. "Pointer & touchpad accessibility" and "Use touchpad gestures" refer to other labels in Settings, and should be translated in exactly the same way. -->
|
||||
<string name="trackpad_gestures_disabled_footer_text" translatable="false">Some settings are unavailable as touchpad gestures have been turned off. You can turn them on via Pointer & touchpad accessibility > Use touchpad gestures</string>
|
||||
<!-- Search keywords for "touchpad" -->
|
||||
<string name="keywords_touchpad">trackpad, track pad, mouse, cursor, scroll, swipe, right click, click, pointer</string>
|
||||
<!-- Search keywords for 'Bottom-right tap', the name of the touchpad setting that allows the user to click the bottom right corner of the touchpad for more options. -->
|
||||
@@ -4963,6 +4966,15 @@
|
||||
<string name="accessibility_pointer_and_touchpad_summary">Pointer color, pointer size & more</string>
|
||||
<!-- Title for the accessibility pointer color customization page. [CHAR LIMIT=50] -->
|
||||
<string name="accessibility_pointer_color_customization_title">Pointer color customization</string>
|
||||
<!-- TODO(b/353947750): finalize the four strings below and mark them translatable. -->
|
||||
<!-- Title for the touchpad section of the accessibility pointer and touchpad page. -->
|
||||
<string name="accessibility_touchpad_title" translatable="false">Touchpad</string>
|
||||
<!-- Title for a settings toggle that allows the user to enable or disable system gestures (3- or 4-finger swipes for going home, back, to the overview screen, or between apps) being made on a touchpad. -->
|
||||
<string name="accessibility_touchpad_system_gestures_enable_title" translatable="false">Use system gestures</string>
|
||||
<!-- Description text for a settings toggle that allows the user to enable or disable system gestures (3- or 4-finger swipes for going home, back, to the overview screen, or between apps) being made on a touchpad. -->
|
||||
<string name="accessibility_touchpad_system_gestures_enable_summary" translatable="false">When turned off, 3- or 4-finger gestures are ignored</string>
|
||||
<!-- List of synonyms used in the settings search bar to find the "Use system gestures" touchpad setting, which allows the user to enable or disable system gestures (3- or 4-finger swipes for going home, back, to the overview screen, or between apps) being made on a touchpad. -->
|
||||
<string name="keywords_accessibility_touchpad_system_gestures_enable" translatable="false">touchpad, trackpad, swipe</string>
|
||||
<!-- Title for the accessibility color contrast page. [CHAR LIMIT=50] -->
|
||||
<string name="accessibility_color_contrast_title">Color contrast</string>
|
||||
<!-- Intro for the accessibility color contrast page. [CHAR LIMIT=NONE] -->
|
||||
|
@@ -46,4 +46,17 @@
|
||||
settings:keywords="@string/keywords_auto_click"
|
||||
settings:controller="com.android.settings.accessibility.AutoclickPreferenceController"/>
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="touchpad_category"
|
||||
android:persistent="false"
|
||||
android:title="@string/accessibility_touchpad_title">
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
android:key="touchpad_system_gestures_enable"
|
||||
android:title="@string/accessibility_touchpad_system_gestures_enable_title"
|
||||
android:summary="@string/accessibility_touchpad_system_gestures_enable_summary"
|
||||
settings:keywords="@string/keywords_accessibility_touchpad_system_gestures_enable"/>
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
</PreferenceScreen>
|
||||
|
@@ -96,4 +96,10 @@
|
||||
android:key="trackpad_touch_gesture"
|
||||
android:title="@string/trackpad_touch_gesture"
|
||||
settings:controller="com.android.settings.inputmethod.TouchGesturesButtonPreferenceController"/>
|
||||
|
||||
<com.android.settingslib.widget.FooterPreference
|
||||
android:key="trackpad_gestures_disabled_footer"
|
||||
android:title="@string/trackpad_gestures_disabled_footer_text"
|
||||
settings:searchable="false"
|
||||
settings:controller="com.android.settings.inputmethod.TrackpadGesturesDisabledFooterPreferenceController"/>
|
||||
</PreferenceScreen>
|
||||
|
@@ -25,14 +25,33 @@ import android.content.Context;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settings.widget.PreferenceCategoryController;
|
||||
import com.android.settingslib.core.AbstractPreferenceController;
|
||||
import com.android.settingslib.search.SearchIndexable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/** Accessibility settings for pointer and touchpad. */
|
||||
@SearchIndexable(forTarget = SearchIndexable.ALL & ~SearchIndexable.ARC)
|
||||
public class PointerTouchpadFragment extends DashboardFragment {
|
||||
|
||||
private static final String TAG = "PointerTouchpadFragment";
|
||||
|
||||
@Override
|
||||
protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
|
||||
return buildPreferenceControllers(context);
|
||||
}
|
||||
|
||||
private static List<AbstractPreferenceController> buildPreferenceControllers(Context context) {
|
||||
TouchpadSystemGesturesPreferenceController systemGesturesController =
|
||||
new TouchpadSystemGesturesPreferenceController(
|
||||
context, "touchpad_system_gestures_enable");
|
||||
return List.of(
|
||||
systemGesturesController,
|
||||
new PreferenceCategoryController(context, "touchpad_category")
|
||||
.setChildren(List.of(systemGesturesController)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetricsCategory() {
|
||||
return SettingsEnums.ACCESSIBILITY_POINTER_TOUCHPAD;
|
||||
@@ -54,5 +73,11 @@ public class PointerTouchpadFragment extends DashboardFragment {
|
||||
protected boolean isPageSearchEnabled(Context context) {
|
||||
return isTouchpad() || isMouse();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AbstractPreferenceController> createPreferenceControllers(
|
||||
Context context) {
|
||||
return buildPreferenceControllers(context);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@@ -21,6 +21,7 @@ import static com.android.systemui.shared.Flags.newTouchpadGesturesTutorial;
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.hardware.input.InputSettings;
|
||||
import android.os.UserHandle;
|
||||
import android.util.FeatureFlagUtils;
|
||||
|
||||
@@ -75,7 +76,14 @@ public class TouchGesturesButtonPreferenceController extends BasePreferenceContr
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
boolean isTouchpad = InputPeripheralsSettingsUtils.isTouchpad();
|
||||
return isTouchpad ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
|
||||
if (isTouchpad) {
|
||||
// If the user's disabled touchpad system gestures in the accessibility settings, the
|
||||
// tutorial won't work or be relevant, so disable the button.
|
||||
return InputSettings.useTouchpadSystemGestures(mContext) ? AVAILABLE
|
||||
: DISABLED_DEPENDENT_SETTING;
|
||||
} else {
|
||||
return CONDITIONALLY_UNAVAILABLE;
|
||||
}
|
||||
}
|
||||
|
||||
private void showTouchpadGestureEducation() {
|
||||
|
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright 2024 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.inputmethod;
|
||||
|
||||
import android.content.Context;
|
||||
import android.hardware.input.InputSettings;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.TogglePreferenceController;
|
||||
|
||||
public class TouchpadSystemGesturesPreferenceController extends TogglePreferenceController {
|
||||
|
||||
public TouchpadSystemGesturesPreferenceController(Context context, String key) {
|
||||
super(context, key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
return InputSettings.isTouchpadSystemGestureDisableFeatureFlagEnabled()
|
||||
&& InputPeripheralsSettingsUtils.isTouchpad() ? AVAILABLE
|
||||
: CONDITIONALLY_UNAVAILABLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isChecked() {
|
||||
return InputSettings.useTouchpadSystemGestures(mContext);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setChecked(boolean isChecked) {
|
||||
InputSettings.setTouchpadSystemGesturesEnabled(mContext, isChecked);
|
||||
// TODO(b/353947750): add a metric for when the setting changes.
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSliceHighlightMenuRes() {
|
||||
return R.string.menu_key_accessibility;
|
||||
}
|
||||
}
|
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright 2024 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.inputmethod;
|
||||
|
||||
import android.content.Context;
|
||||
import android.hardware.input.InputSettings;
|
||||
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
|
||||
public class TrackpadGesturesDisabledFooterPreferenceController extends BasePreferenceController {
|
||||
|
||||
public TrackpadGesturesDisabledFooterPreferenceController(Context context, String key) {
|
||||
super(context, key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
return InputSettings.useTouchpadSystemGestures(mContext) ? CONDITIONALLY_UNAVAILABLE
|
||||
: AVAILABLE;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user