use of com.android.launcher3.LauncherState.OVERVIEW in project Neo-Launcher by NeoApplications.
the class LauncherActivityControllerHelper method prepareRecentsUI.
@Override
public AnimationFactory prepareRecentsUI(Launcher activity, boolean activityVisible, boolean animateActivity, Consumer<AnimatorPlaybackController> callback) {
final LauncherState startState = activity.getStateManager().getState();
LauncherState resetState = startState;
if (startState.disableRestore) {
resetState = activity.getStateManager().getRestState();
}
activity.getStateManager().setRestState(resetState);
final LauncherState fromState = animateActivity ? BACKGROUND_APP : OVERVIEW;
activity.getStateManager().goToState(fromState, false);
// Since all apps is not visible, we can safely reset the scroll position.
// This ensures then the next swipe up to all-apps starts from scroll 0.
activity.getAppsView().reset(false);
return new AnimationFactory() {
private final ShelfPeekAnim mShelfAnim = ((QuickstepAppTransitionManagerImpl) activity.getAppTransitionManager()).getShelfPeekAnim();
private boolean mIsAttachedToWindow;
@Override
public void createActivityController(long transitionLength) {
createActivityControllerInternal(activity, fromState, transitionLength, callback);
// attached state here as well to ensure recents is shown/hidden appropriately.
if (SysUINavigationMode.getMode(activity) == Mode.NO_BUTTON) {
setRecentsAttachedToAppWindow(mIsAttachedToWindow, false);
}
}
@Override
public void adjustActivityControllerInterpolators() {
if (mAdjustInterpolatorsRunnable != null) {
mAdjustInterpolatorsRunnable.run();
}
}
@Override
public void onTransitionCancelled() {
activity.getStateManager().goToState(startState, false);
}
@Override
public void setShelfState(ShelfAnimState shelfState, Interpolator interpolator, long duration) {
mShelfAnim.setShelfState(shelfState, interpolator, duration);
}
@Override
public void setRecentsAttachedToAppWindow(boolean attached, boolean animate) {
if (mIsAttachedToWindow == attached && animate) {
return;
}
mIsAttachedToWindow = attached;
LauncherRecentsView recentsView = activity.getOverviewPanel();
Animator fadeAnim = activity.getStateManager().createStateElementAnimation(INDEX_RECENTS_FADE_ANIM, attached ? 1 : 0);
int runningTaskIndex = recentsView.getRunningTaskIndex();
if (runningTaskIndex == recentsView.getTaskViewStartIndex()) {
// If we are on the first task (we haven't quick switched), translate recents in
// from the side. Calculate the start translation based on current scale/scroll.
float currScale = recentsView.getScaleX();
float scrollOffsetX = recentsView.getScrollOffset();
float offscreenX = recentsView.getOffscreenTranslationX(currScale);
float fromTranslationX = attached ? offscreenX - scrollOffsetX : 0;
float toTranslationX = attached ? 0 : offscreenX - scrollOffsetX;
activity.getStateManager().cancelStateElementAnimation(INDEX_RECENTS_TRANSLATE_X_ANIM);
if (!recentsView.isShown() && animate) {
recentsView.setTranslationX(fromTranslationX);
} else {
fromTranslationX = recentsView.getTranslationX();
}
if (!animate) {
recentsView.setTranslationX(toTranslationX);
} else {
activity.getStateManager().createStateElementAnimation(INDEX_RECENTS_TRANSLATE_X_ANIM, fromTranslationX, toTranslationX).start();
}
fadeAnim.setInterpolator(attached ? INSTANT : ACCEL_2);
} else {
fadeAnim.setInterpolator(ACCEL_DEACCEL);
}
fadeAnim.setDuration(animate ? RECENTS_ATTACH_DURATION : 0).start();
}
};
}
use of com.android.launcher3.LauncherState.OVERVIEW in project Neo-Launcher by NeoApplications.
the class LauncherActivityControllerHelper method playScaleDownAnim.
/**
* Scale down recents from the center task being full screen to being in overview.
*/
private void playScaleDownAnim(AnimatorSet anim, Launcher launcher, LauncherState fromState, LauncherState endState) {
RecentsView recentsView = launcher.getOverviewPanel();
if (recentsView.getCurrentPageTaskView() == null) {
return;
}
LauncherState.ScaleAndTranslation fromScaleAndTranslation = fromState.getOverviewScaleAndTranslation(launcher);
LauncherState.ScaleAndTranslation endScaleAndTranslation = endState.getOverviewScaleAndTranslation(launcher);
float fromTranslationY = fromScaleAndTranslation.translationY;
float endTranslationY = endScaleAndTranslation.translationY;
float fromFullscreenProgress = fromState.getOverviewFullscreenProgress();
float endFullscreenProgress = endState.getOverviewFullscreenProgress();
Animator scale = ObjectAnimator.ofFloat(recentsView, SCALE_PROPERTY, fromScaleAndTranslation.scale, endScaleAndTranslation.scale);
Animator translateY = ObjectAnimator.ofFloat(recentsView, TRANSLATION_Y, fromTranslationY, endTranslationY);
Animator applyFullscreenProgress = ObjectAnimator.ofFloat(recentsView, RecentsView.FULLSCREEN_PROGRESS, fromFullscreenProgress, endFullscreenProgress);
anim.playTogether(scale, translateY, applyFullscreenProgress);
mAdjustInterpolatorsRunnable = () -> {
// Adjust the translateY interpolator to account for the running task's top inset.
// When progress <= 1, this is handled by each task view as they set their fullscreen
// progress. However, once we go to progress > 1, fullscreen progress stays at 0, so
// recents as a whole needs to translate further to keep up with the app window.
TaskView runningTaskView = recentsView.getRunningTaskView();
if (runningTaskView == null) {
runningTaskView = recentsView.getCurrentPageTaskView();
if (runningTaskView == null) {
// There are no task views in LockTask mode when Overview is enabled.
return;
}
}
TimeInterpolator oldInterpolator = translateY.getInterpolator();
Rect fallbackInsets = launcher.getDeviceProfile().getInsets();
float extraTranslationY = runningTaskView.getThumbnail().getInsets(fallbackInsets).top;
float normalizedTranslationY = extraTranslationY / (fromTranslationY - endTranslationY);
translateY.setInterpolator(t -> {
float newT = oldInterpolator.getInterpolation(t);
return newT <= 1f ? newT : newT + normalizedTranslationY * (newT - 1);
});
};
}
use of com.android.launcher3.LauncherState.OVERVIEW in project Neo-Launcher by NeoApplications.
the class LauncherActivityControllerHelper method switchToRecentsIfVisible.
@Override
public boolean switchToRecentsIfVisible(Runnable onCompleteCallback) {
Launcher launcher = getVisibleLauncher();
if (launcher == null) {
return false;
}
launcher.getUserEventDispatcher().logActionCommand(LauncherLogProto.Action.Command.RECENTS_BUTTON, getContainerType(), LauncherLogProto.ContainerType.TASKSWITCHER);
launcher.getStateManager().goToState(OVERVIEW, launcher.getStateManager().shouldAnimateStateChange(), onCompleteCallback);
return true;
}
use of com.android.launcher3.LauncherState.OVERVIEW in project Neo-Launcher by NeoApplications.
the class LauncherActivityControllerHelper method createActivityControllerInternal.
private void createActivityControllerInternal(Launcher activity, LauncherState fromState, long transitionLength, Consumer<AnimatorPlaybackController> callback) {
LauncherState endState = OVERVIEW;
if (fromState == endState) {
return;
}
AnimatorSet anim = new AnimatorSet();
if (!activity.getDeviceProfile().isVerticalBarLayout() && SysUINavigationMode.getMode(activity) != Mode.NO_BUTTON) {
// Don't animate the shelf when the mode is NO_BUTTON, because we update it atomically.
anim.play(activity.getStateManager().createStateElementAnimation(INDEX_SHELF_ANIM, fromState.getVerticalProgress(activity), endState.getVerticalProgress(activity)));
}
playScaleDownAnim(anim, activity, fromState, endState);
anim.setDuration(transitionLength * 2);
anim.setInterpolator(LINEAR);
AnimatorPlaybackController controller = AnimatorPlaybackController.wrap(anim, transitionLength * 2);
activity.getStateManager().setCurrentUserControlledAnimation(controller);
// Since we are changing the start position of the UI, reapply the state, at the end
controller.setEndAction(() -> {
activity.getStateManager().goToState(controller.getInterpolatedProgress() > 0.5 ? endState : fromState, false);
});
callback.accept(controller);
}
use of com.android.launcher3.LauncherState.OVERVIEW in project Neo-Launcher by NeoApplications.
the class RecentsUiFactory method onLauncherStateOrResumeChanged.
/**
* Recents logic that triggers when launcher state changes or launcher activity stops/resumes.
*
* @param launcher the launcher activity
*/
public static void onLauncherStateOrResumeChanged(Launcher launcher) {
LauncherState state = launcher.getStateManager().getState();
DeviceProfile profile = launcher.getDeviceProfile();
boolean visible = (state == NORMAL || state == OVERVIEW) && launcher.isUserActive() && !profile.isVerticalBarLayout();
UiThreadHelper.runAsyncCommand(launcher, SET_SHELF_HEIGHT_CMD, visible ? 1 : 0, profile.hotseatBarSizePx);
if (state == NORMAL) {
launcher.<RecentsView>getOverviewPanel().setSwipeDownShouldLaunchApp(false);
}
}
Aggregations