mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-03-05 02:16:49 +00:00
Merge "Creaet separate pull back animation for AllApps" into tm-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
7ea312db9b
@@ -21,7 +21,7 @@ import static com.android.launcher3.LauncherAnimUtils.SUCCESS_TRANSITION_PROGRES
|
||||
import static com.android.launcher3.LauncherAnimUtils.newCancelListener;
|
||||
import static com.android.launcher3.LauncherState.ALL_APPS;
|
||||
import static com.android.launcher3.LauncherState.NORMAL;
|
||||
import static com.android.launcher3.allapps.AllAppsTransitionController.ALL_APPS_PROGRESS;
|
||||
import static com.android.launcher3.allapps.AllAppsTransitionController.ALL_APPS_PULL_BACK_PROGRESS;
|
||||
import static com.android.launcher3.anim.AnimatorListeners.forSuccessCallback;
|
||||
import static com.android.launcher3.anim.Interpolators.DEACCEL_3;
|
||||
import static com.android.launcher3.config.FeatureFlags.ENABLE_ALL_APPS_EDU;
|
||||
@@ -147,7 +147,7 @@ public class NavBarToHomeTouchController implements TouchController,
|
||||
AbstractFloatingView.closeOpenContainer(mLauncher, AbstractFloatingView.TYPE_TASK_MENU);
|
||||
} else if (mStartState == ALL_APPS) {
|
||||
AllAppsTransitionController allAppsController = mLauncher.getAllAppsController();
|
||||
builder.setFloat(allAppsController, ALL_APPS_PROGRESS,
|
||||
builder.setFloat(allAppsController, ALL_APPS_PULL_BACK_PROGRESS,
|
||||
-mPullbackDistance / allAppsController.getShiftRange(), PULLBACK_INTERPOLATOR);
|
||||
|
||||
// Slightly fade out all apps content to further distinguish from scrolling.
|
||||
|
||||
@@ -76,6 +76,21 @@ public class AllAppsTransitionController
|
||||
}
|
||||
};
|
||||
|
||||
public static final FloatProperty<AllAppsTransitionController> ALL_APPS_PULL_BACK_PROGRESS =
|
||||
new FloatProperty<AllAppsTransitionController>("allAppsPullBackProgress") {
|
||||
|
||||
@Override
|
||||
public Float get(AllAppsTransitionController controller) {
|
||||
return controller.mPullBackProgress;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(AllAppsTransitionController controller, float progress) {
|
||||
controller.setPullBackProgress(progress);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
private ActivityAllAppsContainerView<Launcher> mAppsView;
|
||||
|
||||
private final Launcher mLauncher;
|
||||
@@ -89,15 +104,17 @@ public class AllAppsTransitionController
|
||||
// When {@link mProgress} is 1, all apps container is pulled down.
|
||||
private float mShiftRange; // changes depending on the orientation
|
||||
private float mProgress; // [0, 1], mShiftRange * mProgress = shiftCurrent
|
||||
private float mPullBackProgress; // [0, 1], mShiftRange * mPullBackProgress = shiftCurrent
|
||||
|
||||
private ScrimView mScrimView;
|
||||
private View mPullBackView;
|
||||
|
||||
public AllAppsTransitionController(Launcher l) {
|
||||
mLauncher = l;
|
||||
DeviceProfile dp = mLauncher.getDeviceProfile();
|
||||
setShiftRange(dp.allAppsShiftRange);
|
||||
mProgress = 1f;
|
||||
|
||||
mPullBackProgress = 1f;
|
||||
mIsVerticalLayout = dp.isVerticalBarLayout();
|
||||
mLauncher.addOnDeviceProfileChangeListener(this);
|
||||
}
|
||||
@@ -115,6 +132,8 @@ public class AllAppsTransitionController
|
||||
mLauncher.getHotseat().setTranslationY(0);
|
||||
mLauncher.getWorkspace().getPageIndicator().setTranslationY(0);
|
||||
}
|
||||
|
||||
mPullBackView = dp.isTablet ? mAppsView.getRecyclerViewContainer() : mAppsView;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -134,12 +153,19 @@ public class AllAppsTransitionController
|
||||
return mProgress;
|
||||
}
|
||||
|
||||
private void setPullBackProgress(float progress) {
|
||||
mPullBackProgress = progress;
|
||||
mPullBackView.setTranslationY(mPullBackProgress * mShiftRange);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the vertical transition progress to {@param state} and updates all the dependent UI
|
||||
* accordingly.
|
||||
*/
|
||||
@Override
|
||||
public void setState(LauncherState state) {
|
||||
// Always reset pull back progress when switching states.
|
||||
setPullBackProgress(0f);
|
||||
setProgress(state.getVerticalProgress(mLauncher));
|
||||
setAlphas(state, new StateAnimationConfig(), NO_ANIM_PROPERTY_SETTER);
|
||||
onProgressAnimationEnd();
|
||||
@@ -156,6 +182,8 @@ public class AllAppsTransitionController
|
||||
UiThreadHelper.hideKeyboardAsync(mLauncher, mLauncher.getAppsView().getWindowToken());
|
||||
}
|
||||
|
||||
// Always reset pull back progress when switching states.
|
||||
setPullBackProgress(0f);
|
||||
float targetProgress = toState.getVerticalProgress(mLauncher);
|
||||
if (Float.compare(mProgress, targetProgress) == 0) {
|
||||
setAlphas(toState, config, builder);
|
||||
@@ -217,6 +245,8 @@ public class AllAppsTransitionController
|
||||
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
|
||||
}
|
||||
mAppsView.setScrimView(scrimView);
|
||||
mPullBackView = mLauncher.getDeviceProfile().isTablet
|
||||
? mAppsView.getRecyclerViewContainer() : mAppsView;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user