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

Commit a3bd64aa authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "A11y: Add comments to improve readability for autoclick feature" into main

parents 16e8c06d 6bd0fb68
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -36,17 +36,21 @@ import androidx.annotation.VisibleForTesting;

import com.android.internal.R;

// A visual indicator for the autoclick feature.
/**
 * A view that displays a circular visual indicator for the autoclick feature.
 * The indicator animates a ring to provide visual feedback before an automatic click occurs.
 */
public class AutoclickIndicatorView extends View {
    private static final String TAG = AutoclickIndicatorView.class.getSimpleName();

    // TODO(b/383901288): update delay time once determined by UX.
    static final int SHOW_INDICATOR_DELAY_TIME = 150;

    static final int MINIMAL_ANIMATION_DURATION = 50;

    // Radius of the indicator circle.
    private int mRadius = AUTOCLICK_CURSOR_AREA_SIZE_DEFAULT;

    // Paint object used to draw the indicator.
    private final Paint mPaint;

    private final ValueAnimator mAnimator;
+3 −0
Original line number Diff line number Diff line
@@ -66,6 +66,9 @@ public class AutoclickLinearLayout extends LinearLayout {
        setHovered(action == MotionEvent.ACTION_HOVER_ENTER
                || action == MotionEvent.ACTION_HOVER_MOVE);

        // Return false so that hover events are dispatched to children.
        // This allows individual buttons to handle their own hover states if needed,
        // while this layout still tracks the overall hover state of the group.
        return false;
    }

+5 −0
Original line number Diff line number Diff line
@@ -18,6 +18,11 @@ package com.android.server.accessibility.autoclick;

import com.android.internal.util.FrameworkStatsLog;

/**
 * Helper class for logging autoclick related events and states to FrameworkStatsLog.
 * This class provides static methods to log various aspects of the autoclick feature,
 * such as selected click types, feature enablement, session duration, and settings.
 */
public class AutoclickLogger {
    /**
     * Logs an autoclick clicked type, emit when autoclick is sent.
+20 −0
Original line number Diff line number Diff line
@@ -41,6 +41,14 @@ import com.android.internal.R;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

/**
 * Manages the UI panel for controlling scroll actions in autoclick mode.
 * This panel provides buttons for scrolling in four directions (up, down, left, right)
 * and an exit button to leave scroll mode. It interacts with a
 * {@link ScrollPanelControllerInterface} to notify about hover events and exit requests.
 * It also displays a {@link AutoclickScrollPointIndicator} at the cursor position
 * when the panel is shown.
 */
public class AutoclickScrollPanel {
    public static final int DIRECTION_UP = 0;
    public static final int DIRECTION_DOWN = 1;
@@ -53,6 +61,9 @@ public class AutoclickScrollPanel {
    // TODO(b/388845721): Finalize edge margin.
    private static final int PANEL_EDGE_MARGIN = 15;

    /**
     * Defines the possible scroll directions and actions for the panel buttons.
     */
    @IntDef({
            DIRECTION_UP,
            DIRECTION_DOWN,
@@ -179,6 +190,9 @@ public class AutoclickScrollPanel {
    /**
     * Positions the panel at the bottom right of the cursor coordinates,
     * ensuring it stays within the screen boundaries.
     * If the panel would go off the right or bottom edge, it's repositioned
     * to the left or above the cursor, respectively.
     * The panel's gravity is set to TOP|LEFT for absolute positioning.
     */
    protected void positionPanelAtCursor(float cursorX, float cursorY) {
        // Set gravity to TOP|LEFT for absolute positioning.
@@ -224,6 +238,10 @@ public class AutoclickScrollPanel {

    /**
     * Sets up a hover listener for a button.
     * When the button is hovered or unhovered, it updates the button's style
     * and notifies the {@link ScrollPanelControllerInterface}.
     * @param button The ImageButton to set the listener for.
     * @param direction The {@link ScrollDirection} associated with this button.
     */
    private void setupHoverListenerForButton(ImageButton button, @ScrollDirection int direction) {
        button.setOnHoverListener((v, event) -> {
@@ -253,6 +271,8 @@ public class AutoclickScrollPanel {

    /**
     * Updates the button's style based on hover state.
     * When hovered, a semi-transparent tint is applied to the button's background.
     * When not hovered, the tint is cleared.
     *
     * @param button  The button to update the style for.
     * @param hovered Whether the button is being hovered or not.
+3 −1
Original line number Diff line number Diff line
@@ -32,7 +32,9 @@ import androidx.annotation.VisibleForTesting;
import com.android.internal.R;

/**
 * A visual indicator that displays a point at the scroll cursor location.
 * A custom view that displays a circular visual indicator at the scroll cursor's location.
 * This indicator is shown when the autoclick scroll panel is active, providing a visual cue
 * for the point around which scrolling will occur.
 */
public class AutoclickScrollPointIndicator extends View {
    // 16dp diameter (8dp radius).
Loading