Loading libs/WindowManager/Shell/multivalentTests/src/com/android/wm/shell/bubbles/BubblePositionerTest.kt +27 −0 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.wm.shell.R import com.android.wm.shell.bubbles.BubblePositioner.MAX_HEIGHT import com.android.wm.shell.common.bubbles.BubbleBarLocation import com.google.common.truth.Truth.assertThat import com.google.common.util.concurrent.MoreExecutors.directExecutor import org.junit.Before Loading Loading @@ -486,6 +487,32 @@ class BubblePositionerTest { positioner.screenRect.width() - paddings[0] - paddings[2]) } @Test fun testIsBubbleBarOnLeft_defaultsToRight() { positioner.bubbleBarLocation = BubbleBarLocation.DEFAULT assertThat(positioner.isBubbleBarOnLeft).isFalse() // Check that left and right return expected position positioner.bubbleBarLocation = BubbleBarLocation.LEFT assertThat(positioner.isBubbleBarOnLeft).isTrue() positioner.bubbleBarLocation = BubbleBarLocation.RIGHT assertThat(positioner.isBubbleBarOnLeft).isFalse() } @Test fun testIsBubbleBarOnLeft_rtlEnabled_defaultsToLeft() { positioner.update(defaultDeviceConfig.copy(isRtl = true)) positioner.bubbleBarLocation = BubbleBarLocation.DEFAULT assertThat(positioner.isBubbleBarOnLeft).isTrue() // Check that left and right return expected position positioner.bubbleBarLocation = BubbleBarLocation.LEFT assertThat(positioner.isBubbleBarOnLeft).isTrue() positioner.bubbleBarLocation = BubbleBarLocation.RIGHT assertThat(positioner.isBubbleBarOnLeft).isFalse() } private val defaultYPosition: Float /** * Calculates the Y position bubbles should be placed based on the config. Based on the Loading libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java +26 −1 Original line number Diff line number Diff line Loading @@ -103,6 +103,7 @@ import com.android.wm.shell.common.TaskStackListenerCallback; import com.android.wm.shell.common.TaskStackListenerImpl; import com.android.wm.shell.common.annotations.ShellBackgroundThread; import com.android.wm.shell.common.annotations.ShellMainThread; import com.android.wm.shell.common.bubbles.BubbleBarLocation; import com.android.wm.shell.common.bubbles.BubbleBarUpdate; import com.android.wm.shell.draganddrop.DragAndDropController; import com.android.wm.shell.onehanded.OneHandedController; Loading Loading @@ -708,6 +709,30 @@ public class BubbleController implements ConfigurationChangeListener, return mBubbleProperties.isBubbleBarEnabled() && mBubblePositioner.isLargeScreen(); } /** * Returns current {@link BubbleBarLocation} if bubble bar is being used. * Otherwise returns <code>null</code> */ @Nullable public BubbleBarLocation getBubbleBarLocation() { if (canShowAsBubbleBar()) { return mBubblePositioner.getBubbleBarLocation(); } return null; } /** * Update bubble bar location and trigger and update to listeners */ public void setBubbleBarLocation(BubbleBarLocation bubbleBarLocation) { if (canShowAsBubbleBar()) { mBubblePositioner.setBubbleBarLocation(bubbleBarLocation); BubbleBarUpdate bubbleBarUpdate = new BubbleBarUpdate(); bubbleBarUpdate.bubbleBarLocation = bubbleBarLocation; mBubbleStateListener.onBubbleStateChange(bubbleBarUpdate); } } /** Whether this userId belongs to the current user. */ private boolean isCurrentProfile(int userId) { return userId == UserHandle.USER_ALL Loading Loading @@ -1179,7 +1204,7 @@ public class BubbleController implements ConfigurationChangeListener, */ @VisibleForTesting public void expandStackAndSelectBubbleFromLauncher(String key, Rect bubbleBarBounds) { mBubblePositioner.setBubbleBarPosition(bubbleBarBounds); mBubblePositioner.setBubbleBarBounds(bubbleBarBounds); if (BubbleOverflow.KEY.equals(key)) { mBubbleData.setSelectedBubbleFromLauncher(mBubbleData.getOverflow()); Loading libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleData.java +4 −2 Original line number Diff line number Diff line Loading @@ -165,7 +165,7 @@ public class BubbleData { * used when {@link BubbleController#isShowingAsBubbleBar()} is true. */ BubbleBarUpdate getInitialState() { BubbleBarUpdate bubbleBarUpdate = new BubbleBarUpdate(); BubbleBarUpdate bubbleBarUpdate = BubbleBarUpdate.createInitialState(); bubbleBarUpdate.shouldShowEducation = shouldShowEducation; for (int i = 0; i < bubbles.size(); i++) { bubbleBarUpdate.currentBubbleList.add(bubbles.get(i).asBubbleBarBubble()); Loading Loading @@ -255,7 +255,9 @@ public class BubbleData { * Returns a bubble bar update populated with the current list of active bubbles. */ public BubbleBarUpdate getInitialStateForBubbleBar() { return mStateChange.getInitialState(); BubbleBarUpdate initialState = mStateChange.getInitialState(); initialState.bubbleBarLocation = mPositioner.getBubbleBarLocation(); return initialState; } public void setSuppressionChangedListener(Bubbles.BubbleMetadataFlagListener listener) { Loading libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubblePositioner.java +25 −8 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ import androidx.annotation.VisibleForTesting; import com.android.internal.protolog.common.ProtoLog; import com.android.launcher3.icons.IconNormalizer; import com.android.wm.shell.R; import com.android.wm.shell.common.bubbles.BubbleBarLocation; /** * Keeps track of display size, configuration, and specific bubble sizes. One place for all Loading Loading @@ -95,6 +96,7 @@ public class BubblePositioner { private PointF mRestingStackPosition; private boolean mShowingInBubbleBar; private BubbleBarLocation mBubbleBarLocation = BubbleBarLocation.DEFAULT; private final Rect mBubbleBarBounds = new Rect(); public BubblePositioner(Context context, WindowManager windowManager) { Loading Loading @@ -797,13 +799,35 @@ public class BubblePositioner { mShowingInBubbleBar = showingInBubbleBar; } public void setBubbleBarLocation(BubbleBarLocation location) { mBubbleBarLocation = location; } public BubbleBarLocation getBubbleBarLocation() { return mBubbleBarLocation; } /** * @return <code>true</code> when bubble bar is on the left and <code>false</code> when on right */ public boolean isBubbleBarOnLeft() { return mBubbleBarLocation.isOnLeft(mDeviceConfig.isRtl()); } /** * Sets the position of the bubble bar in display coordinates. */ public void setBubbleBarPosition(Rect bubbleBarBounds) { public void setBubbleBarBounds(Rect bubbleBarBounds) { mBubbleBarBounds.set(bubbleBarBounds); } /** * Returns the display coordinates of the bubble bar. */ public Rect getBubbleBarBounds() { return mBubbleBarBounds; } /** * How wide the expanded view should be when showing from the bubble bar. */ Loading Loading @@ -831,11 +855,4 @@ public class BubblePositioner { public int getBubbleBarExpandedViewPadding() { return mExpandedViewPadding; } /** * Returns the display coordinates of the bubble bar. */ public Rect getBubbleBarBounds() { return mBubbleBarBounds; } } libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/bar/BubbleBarAnimationHelper.java +1 −1 Original line number Diff line number Diff line Loading @@ -477,7 +477,7 @@ public class BubbleBarAnimationHelper { private Point getExpandedViewRestPosition(Size size) { final int padding = mPositioner.getBubbleBarExpandedViewPadding(); Point point = new Point(); if (mLayerView.isOnLeft()) { if (mPositioner.isBubbleBarOnLeft()) { point.x = mPositioner.getInsets().left + padding; } else { point.x = mPositioner.getAvailableRect().width() - size.getWidth() - padding; Loading Loading
libs/WindowManager/Shell/multivalentTests/src/com/android/wm/shell/bubbles/BubblePositionerTest.kt +27 −0 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.wm.shell.R import com.android.wm.shell.bubbles.BubblePositioner.MAX_HEIGHT import com.android.wm.shell.common.bubbles.BubbleBarLocation import com.google.common.truth.Truth.assertThat import com.google.common.util.concurrent.MoreExecutors.directExecutor import org.junit.Before Loading Loading @@ -486,6 +487,32 @@ class BubblePositionerTest { positioner.screenRect.width() - paddings[0] - paddings[2]) } @Test fun testIsBubbleBarOnLeft_defaultsToRight() { positioner.bubbleBarLocation = BubbleBarLocation.DEFAULT assertThat(positioner.isBubbleBarOnLeft).isFalse() // Check that left and right return expected position positioner.bubbleBarLocation = BubbleBarLocation.LEFT assertThat(positioner.isBubbleBarOnLeft).isTrue() positioner.bubbleBarLocation = BubbleBarLocation.RIGHT assertThat(positioner.isBubbleBarOnLeft).isFalse() } @Test fun testIsBubbleBarOnLeft_rtlEnabled_defaultsToLeft() { positioner.update(defaultDeviceConfig.copy(isRtl = true)) positioner.bubbleBarLocation = BubbleBarLocation.DEFAULT assertThat(positioner.isBubbleBarOnLeft).isTrue() // Check that left and right return expected position positioner.bubbleBarLocation = BubbleBarLocation.LEFT assertThat(positioner.isBubbleBarOnLeft).isTrue() positioner.bubbleBarLocation = BubbleBarLocation.RIGHT assertThat(positioner.isBubbleBarOnLeft).isFalse() } private val defaultYPosition: Float /** * Calculates the Y position bubbles should be placed based on the config. Based on the Loading
libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java +26 −1 Original line number Diff line number Diff line Loading @@ -103,6 +103,7 @@ import com.android.wm.shell.common.TaskStackListenerCallback; import com.android.wm.shell.common.TaskStackListenerImpl; import com.android.wm.shell.common.annotations.ShellBackgroundThread; import com.android.wm.shell.common.annotations.ShellMainThread; import com.android.wm.shell.common.bubbles.BubbleBarLocation; import com.android.wm.shell.common.bubbles.BubbleBarUpdate; import com.android.wm.shell.draganddrop.DragAndDropController; import com.android.wm.shell.onehanded.OneHandedController; Loading Loading @@ -708,6 +709,30 @@ public class BubbleController implements ConfigurationChangeListener, return mBubbleProperties.isBubbleBarEnabled() && mBubblePositioner.isLargeScreen(); } /** * Returns current {@link BubbleBarLocation} if bubble bar is being used. * Otherwise returns <code>null</code> */ @Nullable public BubbleBarLocation getBubbleBarLocation() { if (canShowAsBubbleBar()) { return mBubblePositioner.getBubbleBarLocation(); } return null; } /** * Update bubble bar location and trigger and update to listeners */ public void setBubbleBarLocation(BubbleBarLocation bubbleBarLocation) { if (canShowAsBubbleBar()) { mBubblePositioner.setBubbleBarLocation(bubbleBarLocation); BubbleBarUpdate bubbleBarUpdate = new BubbleBarUpdate(); bubbleBarUpdate.bubbleBarLocation = bubbleBarLocation; mBubbleStateListener.onBubbleStateChange(bubbleBarUpdate); } } /** Whether this userId belongs to the current user. */ private boolean isCurrentProfile(int userId) { return userId == UserHandle.USER_ALL Loading Loading @@ -1179,7 +1204,7 @@ public class BubbleController implements ConfigurationChangeListener, */ @VisibleForTesting public void expandStackAndSelectBubbleFromLauncher(String key, Rect bubbleBarBounds) { mBubblePositioner.setBubbleBarPosition(bubbleBarBounds); mBubblePositioner.setBubbleBarBounds(bubbleBarBounds); if (BubbleOverflow.KEY.equals(key)) { mBubbleData.setSelectedBubbleFromLauncher(mBubbleData.getOverflow()); Loading
libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleData.java +4 −2 Original line number Diff line number Diff line Loading @@ -165,7 +165,7 @@ public class BubbleData { * used when {@link BubbleController#isShowingAsBubbleBar()} is true. */ BubbleBarUpdate getInitialState() { BubbleBarUpdate bubbleBarUpdate = new BubbleBarUpdate(); BubbleBarUpdate bubbleBarUpdate = BubbleBarUpdate.createInitialState(); bubbleBarUpdate.shouldShowEducation = shouldShowEducation; for (int i = 0; i < bubbles.size(); i++) { bubbleBarUpdate.currentBubbleList.add(bubbles.get(i).asBubbleBarBubble()); Loading Loading @@ -255,7 +255,9 @@ public class BubbleData { * Returns a bubble bar update populated with the current list of active bubbles. */ public BubbleBarUpdate getInitialStateForBubbleBar() { return mStateChange.getInitialState(); BubbleBarUpdate initialState = mStateChange.getInitialState(); initialState.bubbleBarLocation = mPositioner.getBubbleBarLocation(); return initialState; } public void setSuppressionChangedListener(Bubbles.BubbleMetadataFlagListener listener) { Loading
libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubblePositioner.java +25 −8 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ import androidx.annotation.VisibleForTesting; import com.android.internal.protolog.common.ProtoLog; import com.android.launcher3.icons.IconNormalizer; import com.android.wm.shell.R; import com.android.wm.shell.common.bubbles.BubbleBarLocation; /** * Keeps track of display size, configuration, and specific bubble sizes. One place for all Loading Loading @@ -95,6 +96,7 @@ public class BubblePositioner { private PointF mRestingStackPosition; private boolean mShowingInBubbleBar; private BubbleBarLocation mBubbleBarLocation = BubbleBarLocation.DEFAULT; private final Rect mBubbleBarBounds = new Rect(); public BubblePositioner(Context context, WindowManager windowManager) { Loading Loading @@ -797,13 +799,35 @@ public class BubblePositioner { mShowingInBubbleBar = showingInBubbleBar; } public void setBubbleBarLocation(BubbleBarLocation location) { mBubbleBarLocation = location; } public BubbleBarLocation getBubbleBarLocation() { return mBubbleBarLocation; } /** * @return <code>true</code> when bubble bar is on the left and <code>false</code> when on right */ public boolean isBubbleBarOnLeft() { return mBubbleBarLocation.isOnLeft(mDeviceConfig.isRtl()); } /** * Sets the position of the bubble bar in display coordinates. */ public void setBubbleBarPosition(Rect bubbleBarBounds) { public void setBubbleBarBounds(Rect bubbleBarBounds) { mBubbleBarBounds.set(bubbleBarBounds); } /** * Returns the display coordinates of the bubble bar. */ public Rect getBubbleBarBounds() { return mBubbleBarBounds; } /** * How wide the expanded view should be when showing from the bubble bar. */ Loading Loading @@ -831,11 +855,4 @@ public class BubblePositioner { public int getBubbleBarExpandedViewPadding() { return mExpandedViewPadding; } /** * Returns the display coordinates of the bubble bar. */ public Rect getBubbleBarBounds() { return mBubbleBarBounds; } }
libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/bar/BubbleBarAnimationHelper.java +1 −1 Original line number Diff line number Diff line Loading @@ -477,7 +477,7 @@ public class BubbleBarAnimationHelper { private Point getExpandedViewRestPosition(Size size) { final int padding = mPositioner.getBubbleBarExpandedViewPadding(); Point point = new Point(); if (mLayerView.isOnLeft()) { if (mPositioner.isBubbleBarOnLeft()) { point.x = mPositioner.getInsets().left + padding; } else { point.x = mPositioner.getAvailableRect().width() - size.getWidth() - padding; Loading