Merge "Use FlingOnBackAnimationCallback for predictive back" into main

This commit is contained in:
Johannes Gallmann
2024-11-11 08:29:47 +00:00
committed by Android (Google) Code Review
4 changed files with 14 additions and 15 deletions

View File

@@ -55,6 +55,7 @@ import com.android.launcher3.widget.model.WidgetsListBaseEntriesBuilder;
import com.android.launcher3.widget.model.WidgetsListBaseEntry;
import com.android.launcher3.widget.picker.WidgetsFullSheet;
import com.android.launcher3.widget.picker.model.WidgetPickerDataProvider;
import com.android.systemui.animation.back.FlingOnBackAnimationCallback;
import java.util.ArrayList;
import java.util.HashSet;
@@ -374,12 +375,12 @@ public class WidgetPickerActivity extends BaseActivity {
/**
* Animation callback for different predictive back animation states for the widget picker.
*/
private class BackAnimationCallback implements OnBackAnimationCallback {
private class BackAnimationCallback extends FlingOnBackAnimationCallback {
@Nullable
OnBackAnimationCallback mActiveOnBackAnimationCallback;
@Override
public void onBackStarted(@NonNull BackEvent backEvent) {
public void onBackStartedCompat(@NonNull BackEvent backEvent) {
if (mActiveOnBackAnimationCallback != null) {
mActiveOnBackAnimationCallback.onBackCancelled();
}
@@ -390,7 +391,7 @@ public class WidgetPickerActivity extends BaseActivity {
}
@Override
public void onBackInvoked() {
public void onBackInvokedCompat() {
if (mActiveOnBackAnimationCallback == null) {
return;
}
@@ -399,7 +400,7 @@ public class WidgetPickerActivity extends BaseActivity {
}
@Override
public void onBackProgressed(@NonNull BackEvent backEvent) {
public void onBackProgressedCompat(@NonNull BackEvent backEvent) {
if (mActiveOnBackAnimationCallback == null) {
return;
}
@@ -407,7 +408,7 @@ public class WidgetPickerActivity extends BaseActivity {
}
@Override
public void onBackCancelled() {
public void onBackCancelledCompat() {
if (mActiveOnBackAnimationCallback == null) {
return;
}

View File

@@ -190,6 +190,7 @@ import com.android.quickstep.views.OverviewActionsView;
import com.android.quickstep.views.RecentsView;
import com.android.quickstep.views.RecentsViewContainer;
import com.android.quickstep.views.TaskView;
import com.android.systemui.animation.back.FlingOnBackAnimationCallback;
import com.android.systemui.shared.recents.model.Task;
import com.android.systemui.shared.system.ActivityManagerWrapper;
import com.android.systemui.unfold.RemoteUnfoldSharedComponent;
@@ -900,12 +901,12 @@ public class QuickstepLauncher extends Launcher implements RecentsViewContainer,
protected void registerBackDispatcher() {
getOnBackInvokedDispatcher().registerOnBackInvokedCallback(
OnBackInvokedDispatcher.PRIORITY_DEFAULT,
new OnBackAnimationCallback() {
new FlingOnBackAnimationCallback() {
@Nullable OnBackAnimationCallback mActiveOnBackAnimationCallback;
@Override
public void onBackStarted(@NonNull BackEvent backEvent) {
public void onBackStartedCompat(@NonNull BackEvent backEvent) {
if (mActiveOnBackAnimationCallback != null) {
mActiveOnBackAnimationCallback.onBackCancelled();
}
@@ -915,7 +916,7 @@ public class QuickstepLauncher extends Launcher implements RecentsViewContainer,
@RequiresApi(Build.VERSION_CODES.UPSIDE_DOWN_CAKE)
@Override
public void onBackInvoked() {
public void onBackInvokedCompat() {
// Recreate mActiveOnBackAnimationCallback if necessary to avoid NPE
// because:
// 1. b/260636433: In 3-button-navigation mode, onBackStarted() is not
@@ -931,7 +932,7 @@ public class QuickstepLauncher extends Launcher implements RecentsViewContainer,
}
@Override
public void onBackProgressed(@NonNull BackEvent backEvent) {
public void onBackProgressedCompat(@NonNull BackEvent backEvent) {
if (!FeatureFlags.IS_STUDIO_BUILD
&& mActiveOnBackAnimationCallback == null) {
return;
@@ -940,7 +941,7 @@ public class QuickstepLauncher extends Launcher implements RecentsViewContainer,
}
@Override
public void onBackCancelled() {
public void onBackCancelledCompat() {
if (!FeatureFlags.IS_STUDIO_BUILD
&& mActiveOnBackAnimationCallback == null) {
return;

View File

@@ -43,7 +43,6 @@ import android.view.animation.Interpolator;
import androidx.annotation.FloatRange;
import androidx.annotation.Nullable;
import com.android.app.animation.Interpolators;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.DeviceProfile.OnDeviceProfileChangeListener;
import com.android.launcher3.Launcher;
@@ -277,10 +276,9 @@ public class AllAppsTransitionController
return;
}
float deceleratedProgress = Interpolators.BACK_GESTURE.getInterpolation(backProgress);
float scaleProgress = ScrollableLayoutManager.PREDICTIVE_BACK_MIN_SCALE
+ (1 - ScrollableLayoutManager.PREDICTIVE_BACK_MIN_SCALE)
* (1 - deceleratedProgress);
* (1 - backProgress);
mAllAppScale.updateValue(scaleProgress);
}

View File

@@ -298,8 +298,7 @@ public abstract class AbstractSlideInView<T extends Context & ActivityContext>
@RequiresApi(Build.VERSION_CODES.UPSIDE_DOWN_CAKE)
public void onBackProgressed(BackEvent backEvent) {
final float progress = backEvent.getProgress();
float deceleratedProgress = Interpolators.BACK_GESTURE.getInterpolation(progress);
mSwipeToDismissProgress.updateValue(deceleratedProgress);
mSwipeToDismissProgress.updateValue(progress);
}
/**