Merge "Scaling down hotseat to match prediction row size when going to overview" into ub-launcher3-qt-future-dev
This commit is contained in:
commit
45656e296f
|
@ -17,7 +17,10 @@
|
|||
package com.android.launcher3;
|
||||
|
||||
import static com.android.launcher3.LauncherAnimUtils.VIEW_TRANSLATE_X;
|
||||
import static com.android.launcher3.LauncherState.BACKGROUND_APP;
|
||||
import static com.android.launcher3.LauncherState.HOTSEAT_ICONS;
|
||||
import static com.android.launcher3.LauncherState.NORMAL;
|
||||
import static com.android.launcher3.LauncherState.OVERVIEW;
|
||||
import static com.android.launcher3.anim.Interpolators.AGGRESSIVE_EASE;
|
||||
import static com.android.launcher3.anim.Interpolators.LINEAR;
|
||||
import static com.android.quickstep.TaskViewUtils.findTaskViewToLaunch;
|
||||
|
@ -27,9 +30,15 @@ import android.animation.Animator;
|
|||
import android.animation.AnimatorListenerAdapter;
|
||||
import android.animation.AnimatorSet;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.animation.ValueAnimator;
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.android.launcher3.LauncherState.ScaleAndTranslation;
|
||||
import com.android.launcher3.allapps.AllAppsTransitionController;
|
||||
import com.android.launcher3.anim.AnimatorPlaybackController;
|
||||
import com.android.launcher3.anim.Interpolators;
|
||||
import com.android.launcher3.anim.SpringAnimationBuilder;
|
||||
|
@ -38,9 +47,6 @@ import com.android.quickstep.views.RecentsView;
|
|||
import com.android.quickstep.views.TaskView;
|
||||
import com.android.systemui.shared.system.RemoteAnimationTargetCompat;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* A {@link QuickstepAppTransitionManagerImpl} that also implements recents transitions from
|
||||
* {@link RecentsView}.
|
||||
|
@ -144,8 +150,37 @@ public final class LauncherAppTransitionManagerImpl extends QuickstepAppTransiti
|
|||
@Override
|
||||
public Animator createStateElementAnimation(int index, float... values) {
|
||||
switch (index) {
|
||||
case INDEX_SHELF_ANIM:
|
||||
return mLauncher.getAllAppsController().createSpringAnimation(values);
|
||||
case INDEX_SHELF_ANIM: {
|
||||
AllAppsTransitionController aatc = mLauncher.getAllAppsController();
|
||||
Animator springAnim = aatc.createSpringAnimation(values);
|
||||
|
||||
if ((OVERVIEW.getVisibleElements(mLauncher) & HOTSEAT_ICONS) != 0) {
|
||||
// Translate hotseat with the shelf until reaching overview.
|
||||
float overviewProgress = OVERVIEW.getVerticalProgress(mLauncher);
|
||||
ScaleAndTranslation sat = OVERVIEW.getHotseatScaleAndTranslation(mLauncher);
|
||||
float shiftRange = aatc.getShiftRange();
|
||||
if (values.length == 1) {
|
||||
values = new float[] {aatc.getProgress(), values[0]};
|
||||
}
|
||||
ValueAnimator hotseatAnim = ValueAnimator.ofFloat(values);
|
||||
hotseatAnim.addUpdateListener(anim -> {
|
||||
float progress = (Float) anim.getAnimatedValue();
|
||||
if (progress >= overviewProgress || mLauncher.isInState(BACKGROUND_APP)) {
|
||||
float hotseatShift = (progress - overviewProgress) * shiftRange;
|
||||
mLauncher.getHotseat().setTranslationY(hotseatShift + sat.translationY);
|
||||
}
|
||||
});
|
||||
hotseatAnim.setInterpolator(LINEAR);
|
||||
hotseatAnim.setDuration(springAnim.getDuration());
|
||||
|
||||
AnimatorSet anim = new AnimatorSet();
|
||||
anim.play(hotseatAnim);
|
||||
anim.play(springAnim);
|
||||
return anim;
|
||||
}
|
||||
|
||||
return springAnim;
|
||||
}
|
||||
case INDEX_RECENTS_FADE_ANIM:
|
||||
return ObjectAnimator.ofFloat(mLauncher.getOverviewPanel(),
|
||||
RecentsView.CONTENT_ALPHA, values);
|
||||
|
|
|
@ -98,7 +98,7 @@ public class BackgroundAppState extends OverviewState {
|
|||
if ((getVisibleElements(launcher) & HOTSEAT_ICONS) != 0) {
|
||||
// Translate hotseat offscreen if we show it in overview.
|
||||
ScaleAndTranslation scaleAndTranslation = super.getHotseatScaleAndTranslation(launcher);
|
||||
scaleAndTranslation.translationY = LayoutUtils.getShelfTrackingDistance(launcher,
|
||||
scaleAndTranslation.translationY += LayoutUtils.getShelfTrackingDistance(launcher,
|
||||
launcher.getDeviceProfile());
|
||||
return scaleAndTranslation;
|
||||
}
|
||||
|
|
|
@ -32,7 +32,6 @@ import static com.android.launcher3.anim.Interpolators.OVERSHOOT_1_7;
|
|||
import static com.android.launcher3.logging.LoggerUtils.newContainerTarget;
|
||||
import static com.android.launcher3.states.RotationHelper.REQUEST_ROTATE;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Rect;
|
||||
import android.view.View;
|
||||
|
||||
|
@ -47,6 +46,7 @@ import com.android.launcher3.anim.AnimatorSetBuilder;
|
|||
import com.android.launcher3.userevent.nano.LauncherLogProto.Action;
|
||||
import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType;
|
||||
import com.android.quickstep.SysUINavigationMode;
|
||||
import com.android.quickstep.util.LayoutUtils;
|
||||
import com.android.quickstep.views.RecentsView;
|
||||
import com.android.quickstep.views.TaskView;
|
||||
|
||||
|
@ -91,8 +91,19 @@ public class OverviewState extends LauncherState {
|
|||
@Override
|
||||
public ScaleAndTranslation getHotseatScaleAndTranslation(Launcher launcher) {
|
||||
if ((getVisibleElements(launcher) & HOTSEAT_ICONS) != 0) {
|
||||
// If the hotseat icons are visible in overview, keep them in their normal position.
|
||||
return super.getWorkspaceScaleAndTranslation(launcher);
|
||||
DeviceProfile dp = launcher.getDeviceProfile();
|
||||
if (dp.allAppsIconSizePx >= dp.iconSizePx) {
|
||||
return new ScaleAndTranslation(1, 0, 0);
|
||||
} else {
|
||||
float scale = ((float) dp.allAppsIconSizePx) / dp.iconSizePx;
|
||||
// Distance between the screen center (which is the pivotY for hotseat) and the
|
||||
// bottom of the hotseat (which we want to preserve)
|
||||
float distanceFromBottom = dp.heightPx / 2 - dp.hotseatBarBottomPaddingPx;
|
||||
// On scaling, the bottom edge is moved closer to the pivotY. We move the
|
||||
// hotseat back down so that the bottom edge's position is preserved.
|
||||
float translationY = distanceFromBottom * (1 - scale);
|
||||
return new ScaleAndTranslation(scale, 0, translationY);
|
||||
}
|
||||
}
|
||||
return getWorkspaceScaleAndTranslation(launcher);
|
||||
}
|
||||
|
@ -160,15 +171,7 @@ public class OverviewState extends LauncherState {
|
|||
}
|
||||
|
||||
public static float getDefaultSwipeHeight(Launcher launcher) {
|
||||
return getDefaultSwipeHeight(launcher, launcher.getDeviceProfile());
|
||||
}
|
||||
|
||||
public static float getDefaultSwipeHeight(Context context, DeviceProfile dp) {
|
||||
float swipeHeight = dp.allAppsCellHeightPx - dp.allAppsIconTextSizePx;
|
||||
if (SysUINavigationMode.getMode(context) == SysUINavigationMode.Mode.NO_BUTTON) {
|
||||
swipeHeight -= dp.getInsets().bottom;
|
||||
}
|
||||
return swipeHeight;
|
||||
return LayoutUtils.getDefaultSwipeHeight(launcher, launcher.getDeviceProfile());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -7,7 +7,6 @@ import android.os.Bundle;
|
|||
|
||||
import com.android.launcher3.testing.TestInformationHandler;
|
||||
import com.android.launcher3.testing.TestProtocol;
|
||||
import com.android.launcher3.uioverrides.states.OverviewState;
|
||||
import com.android.launcher3.uioverrides.touchcontrollers.PortraitStatesTouchController;
|
||||
import com.android.quickstep.util.LayoutUtils;
|
||||
import com.android.quickstep.views.RecentsView;
|
||||
|
@ -25,7 +24,7 @@ public class QuickstepTestInformationHandler extends TestInformationHandler {
|
|||
switch (method) {
|
||||
case TestProtocol.REQUEST_HOME_TO_OVERVIEW_SWIPE_HEIGHT: {
|
||||
final float swipeHeight =
|
||||
OverviewState.getDefaultSwipeHeight(mContext, mDeviceProfile);
|
||||
LayoutUtils.getDefaultSwipeHeight(mContext, mDeviceProfile);
|
||||
response.putInt(TestProtocol.TEST_INFO_RESPONSE_FIELD, (int) swipeHeight);
|
||||
return response;
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ import androidx.annotation.IntDef;
|
|||
|
||||
import com.android.launcher3.DeviceProfile;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
import com.android.quickstep.SysUINavigationMode;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
|
||||
|
@ -39,12 +39,27 @@ public class LayoutUtils {
|
|||
@IntDef({MULTI_WINDOW_STRATEGY_HALF_SCREEN, MULTI_WINDOW_STRATEGY_DEVICE_PROFILE})
|
||||
private @interface MultiWindowStrategy {}
|
||||
|
||||
/**
|
||||
* The height for the swipe up motion
|
||||
*/
|
||||
public static float getDefaultSwipeHeight(Context context, DeviceProfile dp) {
|
||||
float swipeHeight = dp.allAppsCellHeightPx - dp.allAppsIconTextSizePx;
|
||||
if (SysUINavigationMode.getMode(context) == SysUINavigationMode.Mode.NO_BUTTON) {
|
||||
swipeHeight -= dp.getInsets().bottom;
|
||||
}
|
||||
return swipeHeight;
|
||||
}
|
||||
|
||||
public static void calculateLauncherTaskSize(Context context, DeviceProfile dp, Rect outRect) {
|
||||
float extraSpace;
|
||||
if (dp.isVerticalBarLayout()) {
|
||||
extraSpace = 0;
|
||||
} else {
|
||||
extraSpace = dp.hotseatBarSizePx + dp.verticalDragHandleSizePx;
|
||||
Resources res = context.getResources();
|
||||
|
||||
extraSpace = getDefaultSwipeHeight(context, dp) + dp.verticalDragHandleSizePx
|
||||
+ res.getDimensionPixelSize(R.dimen.dynamic_grid_hotseat_extra_vertical_size)
|
||||
+ res.getDimensionPixelSize(R.dimen.dynamic_grid_hotseat_bottom_padding);
|
||||
}
|
||||
calculateTaskSize(context, dp, extraSpace, MULTI_WINDOW_STRATEGY_HALF_SCREEN, outRect);
|
||||
}
|
||||
|
|
|
@ -38,12 +38,12 @@ import com.android.launcher3.DeviceProfile;
|
|||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.anim.Interpolators;
|
||||
import com.android.launcher3.uioverrides.states.OverviewState;
|
||||
import com.android.launcher3.util.Themes;
|
||||
import com.android.launcher3.views.ScrimView;
|
||||
import com.android.quickstep.SysUINavigationMode;
|
||||
import com.android.quickstep.SysUINavigationMode.Mode;
|
||||
import com.android.quickstep.SysUINavigationMode.NavigationModeChangeListener;
|
||||
import com.android.quickstep.util.LayoutUtils;
|
||||
|
||||
/**
|
||||
* Scrim used for all-apps and shelf in Overview
|
||||
|
@ -163,7 +163,7 @@ public class ShelfScrimView extends ScrimView implements NavigationModeChangeLis
|
|||
int hotseatSize = dp.hotseatBarSizePx + dp.getInsets().bottom
|
||||
+ hotseatPadding.bottom + hotseatPadding.top;
|
||||
float dragHandleTop =
|
||||
Math.min(hotseatSize, OverviewState.getDefaultSwipeHeight(context, dp));
|
||||
Math.min(hotseatSize, LayoutUtils.getDefaultSwipeHeight(context, dp));
|
||||
mDragHandleProgress = 1 - (dragHandleTop / mShiftRange);
|
||||
}
|
||||
mTopOffset = dp.getInsets().top - mShelfOffset;
|
||||
|
|
|
@ -38,7 +38,6 @@ import com.android.launcher3.LauncherState.ScaleAndTranslation;
|
|||
import com.android.launcher3.LauncherStateManager.AnimationConfig;
|
||||
import com.android.launcher3.anim.AnimatorSetBuilder;
|
||||
import com.android.launcher3.anim.PropertySetter;
|
||||
import com.android.launcher3.dragndrop.DragLayer;
|
||||
import com.android.launcher3.graphics.WorkspaceAndHotseatScrim;
|
||||
|
||||
/**
|
||||
|
@ -96,14 +95,13 @@ public class WorkspaceStateTransitionAnimation {
|
|||
propertySetter.setFloat(mWorkspace, SCALE_PROPERTY, mNewScale, scaleInterpolator);
|
||||
|
||||
if (!hotseat.getRotationMode().isTransposed) {
|
||||
// Set the hotseat's pivot point to match the workspace's, so that it scales together.
|
||||
DragLayer dragLayer = mLauncher.getDragLayer();
|
||||
float[] workspacePivot =
|
||||
new float[]{ mWorkspace.getPivotX(), mWorkspace.getPivotY() };
|
||||
dragLayer.getDescendantCoordRelativeToSelf(mWorkspace, workspacePivot);
|
||||
dragLayer.mapCoordInSelfToDescendant(hotseat, workspacePivot);
|
||||
hotseat.setPivotX(workspacePivot[0]);
|
||||
hotseat.setPivotY(workspacePivot[1]);
|
||||
// Set the hotseat's pivot point to match the workspace's, so that it scales
|
||||
// together. Since both hotseat and workspace can move, transform the point
|
||||
// manually instead of using dragLayer.getDescendantCoordRelativeToSelf and
|
||||
// related methods.
|
||||
hotseat.setPivotY(mWorkspace.getPivotY() + mWorkspace.getTop() - hotseat.getTop());
|
||||
hotseat.setPivotX(mWorkspace.getPivotX()
|
||||
+ mWorkspace.getLeft() - hotseat.getLeft());
|
||||
}
|
||||
float hotseatScale = hotseatScaleAndTranslation.scale;
|
||||
Interpolator hotseatScaleInterpolator = builder.getInterpolator(ANIM_HOTSEAT_SCALE,
|
||||
|
|
|
@ -2,8 +2,6 @@ package com.android.launcher3.allapps;
|
|||
|
||||
import static com.android.launcher3.LauncherState.ALL_APPS_CONTENT;
|
||||
import static com.android.launcher3.LauncherState.ALL_APPS_HEADER_EXTRA;
|
||||
import static com.android.launcher3.LauncherState.BACKGROUND_APP;
|
||||
import static com.android.launcher3.LauncherState.HOTSEAT_ICONS;
|
||||
import static com.android.launcher3.LauncherState.OVERVIEW;
|
||||
import static com.android.launcher3.LauncherState.VERTICAL_SWIPE_INDICATOR;
|
||||
import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_ALL_APPS_FADE;
|
||||
|
@ -134,15 +132,6 @@ public class AllAppsTransitionController implements StateHandler, OnDeviceProfil
|
|||
} else {
|
||||
mLauncher.getSystemUiController().updateUiState(UI_STATE_ALL_APPS, 0);
|
||||
}
|
||||
|
||||
if ((OVERVIEW.getVisibleElements(mLauncher) & HOTSEAT_ICONS) != 0) {
|
||||
// Translate hotseat with the shelf until reaching overview.
|
||||
float overviewProgress = OVERVIEW.getVerticalProgress(mLauncher);
|
||||
if (progress >= overviewProgress || mLauncher.isInState(BACKGROUND_APP)) {
|
||||
float hotseatShift = (progress - overviewProgress) * mShiftRange;
|
||||
mLauncher.getHotseat().setTranslationY(hotseatShift);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public float getProgress() {
|
||||
|
|
Loading…
Reference in New Issue