Merge "Crop based on real-time insets" into main

This commit is contained in:
Jon Miranda
2025-03-19 10:28:40 -07:00
committed by Android (Google) Code Review
2 changed files with 66 additions and 10 deletions

View File

@@ -68,6 +68,7 @@ import static com.android.quickstep.util.AnimUtils.completeRunnableListCallback;
import static com.android.systemui.shared.Flags.returnAnimationFrameworkLibrary;
import static com.android.systemui.shared.system.QuickStepContract.getWindowCornerRadius;
import static com.android.systemui.shared.system.QuickStepContract.supportsRoundedCornersOnWindows;
import static com.android.wm.shell.Flags.enableDynamicInsetsForAppLaunch;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
@@ -283,6 +284,8 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener
private final Interpolator mOpeningXInterpolator;
private final Interpolator mOpeningInterpolator;
private final SystemUiProxy mSystemUiProxy;
public QuickstepTransitionManager(Context context) {
mLauncher = Launcher.cast(Launcher.getLauncher(context));
mDragLayer = mLauncher.getDragLayer();
@@ -297,6 +300,7 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener
mMaxShadowRadius = res.getDimensionPixelSize(R.dimen.max_shadow_radius);
mLauncher.addOnDeviceProfileChangeListener(this);
mSystemUiProxy = SystemUiProxy.INSTANCE.get(mLauncher);
if (ENABLE_SHELL_STARTING_SURFACE) {
mTaskStartParams = new LinkedHashMap<>(MAX_NUM_TASKS) {
@@ -306,8 +310,7 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener
}
};
SystemUiProxy.INSTANCE.get(mLauncher).setStartingWindowListener(
mStartingWindowListener);
mSystemUiProxy.setStartingWindowListener(mStartingWindowListener);
}
mOpeningXInterpolator = AnimationUtils.loadInterpolator(context, R.interpolator.app_open_x);
@@ -522,12 +525,6 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener
4 - rotationChange);
}
}
if (mDeviceProfile.isTaskbarPresentInApps
&& !target.willShowImeOnTarget
&& !isTransientTaskbar(mLauncher)) {
// Animate to above the taskbar.
bounds.bottom -= target.contentInsets.bottom;
}
return bounds;
}
@@ -694,6 +691,13 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener
};
}
private boolean shouldCropToInset(RemoteAnimationTarget target) {
return enableDynamicInsetsForAppLaunch()
&& mDeviceProfile.isTaskbarPresentInApps
&& target != null && !target.willShowImeOnTarget
&& !isTransientTaskbar(mLauncher);
}
/**
* @return Animator that controls the window of the opening targets from app icons.
*/
@@ -702,8 +706,19 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener
RemoteAnimationTarget[] wallpaperTargets,
RemoteAnimationTarget[] nonAppTargets,
boolean launcherClosing) {
RemoteAnimationTargets openingTargets = new RemoteAnimationTargets(appTargets,
wallpaperTargets, nonAppTargets, MODE_OPENING);
int rotationChange = getRotationChange(appTargets);
Rect windowTargetBounds = getWindowTargetBounds(appTargets, rotationChange);
final int[] bottomInsetPos = new int[]{
mSystemUiProxy.getHomeVisibilityState().getNavbarInsetPosition()};
final RemoteAnimationTarget target = openingTargets.getFirstAppTarget();
final boolean cropToInset = shouldCropToInset(target);
if (cropToInset) {
// Animate to above the taskbar.
windowTargetBounds.bottom = Math.min(bottomInsetPos[0],
windowTargetBounds.bottom);
}
boolean appTargetsAreTranslucent = areAllTargetsTranslucent(appTargets);
RectF launcherIconBounds = new RectF();
@@ -716,8 +731,6 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener
Rect crop = new Rect();
Matrix matrix = new Matrix();
RemoteAnimationTargets openingTargets = new RemoteAnimationTargets(appTargets,
wallpaperTargets, nonAppTargets, MODE_OPENING);
SurfaceTransactionApplier surfaceApplier =
new SurfaceTransactionApplier(floatingView);
openingTargets.addReleaseCheck(surfaceApplier);
@@ -823,6 +836,39 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener
@Override
public void onUpdate(float percent, boolean initOnly) {
if (cropToInset && bottomInsetPos[0] != mSystemUiProxy.getHomeVisibilityState()
.getNavbarInsetPosition()) {
final RemoteAnimationTarget target = openingTargets.getFirstAppTarget();
bottomInsetPos[0] = mSystemUiProxy.getHomeVisibilityState()
.getNavbarInsetPosition();
final Rect bounds = target != null
? target.screenSpaceBounds : windowTargetBounds;
// Animate to above the taskbar.
int bottomLevel = Math.min(bottomInsetPos[0], bounds.bottom);
windowTargetBounds.bottom = bottomLevel;
final int endHeight = bottomLevel - bounds.top;
AnimOpenProperties prop = new AnimOpenProperties(mLauncher.getResources(),
mDeviceProfile, windowTargetBounds, launcherIconBounds, v,
dragLayerBounds[0], dragLayerBounds[1], hasSplashScreen,
floatingView.isDifferentFromAppIcon());
mCropRectCenterY = new FloatProp(prop.cropCenterYStart, prop.cropCenterYEnd,
mOpeningInterpolator);
mCropRectHeight = new FloatProp(prop.cropHeightStart, prop.cropHeightEnd,
mOpeningInterpolator);
mDy = new FloatProp(0, prop.dY, mOpeningInterpolator);
mIconScaleToFitScreen = new FloatProp(prop.initialAppIconScale,
prop.finalAppIconScale, mOpeningInterpolator);
float interpolatedPercent = mOpeningInterpolator.getInterpolation(percent);
mCropRectHeight.value = Utilities.mapRange(interpolatedPercent,
prop.cropHeightStart, prop.cropHeightEnd);
mCropRectCenterY.value = Utilities.mapRange(interpolatedPercent,
prop.cropCenterYStart, prop.cropCenterYEnd);
mDy.value = Utilities.mapRange(interpolatedPercent, 0, prop.dY);
mIconScaleToFitScreen.value = Utilities.mapRange(interpolatedPercent,
prop.initialAppIconScale, prop.finalAppIconScale);
}
// Calculate the size of the scaled icon.
float iconWidth = launcherIconBounds.width() * mIconScaleToFitScreen.value;
float iconHeight = launcherIconBounds.height() * mIconScaleToFitScreen.value;