Update placement of the nav bar in persistent taskbar for 3 button nav
Implemented nav bar placement update to be located opposite to the bubble bar. When bubble bar is moved to the other side of the bar, 3 button nav will swap sides (without animation). If taskbar has to be repositioned it does that with the animation. Test: TaskbarViewControllerTest Bug: 346381754 Flag: com.android.wm.shell.enable_bubble_bar Change-Id: Id031706183c60cbd9c67537b01530acb43bae614
This commit is contained in:
@@ -91,6 +91,7 @@ import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.anim.AlphaUpdateListener;
|
||||
import com.android.launcher3.anim.AnimatedFloat;
|
||||
import com.android.launcher3.taskbar.TaskbarNavButtonController.TaskbarButton;
|
||||
import com.android.launcher3.taskbar.bubbles.BubbleBarController;
|
||||
import com.android.launcher3.taskbar.navbutton.NavButtonLayoutFactory;
|
||||
import com.android.launcher3.taskbar.navbutton.NavButtonLayoutFactory.NavButtonLayoutter;
|
||||
import com.android.launcher3.taskbar.navbutton.NearestTouchFrame;
|
||||
@@ -106,6 +107,7 @@ import com.android.systemui.shared.rotation.RotationButton;
|
||||
import com.android.systemui.shared.statusbar.phone.BarTransitions;
|
||||
import com.android.systemui.shared.system.QuickStepContract;
|
||||
import com.android.systemui.shared.system.QuickStepContract.SystemUiStateFlags;
|
||||
import com.android.wm.shell.shared.bubbles.BubbleBarLocation;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.util.ArrayList;
|
||||
@@ -115,7 +117,8 @@ import java.util.function.IntPredicate;
|
||||
/**
|
||||
* Controller for managing nav bar buttons in taskbar
|
||||
*/
|
||||
public class NavbarButtonsViewController implements TaskbarControllers.LoggableTaskbarController {
|
||||
public class NavbarButtonsViewController implements TaskbarControllers.LoggableTaskbarController,
|
||||
BubbleBarController.BubbleBarLocationListener {
|
||||
|
||||
private final Rect mTempRect = new Rect();
|
||||
|
||||
@@ -397,6 +400,12 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT
|
||||
}
|
||||
};
|
||||
mSeparateWindowParent.recreateControllers();
|
||||
if (com.android.wm.shell.Flags.enableBubbleBarInPersistentTaskBar()
|
||||
&& mControllers.bubbleControllers.isPresent()) {
|
||||
BubbleBarLocation bubblesLocation = mControllers.bubbleControllers.get()
|
||||
.bubbleBarViewController.getBubbleBarLocation();
|
||||
onBubbleBarLocationUpdated(bubblesLocation);
|
||||
}
|
||||
}
|
||||
|
||||
private void initButtons(ViewGroup navContainer, ViewGroup endContainer,
|
||||
@@ -1168,6 +1177,52 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT
|
||||
mHitboxExtender.onAnimationProgressToOverview(alignment);
|
||||
}
|
||||
|
||||
/** Adjusts navigation buttons layout accordingly to the bubble bar position. */
|
||||
@Override
|
||||
public void onBubbleBarLocationUpdated(BubbleBarLocation location) {
|
||||
mNavButtonContainer.setTranslationX(getNavBarTranslationX(location));
|
||||
}
|
||||
|
||||
/** Animates navigation buttons accordingly to the bubble bar position. */
|
||||
@Override
|
||||
public void onBubbleBarLocationAnimated(BubbleBarLocation location) {
|
||||
// TODO(b/346381754) add the teleport animation similarly to the bubble bar
|
||||
mNavButtonContainer.setTranslationX(getNavBarTranslationX(location));
|
||||
}
|
||||
|
||||
private int getNavBarTranslationX(BubbleBarLocation location) {
|
||||
boolean isNavbarOnRight = location.isOnLeft(mNavButtonsView.isLayoutRtl());
|
||||
DeviceProfile dp = mContext.getDeviceProfile();
|
||||
float navBarTargetStartX;
|
||||
if (mContext.shouldStartAlignTaskbar()) {
|
||||
int navBarSpacing = dp.inlineNavButtonsEndSpacingPx;
|
||||
// If the taskbar is start aligned the navigation bar is aligned to the start or end of
|
||||
// the container, depending on the bubble bar location
|
||||
if (isNavbarOnRight) {
|
||||
navBarTargetStartX = dp.widthPx - navBarSpacing - mNavButtonContainer.getWidth();
|
||||
} else {
|
||||
navBarTargetStartX = navBarSpacing;
|
||||
}
|
||||
} else {
|
||||
// If the task bar is not start aligned, the navigation bar is located in the center
|
||||
// between the taskbar and screen edges, depending on the bubble bar location.
|
||||
float navbarWidth = mNavButtonContainer.getWidth();
|
||||
Rect taskbarBounds = mControllers.taskbarViewController.getIconLayoutBounds();
|
||||
if (isNavbarOnRight) {
|
||||
if (mNavButtonsView.isLayoutRtl()) {
|
||||
float taskBarEnd = taskbarBounds.right;
|
||||
navBarTargetStartX = (dp.widthPx + taskBarEnd - navbarWidth) / 2;
|
||||
} else {
|
||||
navBarTargetStartX = mNavButtonContainer.getLeft();
|
||||
}
|
||||
} else {
|
||||
float taskBarStart = taskbarBounds.left;
|
||||
navBarTargetStartX = (taskBarStart - navbarWidth) / 2;
|
||||
}
|
||||
}
|
||||
return (int) navBarTargetStartX - mNavButtonContainer.getLeft();
|
||||
}
|
||||
|
||||
private class RotationButtonListener implements RotationButton.RotationButtonUpdatesCallback {
|
||||
@Override
|
||||
public void onVisibilityChanged(boolean isVisible) {
|
||||
|
||||
@@ -690,6 +690,11 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
|
||||
return mNavMode == NavigationMode.THREE_BUTTONS;
|
||||
}
|
||||
|
||||
/** Returns whether taskbar should start align. */
|
||||
public boolean shouldStartAlignTaskbar() {
|
||||
return isThreeButtonNav() && mDeviceProfile.startAlignTaskbar;
|
||||
}
|
||||
|
||||
public boolean isGestureNav() {
|
||||
return mNavMode == NavigationMode.NO_BUTTON;
|
||||
}
|
||||
|
||||
@@ -87,6 +87,7 @@ public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconPar
|
||||
private final boolean mIsRtl;
|
||||
|
||||
private final TaskbarActivityContext mActivityContext;
|
||||
@Nullable private BubbleBarLocation mBubbleBarLocation = null;
|
||||
|
||||
// Initialized in init.
|
||||
private TaskbarViewCallbacks mControllerCallbacks;
|
||||
@@ -197,7 +198,7 @@ public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconPar
|
||||
|
||||
@Override
|
||||
public void onDeviceProfileChanged(DeviceProfile dp) {
|
||||
mShouldTryStartAlign = mActivityContext.isThreeButtonNav() && dp.startAlignTaskbar;
|
||||
mShouldTryStartAlign = mActivityContext.shouldStartAlignTaskbar();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -494,39 +495,60 @@ public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconPar
|
||||
icon.setOnHoverListener(mControllerCallbacks.getIconOnHoverListener(icon));
|
||||
}
|
||||
|
||||
/** Updates taskbar icons accordingly to the new bubble bar location. */
|
||||
public void onBubbleBarLocationUpdated(BubbleBarLocation location) {
|
||||
if (mBubbleBarLocation == location) return;
|
||||
mBubbleBarLocation = location;
|
||||
requestLayout();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns translation X for the taskbar icons for provided {@link BubbleBarLocation}. If the
|
||||
* bubble bar is not enabled, or location of the bubble bar is the same, or taskbar is not start
|
||||
* aligned - returns 0.
|
||||
*/
|
||||
public float getTranslationXForBubbleBarPosition(BubbleBarLocation location) {
|
||||
if (!mControllerCallbacks.isBubbleBarEnabledInPersistentTaskbar()
|
||||
|| location == mBubbleBarLocation
|
||||
|| !mActivityContext.shouldStartAlignTaskbar()
|
||||
) {
|
||||
return 0;
|
||||
}
|
||||
Rect iconsBounds = getIconLayoutBounds();
|
||||
return getTaskBarIconsEndForBubbleBarLocation(location) - iconsBounds.right;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
|
||||
int count = getChildCount();
|
||||
DeviceProfile deviceProfile = mActivityContext.getDeviceProfile();
|
||||
int spaceNeeded = getIconLayoutWidth();
|
||||
int navSpaceNeeded = deviceProfile.hotseatBarEndOffset;
|
||||
boolean layoutRtl = isLayoutRtl();
|
||||
int centerAlignIconEnd = right - (right - left - spaceNeeded) / 2;
|
||||
int iconEnd;
|
||||
|
||||
DeviceProfile deviceProfile = mActivityContext.getDeviceProfile();
|
||||
int navSpaceNeeded = deviceProfile.hotseatBarEndOffset;
|
||||
int centerAlignIconEnd = (right + left + spaceNeeded) / 2;
|
||||
int iconEnd = centerAlignIconEnd;
|
||||
if (mShouldTryStartAlign) {
|
||||
// Taskbar is aligned to the start
|
||||
int startSpacingPx = deviceProfile.inlineNavButtonsEndSpacingPx;
|
||||
|
||||
if (layoutRtl) {
|
||||
iconEnd = right - startSpacingPx;
|
||||
if (mControllerCallbacks.isBubbleBarEnabledInPersistentTaskbar()
|
||||
&& mBubbleBarLocation != null
|
||||
&& mActivityContext.shouldStartAlignTaskbar()) {
|
||||
iconEnd = (int) getTaskBarIconsEndForBubbleBarLocation(mBubbleBarLocation);
|
||||
} else {
|
||||
iconEnd = startSpacingPx + spaceNeeded;
|
||||
if (layoutRtl) {
|
||||
iconEnd = right - startSpacingPx;
|
||||
} else {
|
||||
iconEnd = startSpacingPx + spaceNeeded;
|
||||
}
|
||||
boolean needMoreSpaceForNav = layoutRtl
|
||||
? navSpaceNeeded > (iconEnd - spaceNeeded)
|
||||
: iconEnd > (right - navSpaceNeeded);
|
||||
if (needMoreSpaceForNav) {
|
||||
// Add offset to account for nav bar when taskbar is centered
|
||||
int offset = layoutRtl
|
||||
? navSpaceNeeded - (centerAlignIconEnd - spaceNeeded)
|
||||
: (right - navSpaceNeeded) - centerAlignIconEnd;
|
||||
iconEnd = centerAlignIconEnd + offset;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
iconEnd = centerAlignIconEnd;
|
||||
}
|
||||
|
||||
boolean needMoreSpaceForNav = layoutRtl
|
||||
? navSpaceNeeded > (iconEnd - spaceNeeded)
|
||||
: iconEnd > (right - navSpaceNeeded);
|
||||
if (needMoreSpaceForNav) {
|
||||
// Add offset to account for nav bar when taskbar is centered
|
||||
int offset = layoutRtl
|
||||
? navSpaceNeeded - (centerAlignIconEnd - spaceNeeded)
|
||||
: (right - navSpaceNeeded) - centerAlignIconEnd;
|
||||
|
||||
iconEnd = centerAlignIconEnd + offset;
|
||||
}
|
||||
|
||||
// Currently, we support only one device with display cutout and we only are concern about
|
||||
@@ -558,6 +580,7 @@ public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconPar
|
||||
mIconLayoutBounds.right = iconEnd;
|
||||
mIconLayoutBounds.top = (bottom - top - mIconTouchSize) / 2;
|
||||
mIconLayoutBounds.bottom = mIconLayoutBounds.top + mIconTouchSize;
|
||||
int count = getChildCount();
|
||||
for (int i = count; i > 0; i--) {
|
||||
View child = getChildAt(i - 1);
|
||||
if (child == mQsb) {
|
||||
@@ -770,4 +793,19 @@ public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconPar
|
||||
}
|
||||
return mAllAppsButtonContainer;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method only works for bubble bar enabled in persistent task bar and the taskbar is start
|
||||
* aligned.
|
||||
*/
|
||||
private float getTaskBarIconsEndForBubbleBarLocation(BubbleBarLocation location) {
|
||||
DeviceProfile deviceProfile = mActivityContext.getDeviceProfile();
|
||||
boolean navbarOnRight = location.isOnLeft(isLayoutRtl());
|
||||
int navSpaceNeeded = deviceProfile.hotseatBarEndOffset;
|
||||
if (navbarOnRight) {
|
||||
return getWidth() - navSpaceNeeded;
|
||||
} else {
|
||||
return navSpaceNeeded + getIconLayoutWidth();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ import androidx.annotation.Nullable;
|
||||
import com.android.internal.jank.Cuj;
|
||||
import com.android.launcher3.taskbar.bubbles.BubbleBarViewController;
|
||||
import com.android.systemui.shared.system.InteractionJankMonitorWrapper;
|
||||
import com.android.wm.shell.Flags;
|
||||
import com.android.wm.shell.shared.bubbles.BubbleBarLocation;
|
||||
|
||||
/**
|
||||
@@ -127,4 +128,10 @@ public class TaskbarViewCallbacks {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/** Returns true if bubble bar controllers present and enabled in persistent taskbar. */
|
||||
public boolean isBubbleBarEnabledInPersistentTaskbar() {
|
||||
return Flags.enableBubbleBarInPersistentTaskBar()
|
||||
&& mControllers.bubbleControllers.isPresent();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,10 @@ import static com.android.launcher3.config.FeatureFlags.ENABLE_TASKBAR_NAVBAR_UN
|
||||
import static com.android.launcher3.config.FeatureFlags.enableTaskbarPinning;
|
||||
import static com.android.launcher3.taskbar.TaskbarPinningController.PINNING_PERSISTENT;
|
||||
import static com.android.launcher3.taskbar.TaskbarPinningController.PINNING_TRANSIENT;
|
||||
import static com.android.launcher3.taskbar.bubbles.BubbleBarView.FADE_IN_ANIM_ALPHA_DURATION_MS;
|
||||
import static com.android.launcher3.taskbar.bubbles.BubbleBarView.FADE_OUT_ANIM_POSITION_DURATION_MS;
|
||||
import static com.android.launcher3.util.MultiPropertyFactory.MULTI_PROPERTY_VALUE;
|
||||
import static com.android.launcher3.util.MultiTranslateDelegate.INDEX_NAV_BAR_ANIM;
|
||||
import static com.android.launcher3.util.MultiTranslateDelegate.INDEX_TASKBAR_ALIGNMENT_ANIM;
|
||||
import static com.android.launcher3.util.MultiTranslateDelegate.INDEX_TASKBAR_PINNING_ANIM;
|
||||
import static com.android.launcher3.util.MultiTranslateDelegate.INDEX_TASKBAR_REVEAL_ANIM;
|
||||
@@ -66,6 +69,7 @@ import com.android.launcher3.anim.RoundedRectRevealOutlineProvider;
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
import com.android.launcher3.model.data.ItemInfo;
|
||||
import com.android.launcher3.model.data.TaskItemInfo;
|
||||
import com.android.launcher3.taskbar.bubbles.BubbleBarController;
|
||||
import com.android.launcher3.util.DisplayController;
|
||||
import com.android.launcher3.util.ItemInfoMatcher;
|
||||
import com.android.launcher3.util.LauncherBindableItemsContainer;
|
||||
@@ -74,6 +78,8 @@ import com.android.launcher3.util.MultiTranslateDelegate;
|
||||
import com.android.launcher3.util.MultiValueAlpha;
|
||||
import com.android.quickstep.util.GroupTask;
|
||||
import com.android.systemui.shared.recents.model.Task;
|
||||
import com.android.wm.shell.Flags;
|
||||
import com.android.wm.shell.shared.bubbles.BubbleBarLocation;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.util.Set;
|
||||
@@ -82,7 +88,8 @@ import java.util.function.Predicate;
|
||||
/**
|
||||
* Handles properties/data collection, then passes the results to TaskbarView to render.
|
||||
*/
|
||||
public class TaskbarViewController implements TaskbarControllers.LoggableTaskbarController {
|
||||
public class TaskbarViewController implements TaskbarControllers.LoggableTaskbarController,
|
||||
BubbleBarController.BubbleBarLocationListener {
|
||||
|
||||
private static final String TAG = "TaskbarViewController";
|
||||
|
||||
@@ -122,6 +129,14 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar
|
||||
private final AnimatedFloat mTaskbarIconTranslationXForPinning = new AnimatedFloat(
|
||||
this::updateTaskbarIconTranslationXForPinning);
|
||||
|
||||
private final AnimatedFloat mIconsTranslationXForNavbar = new AnimatedFloat(
|
||||
this::updateTranslationXForNavBar);
|
||||
|
||||
@Nullable
|
||||
private Animator mTaskbarShiftXAnim;
|
||||
@Nullable
|
||||
private BubbleBarLocation mCurrentBubbleBarLocation;
|
||||
|
||||
private final AnimatedFloat mTaskbarIconTranslationYForPinning = new AnimatedFloat(
|
||||
this::updateTranslationY);
|
||||
|
||||
@@ -226,6 +241,54 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar
|
||||
}
|
||||
}
|
||||
|
||||
/** Adjusts start aligned taskbar layout accordingly to the bubble bar position. */
|
||||
@Override
|
||||
public void onBubbleBarLocationUpdated(BubbleBarLocation location) {
|
||||
updateCurrentBubbleBarLocation(location);
|
||||
if (!shouldMoveTaskbarOnBubbleBarLocationUpdate()) return;
|
||||
cancelTaskbarShiftAnimation();
|
||||
// reset translation x, taskbar will position icons with the updated location
|
||||
mIconsTranslationXForNavbar.updateValue(0);
|
||||
mTaskbarView.onBubbleBarLocationUpdated(location);
|
||||
}
|
||||
|
||||
/** Animates start aligned taskbar accordingly to the bubble bar position. */
|
||||
@Override
|
||||
public void onBubbleBarLocationAnimated(BubbleBarLocation location) {
|
||||
if (!updateCurrentBubbleBarLocation(location)
|
||||
|| !shouldMoveTaskbarOnBubbleBarLocationUpdate()) {
|
||||
return;
|
||||
}
|
||||
cancelTaskbarShiftAnimation();
|
||||
float translationX = mTaskbarView.getTranslationXForBubbleBarPosition(location);
|
||||
mTaskbarShiftXAnim = createTaskbarIconsShiftAnimator(translationX);
|
||||
mTaskbarShiftXAnim.start();
|
||||
}
|
||||
|
||||
/** Updates the mCurrentBubbleBarLocation, returns {@code} true if location is updated. */
|
||||
private boolean updateCurrentBubbleBarLocation(BubbleBarLocation location) {
|
||||
if (mCurrentBubbleBarLocation == location || location == null) {
|
||||
return false;
|
||||
} else {
|
||||
mCurrentBubbleBarLocation = location;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/** Returns whether taskbar should be moved on the bubble bar location update. */
|
||||
private boolean shouldMoveTaskbarOnBubbleBarLocationUpdate() {
|
||||
return Flags.enableBubbleBarInPersistentTaskBar()
|
||||
&& mControllers.bubbleControllers.isPresent()
|
||||
&& mActivity.shouldStartAlignTaskbar()
|
||||
&& mActivity.isThreeButtonNav();
|
||||
}
|
||||
|
||||
private void cancelTaskbarShiftAnimation() {
|
||||
if (mTaskbarShiftXAnim != null) {
|
||||
mTaskbarShiftXAnim.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Announcement for Accessibility when Taskbar stashes/unstashes.
|
||||
*/
|
||||
@@ -459,6 +522,17 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar
|
||||
+ mTaskbarIconTranslationYForSpringOnStash);
|
||||
}
|
||||
|
||||
private void updateTranslationXForNavBar() {
|
||||
View[] iconViews = mTaskbarView.getIconViews();
|
||||
float translationX = mIconsTranslationXForNavbar.value;
|
||||
for (int iconIndex = 0; iconIndex < iconViews.length; iconIndex++) {
|
||||
View iconView = iconViews[iconIndex];
|
||||
MultiTranslateDelegate translateDelegate =
|
||||
((Reorderable) iconView).getTranslateDelegate();
|
||||
translateDelegate.getTranslationX(INDEX_NAV_BAR_ANIM).setValue(translationX);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes translation y for taskbar pinning.
|
||||
*/
|
||||
@@ -1017,4 +1091,12 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar
|
||||
public static void enableModelLoadingForTests(boolean enable) {
|
||||
sEnableModelLoadingForTests = enable;
|
||||
}
|
||||
|
||||
private ObjectAnimator createTaskbarIconsShiftAnimator(float translationX) {
|
||||
ObjectAnimator animator = mIconsTranslationXForNavbar.animateToValue(translationX);
|
||||
animator.setStartDelay(FADE_OUT_ANIM_POSITION_DURATION_MS);
|
||||
animator.setDuration(FADE_IN_ANIM_ALPHA_DURATION_MS);
|
||||
animator.setInterpolator(Interpolators.EMPHASIZED);
|
||||
return animator;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,6 +118,7 @@ public class BubbleBarController extends IBubblesListener.Stub {
|
||||
private Optional<BubbleStashedHandleViewController> mBubbleStashedHandleViewController;
|
||||
private BubblePinController mBubblePinController;
|
||||
private BubbleCreator mBubbleCreator;
|
||||
private BubbleBarLocationListener mBubbleBarLocationListener;
|
||||
|
||||
// Cache last sent top coordinate to avoid sending duplicate updates to shell
|
||||
private int mLastSentBubbleBarTop;
|
||||
@@ -176,6 +177,7 @@ public class BubbleBarController extends IBubblesListener.Stub {
|
||||
|
||||
/** Initializes controllers. */
|
||||
public void init(BubbleControllers bubbleControllers,
|
||||
BubbleBarLocationListener bubbleBarLocationListener,
|
||||
ImeVisibilityChecker imeVisibilityChecker) {
|
||||
mImeVisibilityChecker = imeVisibilityChecker;
|
||||
mBubbleBarViewController = bubbleControllers.bubbleBarViewController;
|
||||
@@ -183,6 +185,7 @@ public class BubbleBarController extends IBubblesListener.Stub {
|
||||
mBubbleStashedHandleViewController = bubbleControllers.bubbleStashedHandleViewController;
|
||||
mBubblePinController = bubbleControllers.bubblePinController;
|
||||
mBubbleCreator = bubbleControllers.bubbleCreator;
|
||||
mBubbleBarLocationListener = bubbleBarLocationListener;
|
||||
|
||||
bubbleControllers.runAfterInit(() -> {
|
||||
mBubbleBarViewController.setHiddenForBubbles(
|
||||
@@ -488,12 +491,16 @@ public class BubbleBarController extends IBubblesListener.Stub {
|
||||
private void updateBubbleBarLocationInternal(BubbleBarLocation location) {
|
||||
mBubbleBarViewController.setBubbleBarLocation(location);
|
||||
mBubbleStashController.setBubbleBarLocation(location);
|
||||
mBubbleBarLocationListener.onBubbleBarLocationUpdated(location);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void animateBubbleBarLocation(BubbleBarLocation bubbleBarLocation) {
|
||||
MAIN_EXECUTOR.execute(
|
||||
() -> mBubbleBarViewController.animateBubbleBarLocation(bubbleBarLocation));
|
||||
() -> {
|
||||
mBubbleBarViewController.animateBubbleBarLocation(bubbleBarLocation);
|
||||
mBubbleBarLocationListener.onBubbleBarLocationAnimated(bubbleBarLocation);
|
||||
});
|
||||
}
|
||||
|
||||
/** Notifies WMShell to show the expanded view. */
|
||||
@@ -518,4 +525,14 @@ public class BubbleBarController extends IBubblesListener.Stub {
|
||||
/** Whether the IME is visible. */
|
||||
boolean isImeVisible();
|
||||
}
|
||||
|
||||
/** Listener of {@link BubbleBarLocation} updates. */
|
||||
public interface BubbleBarLocationListener {
|
||||
|
||||
/** Called when {@link BubbleBarLocation} is animated, but change is not yet final. */
|
||||
void onBubbleBarLocationAnimated(BubbleBarLocation location);
|
||||
|
||||
/** Called when {@link BubbleBarLocation} is updated permanently. */
|
||||
void onBubbleBarLocationUpdated(BubbleBarLocation location);
|
||||
}
|
||||
}
|
||||
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright (C) 2024 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.
|
||||
*/
|
||||
|
||||
package com.android.launcher3.taskbar.bubbles
|
||||
|
||||
import com.android.launcher3.taskbar.bubbles.BubbleBarController.BubbleBarLocationListener
|
||||
import com.android.wm.shell.shared.bubbles.BubbleBarLocation
|
||||
|
||||
/** Composite implementation of [BubbleBarLocationListener] interface */
|
||||
class BubbleBarLocationCompositeListener(private val listeners: List<BubbleBarLocationListener>) :
|
||||
BubbleBarLocationListener {
|
||||
|
||||
constructor(vararg listeners: BubbleBarLocationListener) : this(listOf(*listeners))
|
||||
|
||||
override fun onBubbleBarLocationAnimated(location: BubbleBarLocation?) {
|
||||
listeners.forEach { it.onBubbleBarLocationAnimated(location) }
|
||||
}
|
||||
|
||||
override fun onBubbleBarLocationUpdated(location: BubbleBarLocation?) {
|
||||
listeners.forEach { it.onBubbleBarLocationUpdated(location) }
|
||||
}
|
||||
}
|
||||
@@ -27,6 +27,7 @@ import android.view.View
|
||||
import android.widget.FrameLayout
|
||||
import androidx.core.view.updateLayoutParams
|
||||
import com.android.launcher3.R
|
||||
import com.android.launcher3.taskbar.bubbles.BubbleBarController.BubbleBarLocationListener
|
||||
import com.android.launcher3.taskbar.bubbles.stashing.BubbleStashController
|
||||
import com.android.wm.shell.shared.bubbles.BaseBubblePinController
|
||||
import com.android.wm.shell.shared.bubbles.BubbleBarLocation
|
||||
@@ -42,12 +43,17 @@ class BubbleBarPinController(
|
||||
|
||||
private lateinit var bubbleBarViewController: BubbleBarViewController
|
||||
private lateinit var bubbleStashController: BubbleStashController
|
||||
private lateinit var bubbleBarLocationListener: BubbleBarLocationListener
|
||||
private var exclRectWidth: Float = 0f
|
||||
private var exclRectHeight: Float = 0f
|
||||
|
||||
private var dropTargetView: View? = null
|
||||
|
||||
fun init(bubbleControllers: BubbleControllers) {
|
||||
fun init(
|
||||
bubbleControllers: BubbleControllers,
|
||||
bubbleBarLocationListener: BubbleBarLocationListener
|
||||
) {
|
||||
this.bubbleBarLocationListener = bubbleBarLocationListener
|
||||
bubbleBarViewController = bubbleControllers.bubbleBarViewController
|
||||
bubbleStashController = bubbleControllers.bubbleStashController
|
||||
exclRectWidth = context.resources.getDimension(R.dimen.bubblebar_dismiss_zone_width)
|
||||
@@ -86,6 +92,7 @@ class BubbleBarPinController(
|
||||
|
||||
val bounds = bubbleBarViewController.bubbleBarBounds
|
||||
val horizontalMargin = bubbleBarViewController.horizontalMargin
|
||||
bubbleBarLocationListener.onBubbleBarLocationAnimated(location)
|
||||
dropTargetView?.updateLayoutParams<FrameLayout.LayoutParams> {
|
||||
width = bounds.width()
|
||||
height = bounds.height()
|
||||
|
||||
@@ -95,11 +95,11 @@ public class BubbleBarView extends FrameLayout {
|
||||
|
||||
private static final long FADE_OUT_ANIM_ALPHA_DURATION_MS = 50L;
|
||||
private static final long FADE_OUT_ANIM_ALPHA_DELAY_MS = 50L;
|
||||
private static final long FADE_OUT_ANIM_POSITION_DURATION_MS = 100L;
|
||||
public static final long FADE_OUT_ANIM_POSITION_DURATION_MS = 100L;
|
||||
// During fade out animation we shift the bubble bar 1/80th of the screen width
|
||||
private static final float FADE_OUT_ANIM_POSITION_SHIFT = 1 / 80f;
|
||||
|
||||
private static final long FADE_IN_ANIM_ALPHA_DURATION_MS = 100L;
|
||||
public static final long FADE_IN_ANIM_ALPHA_DURATION_MS = 100L;
|
||||
// Use STIFFNESS_MEDIUMLOW which is not defined in the API constants
|
||||
private static final float FADE_IN_ANIM_POSITION_SPRING_STIFFNESS = 400f;
|
||||
// During fade in animation we shift the bubble bar 1/60th of the screen width
|
||||
|
||||
@@ -76,7 +76,14 @@ public class BubbleControllers {
|
||||
* in constructors for now, as some controllers may still be waiting for init().
|
||||
*/
|
||||
public void init(TaskbarControllers taskbarControllers) {
|
||||
// TODO(b/346381754) add TaskbarLauncherStateController implementation to adjust the hotseat
|
||||
BubbleBarLocationCompositeListener bubbleBarLocationListeners =
|
||||
new BubbleBarLocationCompositeListener(
|
||||
taskbarControllers.navbarButtonsViewController,
|
||||
taskbarControllers.taskbarViewController
|
||||
);
|
||||
bubbleBarController.init(this,
|
||||
bubbleBarLocationListeners,
|
||||
taskbarControllers.navbarButtonsViewController::isImeVisible);
|
||||
bubbleStashedHandleViewController.ifPresent(
|
||||
controller -> controller.init(/* bubbleControllers = */ this));
|
||||
@@ -102,7 +109,7 @@ public class BubbleControllers {
|
||||
});
|
||||
bubbleDragController.init(/* bubbleControllers = */ this);
|
||||
bubbleDismissController.init(/* bubbleControllers = */ this);
|
||||
bubbleBarPinController.init(this);
|
||||
bubbleBarPinController.init(this, bubbleBarLocationListeners);
|
||||
bubblePinController.init(this);
|
||||
|
||||
mPostInitRunnables.executeAllAndDestroy();
|
||||
|
||||
@@ -37,6 +37,7 @@ public class MultiTranslateDelegate {
|
||||
public static final int INDEX_TASKBAR_ALIGNMENT_ANIM = 3;
|
||||
public static final int INDEX_TASKBAR_REVEAL_ANIM = 4;
|
||||
public static final int INDEX_TASKBAR_PINNING_ANIM = 5;
|
||||
public static final int INDEX_NAV_BAR_ANIM = 6;
|
||||
|
||||
// Affect all items inside of a MultipageCellLayout
|
||||
public static final int INDEX_CELLAYOUT_MULTIPAGE_SPACING = 3;
|
||||
@@ -47,7 +48,7 @@ public class MultiTranslateDelegate {
|
||||
// Specific for hotseat items when adjusting for bubbles
|
||||
public static final int INDEX_BUBBLE_ADJUSTMENT_ANIM = 3;
|
||||
|
||||
public static final int COUNT = 6;
|
||||
public static final int COUNT = 7;
|
||||
|
||||
private final MultiPropertyFactory<View> mTranslationX;
|
||||
private final MultiPropertyFactory<View> mTranslationY;
|
||||
|
||||
Reference in New Issue
Block a user