Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c3dac341 authored by Harry Cutts's avatar Harry Cutts Committed by Android (Google) Code Review
Browse files

Merge "Add a11y setting for disabling touchpad system gestures" into main

parents 01043fdf b2530053
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -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 &amp; 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 &amp; 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] -->
+13 −0
Original line number Diff line number Diff line
@@ -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>
+6 −0
Original line number Diff line number Diff line
@@ -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 −0
Original line number Diff line number Diff line
@@ -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);
                }
            };
}
+9 −1
Original line number Diff line number Diff line
@@ -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() {
Loading