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

Commit 1e08648a authored by Yuhan Yang's avatar Yuhan Yang Committed by Android (Google) Code Review
Browse files

Merge "Add long press button to autoclick panel" into main

parents 52a83a10 a8285b98
Loading
Loading
Loading
Loading
+26 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- 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.
-->

<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="20dp"
    android:height="20dp"
    android:viewportWidth="960"
    android:viewportHeight="960"
    android:tint="?attr/colorControlNormal">
<path
    android:fillColor="@color/materialColorPrimary"
    android:pathData="M464,864Q440,864 419,854Q398,844 382,826L155,563L184,534Q199,519 220,514Q241,509 261,517L336,547L336,228Q336,212.7 346.29,202.35Q356.58,192 371.79,192Q387,192 397.5,202.35Q408,212.71 408,228.02L408,653L287,605L437,780Q442.23,785.6 449.19,788.8Q456.16,792 464,792L624,792Q653.7,792 674.85,770.85Q696,749.7 696,720L696,550Q696,540 688.53,534Q681.05,528 670,528L480,528L480,456L670,456Q710,456 739,483Q768,510 768,550L768,720Q768,780 726,822Q684,864 624,864L464,864ZM195,354Q182,331 175,305.5Q168,280 168,252.26Q168,167 227.74,107.5Q287.48,48 372.24,48Q457,48 516.5,107.67Q576,167.34 576,252Q576,280 569,305.5Q562,331 549,354L486,318Q494,304 499,287Q504,270 504,252Q504,197 465.5,158.5Q427,120 372,120Q317,120 278.5,158.5Q240,197 240,252Q240,270 245,287Q250,304 258,318L195,354ZM492,624L492,624L492,624L492,624Q492,624 492,624Q492,624 492,624L492,624Q492,624 492,624Q492,624 492,624L492,624Q492,624 492,624Q492,624 492,624L492,624L492,624Z"/>
</vector>
+12 −0
Original line number Diff line number Diff line
@@ -41,6 +41,18 @@
            android:orientation="horizontal"
            android:padding="3dp">

            <LinearLayout
                android:id="@+id/accessibility_autoclick_long_press_layout"
                style="@style/AccessibilityAutoclickPanelButtonLayoutStyle">

                <ImageButton
                    android:id="@+id/accessibility_autoclick_long_press_button"
                    style="@style/AccessibilityAutoclickPanelImageButtonStyle"
                    android:contentDescription="@string/accessibility_autoclick_long_press"
                    android:src="@drawable/accessibility_autoclick_long_press"
                    android:clickable="false" />
            </LinearLayout>

            <LinearLayout
                android:id="@+id/accessibility_autoclick_drag_layout"
                style="@style/AccessibilityAutoclickPanelButtonLayoutStyle">
+2 −0
Original line number Diff line number Diff line
@@ -6225,6 +6225,8 @@
    <string name="accessibility_autoclick_drag">Drag</string>
    <!-- Label for autoclick scroll button [CHAR LIMIT=NONE] -->
    <string name="accessibility_autoclick_scroll">Scroll</string>
    <!-- Label for autoclick drag button [CHAR LIMIT=NONE] -->
    <string name="accessibility_autoclick_long_press">Long press</string>
    <!-- Label for autoclick pause button [CHAR LIMIT=NONE] -->
    <string name="accessibility_autoclick_pause">Pause</string>
    <!-- Label for autoclick position button [CHAR LIMIT=NONE] -->
+3 −0
Original line number Diff line number Diff line
@@ -5666,6 +5666,7 @@
  <java-symbol type="string" name="accessibility_autoclick_double_click" />
  <java-symbol type="string" name="accessibility_autoclick_drag" />
  <java-symbol type="string" name="accessibility_autoclick_scroll" />
  <java-symbol type="string" name="accessibility_autoclick_long_press" />
  <java-symbol type="string" name="accessibility_autoclick_pause" />
  <java-symbol type="string" name="accessibility_autoclick_position" />
  <java-symbol type="dimen" name="accessibility_autoclick_type_panel_button_spacing" />
@@ -5684,6 +5685,8 @@
  <java-symbol type="id" name="accessibility_autoclick_drag_button" />
  <java-symbol type="id" name="accessibility_autoclick_scroll_layout" />
  <java-symbol type="id" name="accessibility_autoclick_scroll_button" />
  <java-symbol type="id" name="accessibility_autoclick_long_press_layout" />
  <java-symbol type="id" name="accessibility_autoclick_long_press_button" />
  <java-symbol type="id" name="accessibility_autoclick_pause_layout" />
  <java-symbol type="id" name="accessibility_autoclick_pause_button" />
  <java-symbol type="id" name="accessibility_autoclick_position_layout" />
+10 −0
Original line number Diff line number Diff line
@@ -49,6 +49,7 @@ public class AutoclickTypePanel {
    public static final int AUTOCLICK_TYPE_DOUBLE_CLICK = 2;
    public static final int AUTOCLICK_TYPE_DRAG = 3;
    public static final int AUTOCLICK_TYPE_SCROLL = 4;
    public static final int AUTOCLICK_TYPE_LONG_PRESS = 5;

    public static final int CORNER_BOTTOM_RIGHT = 0;
    public static final int CORNER_BOTTOM_LEFT = 1;
@@ -75,6 +76,7 @@ public class AutoclickTypePanel {
        AUTOCLICK_TYPE_DOUBLE_CLICK,
        AUTOCLICK_TYPE_DRAG,
        AUTOCLICK_TYPE_SCROLL,
        AUTOCLICK_TYPE_LONG_PRESS,
    })
    public @interface AutoclickType {}

@@ -140,6 +142,7 @@ public class AutoclickTypePanel {
    private final LinearLayout mScrollButton;
    private final LinearLayout mPauseButton;
    private final LinearLayout mPositionButton;
    private final LinearLayout mLongPressButton;

    private LinearLayout mSelectedButton;

@@ -176,6 +179,8 @@ public class AutoclickTypePanel {
        mDragButton = mContentView.findViewById(R.id.accessibility_autoclick_drag_layout);
        mPauseButton = mContentView.findViewById(R.id.accessibility_autoclick_pause_layout);
        mPositionButton = mContentView.findViewById(R.id.accessibility_autoclick_position_layout);
        mLongPressButton =
                mContentView.findViewById(R.id.accessibility_autoclick_long_press_layout);

        initializeButtonState();

@@ -278,6 +283,8 @@ public class AutoclickTypePanel {
                wrapWithTogglePauseListener(v -> togglePanelExpansion(AUTOCLICK_TYPE_SCROLL)));
        mDragButton.setOnClickListener(
                wrapWithTogglePauseListener(v -> togglePanelExpansion(AUTOCLICK_TYPE_DRAG)));
        mLongPressButton.setOnClickListener(
                wrapWithTogglePauseListener(v -> togglePanelExpansion(AUTOCLICK_TYPE_LONG_PRESS)));
        mPositionButton.setOnClickListener(wrapWithTogglePauseListener(v -> moveToNextCorner()));

        // The pause button calls `togglePause()` directly so it does not need extra logic.
@@ -395,6 +402,7 @@ public class AutoclickTypePanel {
        mDoubleClickButton.setVisibility(View.GONE);
        mDragButton.setVisibility(View.GONE);
        mScrollButton.setVisibility(View.GONE);
        mLongPressButton.setVisibility(View.GONE);
    }

    /** Show all buttons on the panel except pause and position buttons. */
@@ -404,6 +412,7 @@ public class AutoclickTypePanel {
        mDoubleClickButton.setVisibility(View.VISIBLE);
        mDragButton.setVisibility(View.VISIBLE);
        mScrollButton.setVisibility(View.VISIBLE);
        mLongPressButton.setVisibility(View.VISIBLE);
    }

    private LinearLayout getButtonFromClickType(@AutoclickType int clickType) {
@@ -413,6 +422,7 @@ public class AutoclickTypePanel {
            case AUTOCLICK_TYPE_DOUBLE_CLICK -> mDoubleClickButton;
            case AUTOCLICK_TYPE_DRAG -> mDragButton;
            case AUTOCLICK_TYPE_SCROLL -> mScrollButton;
            case AUTOCLICK_TYPE_LONG_PRESS -> mLongPressButton;
            default -> throw new IllegalArgumentException("Unknown clickType " + clickType);
        };
    }
Loading