Merge "Stash the bar after settling in Overview" into sc-v2-dev
This commit is contained in:
commit
088ec093e5
|
@ -19,10 +19,12 @@ import static com.android.launcher3.LauncherState.HOTSEAT_ICONS;
|
|||
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TASKBAR_LONGPRESS_HIDE;
|
||||
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TASKBAR_LONGPRESS_SHOW;
|
||||
import static com.android.launcher3.taskbar.TaskbarStashController.FLAG_IN_APP;
|
||||
import static com.android.launcher3.taskbar.TaskbarStashController.FLAG_IN_STASHED_LAUNCHER_STATE;
|
||||
import static com.android.launcher3.taskbar.TaskbarViewController.ALPHA_INDEX_HOME;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
import android.animation.AnimatorSet;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.graphics.Rect;
|
||||
import android.view.MotionEvent;
|
||||
|
@ -42,6 +44,7 @@ import com.android.launcher3.logging.InstanceId;
|
|||
import com.android.launcher3.logging.InstanceIdSequence;
|
||||
import com.android.launcher3.model.data.ItemInfoWithIcon;
|
||||
import com.android.launcher3.model.data.WorkspaceItemInfo;
|
||||
import com.android.launcher3.statemanager.StateManager;
|
||||
import com.android.launcher3.util.MultiValueAlpha;
|
||||
import com.android.launcher3.util.MultiValueAlpha.AlphaProperty;
|
||||
import com.android.launcher3.util.OnboardingPrefs;
|
||||
|
@ -76,6 +79,16 @@ public class LauncherTaskbarUIController extends TaskbarUIController {
|
|||
private final DeviceProfile.OnDeviceProfileChangeListener mOnDeviceProfileChangeListener =
|
||||
this::onStashedInAppChanged;
|
||||
|
||||
private final StateManager.StateListener<LauncherState> mStateListener =
|
||||
new StateManager.StateListener<LauncherState>() {
|
||||
@Override
|
||||
public void onStateTransitionComplete(LauncherState finalState) {
|
||||
TaskbarStashController controller = mControllers.taskbarStashController;
|
||||
controller.updateStateForFlag(FLAG_IN_STASHED_LAUNCHER_STATE,
|
||||
finalState.isTaskbarStashed());
|
||||
}
|
||||
};
|
||||
|
||||
// Initialized in init.
|
||||
private TaskbarControllers mControllers;
|
||||
private AnimatedFloat mTaskbarBackgroundAlpha;
|
||||
|
@ -118,6 +131,7 @@ public class LauncherTaskbarUIController extends TaskbarUIController {
|
|||
|
||||
onStashedInAppChanged(mLauncher.getDeviceProfile());
|
||||
mLauncher.addOnDeviceProfileChangeListener(mOnDeviceProfileChangeListener);
|
||||
mLauncher.getStateManager().addStateListener(mStateListener);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -127,6 +141,7 @@ public class LauncherTaskbarUIController extends TaskbarUIController {
|
|||
mIconAlignmentForGestureState.finishAnimation();
|
||||
|
||||
mLauncher.removeOnDeviceProfileChangeListener(mOnDeviceProfileChangeListener);
|
||||
mLauncher.getStateManager().removeStateListener(mStateListener);
|
||||
mLauncher.getHotseat().setIconsAlpha(1f);
|
||||
mLauncher.setTaskbarUIController(null);
|
||||
}
|
||||
|
@ -184,24 +199,28 @@ public class LauncherTaskbarUIController extends TaskbarUIController {
|
|||
*/
|
||||
public Animator createAnimToLauncher(@NonNull LauncherState toState,
|
||||
@NonNull RecentsAnimationCallbacks callbacks, long duration) {
|
||||
AnimatorSet animatorSet = new AnimatorSet();
|
||||
TaskbarStashController stashController = mControllers.taskbarStashController;
|
||||
ObjectAnimator animator = mIconAlignmentForGestureState
|
||||
.animateToValue(1)
|
||||
.setDuration(duration);
|
||||
animator.addListener(new AnimatorListenerAdapter() {
|
||||
stashController.updateStateForFlag(FLAG_IN_STASHED_LAUNCHER_STATE,
|
||||
toState.isTaskbarStashed());
|
||||
if (toState.isTaskbarStashed()) {
|
||||
animatorSet.play(stashController.applyStateWithoutStart(duration));
|
||||
} else {
|
||||
animatorSet.play(mIconAlignmentForGestureState
|
||||
.animateToValue(1)
|
||||
.setDuration(duration));
|
||||
}
|
||||
animatorSet.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
public void onAnimationEnd(Animator animator) {
|
||||
mTargetStateOverride = null;
|
||||
animator.removeListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationStart(Animator animation) {
|
||||
public void onAnimationStart(Animator animator) {
|
||||
mTargetStateOverride = toState;
|
||||
mIsAnimatingToLauncherViaGesture = true;
|
||||
// TODO: FLAG_IN_APP might be sufficient for now, but in the future we do want to
|
||||
// add another flag for LauncherState as well. We will need to decide whether to
|
||||
// show hotseat or the task bar.
|
||||
stashController.updateStateForFlag(FLAG_IN_APP, false);
|
||||
stashController.applyState(duration);
|
||||
}
|
||||
|
@ -215,7 +234,7 @@ public class LauncherTaskbarUIController extends TaskbarUIController {
|
|||
callbacks.removeListener(listener);
|
||||
});
|
||||
|
||||
return animator;
|
||||
return animatorSet;
|
||||
}
|
||||
|
||||
private float getCurrentIconAlignmentRatio() {
|
||||
|
|
|
@ -41,6 +41,7 @@ public class TaskbarStashController {
|
|||
|
||||
public static final int FLAG_IN_APP = 1 << 0;
|
||||
public static final int FLAG_STASHED_IN_APP = 1 << 1;
|
||||
public static final int FLAG_IN_STASHED_LAUNCHER_STATE = 1 << 2;
|
||||
|
||||
/**
|
||||
* How long to stash/unstash when manually invoked via long press.
|
||||
|
@ -83,9 +84,6 @@ public class TaskbarStashController {
|
|||
private final int mStashedHeight;
|
||||
private final int mUnstashedHeight;
|
||||
|
||||
private final StatePropertyHolder mStatePropertyHolder = new StatePropertyHolder(
|
||||
flags -> (((flags & FLAG_IN_APP) != 0) && (flags & FLAG_STASHED_IN_APP) != 0));
|
||||
|
||||
// Initialized in init.
|
||||
private TaskbarControllers mControllers;
|
||||
// Taskbar background properties.
|
||||
|
@ -106,6 +104,18 @@ public class TaskbarStashController {
|
|||
|
||||
private @Nullable AnimatorSet mAnimator;
|
||||
|
||||
// Evaluate whether the handle should be stashed
|
||||
private final StatePropertyHolder mStatePropertyHolder = new StatePropertyHolder(
|
||||
flags -> {
|
||||
if (!supportsStashing()) {
|
||||
return false;
|
||||
}
|
||||
boolean inApp = (flags & FLAG_IN_APP) != 0;
|
||||
boolean stashedInApp = (flags & FLAG_STASHED_IN_APP) != 0;
|
||||
boolean stashedLauncherState = (flags & FLAG_IN_STASHED_LAUNCHER_STATE) != 0;
|
||||
return (inApp && stashedInApp) || (!inApp && stashedLauncherState);
|
||||
});
|
||||
|
||||
public TaskbarStashController(TaskbarActivityContext activity) {
|
||||
mActivity = activity;
|
||||
mPrefs = Utilities.getPrefs(mActivity);
|
||||
|
@ -331,7 +341,15 @@ public class TaskbarStashController {
|
|||
}
|
||||
|
||||
public void applyState(long duration) {
|
||||
mStatePropertyHolder.setState(mState, duration);
|
||||
mStatePropertyHolder.setState(mState, duration, true);
|
||||
}
|
||||
|
||||
public Animator applyStateWithoutStart() {
|
||||
return applyStateWithoutStart(TASKBAR_STASH_DURATION);
|
||||
}
|
||||
|
||||
public Animator applyStateWithoutStart(long duration) {
|
||||
return mStatePropertyHolder.setState(mState, duration, false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -360,12 +378,16 @@ public class TaskbarStashController {
|
|||
mStashCondition = stashCondition;
|
||||
}
|
||||
|
||||
public void setState(int flags, long duration) {
|
||||
public Animator setState(int flags, long duration, boolean start) {
|
||||
boolean isStashed = mStashCondition.test(flags);
|
||||
if (mIsStashed != isStashed) {
|
||||
mIsStashed = isStashed;
|
||||
createAnimToIsStashed(mIsStashed, duration).start();
|
||||
Animator animator = createAnimToIsStashed(mIsStashed, duration);
|
||||
if (start) {
|
||||
animator.start();
|
||||
}
|
||||
}
|
||||
return mAnimator;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -96,6 +96,11 @@ public class OverviewState extends LauncherState {
|
|||
return CLEAR_ALL_BUTTON | OVERVIEW_ACTIONS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTaskbarStashed() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWorkspaceScrimColor(Launcher launcher) {
|
||||
return Themes.getAttrColor(launcher, R.attr.overviewScrimColor);
|
||||
|
|
|
@ -197,6 +197,10 @@ public abstract class LauncherState implements BaseState<LauncherState> {
|
|||
return (getVisibleElements(launcher) & elements) == elements;
|
||||
}
|
||||
|
||||
public boolean isTaskbarStashed() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fraction shift in the vertical translation UI and related properties
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue