Loading core/res/res/layout/accessibility_autoclick_type_panel.xml +2 −3 Original line number Diff line number Diff line Loading @@ -24,7 +24,7 @@ android:layout_gravity="center_horizontal" android:background="@drawable/accessibility_autoclick_type_panel_rounded_background" android:orientation="vertical" android:padding="16dp"> android:padding="8dp"> <LinearLayout android:id="@+id/accessibility_autoclick_button_group_container" Loading @@ -38,8 +38,7 @@ android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:background="@drawable/accessibility_autoclick_button_group_rounded_background" android:orientation="horizontal" android:padding="3dp"> android:orientation="horizontal"> <LinearLayout android:id="@+id/accessibility_autoclick_long_press_layout" Loading core/res/res/values/dimens.xml +1 −1 Original line number Diff line number Diff line Loading @@ -759,7 +759,7 @@ <dimen name="accessibility_window_magnifier_min_size">122dp</dimen> <!-- The accessibility autoclick panel button spacing --> <dimen name="accessibility_autoclick_type_panel_button_spacing">12dp</dimen> <dimen name="accessibility_autoclick_type_panel_button_spacing">8dp</dimen> <!-- The accessibility autoclick panel button width and height --> <dimen name="accessibility_autoclick_type_panel_button_size">36dp</dimen> Loading services/accessibility/java/com/android/server/accessibility/autoclick/AutoclickTypePanel.java +45 −0 Original line number Diff line number Diff line Loading @@ -291,6 +291,9 @@ public class AutoclickTypePanel { mPauseButton.setOnClickListener(v -> togglePause()); resetSelectedClickType(); // Remove spacing between buttons when initialized. adjustPanelSpacing(/* isExpanded= */ false); } /** Reset panel as collapsed state and only displays the left click button. */ Loading Loading @@ -374,9 +377,15 @@ public class AutoclickTypePanel { // Sets the newly selected button. setSelectedClickType(clickType); // Remove spacing between buttons when collapsed. adjustPanelSpacing(/* isExpanded= */ false); } else { // If the panel is already collapsed, we just need to expand it. showAllClickTypeButtons(); // Add spacing when panel is expanded. adjustPanelSpacing(/* isExpanded= */ true); } // Toggle the state. Loading Loading @@ -557,6 +566,42 @@ public class AutoclickTypePanel { }; } /** * Applies the appropriate spacing between buttons based on panel state. * * @param isExpanded Whether the panel is in expanded state. */ private void adjustPanelSpacing(boolean isExpanded) { int spacing = (int) mContext.getResources().getDimension( R.dimen.accessibility_autoclick_type_panel_button_spacing); // Get the button container and button group. LinearLayout buttonGroupContainer = mContentView.findViewById( R.id.accessibility_autoclick_button_group_container); LinearLayout buttonGroup = (LinearLayout) buttonGroupContainer.getChildAt(0); if (isExpanded) { // When expanded: Apply padding to the button group with rounded background (all sides). buttonGroup.setPadding(spacing, spacing, spacing, spacing); // Remove extra padding from container. buttonGroupContainer.setPadding(0, 0, 0, 0); } else { // When collapsed: Remove button group padding. buttonGroup.setPadding(0, 0, 0, 0); // Add extra vertical padding to the button group container. buttonGroupContainer.setPadding(0, spacing, 0, spacing); } // Set end margin on each button (for spacing between buttons) when expanded. int buttonSpacing = isExpanded ? spacing : 0; for (int i = 0; i < buttonGroup.getChildCount() - 1; i++) { LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) buttonGroup.getChildAt(i).getLayoutParams(); params.setMarginEnd(buttonSpacing); buttonGroup.getChildAt(i).setLayoutParams(params); } } @VisibleForTesting boolean getExpansionStateForTesting() { return mExpanded; Loading Loading
core/res/res/layout/accessibility_autoclick_type_panel.xml +2 −3 Original line number Diff line number Diff line Loading @@ -24,7 +24,7 @@ android:layout_gravity="center_horizontal" android:background="@drawable/accessibility_autoclick_type_panel_rounded_background" android:orientation="vertical" android:padding="16dp"> android:padding="8dp"> <LinearLayout android:id="@+id/accessibility_autoclick_button_group_container" Loading @@ -38,8 +38,7 @@ android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:background="@drawable/accessibility_autoclick_button_group_rounded_background" android:orientation="horizontal" android:padding="3dp"> android:orientation="horizontal"> <LinearLayout android:id="@+id/accessibility_autoclick_long_press_layout" Loading
core/res/res/values/dimens.xml +1 −1 Original line number Diff line number Diff line Loading @@ -759,7 +759,7 @@ <dimen name="accessibility_window_magnifier_min_size">122dp</dimen> <!-- The accessibility autoclick panel button spacing --> <dimen name="accessibility_autoclick_type_panel_button_spacing">12dp</dimen> <dimen name="accessibility_autoclick_type_panel_button_spacing">8dp</dimen> <!-- The accessibility autoclick panel button width and height --> <dimen name="accessibility_autoclick_type_panel_button_size">36dp</dimen> Loading
services/accessibility/java/com/android/server/accessibility/autoclick/AutoclickTypePanel.java +45 −0 Original line number Diff line number Diff line Loading @@ -291,6 +291,9 @@ public class AutoclickTypePanel { mPauseButton.setOnClickListener(v -> togglePause()); resetSelectedClickType(); // Remove spacing between buttons when initialized. adjustPanelSpacing(/* isExpanded= */ false); } /** Reset panel as collapsed state and only displays the left click button. */ Loading Loading @@ -374,9 +377,15 @@ public class AutoclickTypePanel { // Sets the newly selected button. setSelectedClickType(clickType); // Remove spacing between buttons when collapsed. adjustPanelSpacing(/* isExpanded= */ false); } else { // If the panel is already collapsed, we just need to expand it. showAllClickTypeButtons(); // Add spacing when panel is expanded. adjustPanelSpacing(/* isExpanded= */ true); } // Toggle the state. Loading Loading @@ -557,6 +566,42 @@ public class AutoclickTypePanel { }; } /** * Applies the appropriate spacing between buttons based on panel state. * * @param isExpanded Whether the panel is in expanded state. */ private void adjustPanelSpacing(boolean isExpanded) { int spacing = (int) mContext.getResources().getDimension( R.dimen.accessibility_autoclick_type_panel_button_spacing); // Get the button container and button group. LinearLayout buttonGroupContainer = mContentView.findViewById( R.id.accessibility_autoclick_button_group_container); LinearLayout buttonGroup = (LinearLayout) buttonGroupContainer.getChildAt(0); if (isExpanded) { // When expanded: Apply padding to the button group with rounded background (all sides). buttonGroup.setPadding(spacing, spacing, spacing, spacing); // Remove extra padding from container. buttonGroupContainer.setPadding(0, 0, 0, 0); } else { // When collapsed: Remove button group padding. buttonGroup.setPadding(0, 0, 0, 0); // Add extra vertical padding to the button group container. buttonGroupContainer.setPadding(0, spacing, 0, spacing); } // Set end margin on each button (for spacing between buttons) when expanded. int buttonSpacing = isExpanded ? spacing : 0; for (int i = 0; i < buttonGroup.getChildCount() - 1; i++) { LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) buttonGroup.getChildAt(i).getLayoutParams(); params.setMarginEnd(buttonSpacing); buttonGroup.getChildAt(i).setLayoutParams(params); } } @VisibleForTesting boolean getExpansionStateForTesting() { return mExpanded; Loading