Merge "Add getOverviewFullscreenProgress() to LauncherState" into ub-launcher3-qt-dev

This commit is contained in:
TreeHugger Robot
2019-05-17 20:39:42 +00:00
committed by Android (Google) Code Review
7 changed files with 68 additions and 61 deletions
@@ -18,6 +18,7 @@ package com.android.launcher3.uioverrides;
import static com.android.launcher3.LauncherState.RECENTS_CLEAR_ALL_BUTTON;
import static com.android.launcher3.anim.Interpolators.LINEAR;
import static com.android.quickstep.views.RecentsView.CONTENT_ALPHA;
import static com.android.quickstep.views.RecentsView.FULLSCREEN_PROGRESS;
import android.animation.ValueAnimator;
import android.annotation.TargetApi;
@@ -64,6 +65,7 @@ public final class RecentsViewStateController extends
}
}
setAlphas(PropertySetter.NO_ANIM_PROPERTY_SETTER, state.getVisibleElements(mLauncher));
mRecentsView.setFullscreenProgress(state.getOverviewFullscreenProgress());
}
@Override
@@ -95,7 +97,10 @@ public final class RecentsViewStateController extends
builder.addOnFinishRunnable(() -> mRecentsView.setHintVisibility(1f));
}
setAlphas(config.getPropertySetter(builder), toState.getVisibleElements(mLauncher));
PropertySetter propertySetter = config.getPropertySetter(builder);
setAlphas(propertySetter, toState.getVisibleElements(mLauncher));
float fullscreenProgress = toState.getOverviewFullscreenProgress();
propertySetter.setFloat(mRecentsView, FULLSCREEN_PROGRESS, fullscreenProgress, LINEAR);
}
private void setAlphas(PropertySetter propertySetter, int visibleElements) {
@@ -17,14 +17,12 @@ package com.android.launcher3.uioverrides.states;
import static com.android.launcher3.LauncherAnimUtils.OVERVIEW_TRANSITION_MS;
import android.os.RemoteException;
import com.android.launcher3.Launcher;
import com.android.launcher3.allapps.AllAppsTransitionController;
import com.android.quickstep.RecentsModel;
import com.android.launcher3.userevent.nano.LauncherLogProto;
import com.android.quickstep.util.LayoutUtils;
import com.android.quickstep.views.RecentsView;
import com.android.systemui.shared.recents.ISystemUiProxy;
import com.android.quickstep.views.TaskView;
/**
* State indicating that the Launcher is behind an app
@@ -35,7 +33,11 @@ public class BackgroundAppState extends OverviewState {
FLAG_DISABLE_RESTORE | FLAG_OVERVIEW_UI | FLAG_DISABLE_ACCESSIBILITY;
public BackgroundAppState(int id) {
super(id, OVERVIEW_TRANSITION_MS, STATE_FLAGS);
this(id, LauncherLogProto.ContainerType.TASKSWITCHER);
}
protected BackgroundAppState(int id, int logContainer) {
super(id, logContainer, OVERVIEW_TRANSITION_MS, STATE_FLAGS);
}
@Override
@@ -55,23 +57,17 @@ public class BackgroundAppState extends OverviewState {
public ScaleAndTranslation getOverviewScaleAndTranslation(Launcher launcher) {
// Initialize the recents view scale to what it would be when starting swipe up
RecentsView recentsView = launcher.getOverviewPanel();
recentsView.getTaskSize(sTempRect);
int appWidth = launcher.getDragLayer().getWidth();
if (recentsView.shouldUseMultiWindowTaskSizeStrategy()) {
ISystemUiProxy sysUiProxy = RecentsModel.INSTANCE.get(launcher).getSystemUiProxy();
if (sysUiProxy != null) {
try {
// Try to use the actual non-minimized app width (launcher will be resized to
// the non-minimized bounds, which differs from the app width in landscape
// multi-window mode
appWidth = sysUiProxy.getNonMinimizedSplitScreenSecondaryBounds().width();
} catch (RemoteException e) {
// Ignore, fall back to just using the drag layer width
}
}
if (recentsView.getTaskViewCount() == 0) {
return super.getOverviewScaleAndTranslation(launcher);
}
float scale = (float) appWidth / sTempRect.width();
return new ScaleAndTranslation(scale, 0f, 0f);
TaskView dummyTask = recentsView.getTaskViewAt(recentsView.getCurrentPage());
return recentsView.getTempClipAnimationHelper()
.getOverviewFullscreenScaleAndTranslation(dummyTask);
}
@Override
public float getOverviewFullscreenProgress() {
return 1;
}
@Override
@@ -15,11 +15,8 @@
*/
package com.android.launcher3.uioverrides.states;
import static com.android.launcher3.LauncherAnimUtils.OVERVIEW_TRANSITION_MS;
import com.android.launcher3.Launcher;
import com.android.launcher3.userevent.nano.LauncherLogProto;
import com.android.quickstep.util.ClipAnimationHelper;
import com.android.quickstep.views.RecentsView;
import com.android.quickstep.views.TaskView;
@@ -28,23 +25,10 @@ import com.android.quickstep.views.TaskView;
* quick switching from launcher; quick switching from an app uses WindowTransformSwipeHelper.
* @see com.android.quickstep.WindowTransformSwipeHandler.GestureEndTarget#NEW_TASK
*/
public class QuickSwitchState extends OverviewState {
private static final int STATE_FLAGS =
FLAG_DISABLE_RESTORE | FLAG_OVERVIEW_UI | FLAG_DISABLE_ACCESSIBILITY;
public class QuickSwitchState extends BackgroundAppState {
public QuickSwitchState(int id) {
super(id, LauncherLogProto.ContainerType.APP, OVERVIEW_TRANSITION_MS, STATE_FLAGS);
}
@Override
public ScaleAndTranslation getOverviewScaleAndTranslation(Launcher launcher) {
RecentsView recentsView = launcher.getOverviewPanel();
if (recentsView.getTaskViewCount() == 0) {
return super.getOverviewScaleAndTranslation(launcher);
}
TaskView dummyTask = recentsView.getTaskViewAt(0);
ClipAnimationHelper clipAnimationHelper = new ClipAnimationHelper(launcher);
return clipAnimationHelper.getOverviewFullscreenScaleAndTranslation(dummyTask);
super(id, LauncherLogProto.ContainerType.APP);
}
@Override
@@ -55,11 +39,6 @@ public class QuickSwitchState extends OverviewState {
return new ScaleAndTranslation(1, 0, translationY);
}
@Override
public float getVerticalProgress(Launcher launcher) {
return BACKGROUND_APP.getVerticalProgress(launcher);
}
@Override
public int getVisibleElements(Launcher launcher) {
return NONE;
@@ -55,7 +55,6 @@ import com.android.launcher3.compat.AccessibilityManagerCompat;
import com.android.launcher3.userevent.nano.LauncherLogProto;
import com.android.launcher3.views.FloatingIconView;
import com.android.quickstep.SysUINavigationMode.Mode;
import com.android.quickstep.util.ClipAnimationHelper;
import com.android.quickstep.util.LayoutUtils;
import com.android.quickstep.views.RecentsView;
import com.android.quickstep.views.TaskView;
@@ -266,7 +265,7 @@ public final class LauncherActivityControllerHelper implements ActivityControlHe
endState.getVerticalProgress(activity));
anim.play(shiftAnim);
}
playScaleDownAnim(anim, activity, endState);
playScaleDownAnim(anim, activity, fromState, endState);
anim.setDuration(transitionLength * 2);
AnimatorPlaybackController controller =
@@ -292,7 +291,7 @@ public final class LauncherActivityControllerHelper implements ActivityControlHe
/**
* Scale down recents from the center task being full screen to being in overview.
*/
private void playScaleDownAnim(AnimatorSet anim, Launcher launcher,
private void playScaleDownAnim(AnimatorSet anim, Launcher launcher, LauncherState fromState,
LauncherState endState) {
RecentsView recentsView = launcher.getOverviewPanel();
TaskView v = recentsView.getTaskViewAt(recentsView.getCurrentPage());
@@ -300,19 +299,23 @@ public final class LauncherActivityControllerHelper implements ActivityControlHe
return;
}
ClipAnimationHelper clipHelper = new ClipAnimationHelper(launcher);
LauncherState.ScaleAndTranslation fromScaleAndTranslation
= clipHelper.getOverviewFullscreenScaleAndTranslation(v);
= fromState.getOverviewScaleAndTranslation(launcher);
LauncherState.ScaleAndTranslation endScaleAndTranslation
= endState.getOverviewScaleAndTranslation(launcher);
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,
fromScaleAndTranslation.translationY, endScaleAndTranslation.translationY);
Animator applyFullscreenProgress = ObjectAnimator.ofFloat(recentsView,
RecentsView.FULLSCREEN_PROGRESS, fromFullscreenProgress, endFullscreenProgress);
scale.setInterpolator(LINEAR);
translateY.setInterpolator(LINEAR);
anim.playTogether(scale, translateY);
applyFullscreenProgress.setInterpolator(LINEAR);
anim.playTogether(scale, translateY, applyFullscreenProgress);
}
@Override
@@ -504,6 +504,7 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity>
private void setupRecentsViewUi() {
if (mContinuingLastGesture) {
updateSysUiFlags(mCurrentShift.value);
return;
}
mRecentsView.onGestureAnimationStart(mRunningTaskId);
@@ -677,15 +678,6 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity>
HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING);
}
}
// Update insets of the non-running tasks, as we might switch to them.
int runningTaskIndex = mRecentsView == null ? -1 : mRecentsView.getRunningTaskIndex();
if (runningTaskIndex >= 0) {
for (int i = 0; i < mRecentsView.getTaskViewCount(); i++) {
if (i != runningTaskIndex || !mRecentsAnimationWrapper.hasTargets()) {
mRecentsView.getTaskViewAt(i).setFullscreenProgress(1 - mCurrentShift.value);
}
}
}
if (mLauncherTransitionController == null || mLauncherTransitionController
.getAnimationPlayer().isStarted()) {
@@ -142,6 +142,19 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl
}
};
public static final FloatProperty<RecentsView> FULLSCREEN_PROGRESS =
new FloatProperty<RecentsView>("fullscreenProgress") {
@Override
public void setValue(RecentsView recentsView, float v) {
recentsView.setFullscreenProgress(v);
}
@Override
public Float get(RecentsView recentsView) {
return recentsView.mFullscreenProgress;
}
};
protected RecentsAnimationWrapper mRecentsAnimationWrapper;
protected ClipAnimationHelper mClipAnimationHelper;
protected SyncRtSurfaceTransactionApplierCompat mSyncTransactionApplier;
@@ -165,6 +178,7 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl
private final ClearAllButton mClearAllButton;
private final Rect mClearAllButtonDeadZoneRect = new Rect();
private final Rect mTaskViewDeadZoneRect = new Rect();
protected final ClipAnimationHelper mTempClipAnimationHelper;
private final ScrollState mScrollState = new ScrollState();
// Keeps track of the previously known visible tasks for purposes of loading/unloading task data
@@ -276,6 +290,8 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl
@ViewDebug.ExportedProperty(category = "launcher")
private float mContentAlpha = 1;
@ViewDebug.ExportedProperty(category = "launcher")
private float mFullscreenProgress = 0;
// Keeps track of task id whose visual state should not be reset
private int mIgnoreResetTaskId = -1;
@@ -310,6 +326,7 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl
mActivity = (T) BaseActivity.fromContext(context);
mModel = RecentsModel.INSTANCE.get(context);
mIdp = InvariantDeviceProfile.INSTANCE.get(context);
mTempClipAnimationHelper = new ClipAnimationHelper(context);
mClearAllButton = (ClearAllButton) LayoutInflater.from(context)
.inflate(R.layout.overview_clear_all_button, this, false);
@@ -598,6 +615,14 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl
loadVisibleTaskData();
}
public void setFullscreenProgress(float fullscreenProgress) {
mFullscreenProgress = fullscreenProgress;
int taskCount = getTaskViewCount();
for (int i = 0; i < taskCount; i++) {
getTaskViewAt(i).setFullscreenProgress(mFullscreenProgress);
}
}
private void updateTaskStackListenerState() {
boolean handleTaskStackChanges = mOverviewStateEnabled && isAttachedToWindow()
&& getWindowVisibility() == VISIBLE;
@@ -1714,4 +1739,8 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl
true /* hideOriginal */, iconLocation, false /* isOpening */, mFloatingIconView);
return mFloatingIconView;
}
public ClipAnimationHelper getTempClipAnimationHelper() {
return mTempClipAnimationHelper;
}
}
+4 -1
View File
@@ -18,7 +18,6 @@ package com.android.launcher3;
import static android.view.View.IMPORTANT_FOR_ACCESSIBILITY_AUTO;
import static android.view.View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS;
import static android.view.accessibility.AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED;
import static com.android.launcher3.TestProtocol.ALL_APPS_STATE_ORDINAL;
import static com.android.launcher3.TestProtocol.BACKGROUND_APP_STATE_ORDINAL;
import static com.android.launcher3.TestProtocol.NORMAL_STATE_ORDINAL;
@@ -203,6 +202,10 @@ public class LauncherState {
return UiFactory.getOverviewScaleAndTranslationForNormalState(launcher);
}
public float getOverviewFullscreenProgress() {
return 0;
}
public void onStateEnabled(Launcher launcher) {
dispatchWindowStateChanged(launcher);
}