Merge "Add transient taskbar UI" into tm-qpr-dev am: 661f38cdb8 am: e095ae843f

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/20197462

Change-Id: I5b170eca6e19ce8e771d3dea7994cb6b3750e2a1
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Jon Miranda
2022-10-26 15:59:32 +00:00
committed by Automerger Merge Worker
15 changed files with 260 additions and 35 deletions
@@ -110,6 +110,7 @@ import com.android.launcher3.testing.shared.ResourceUtils;
import com.android.launcher3.touch.PagedOrientationHandler;
import com.android.launcher3.uioverrides.QuickstepLauncher;
import com.android.launcher3.util.ActivityOptionsWrapper;
import com.android.launcher3.util.DisplayController;
import com.android.launcher3.util.DynamicResource;
import com.android.launcher3.util.ObjectWrapper;
import com.android.launcher3.util.RunnableList;
@@ -452,7 +453,9 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener
4 - rotationChange);
}
}
if (mDeviceProfile.isTaskbarPresentInApps && !target.willShowImeOnTarget) {
if (mDeviceProfile.isTaskbarPresentInApps
&& !target.willShowImeOnTarget
&& !DisplayController.isTransientTaskbar(mLauncher)) {
// Animate to above the taskbar.
bounds.bottom -= target.contentInsets.bottom;
}
@@ -44,6 +44,7 @@ import com.android.launcher3.logging.InstanceIdSequence;
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.model.data.ItemInfoWithIcon;
import com.android.launcher3.uioverrides.QuickstepLauncher;
import com.android.launcher3.util.DisplayController;
import com.android.launcher3.util.OnboardingPrefs;
import com.android.quickstep.AnimatedFloat;
import com.android.quickstep.RecentsAnimationCallbacks;
@@ -227,7 +228,9 @@ public class LauncherTaskbarUIController extends TaskbarUIController {
} else {
// Adjust task transition spec to account for taskbar being visible
@ColorInt int taskAnimationBackgroundColor =
mLauncher.getColor(R.color.taskbar_background);
DisplayController.isTransientTaskbar(mLauncher)
? mLauncher.getColor(R.color.transient_taskbar_background)
: mLauncher.getColor(R.color.taskbar_background);
TaskTransitionSpec customTaskAnimationSpec = new TaskTransitionSpec(
taskAnimationBackgroundColor,
@@ -286,6 +289,10 @@ public class LauncherTaskbarUIController extends TaskbarUIController {
@Override
public void setSystemGestureInProgress(boolean inProgress) {
super.setSystemGestureInProgress(inProgress);
if (DisplayController.isTransientTaskbar(mLauncher)) {
forceHideBackground(false);
return;
}
if (!FeatureFlags.ENABLE_TASKBAR_IN_OVERVIEW.get()) {
// Launcher's ScrimView will draw the background throughout the gesture. But once the
// gesture ends, start drawing taskbar's background again since launcher might stop
@@ -135,14 +135,16 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
private boolean mBindingItems = false;
private boolean mAddedWindow = false;
// The bounds of the taskbar items relative to TaskbarDragLayer
private final Rect mTransientTaskbarBounds = new Rect();
private final TaskbarShortcutMenuAccessibilityDelegate mAccessibilityDelegate;
public TaskbarActivityContext(Context windowContext, DeviceProfile dp,
public TaskbarActivityContext(Context windowContext, DeviceProfile launcherDp,
TaskbarNavButtonController buttonController, ScopedUnfoldTransitionProgressProvider
unfoldTransitionProgressProvider) {
super(windowContext);
mDeviceProfile = dp.copy(this);
mDeviceProfile = launcherDp.copy(this);
final Resources resources = getResources();
@@ -173,8 +175,10 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
mRightCorner = display.getRoundedCorner(RoundedCorner.POSITION_BOTTOM_RIGHT);
// Inflate views.
mDragLayer = (TaskbarDragLayer) mLayoutInflater.inflate(
R.layout.taskbar, null, false);
int taskbarLayout = DisplayController.isTransientTaskbar(this)
? R.layout.transient_taskbar
: R.layout.taskbar;
mDragLayer = (TaskbarDragLayer) mLayoutInflater.inflate(taskbarLayout, null, false);
TaskbarView taskbarView = mDragLayer.findViewById(R.id.taskbar_view);
TaskbarScrimView taskbarScrimView = mDragLayer.findViewById(R.id.taskbar_scrim);
FrameLayout navButtonsView = mDragLayer.findViewById(R.id.navbuttons_view);
@@ -213,7 +217,7 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
new TaskbarAutohideSuspendController(this),
new TaskbarPopupController(this),
new TaskbarForceVisibleImmersiveController(this),
new TaskbarOverlayController(this, dp),
new TaskbarOverlayController(this, launcherDp),
new TaskbarAllAppsController(),
new TaskbarInsetsController(this),
new VoiceInteractionWindowController(this),
@@ -244,10 +248,10 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
}
/** Updates {@link DeviceProfile} instances for any Taskbar windows. */
public void updateDeviceProfile(DeviceProfile dp, NavigationMode navMode) {
public void updateDeviceProfile(DeviceProfile launcherDp, NavigationMode navMode) {
mNavMode = navMode;
mControllers.taskbarOverlayController.updateDeviceProfile(dp);
mDeviceProfile = dp.copy(this);
mControllers.taskbarOverlayController.updateLauncherDeviceProfile(launcherDp);
mDeviceProfile = launcherDp.copy(this);
updateIconSize(getResources());
AbstractFloatingView.closeAllOpenViewsExcept(this, false, TYPE_REBIND_SAFE);
@@ -258,12 +262,21 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
}
private void updateIconSize(Resources resources) {
float taskbarIconSize = resources.getDimension(R.dimen.taskbar_icon_size);
float taskbarIconSize = DisplayController.isTransientTaskbar(this)
? resources.getDimension(R.dimen.transient_taskbar_icon_size)
: resources.getDimension(R.dimen.taskbar_icon_size);
mDeviceProfile.updateIconSize(1, resources);
float iconScale = taskbarIconSize / mDeviceProfile.iconSizePx;
mDeviceProfile.updateIconSize(iconScale, resources);
}
/**
* Returns the View bounds of transient taskbar.
*/
public Rect getTransientTaskbarBounds() {
return mTransientTaskbarBounds;
}
@VisibleForTesting
@Override
public StatsLogManager getStatsLogManager() {
@@ -624,16 +637,24 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
* Returns the default height of the window, including the static corner radii above taskbar.
*/
public int getDefaultTaskbarWindowHeight() {
Resources resources = getResources();
if (FLAG_HIDE_NAVBAR_WINDOW && mDeviceProfile.isPhone) {
Resources resources = getResources();
return isThreeButtonNav() ?
resources.getDimensionPixelSize(R.dimen.taskbar_size) :
resources.getDimensionPixelSize(R.dimen.taskbar_stashed_size);
}
if (!isUserSetupComplete()) {
return getResources().getDimensionPixelSize(R.dimen.taskbar_suw_frame);
return resources.getDimensionPixelSize(R.dimen.taskbar_suw_frame);
}
if (DisplayController.isTransientTaskbar(this)) {
return resources.getDimensionPixelSize(R.dimen.transient_taskbar_size)
+ (2 * resources.getDimensionPixelSize(R.dimen.transient_taskbar_margin))
+ resources.getDimensionPixelSize(R.dimen.transient_taskbar_shadow_blur);
}
return mDeviceProfile.taskbarSize + Math.max(getLeftCornerRadius(), getRightCornerRadius());
}
@@ -16,10 +16,16 @@
package com.android.launcher3.taskbar
import com.android.launcher3.icons.GraphicsUtils.setColorAlphaBound
import com.android.launcher3.Utilities.mapToRange
import android.graphics.Canvas
import android.graphics.Color
import android.graphics.Paint
import android.graphics.Path
import com.android.launcher3.R
import com.android.launcher3.anim.Interpolators
import com.android.launcher3.util.DisplayController
/**
* Helps draw the taskbar background, made up of a rectangle plus two inverted rounded corners.
@@ -29,6 +35,13 @@ class TaskbarBackgroundRenderer(context: TaskbarActivityContext) {
val paint: Paint = Paint()
var backgroundHeight = context.deviceProfile.taskbarSize.toFloat()
private var maxBackgroundHeight = context.deviceProfile.taskbarSize.toFloat()
private val transientBackgroundBounds = context.transientTaskbarBounds
private var shadowBlur = 0f
private var keyShadowDistance = 0f
private var bottomMargin = 0
private val leftCornerRadius = context.leftCornerRadius.toFloat()
private val rightCornerRadius = context.rightCornerRadius.toFloat()
private val invertedLeftCornerPath: Path = Path()
@@ -39,6 +52,15 @@ class TaskbarBackgroundRenderer(context: TaskbarActivityContext) {
paint.flags = Paint.ANTI_ALIAS_FLAG
paint.style = Paint.Style.FILL
if (DisplayController.isTransientTaskbar(context)) {
paint.color = context.getColor(R.color.transient_taskbar_background)
val res = context.resources
bottomMargin = res.getDimensionPixelSize(R.dimen.transient_taskbar_margin)
shadowBlur = res.getDimension(R.dimen.transient_taskbar_shadow_blur)
keyShadowDistance = res.getDimension(R.dimen.transient_taskbar_key_shadow_distance)
}
// Create the paths for the inverted rounded corners above the taskbar. Start with a filled
// square, and then subtract out a circle from the appropriate corner.
val square = Path()
@@ -58,17 +80,42 @@ class TaskbarBackgroundRenderer(context: TaskbarActivityContext) {
*/
fun draw(canvas: Canvas) {
canvas.save()
canvas.translate(0f, canvas.height - backgroundHeight)
canvas.translate(0f, canvas.height - backgroundHeight - bottomMargin)
if (transientBackgroundBounds.isEmpty) {
// Draw the background behind taskbar content.
canvas.drawRect(0f, 0f, canvas.width.toFloat(), backgroundHeight, paint)
// Draw the background behind taskbar content.
canvas.drawRect(0f, 0f, canvas.width.toFloat(), backgroundHeight, paint)
// Draw the inverted rounded corners above the taskbar.
canvas.translate(0f, -leftCornerRadius)
canvas.drawPath(invertedLeftCornerPath, paint)
canvas.translate(0f, leftCornerRadius)
canvas.translate(canvas.width - rightCornerRadius, -rightCornerRadius)
canvas.drawPath(invertedRightCornerPath, paint)
} else {
val scaleFactor = backgroundHeight / maxBackgroundHeight
val width = transientBackgroundBounds.width()
val widthScale = mapToRange(scaleFactor, 0f, 1f, 0.4f, 1f, Interpolators.LINEAR)
val newWidth = widthScale * width
val delta = width - newWidth
// Draw the inverted rounded corners above the taskbar.
canvas.translate(0f, -leftCornerRadius)
canvas.drawPath(invertedLeftCornerPath, paint)
canvas.translate(0f, leftCornerRadius)
canvas.translate(canvas.width - rightCornerRadius, -rightCornerRadius)
canvas.drawPath(invertedRightCornerPath, paint)
// Draw shadow.
val shadowAlpha = mapToRange(paint.alpha.toFloat(), 0f, 255f, 0f, 25f,
Interpolators.LINEAR)
paint.setShadowLayer(shadowBlur, 0f, keyShadowDistance,
setColorAlphaBound(Color.BLACK, Math.round(shadowAlpha))
)
// Draw background.
val radius = backgroundHeight / 2f;
canvas.drawRoundRect(
transientBackgroundBounds.left + (delta / 2f),
0f,
transientBackgroundBounds.right - (delta / 2f),
backgroundHeight,
radius, radius, paint
)
}
canvas.restore()
}
@@ -45,6 +45,7 @@ import com.android.launcher3.icons.ThemedIconDrawable;
import com.android.launcher3.model.data.FolderInfo;
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.model.data.WorkspaceItemInfo;
import com.android.launcher3.util.DisplayController;
import com.android.launcher3.util.LauncherBindableItemsContainer;
import com.android.launcher3.views.ActivityContext;
import com.android.launcher3.views.DoubleShadowBubbleTextView;
@@ -61,7 +62,7 @@ public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconPar
public int mThemeIconsBackground;
private final int[] mTempOutLocation = new int[2];
private final Rect mIconLayoutBounds = new Rect();
private final Rect mIconLayoutBounds;
private final int mIconTouchSize;
private final int mItemMarginLeftRight;
private final int mItemPadding;
@@ -107,11 +108,14 @@ public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconPar
int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
mActivityContext = ActivityContext.lookupContext(context);
mIconLayoutBounds = mActivityContext.getTransientTaskbarBounds();
Resources resources = getResources();
mIconTouchSize = resources.getDimensionPixelSize(R.dimen.taskbar_icon_touch_size);
int actualMargin = resources.getDimensionPixelSize(R.dimen.taskbar_icon_spacing);
int actualMargin = DisplayController.isTransientTaskbar(mActivityContext)
? resources.getDimensionPixelSize(R.dimen.transient_taskbar_icon_spacing)
: resources.getDimensionPixelSize(R.dimen.taskbar_icon_spacing);
int actualIconSize = mActivityContext.getDeviceProfile().iconSizePx;
// We layout the icons to be of mIconTouchSize in width and height
@@ -17,6 +17,7 @@ package com.android.launcher3.taskbar;
import static com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY;
import static com.android.launcher3.LauncherAnimUtils.VIEW_ALPHA;
import static com.android.launcher3.LauncherAnimUtils.VIEW_TRANSLATE_Y;
import static com.android.launcher3.Utilities.squaredHypot;
import static com.android.launcher3.anim.Interpolators.LINEAR;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TASKBAR_ALLAPPS_BUTTON_TAP;
@@ -47,6 +48,7 @@ import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.folder.FolderIcon;
import com.android.launcher3.icons.ThemedIconDrawable;
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.util.DisplayController;
import com.android.launcher3.util.HorizontalInsettableView;
import com.android.launcher3.util.ItemInfoMatcher;
import com.android.launcher3.util.LauncherBindableItemsContainer;
@@ -88,6 +90,8 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar
private AnimatedFloat mTaskbarNavButtonTranslationY;
private AnimatedFloat mTaskbarNavButtonTranslationYForInAppDisplay;
private final int mTaskbarBottomMargin;
private final AnimatedFloat mThemeIconsBackground = new AnimatedFloat(
this::updateIconsBackground);
@@ -112,6 +116,9 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar
mTaskbarIconAlpha = new MultiValueAlpha(mTaskbarView, NUM_ALPHA_CHANNELS);
mTaskbarIconAlpha.setUpdateVisibility(true);
mModelCallbacks = new TaskbarModelCallbacks(activity, mTaskbarView);
mTaskbarBottomMargin = DisplayController.isTransientTaskbar(activity)
? activity.getResources().getDimensionPixelSize(R.dimen.transient_taskbar_margin)
: 0;
}
public void init(TaskbarControllers controllers) {
@@ -317,6 +324,8 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar
float scale = ((float) taskbarDp.iconSizePx) / launcherDp.hotseatQsbVisualHeight;
setter.addFloat(child, SCALE_PROPERTY, scale, 1f, LINEAR);
setter.setFloat(child, VIEW_TRANSLATE_Y, mTaskbarBottomMargin, LINEAR);
setter.addFloat(child, VIEW_ALPHA, 0f, 1f,
isToHome
? Interpolators.clampToProgress(LINEAR, 0f, 0.35f)
@@ -342,6 +351,8 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar
float childCenter = (child.getLeft() + child.getRight()) / 2f;
setter.setFloat(child, ICON_TRANSLATE_X, hotseatIconCenter - childCenter, LINEAR);
setter.setFloat(child, VIEW_TRANSLATE_Y, mTaskbarBottomMargin, LINEAR);
setter.setFloat(child, SCALE_PROPERTY, scaleUp, LINEAR);
}
@@ -84,7 +84,7 @@ public class TaskbarOverlayContext extends BaseTaskbarContext {
@Override
public DeviceProfile getDeviceProfile() {
return mOverlayController.getDeviceProfile();
return mOverlayController.getLauncherDeviceProfile();
}
@Override
@@ -63,17 +63,17 @@ public final class TaskbarOverlayController {
}
};
private DeviceProfile mDeviceProfile;
private DeviceProfile mLauncherDeviceProfile;
private @Nullable TaskbarOverlayContext mOverlayContext;
private TaskbarControllers mControllers; // Initialized in init.
public TaskbarOverlayController(
TaskbarActivityContext taskbarContext, DeviceProfile deviceProfile) {
TaskbarActivityContext taskbarContext, DeviceProfile launcherDeviceProfile) {
mTaskbarContext = taskbarContext;
mWindowContext = mTaskbarContext.createWindowContext(TYPE_APPLICATION_OVERLAY, null);
mProxyView = new TaskbarOverlayProxyView();
mLayoutParams = createLayoutParams();
mDeviceProfile = deviceProfile;
mLauncherDeviceProfile = launcherDeviceProfile;
}
/** Initialize the controller. */
@@ -132,13 +132,13 @@ public final class TaskbarOverlayController {
}
/** The current device profile for the overlay window. */
public DeviceProfile getDeviceProfile() {
return mDeviceProfile;
public DeviceProfile getLauncherDeviceProfile() {
return mLauncherDeviceProfile;
}
/** Updates {@link DeviceProfile} instance for Taskbar's overlay window. */
public void updateDeviceProfile(DeviceProfile dp) {
mDeviceProfile = dp;
public void updateLauncherDeviceProfile(DeviceProfile dp) {
mLauncherDeviceProfile = dp;
Optional.ofNullable(mOverlayContext).ifPresent(c -> {
AbstractFloatingView.closeAllOpenViewsExcept(c, false, TYPE_REBIND_SAFE);
c.dispatchDeviceProfileChanged();
@@ -79,6 +79,7 @@ import com.android.launcher3.testing.shared.TestProtocol;
import com.android.launcher3.touch.PagedOrientationHandler;
import com.android.launcher3.util.ActivityOptionsWrapper;
import com.android.launcher3.util.ComponentKey;
import com.android.launcher3.util.DisplayController;
import com.android.launcher3.util.RunnableList;
import com.android.launcher3.util.SplitConfigurationOptions;
import com.android.launcher3.util.SplitConfigurationOptions.SplitPositionOption;
@@ -1574,9 +1575,12 @@ public class TaskView extends FrameLayout implements Reusable {
/** The current scale we apply to the thumbnail to adjust for new left/right insets. */
public float mScale = 1;
private boolean mIsTaskbarTransient;
public FullscreenDrawParams(Context context) {
mCornerRadius = TaskCornerRadius.get(context);
mWindowCornerRadius = QuickStepContract.getWindowCornerRadius(context);
mIsTaskbarTransient = DisplayController.isTransientTaskbar(context);
mCurrentDrawnCornerRadius = mCornerRadius;
}
@@ -1586,7 +1590,7 @@ public class TaskView extends FrameLayout implements Reusable {
*/
public void setProgress(float fullscreenProgress, float parentScale, float taskViewScale,
int previewWidth, DeviceProfile dp, PreviewPositionHelper pph) {
RectF insets = getInsetsToDrawInFullscreen(pph, dp);
RectF insets = getInsetsToDrawInFullscreen(pph, dp, mIsTaskbarTransient);
float currentInsetsLeft = insets.left * fullscreenProgress;
float currentInsetsTop = insets.top * fullscreenProgress;
@@ -1609,7 +1613,11 @@ public class TaskView extends FrameLayout implements Reusable {
/**
* Insets to used for clipping the thumbnail (in case it is drawing outside its own space)
*/
private static RectF getInsetsToDrawInFullscreen(PreviewPositionHelper pph, DeviceProfile dp) {
private static RectF getInsetsToDrawInFullscreen(PreviewPositionHelper pph,
DeviceProfile dp, boolean isTaskbarTransient) {
if (isTaskbarTransient) {
return pph.getClippedInsets();
}
return dp.isTaskbarPresent && !dp.isTaskbarPresentInApps
? pph.getClippedInsets() : EMPTY_RECT_F;
}