Merge changes from topic "taskbar-crop-tasks" into sc-v2-dev am: 40f86763bc
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/15587788 Change-Id: I485467f809b6cd571915a7d5cfebc1a485987842
This commit is contained in:
@@ -85,6 +85,7 @@ import com.android.launcher3.dragndrop.DragLayer;
|
||||
import com.android.launcher3.icons.FastBitmapDrawable;
|
||||
import com.android.launcher3.shortcuts.DeepShortcutView;
|
||||
import com.android.launcher3.statehandlers.DepthController;
|
||||
import com.android.launcher3.taskbar.LauncherTaskbarUIController;
|
||||
import com.android.launcher3.util.ActivityOptionsWrapper;
|
||||
import com.android.launcher3.util.MultiValueAlpha.AlphaProperty;
|
||||
import com.android.launcher3.util.RunnableList;
|
||||
@@ -427,6 +428,10 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener
|
||||
4 - rotationChange);
|
||||
}
|
||||
}
|
||||
// TODO(b/196637509): don't do this for immersive apps.
|
||||
if (mDeviceProfile.isTaskbarPresentInApps) {
|
||||
bounds.bottom -= mDeviceProfile.taskbarSize;
|
||||
}
|
||||
return bounds;
|
||||
}
|
||||
|
||||
@@ -511,7 +516,10 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener
|
||||
|
||||
final boolean scrimEnabled = ENABLE_SCRIM_FOR_APP_LAUNCH.get();
|
||||
if (scrimEnabled) {
|
||||
int scrimColor = Themes.getAttrColor(mLauncher, R.attr.overviewScrimColor);
|
||||
boolean useTaskbarColor = mDeviceProfile.isTaskbarPresentInApps;
|
||||
int scrimColor = useTaskbarColor
|
||||
? mLauncher.getResources().getColor(R.color.taskbar_background)
|
||||
: Themes.getAttrColor(mLauncher, R.attr.overviewScrimColor);
|
||||
int scrimColorTrans = ColorUtils.setAlphaComponent(scrimColor, 0);
|
||||
int[] colors = isAppOpening
|
||||
? new int[]{scrimColorTrans, scrimColor}
|
||||
@@ -524,6 +532,30 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener
|
||||
colors);
|
||||
scrim.setDuration(CONTENT_SCRIM_DURATION);
|
||||
scrim.setInterpolator(DEACCEL_1_5);
|
||||
|
||||
if (useTaskbarColor) {
|
||||
// Hide the taskbar background color since it would duplicate the scrim.
|
||||
scrim.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationStart(Animator animation) {
|
||||
LauncherTaskbarUIController taskbarUIController =
|
||||
mLauncher.getTaskbarUIController();
|
||||
if (taskbarUIController != null) {
|
||||
taskbarUIController.forceHideBackground(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
LauncherTaskbarUIController taskbarUIController =
|
||||
mLauncher.getTaskbarUIController();
|
||||
if (taskbarUIController != null) {
|
||||
taskbarUIController.forceHideBackground(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
launcherAnimator.play(scrim);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ import android.view.MotionEvent;
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.android.launcher3.BaseQuickstepLauncher;
|
||||
import com.android.launcher3.DeviceProfile;
|
||||
import com.android.launcher3.LauncherState;
|
||||
import com.android.launcher3.QuickstepTransitionManager;
|
||||
import com.android.launcher3.R;
|
||||
@@ -58,9 +59,13 @@ public class LauncherTaskbarUIController extends TaskbarUIController {
|
||||
private final AnimatedFloat mIconAlignmentForGestureState =
|
||||
new AnimatedFloat(this::onIconAlignmentRatioChanged);
|
||||
|
||||
private final DeviceProfile.OnDeviceProfileChangeListener mOnDeviceProfileChangeListener =
|
||||
this::onStashedInAppChanged;
|
||||
|
||||
// Initialized in init.
|
||||
private TaskbarControllers mControllers;
|
||||
private AnimatedFloat mTaskbarBackgroundAlpha;
|
||||
private AnimatedFloat mTaskbarOverrideBackgroundAlpha;
|
||||
private AlphaProperty mIconAlphaForHome;
|
||||
private boolean mIsAnimatingToLauncherViaResume;
|
||||
private boolean mIsAnimatingToLauncherViaGesture;
|
||||
@@ -84,6 +89,8 @@ public class LauncherTaskbarUIController extends TaskbarUIController {
|
||||
|
||||
mTaskbarBackgroundAlpha = mControllers.taskbarDragLayerController
|
||||
.getTaskbarBackgroundAlpha();
|
||||
mTaskbarOverrideBackgroundAlpha = mControllers.taskbarDragLayerController
|
||||
.getOverrideBackgroundAlpha();
|
||||
|
||||
MultiValueAlpha taskbarIconAlpha = mControllers.taskbarViewController.getTaskbarIconAlpha();
|
||||
mIconAlphaForHome = taskbarIconAlpha.getProperty(ALPHA_INDEX_HOME);
|
||||
@@ -94,6 +101,9 @@ public class LauncherTaskbarUIController extends TaskbarUIController {
|
||||
onLauncherResumedOrPaused(mLauncher.hasBeenResumed());
|
||||
mIconAlignmentForResumedState.finishAnimation();
|
||||
onIconAlignmentRatioChanged();
|
||||
|
||||
onStashedInAppChanged(mLauncher.getDeviceProfile());
|
||||
mLauncher.addOnDeviceProfileChangeListener(mOnDeviceProfileChangeListener);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -102,6 +112,7 @@ public class LauncherTaskbarUIController extends TaskbarUIController {
|
||||
mIconAlignmentForResumedState.finishAnimation();
|
||||
mIconAlignmentForGestureState.finishAnimation();
|
||||
|
||||
mLauncher.removeOnDeviceProfileChangeListener(mOnDeviceProfileChangeListener);
|
||||
mLauncher.getHotseat().setIconsAlpha(1f);
|
||||
mLauncher.setTaskbarUIController(null);
|
||||
}
|
||||
@@ -192,7 +203,7 @@ public class LauncherTaskbarUIController extends TaskbarUIController {
|
||||
}
|
||||
|
||||
private float getCurrentIconAlignmentRatio() {
|
||||
return Math.max(mIconAlignmentForResumedState.value, mIconAlignmentForGestureState.value);
|
||||
return Math.max(mIconAlignmentForResumedState.value, mIconAlignmentForGestureState.value);
|
||||
}
|
||||
|
||||
private void onIconAlignmentRatioChanged() {
|
||||
@@ -233,6 +244,23 @@ public class LauncherTaskbarUIController extends TaskbarUIController {
|
||||
mLauncher.getHotseat().setIconsAlpha(isVisible ? 0f : 1f);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStashedInAppChanged() {
|
||||
onStashedInAppChanged(mLauncher.getDeviceProfile());
|
||||
}
|
||||
|
||||
private void onStashedInAppChanged(DeviceProfile deviceProfile) {
|
||||
boolean taskbarStashedInApps = mControllers.taskbarStashController.isStashedInApp();
|
||||
deviceProfile.isTaskbarPresentInApps = !taskbarStashedInApps;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether the background behind the taskbar/nav bar should be hidden.
|
||||
*/
|
||||
public void forceHideBackground(boolean forceHide) {
|
||||
mTaskbarOverrideBackgroundAlpha.updateValue(forceHide ? 0 : 1);
|
||||
}
|
||||
|
||||
private final class TaskBarRecentsAnimationListener implements RecentsAnimationListener {
|
||||
private final RecentsAnimationCallbacks mCallbacks;
|
||||
|
||||
|
||||
@@ -36,10 +36,14 @@ public class TaskbarDragLayerController {
|
||||
private final TaskbarActivityContext mActivity;
|
||||
private final TaskbarDragLayer mTaskbarDragLayer;
|
||||
private final int mFolderMargin;
|
||||
|
||||
// Alpha properties for taskbar background.
|
||||
private final AnimatedFloat mBgTaskbar = new AnimatedFloat(this::updateBackgroundAlpha);
|
||||
private final AnimatedFloat mBgNavbar = new AnimatedFloat(this::updateBackgroundAlpha);
|
||||
private final AnimatedFloat mKeyguardBgTaskbar = new AnimatedFloat(this::updateBackgroundAlpha);
|
||||
// Used to hide our background color when someone else (e.g. ScrimView) is handling it.
|
||||
private final AnimatedFloat mBgOverride = new AnimatedFloat(this::updateBackgroundAlpha);
|
||||
|
||||
// Translation property for taskbar background.
|
||||
private final AnimatedFloat mBgOffset = new AnimatedFloat(this::updateBackgroundOffset);
|
||||
|
||||
@@ -58,6 +62,7 @@ public class TaskbarDragLayerController {
|
||||
mControllers = controllers;
|
||||
mTaskbarDragLayer.init(new TaskbarDragLayerCallbacks());
|
||||
mKeyguardBgTaskbar.value = 1;
|
||||
mBgOverride.value = 1;
|
||||
}
|
||||
|
||||
public void onDestroy() {
|
||||
@@ -86,13 +91,19 @@ public class TaskbarDragLayerController {
|
||||
return mKeyguardBgTaskbar;
|
||||
}
|
||||
|
||||
public AnimatedFloat getOverrideBackgroundAlpha() {
|
||||
return mBgOverride;
|
||||
}
|
||||
|
||||
public AnimatedFloat getTaskbarBackgroundOffset() {
|
||||
return mBgOffset;
|
||||
}
|
||||
|
||||
private void updateBackgroundAlpha() {
|
||||
final float bgNavbar = mBgNavbar.value;
|
||||
final float bgTaskbar = mBgTaskbar.value * mKeyguardBgTaskbar.value;
|
||||
mTaskbarDragLayer.setTaskbarBackgroundAlpha(
|
||||
Math.max(mBgNavbar.value, mBgTaskbar.value * mKeyguardBgTaskbar.value)
|
||||
mBgOverride.value * Math.max(bgNavbar, bgTaskbar)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -197,6 +197,7 @@ public class TaskbarStashController {
|
||||
if (wasStashed != isStashed) {
|
||||
SystemUiProxy.INSTANCE.get(mActivity)
|
||||
.notifyTaskbarStatus(/* visible */ true, /* stashed */ isStashed);
|
||||
mControllers.uiController.onStashedInAppChanged();
|
||||
createAnimToIsStashed(isStashed, TASKBAR_STASH_DURATION).start();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -33,4 +33,6 @@ public class TaskbarUIController {
|
||||
}
|
||||
|
||||
protected void updateContentInsets(Rect outContentInsets) { }
|
||||
|
||||
protected void onStashedInAppChanged() { }
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import android.graphics.Color;
|
||||
import com.android.launcher3.BaseDraggingActivity;
|
||||
import com.android.launcher3.DeviceProfile;
|
||||
import com.android.launcher3.Launcher;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.allapps.AllAppsTransitionController;
|
||||
import com.android.quickstep.util.LayoutUtils;
|
||||
import com.android.quickstep.views.RecentsView;
|
||||
@@ -89,6 +90,10 @@ public class BackgroundAppState extends OverviewState {
|
||||
|
||||
@Override
|
||||
public int getWorkspaceScrimColor(Launcher launcher) {
|
||||
DeviceProfile dp = launcher.getDeviceProfile();
|
||||
if (dp.isTaskbarPresentInApps) {
|
||||
return launcher.getColor(R.color.taskbar_background);
|
||||
}
|
||||
return Color.TRANSPARENT;
|
||||
}
|
||||
|
||||
|
||||
@@ -262,14 +262,14 @@ public abstract class BaseActivityInterface<STATE_TYPE extends BaseState<STATE_T
|
||||
public static void getTaskDimension(Context context, DeviceProfile dp, PointF out) {
|
||||
if (dp.isMultiWindowMode) {
|
||||
WindowBounds bounds = SplitScreenBounds.INSTANCE.getSecondaryWindowBounds(context);
|
||||
if (TaskView.CLIP_STATUS_AND_NAV_BARS) {
|
||||
if (TaskView.clipStatusAndNavBars(dp)) {
|
||||
out.x = bounds.availableSize.x;
|
||||
out.y = bounds.availableSize.y;
|
||||
} else {
|
||||
out.x = bounds.availableSize.x + bounds.insets.left + bounds.insets.right;
|
||||
out.y = bounds.availableSize.y + bounds.insets.top + bounds.insets.bottom;
|
||||
}
|
||||
} else if (TaskView.CLIP_STATUS_AND_NAV_BARS) {
|
||||
} else if (TaskView.clipStatusAndNavBars(dp)) {
|
||||
out.x = dp.availableWidthPx;
|
||||
out.y = dp.availableHeightPx;
|
||||
} else {
|
||||
|
||||
@@ -396,7 +396,7 @@ public class RecentsOrientedState implements
|
||||
Rect insets = dp.getInsets();
|
||||
float fullWidth = dp.widthPx;
|
||||
float fullHeight = dp.heightPx;
|
||||
if (TaskView.CLIP_STATUS_AND_NAV_BARS) {
|
||||
if (TaskView.clipStatusAndNavBars(dp)) {
|
||||
fullWidth -= insets.left + insets.right;
|
||||
fullHeight -= insets.top + insets.bottom;
|
||||
}
|
||||
|
||||
@@ -211,7 +211,7 @@ public class TaskThumbnailView extends View implements PluginListener<OverviewSc
|
||||
return Insets.NONE;
|
||||
}
|
||||
|
||||
if (!TaskView.CLIP_STATUS_AND_NAV_BARS) {
|
||||
if (!TaskView.clipStatusAndNavBars(mActivity.getDeviceProfile())) {
|
||||
return Insets.NONE;
|
||||
}
|
||||
|
||||
@@ -440,7 +440,7 @@ public class TaskThumbnailView extends View implements PluginListener<OverviewSc
|
||||
|
||||
int thumbnailRotation = thumbnailData.rotation;
|
||||
int deltaRotate = getRotationDelta(currentRotation, thumbnailRotation);
|
||||
RectF thumbnailClipHint = TaskView.CLIP_STATUS_AND_NAV_BARS
|
||||
RectF thumbnailClipHint = TaskView.clipStatusAndNavBars(dp)
|
||||
? new RectF(thumbnailData.insets) : new RectF();
|
||||
|
||||
float scale = thumbnailData.scale;
|
||||
@@ -554,7 +554,7 @@ public class TaskThumbnailView extends View implements PluginListener<OverviewSc
|
||||
-thumbnailClipHint.left * scale,
|
||||
-thumbnailClipHint.top * scale);
|
||||
} else {
|
||||
setThumbnailRotation(deltaRotate, thumbnailClipHint, scale, thumbnailBounds);
|
||||
setThumbnailRotation(deltaRotate, thumbnailClipHint, scale, thumbnailBounds, dp);
|
||||
}
|
||||
|
||||
final float widthWithInsets;
|
||||
@@ -599,7 +599,7 @@ public class TaskThumbnailView extends View implements PluginListener<OverviewSc
|
||||
}
|
||||
|
||||
private void setThumbnailRotation(int deltaRotate, RectF thumbnailInsets, float scale,
|
||||
Rect thumbnailPosition) {
|
||||
Rect thumbnailPosition, DeviceProfile dp) {
|
||||
float newLeftInset = 0;
|
||||
float newTopInset = 0;
|
||||
float translateX = 0;
|
||||
@@ -626,7 +626,7 @@ public class TaskThumbnailView extends View implements PluginListener<OverviewSc
|
||||
}
|
||||
mClippedInsets.offsetTo(newLeftInset * scale, newTopInset * scale);
|
||||
mMatrix.postTranslate(translateX, translateY);
|
||||
if (TaskView.FULL_THUMBNAIL) {
|
||||
if (TaskView.useFullThumbnail(dp)) {
|
||||
mMatrix.postTranslate(-mClippedInsets.left, -mClippedInsets.top);
|
||||
}
|
||||
}
|
||||
@@ -634,8 +634,8 @@ public class TaskThumbnailView extends View implements PluginListener<OverviewSc
|
||||
/**
|
||||
* Insets to used for clipping the thumbnail (in case it is drawing outside its own space)
|
||||
*/
|
||||
public RectF getInsetsToDrawInFullscreen() {
|
||||
return TaskView.FULL_THUMBNAIL ? mClippedInsets : EMPTY_RECT_F;
|
||||
public RectF getInsetsToDrawInFullscreen(DeviceProfile dp) {
|
||||
return TaskView.useFullThumbnail(dp) ? mClippedInsets : EMPTY_RECT_F;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,12 +144,16 @@ public class TaskView extends FrameLayout implements Reusable {
|
||||
* Should the TaskView display clip off the status and navigation bars in recents. When this
|
||||
* is false the overview shows the whole screen scaled down instead.
|
||||
*/
|
||||
public static final boolean CLIP_STATUS_AND_NAV_BARS = false;
|
||||
public static boolean clipStatusAndNavBars(DeviceProfile deviceProfile) {
|
||||
return deviceProfile.isTaskbarPresentInApps;
|
||||
}
|
||||
|
||||
/**
|
||||
* Should the TaskView scale down to fit whole thumbnail in fullscreen.
|
||||
*/
|
||||
public static final boolean FULL_THUMBNAIL = false;
|
||||
public static boolean useFullThumbnail(DeviceProfile deviceProfile) {
|
||||
return deviceProfile.isTaskbarPresentInApps;
|
||||
};
|
||||
|
||||
private static final float EDGE_SCALE_DOWN_FACTOR_CAROUSEL = 0.03f;
|
||||
private static final float EDGE_SCALE_DOWN_FACTOR_GRID = 0.00f;
|
||||
@@ -1489,12 +1493,16 @@ public class TaskView extends FrameLayout implements Reusable {
|
||||
*/
|
||||
public void setProgress(float fullscreenProgress, float parentScale, float taskViewScale,
|
||||
int previewWidth, DeviceProfile dp, PreviewPositionHelper pph) {
|
||||
RectF insets = pph.getInsetsToDrawInFullscreen();
|
||||
RectF insets = pph.getInsetsToDrawInFullscreen(dp);
|
||||
|
||||
float currentInsetsLeft = insets.left * fullscreenProgress;
|
||||
float currentInsetsRight = insets.right * fullscreenProgress;
|
||||
float insetsBottom = insets.bottom;
|
||||
if (dp.isTaskbarPresentInApps) {
|
||||
insetsBottom = Math.max(0, insetsBottom - dp.taskbarSize);
|
||||
}
|
||||
mCurrentDrawnInsets.set(currentInsetsLeft, insets.top * fullscreenProgress,
|
||||
currentInsetsRight, insets.bottom * fullscreenProgress);
|
||||
currentInsetsRight, insetsBottom * fullscreenProgress);
|
||||
float fullscreenCornerRadius = dp.isMultiWindowMode ? 0 : mWindowCornerRadius;
|
||||
|
||||
mCurrentDrawnCornerRadius =
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package com.android.launcher3;
|
||||
|
||||
import static android.util.DisplayMetrics.DENSITY_DEVICE_STABLE;
|
||||
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION;
|
||||
|
||||
import static com.android.launcher3.ResourceUtils.pxFromDp;
|
||||
import static com.android.launcher3.Utilities.dpiFromPx;
|
||||
@@ -33,11 +32,8 @@ import android.graphics.Path;
|
||||
import android.graphics.Point;
|
||||
import android.graphics.PointF;
|
||||
import android.graphics.Rect;
|
||||
import android.hardware.display.DisplayManager;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.Surface;
|
||||
import android.view.WindowInsets;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import com.android.launcher3.CellLayout.ContainerType;
|
||||
import com.android.launcher3.DevicePaddings.DevicePadding;
|
||||
@@ -214,6 +210,8 @@ public class DeviceProfile {
|
||||
|
||||
// Taskbar
|
||||
public boolean isTaskbarPresent;
|
||||
// Whether Taskbar will inset the bottom of apps by taskbarSize.
|
||||
public boolean isTaskbarPresentInApps;
|
||||
public int taskbarSize;
|
||||
// How much of the bottom inset is due to Taskbar rather than other system elements.
|
||||
public int nonOverlappingTaskbarInset;
|
||||
@@ -267,13 +265,7 @@ public class DeviceProfile {
|
||||
// Taskbar will be added later, but provides bottom insets that we should subtract
|
||||
// from availableHeightPx.
|
||||
taskbarSize = res.getDimensionPixelSize(R.dimen.taskbar_size);
|
||||
WindowInsets windowInsets =
|
||||
context.createWindowContext(
|
||||
context.getSystemService(DisplayManager.class).getDisplay(mInfo.id),
|
||||
TYPE_APPLICATION, null)
|
||||
.getSystemService(WindowManager.class)
|
||||
.getCurrentWindowMetrics().getWindowInsets();
|
||||
nonOverlappingTaskbarInset = taskbarSize - windowInsets.getSystemWindowInsetBottom();
|
||||
nonOverlappingTaskbarInset = taskbarSize - windowBounds.insets.bottom;
|
||||
if (nonOverlappingTaskbarInset > 0) {
|
||||
nonFinalAvailableHeightPx -= nonOverlappingTaskbarInset;
|
||||
}
|
||||
@@ -1089,6 +1081,7 @@ public class DeviceProfile {
|
||||
writer.println(prefix + "\tnumShownHotseatIcons: " + numShownHotseatIcons);
|
||||
|
||||
writer.println(prefix + "\tisTaskbarPresent:" + isTaskbarPresent);
|
||||
writer.println(prefix + "\tisTaskbarPresentInApps:" + isTaskbarPresentInApps);
|
||||
|
||||
writer.println(prefix + pxToDpStr("taskbarSize", taskbarSize));
|
||||
writer.println(prefix + pxToDpStr("nonOverlappingTaskbarInset",
|
||||
|
||||
Reference in New Issue
Block a user