From 3ea1acb8ca36571bdf42b441477ad8e460148a1f Mon Sep 17 00:00:00 2001 From: Oli Thompson Date: Mon, 13 May 2024 11:06:50 +0000 Subject: [PATCH 1/3] Show edu card when managed profile removed Reset the work edu card bit so the edu card shows if the managed profile is removed Also remove padding from the close button so it doesn't clip. screenshot https://screenshot.googleplex.com/96Yc6yExZ57btxG Bug: 315449027 Bug: 293642345 Test: manual Flag: NONE Change-Id: I60cfc0c258d28a6674aec41862c1770550a14955 --- res/layout/work_apps_edu.xml | 2 +- res/values/dimens.xml | 1 - src/com/android/launcher3/LauncherModel.java | 4 ++++ src/com/android/launcher3/pm/UserCache.java | 1 + 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/res/layout/work_apps_edu.xml b/res/layout/work_apps_edu.xml index f557fb695c..99db8c6f41 100644 --- a/res/layout/work_apps_edu.xml +++ b/res/layout/work_apps_edu.xml @@ -50,9 +50,9 @@ android:id="@+id/action_btn" android:layout_width="@dimen/x_icon_size" android:layout_height="@dimen/x_icon_size" + android:scaleType="centerInside" android:layout_gravity="center" android:contentDescription="@string/accessibility_close" - android:padding="@dimen/x_icon_padding" android:background="@android:color/transparent" android:src="@drawable/ic_remove_no_shadow" /> diff --git a/res/values/dimens.xml b/res/values/dimens.xml index 54edab469f..a75c989e7b 100644 --- a/res/values/dimens.xml +++ b/res/values/dimens.xml @@ -167,7 +167,6 @@ 24dp 16dp - 4dp 48dp diff --git a/src/com/android/launcher3/LauncherModel.java b/src/com/android/launcher3/LauncherModel.java index e3da38937d..47a71152e0 100644 --- a/src/com/android/launcher3/LauncherModel.java +++ b/src/com/android/launcher3/LauncherModel.java @@ -19,6 +19,7 @@ package com.android.launcher3; import static android.app.admin.DevicePolicyManager.ACTION_DEVICE_POLICY_RESOURCE_UPDATED; import static com.android.launcher3.LauncherAppState.ACTION_FORCE_ROLOAD; +import static com.android.launcher3.LauncherPrefs.WORK_EDU_STEP; import static com.android.launcher3.config.FeatureFlags.IS_STUDIO_BUILD; import static com.android.launcher3.icons.cache.BaseIconCache.EMPTY_CLASS_NAME; import static com.android.launcher3.model.PackageUpdatedTask.OP_UPDATE; @@ -276,6 +277,9 @@ public class LauncherModel implements InstallSessionTracker.Callback { enqueueModelUpdateTask(new PackageUpdatedTask( PackageUpdatedTask.OP_USER_AVAILABILITY_CHANGE, user)); } + if (Intent.ACTION_MANAGED_PROFILE_REMOVED.equals(action)) { + LauncherPrefs.get(mApp.getContext()).put(WORK_EDU_STEP, 0); + } } /** diff --git a/src/com/android/launcher3/pm/UserCache.java b/src/com/android/launcher3/pm/UserCache.java index b7b557dbd4..ed25186da4 100644 --- a/src/com/android/launcher3/pm/UserCache.java +++ b/src/com/android/launcher3/pm/UserCache.java @@ -101,6 +101,7 @@ public class UserCache implements SafeCloseable { mUserChangeReceiver.register(mContext, Intent.ACTION_MANAGED_PROFILE_AVAILABLE, Intent.ACTION_MANAGED_PROFILE_UNAVAILABLE, + Intent.ACTION_MANAGED_PROFILE_REMOVED, ACTION_PROFILE_ADDED, ACTION_PROFILE_REMOVED, ACTION_PROFILE_UNLOCKED, From b17af6ff7544ff9a93a17c84f82c2d9abba99224 Mon Sep 17 00:00:00 2001 From: Tracy Zhou Date: Thu, 16 May 2024 21:35:44 -0700 Subject: [PATCH 2/3] Set inset in phone setup mode to setup inset - In phone setup mode, gesture mode is no button but the inset we report should be setup inset Fixes: 340998601 Test: https://screenshot.googleplex.com/8Q4WHorpUeqWSjw Change-Id: I84d60ecc7179008e80e7b09eda5b3a1abb24e138 --- .../android/launcher3/taskbar/TaskbarStashController.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java index 1a3c497be7..74d2d60014 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java @@ -424,14 +424,15 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba * @see android.view.WindowInsets.Type#systemBars() */ public int getContentHeightToReportToApps() { - if ((mActivity.isPhoneMode() && !mActivity.isThreeButtonNav()) - || DisplayController.isTransientTaskbar(mActivity)) { + if (mActivity.isUserSetupComplete() && (mActivity.isPhoneGestureNavMode() + || DisplayController.isTransientTaskbar(mActivity))) { return getStashedHeight(); } if (supportsVisualStashing() && hasAnyFlag(FLAGS_REPORT_STASHED_INSETS_TO_APP)) { DeviceProfile dp = mActivity.getDeviceProfile(); - if (hasAnyFlag(FLAG_STASHED_IN_APP_SETUP) && dp.isTaskbarPresent) { + if (hasAnyFlag(FLAG_STASHED_IN_APP_SETUP) && (dp.isTaskbarPresent + || mActivity.isPhoneGestureNavMode())) { // We always show the back button in SUW but in portrait the SUW layout may not // be wide enough to support overlapping the nav bar with its content. // We're sending different res values in portrait vs landscape From b34f8c88315d9e685f0b281ec3e68096aca7a138 Mon Sep 17 00:00:00 2001 From: Ats Jenk Date: Mon, 13 May 2024 16:41:49 -0700 Subject: [PATCH 3/3] Only send bubble bar top coordinate to shell Stop sending entire bubble bar bounds to shell. Keeping the bounds in sync was error prone as bubble bar can expand and collapse. Bubbles can be added/removed. In each of these cases we had to make sure that shell gets updated. Shell only needed the full bounds for collapse/expand animation. But after updating the animation, shell only needs the top coordinate of the bubble bar. Bug: 330585402 Flag: com.android.wm.shell.enable_bubble_bar Test: bubble bar drag - drag bar from right to left - expand the bar - check that expanded view scales in from left edge - collapse and drag bar back, check the animation Test: selected bubble drag - drag expanded bubble from right to left - check that expanded view scales in from the left edge - drag the bubble back to right, check animation Test: other bubble drag - drag a unselected bubble from right to left - check that the selected bubble expands in from left edge - drag the bubble back to right, check animation again Test: drag bubble from right to left, observe that expanded view expand animation originates from the bubble bar Change-Id: Ib66cef8d3c04bce54a69e30e99edd408a31f018f --- .../taskbar/bubbles/BubbleBarController.java | 51 ++++--------------- .../taskbar/bubbles/BubbleBarView.java | 10 ++++ .../bubbles/BubbleBarViewController.java | 23 +++------ .../taskbar/bubbles/BubbleDragController.java | 8 +-- .../com/android/quickstep/SystemUiProxy.java | 23 +++++---- 5 files changed, 44 insertions(+), 71 deletions(-) diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarController.java b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarController.java index 46c2e25c62..046f5b6afe 100644 --- a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarController.java +++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarController.java @@ -31,8 +31,6 @@ import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_Q import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_STATUS_BAR_KEYGUARD_SHOWING; import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_STATUS_BAR_KEYGUARD_SHOWING_OCCLUDED; -import static java.lang.Math.abs; - import android.annotation.BinderThread; import android.annotation.Nullable; import android.app.Notification; @@ -47,7 +45,6 @@ import android.graphics.Color; import android.graphics.Matrix; import android.graphics.Path; import android.graphics.Point; -import android.graphics.Rect; import android.graphics.drawable.AdaptiveIconDrawable; import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; @@ -67,7 +64,6 @@ import com.android.launcher3.R; import com.android.launcher3.icons.BitmapInfo; import com.android.launcher3.icons.BubbleIconFactory; import com.android.launcher3.shortcuts.ShortcutRequest; -import com.android.launcher3.util.DisplayController; import com.android.launcher3.util.Executors.SimpleThreadFactory; import com.android.quickstep.SystemUiProxy; import com.android.systemui.shared.system.QuickStepContract.SystemUiStateFlags; @@ -153,8 +149,8 @@ public class BubbleBarController extends IBubblesListener.Stub { private BubbleStashedHandleViewController mBubbleStashedHandleViewController; private BubblePinController mBubblePinController; - // Keep track of bubble bar bounds sent to shell to avoid sending duplicate updates - private final Rect mLastSentBubbleBarBounds = new Rect(); + // Cache last sent top coordinate to avoid sending duplicate updates to shell + private int mLastSentBubbleBarTop; /** * Similar to {@link BubbleBarUpdate} but rather than {@link BubbleInfo}s it uses @@ -445,9 +441,8 @@ public class BubbleBarController extends IBubblesListener.Stub { info.getFlags() | Notification.BubbleMetadata.FLAG_SUPPRESS_NOTIFICATION); mSelectedBubble.getView().updateDotVisibility(true /* animate */); } - Rect bounds = getExpandedBubbleBarDisplayBounds(); - mLastSentBubbleBarBounds.set(bounds); - mSystemUiProxy.showBubble(getSelectedBubbleKey(), bounds); + mLastSentBubbleBarTop = mBarView.getRestingTopPositionOnScreen(); + mSystemUiProxy.showBubble(getSelectedBubbleKey(), mLastSentBubbleBarTop); } else { Log.w(TAG, "Trying to show the selected bubble but it's null"); } @@ -636,42 +631,14 @@ public class BubbleBarController extends IBubblesListener.Stub { return mIconFactory.createBadgedIconBitmap(drawable).icon; } - private void onBubbleBarBoundsChanged(Rect newBounds) { - Rect displayBounds = convertToDisplayBounds(newBounds); - // Only send bounds over if they changed - if (!displayBounds.equals(mLastSentBubbleBarBounds)) { - mLastSentBubbleBarBounds.set(displayBounds); - mSystemUiProxy.setBubbleBarBounds(displayBounds); + private void onBubbleBarBoundsChanged() { + int newTop = mBarView.getRestingTopPositionOnScreen(); + if (newTop != mLastSentBubbleBarTop) { + mLastSentBubbleBarTop = newTop; + mSystemUiProxy.updateBubbleBarTopOnScreen(newTop); } } - /** - * Get bounds of the bubble bar as if it would be expanded. - * Calculates the bounds instead of retrieving current view location as the view may be - * animating. - */ - private Rect getExpandedBubbleBarDisplayBounds() { - return convertToDisplayBounds(mBarView.getBubbleBarBounds()); - } - - private Rect convertToDisplayBounds(Rect currentBarBounds) { - Point displaySize = DisplayController.INSTANCE.get(mContext).getInfo().currentSize; - Rect displayBounds = new Rect(); - // currentBarBounds is only useful for distance from left or right edge. - // It contains the current bounds, calculate the expanded bounds. - if (mBarView.getBubbleBarLocation().isOnLeft(mBarView.isLayoutRtl())) { - displayBounds.left = currentBarBounds.left; - displayBounds.right = (int) (currentBarBounds.left + mBarView.expandedWidth()); - } else { - displayBounds.left = (int) (currentBarBounds.right - mBarView.expandedWidth()); - displayBounds.right = currentBarBounds.right; - } - final int translation = (int) abs(mBubbleStashController.getBubbleBarTranslationY()); - displayBounds.top = displaySize.y - currentBarBounds.height() - translation; - displayBounds.bottom = displaySize.y - translation; - return displayBounds; - } - /** Interface for checking whether the IME is visible. */ public interface ImeVisibilityChecker { /** Whether the IME is visible. */ diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java index f3ac1e44ba..b8501c32f9 100644 --- a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java +++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java @@ -43,6 +43,7 @@ import androidx.dynamicanimation.animation.SpringForce; import com.android.launcher3.R; import com.android.launcher3.anim.SpringAnimationBuilder; +import com.android.launcher3.util.DisplayController; import com.android.wm.shell.common.bubbles.BubbleBarLocation; import java.util.List; @@ -550,6 +551,15 @@ public class BubbleBarView extends FrameLayout { setAlpha(1f); } + /** + * Get bubble bar top coordinate on screen when bar is resting + */ + public int getRestingTopPositionOnScreen() { + int displayHeight = DisplayController.INSTANCE.get(getContext()).getInfo().currentSize.y; + int bubbleBarHeight = getBubbleBarBounds().height(); + return displayHeight - bubbleBarHeight + (int) mController.getBubbleBarTranslationY(); + } + /** * Updates the bounds with translation that may have been applied and returns the result. */ diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java index 5f75b3b616..f614dc66ea 100644 --- a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java +++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java @@ -93,8 +93,6 @@ public class BubbleBarViewController { @Nullable private BubbleBarBoundsChangeListener mBoundsChangeListener; - private final Rect mPreviousBubbleBarBounds = new Rect(); - public BubbleBarViewController(TaskbarActivityContext activity, BubbleBarView barView) { mActivity = activity; mBarView = barView; @@ -122,12 +120,8 @@ public class BubbleBarViewController { mBarView.addOnLayoutChangeListener( (v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) -> { mTaskbarInsetsController.onTaskbarOrBubblebarWindowHeightOrInsetsChanged(); - Rect bubbleBarBounds = mBarView.getBubbleBarBounds(); - if (!bubbleBarBounds.equals(mPreviousBubbleBarBounds)) { - mPreviousBubbleBarBounds.set(bubbleBarBounds); - if (mBoundsChangeListener != null) { - mBoundsChangeListener.onBoundsChanged(bubbleBarBounds); - } + if (mBoundsChangeListener != null) { + mBoundsChangeListener.onBoundsChanged(); } }); @@ -497,7 +491,7 @@ public class BubbleBarViewController { * that a bubble is being dragged to dismiss. * @param bubbleView dragged bubble view */ - public void onDragStart(@NonNull BubbleView bubbleView) { + public void onBubbleDragStart(@NonNull BubbleView bubbleView) { if (bubbleView.getBubble() == null) return; mSystemUiProxy.startBubbleDrag(bubbleView.getBubble().getKey()); @@ -507,20 +501,19 @@ public class BubbleBarViewController { /** * Notifies SystemUI to expand the selected bubble when the bubble is released. */ - public void onDragRelease(BubbleBarLocation location) { - // TODO(b/330585402): send new bubble bar bounds to shell for the animation - mSystemUiProxy.stopBubbleDrag(location); + public void onBubbleDragRelease(BubbleBarLocation location) { + mSystemUiProxy.stopBubbleDrag(location, mBarView.getRestingTopPositionOnScreen()); } /** * Notifies {@link BubbleBarView} that drag and all animations are finished. */ - public void onDragBubbleEnded() { + public void onBubbleDragEnd() { mBarView.setDraggedBubble(null); } /** Notifies that dragging the bubble bar ended. */ - public void onDragBubbleBarEnded() { + public void onBubbleBarDragEnd() { // we may have changed the bubble bar translation Y value from the value it had at the // beginning of the drag, so update the translation Y animator state mBubbleBarTranslationY.updateValue(mBarView.getTranslationY()); @@ -576,6 +569,6 @@ public class BubbleBarViewController { */ public interface BubbleBarBoundsChangeListener { /** Called when bounds have changed */ - void onBoundsChanged(Rect newBounds); + void onBoundsChanged(); } } diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleDragController.java b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleDragController.java index 604ae89284..2ebc3e84c4 100644 --- a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleDragController.java +++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleDragController.java @@ -97,7 +97,7 @@ public class BubbleDragController { @Override void onDragStart() { mBubblePinController.setListener(mLocationChangeListener); - mBubbleBarViewController.onDragStart(bubbleView); + mBubbleBarViewController.onBubbleDragStart(bubbleView); mBubblePinController.onDragStart( mBubbleBarViewController.getBubbleBarLocation().isOnLeft( bubbleView.isLayoutRtl())); @@ -113,7 +113,7 @@ public class BubbleDragController { @Override protected void onDragRelease() { mBubblePinController.onDragEnd(); - mBubbleBarViewController.onDragRelease(mReleasedLocation); + mBubbleBarViewController.onBubbleDragRelease(mReleasedLocation); } @Override @@ -124,7 +124,7 @@ public class BubbleDragController { @Override void onDragEnd() { mBubbleBarController.updateBubbleBarLocation(mReleasedLocation); - mBubbleBarViewController.onDragBubbleEnded(); + mBubbleBarViewController.onBubbleDragEnd(); mBubblePinController.setListener(null); } @@ -192,7 +192,7 @@ public class BubbleDragController { bubbleBarView.setIsDragging(false); // Restoring the initial pivot for the bubble bar view bubbleBarView.setRelativePivot(initialRelativePivot.x, initialRelativePivot.y); - mBubbleBarViewController.onDragBubbleBarEnded(); + mBubbleBarViewController.onBubbleBarDragEnd(); mBubbleBarPinController.setListener(null); } diff --git a/quickstep/src/com/android/quickstep/SystemUiProxy.java b/quickstep/src/com/android/quickstep/SystemUiProxy.java index da1d322f3d..0ac3ec7074 100644 --- a/quickstep/src/com/android/quickstep/SystemUiProxy.java +++ b/quickstep/src/com/android/quickstep/SystemUiProxy.java @@ -761,12 +761,12 @@ public class SystemUiProxy implements ISystemUiProxy, NavHandle, SafeCloseable { /** * Tells SysUI to show the bubble with the provided key. * @param key the key of the bubble to show. - * @param bubbleBarBounds bounds of the bubble bar in display coordinates + * @param top top coordinate of bubble bar on screen */ - public void showBubble(String key, Rect bubbleBarBounds) { + public void showBubble(String key, int top) { if (mBubbles != null) { try { - mBubbles.showBubble(key, bubbleBarBounds); + mBubbles.showBubble(key, top); } catch (RemoteException e) { Log.w(TAG, "Failed call showBubble"); } @@ -815,12 +815,14 @@ public class SystemUiProxy implements ISystemUiProxy, NavHandle, SafeCloseable { /** * Tells SysUI when the bubble stops being dragged. * Should be called only when the bubble bar is expanded. + * * @param location location of the bubble bar + * @param top new top coordinate for bubble bar on screen */ - public void stopBubbleDrag(BubbleBarLocation location) { + public void stopBubbleDrag(BubbleBarLocation location, int top) { if (mBubbles == null) return; try { - mBubbles.stopBubbleDrag(location); + mBubbles.stopBubbleDrag(location, top); } catch (RemoteException e) { Log.w(TAG, "Failed call stopBubbleDrag"); } @@ -864,16 +866,17 @@ public class SystemUiProxy implements ISystemUiProxy, NavHandle, SafeCloseable { } /** - * Tells SysUI the bounds for the bubble bar - * @param bubbleBarBounds bounds of the bubble bar in display coordinates + * Tells SysUI the top coordinate of bubble bar on screen + * + * @param topOnScreen top coordinate for bubble bar on screen */ - public void setBubbleBarBounds(Rect bubbleBarBounds) { + public void updateBubbleBarTopOnScreen(int topOnScreen) { try { if (mBubbles != null) { - mBubbles.setBubbleBarBounds(bubbleBarBounds); + mBubbles.updateBubbleBarTopOnScreen(topOnScreen); } } catch (RemoteException e) { - Log.w(TAG, "Failed call setBubbleBarBounds"); + Log.w(TAG, "Failed call updateBubbleBarTopOnScreen"); } }