Loading services/accessibility/java/com/android/server/accessibility/autoclick/AutoclickTypePanel.java +29 −0 Original line number Diff line number Diff line Loading @@ -157,6 +157,10 @@ public class AutoclickTypePanel { private int mStatusBarHeight = 0; // True when the fully expanded panel is wider than the screen display so certain buttons need // to be hidden. private boolean mIsExpandedPanelWiderThanScreen = false; // The current corner position of the panel, default to bottom right. private @Corner int mCurrentCorner = CORNER_BOTTOM_RIGHT; Loading Loading @@ -354,6 +358,14 @@ public class AutoclickTypePanel { updatePauseButtonAppearance(); mContentView.post(() -> { updatePositionButtonIcon(getVisualCorner()); // If the expanded panel is too wide for the display, hide the rightmost buttons. if (mContentView.getWidth() >= mContext.getResources().getDisplayMetrics().widthPixels) { mIsExpandedPanelWiderThanScreen = true; mPauseButton.setVisibility(View.GONE); mPositionButton.setVisibility(View.GONE); } }); } Loading Loading @@ -474,6 +486,12 @@ public class AutoclickTypePanel { /** Toggles the panel expanded or collapsed state. */ private void togglePanelExpansion(@AutoclickType int clickType) { if (mExpanded) { // When collapsing the panel show these buttons again. if (mIsExpandedPanelWiderThanScreen) { mPauseButton.setVisibility(View.VISIBLE); mPositionButton.setVisibility(View.VISIBLE); } // If the panel is already in expanded state, we should collapse it by hiding all // buttons except the one user selected. collapsePanelWithClickType(clickType); Loading @@ -484,6 +502,12 @@ public class AutoclickTypePanel { // Add spacing when panel is expanded. adjustPanelSpacing(/* isExpanded= */ true); // If the expanded panel is too wide for the display, hide the rightmost buttons. if (mIsExpandedPanelWiderThanScreen) { mPauseButton.setVisibility(View.GONE); mPositionButton.setVisibility(View.GONE); } // Toggle the state. mExpanded = true; } Loading Loading @@ -970,6 +994,11 @@ public class AutoclickTypePanel { return mCurrentCursor; } @VisibleForTesting void setIsExpandedPanelWiderThanScreenForTesting(boolean isExpandedPanelWiderThanScreen) { mIsExpandedPanelWiderThanScreen = isExpandedPanelWiderThanScreen; } /** * Retrieves the layout params for AutoclickIndicatorView, used when it's added to the Window * Manager. Loading services/tests/servicestests/src/com/android/server/accessibility/autoclick/AutoclickTypePanelTest.java +26 −0 Original line number Diff line number Diff line Loading @@ -206,6 +206,32 @@ public class AutoclickTypePanelTest { assertThat(mActiveClickType).isEqualTo(AUTOCLICK_TYPE_SCROLL); } @Test public void togglePanelExpansion_largeScreen_AllButtonsShowing() { mAutoclickTypePanel.setIsExpandedPanelWiderThanScreenForTesting(false); // Close and re-expand the panel. mLeftClickButton.callOnClick(); mLeftClickButton.callOnClick(); // Expect the buttons to be shown because the screen can fit the whole panel. assertThat(mPauseButton.getVisibility()).isEqualTo(View.VISIBLE); assertThat(mPositionButton.getVisibility()).isEqualTo(View.VISIBLE); } @Test public void togglePanelExpansion_smallScreen_HideButtons() { mAutoclickTypePanel.setIsExpandedPanelWiderThanScreenForTesting(true); // Close and re-expand the panel. mLeftClickButton.callOnClick(); mLeftClickButton.callOnClick(); // Expect the buttons to be hidden because the screen is too small. assertThat(mPauseButton.getVisibility()).isEqualTo(View.GONE); assertThat(mPositionButton.getVisibility()).isEqualTo(View.GONE); } @Test public void clickLeftClickButton_resumeAutoClick() { // Pause autoclick. Loading Loading
services/accessibility/java/com/android/server/accessibility/autoclick/AutoclickTypePanel.java +29 −0 Original line number Diff line number Diff line Loading @@ -157,6 +157,10 @@ public class AutoclickTypePanel { private int mStatusBarHeight = 0; // True when the fully expanded panel is wider than the screen display so certain buttons need // to be hidden. private boolean mIsExpandedPanelWiderThanScreen = false; // The current corner position of the panel, default to bottom right. private @Corner int mCurrentCorner = CORNER_BOTTOM_RIGHT; Loading Loading @@ -354,6 +358,14 @@ public class AutoclickTypePanel { updatePauseButtonAppearance(); mContentView.post(() -> { updatePositionButtonIcon(getVisualCorner()); // If the expanded panel is too wide for the display, hide the rightmost buttons. if (mContentView.getWidth() >= mContext.getResources().getDisplayMetrics().widthPixels) { mIsExpandedPanelWiderThanScreen = true; mPauseButton.setVisibility(View.GONE); mPositionButton.setVisibility(View.GONE); } }); } Loading Loading @@ -474,6 +486,12 @@ public class AutoclickTypePanel { /** Toggles the panel expanded or collapsed state. */ private void togglePanelExpansion(@AutoclickType int clickType) { if (mExpanded) { // When collapsing the panel show these buttons again. if (mIsExpandedPanelWiderThanScreen) { mPauseButton.setVisibility(View.VISIBLE); mPositionButton.setVisibility(View.VISIBLE); } // If the panel is already in expanded state, we should collapse it by hiding all // buttons except the one user selected. collapsePanelWithClickType(clickType); Loading @@ -484,6 +502,12 @@ public class AutoclickTypePanel { // Add spacing when panel is expanded. adjustPanelSpacing(/* isExpanded= */ true); // If the expanded panel is too wide for the display, hide the rightmost buttons. if (mIsExpandedPanelWiderThanScreen) { mPauseButton.setVisibility(View.GONE); mPositionButton.setVisibility(View.GONE); } // Toggle the state. mExpanded = true; } Loading Loading @@ -970,6 +994,11 @@ public class AutoclickTypePanel { return mCurrentCursor; } @VisibleForTesting void setIsExpandedPanelWiderThanScreenForTesting(boolean isExpandedPanelWiderThanScreen) { mIsExpandedPanelWiderThanScreen = isExpandedPanelWiderThanScreen; } /** * Retrieves the layout params for AutoclickIndicatorView, used when it's added to the Window * Manager. Loading
services/tests/servicestests/src/com/android/server/accessibility/autoclick/AutoclickTypePanelTest.java +26 −0 Original line number Diff line number Diff line Loading @@ -206,6 +206,32 @@ public class AutoclickTypePanelTest { assertThat(mActiveClickType).isEqualTo(AUTOCLICK_TYPE_SCROLL); } @Test public void togglePanelExpansion_largeScreen_AllButtonsShowing() { mAutoclickTypePanel.setIsExpandedPanelWiderThanScreenForTesting(false); // Close and re-expand the panel. mLeftClickButton.callOnClick(); mLeftClickButton.callOnClick(); // Expect the buttons to be shown because the screen can fit the whole panel. assertThat(mPauseButton.getVisibility()).isEqualTo(View.VISIBLE); assertThat(mPositionButton.getVisibility()).isEqualTo(View.VISIBLE); } @Test public void togglePanelExpansion_smallScreen_HideButtons() { mAutoclickTypePanel.setIsExpandedPanelWiderThanScreenForTesting(true); // Close and re-expand the panel. mLeftClickButton.callOnClick(); mLeftClickButton.callOnClick(); // Expect the buttons to be hidden because the screen is too small. assertThat(mPauseButton.getVisibility()).isEqualTo(View.GONE); assertThat(mPositionButton.getVisibility()).isEqualTo(View.GONE); } @Test public void clickLeftClickButton_resumeAutoClick() { // Pause autoclick. Loading