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

Commit 1d45cd7a authored by Wenyu Zhang's avatar Wenyu Zhang Committed by Android (Google) Code Review
Browse files

Merge "a11y: Add "Ignore minor cursor movement" autoclick setting" into main

parents 88d40f1c d683d181
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -5604,6 +5604,9 @@
    <!-- Summary for the seekbar that adjust auto click cursor area size. [CHAR_LIMIT=NONE] -->
    <!-- TODO(b/383901288): Update string to translatable once approved by UXW. -->
    <string name="autoclick_cursor_area_size_summary" translatable="false">Adjust the autoclick ring indicator area size</string>
    <!-- Title for the toggle button that turns on/off the autoclick setting of ignoring minor cursor movement. [CHAR_LIMIT=NONE] -->
    <!-- TODO(b/388845718): Update string to translatable once approved by UXW. -->
    <string name="autoclick_ignore_minor_cursor_movement_title" translatable="false">Ignore minor cursor movement</string>
    <!-- Title for preference screen for configuring vibrations. [CHAR LIMIT=NONE] -->
    <string name="accessibility_vibration_settings_title">Vibration &amp; haptics</string>
    <!-- Summary for preference screen for configuring vibrations. [CHAR LIMIT=NONE] -->
+5 −0
Original line number Diff line number Diff line
@@ -84,6 +84,11 @@
        settings:searchable="false"
        settings:controller="com.android.settings.accessibility.ToggleAutoclickCursorAreaSizeController"/>

    <SwitchPreferenceCompat
        android:key="accessibility_control_autoclick_ignore_minor_cursor_movement"
        android:title="@string/autoclick_ignore_minor_cursor_movement_title"
        settings:controller="com.android.settings.accessibility.ToggleAutoclickIgnoreMinorCursorMovementController"/>

    <com.android.settings.accessibility.AccessibilityFooterPreference
        android:key="accessibility_autoclick_footer"
        android:title="@string/accessibility_autoclick_description"
+58 −0
Original line number Diff line number Diff line
/*
 * Copyright 2025 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.content.Context;

import androidx.annotation.NonNull;

import com.android.server.accessibility.Flags;
import com.android.settings.R;
import com.android.settings.core.TogglePreferenceController;

public class ToggleAutoclickIgnoreMinorCursorMovementController extends TogglePreferenceController {

    private static final String TAG =
            ToggleAutoclickIgnoreMinorCursorMovementController.class.getSimpleName();

    public ToggleAutoclickIgnoreMinorCursorMovementController(
            @NonNull Context context, @NonNull String key) {
        super(context, key);
    }

    @Override
    public int getAvailabilityStatus() {
        return Flags.enableAutoclickIndicator() ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
    }

    @Override
    public boolean isChecked() {
        // TODO(b/388845718): retrieve check status from settings.
        return false;
    }

    @Override
    public boolean setChecked(boolean isChecked) {
        // TODO(b/388845718): Update settings.
        return true;
    }

    @Override
    public int getSliceHighlightMenuRes() {
        return R.string.menu_key_accessibility;
    }
}
+69 −0
Original line number Diff line number Diff line
/*
 * Copyright 2025 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.google.common.truth.Truth.assertThat;

import android.content.Context;
import android.platform.test.annotations.DisableFlags;
import android.platform.test.annotations.EnableFlags;
import android.platform.test.flag.junit.SetFlagsRule;

import androidx.test.core.app.ApplicationProvider;

import com.android.settings.core.BasePreferenceController;

import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.junit.MockitoJUnit;
import org.mockito.junit.MockitoRule;
import org.robolectric.RobolectricTestRunner;

/** Tests for {@link ToggleAutoclickIgnoreMinorCursorMovementController}. */
@RunWith(RobolectricTestRunner.class)
public class ToggleAutoclickIgnoreMinorCursorMovementControllerTest {

    private static final String PREFERENCE_KEY =
            "accessibility_control_autoclick_ignore_minor_cursor_movement";

    @Rule public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
    @Rule public final MockitoRule mMockitoRule = MockitoJUnit.rule();
    private final Context mContext = ApplicationProvider.getApplicationContext();
    private ToggleAutoclickIgnoreMinorCursorMovementController mController;

    @Before
    public void setUp() {
        mController =
                new ToggleAutoclickIgnoreMinorCursorMovementController(mContext, PREFERENCE_KEY);
    }

    @Test
    @EnableFlags(com.android.server.accessibility.Flags.FLAG_ENABLE_AUTOCLICK_INDICATOR)
    public void getAvailabilityStatus_availableWhenFlagOn() {
        assertThat(mController.getAvailabilityStatus())
                .isEqualTo(BasePreferenceController.AVAILABLE);
    }

    @Test
    @DisableFlags(com.android.server.accessibility.Flags.FLAG_ENABLE_AUTOCLICK_INDICATOR)
    public void getAvailabilityStatus_conditionallyUnavailableWhenFlagOn() {
        assertThat(mController.getAvailabilityStatus())
                .isEqualTo(BasePreferenceController.CONDITIONALLY_UNAVAILABLE);
    }
}