Separating the draglayer alpha into multiple dimensions so that different animaitons
can run without affecting the other. Bug: 79323355 Bug: 78880824 Change-Id: I11cb464ebdaad0a7f0a56d4bc4c3dff1d56da16b
This commit is contained in:
1 parent
08cf36ea54
commit
6001ea2e2f
9 files changed
+199
-45
No files matched your search
@@ -25,6 +25,7 @@ import static com.android.launcher3.Utilities.postAsyncCallback;
|
|||||||
import static com.android.launcher3.anim.Interpolators.AGGRESSIVE_EASE;
|
import static com.android.launcher3.anim.Interpolators.AGGRESSIVE_EASE;
|
||||||
import static com.android.launcher3.anim.Interpolators.DEACCEL_1_7;
|
import static com.android.launcher3.anim.Interpolators.DEACCEL_1_7;
|
||||||
import static com.android.launcher3.anim.Interpolators.LINEAR;
|
import static com.android.launcher3.anim.Interpolators.LINEAR;
|
||||||
|
import static com.android.launcher3.dragndrop.DragLayer.ALPHA_INDEX_TRANSITIONS;
|
||||||
import static com.android.quickstep.TaskUtils.findTaskViewToLaunch;
|
import static com.android.quickstep.TaskUtils.findTaskViewToLaunch;
|
||||||
import static com.android.quickstep.TaskUtils.getRecentsWindowAnimator;
|
import static com.android.quickstep.TaskUtils.getRecentsWindowAnimator;
|
||||||
import static com.android.quickstep.TaskUtils.taskIsATargetWithMode;
|
import static com.android.quickstep.TaskUtils.taskIsATargetWithMode;
|
||||||
@@ -62,6 +63,8 @@ import com.android.launcher3.anim.Interpolators;
|
|||||||
import com.android.launcher3.dragndrop.DragLayer;
|
import com.android.launcher3.dragndrop.DragLayer;
|
||||||
import com.android.launcher3.graphics.DrawableFactory;
|
import com.android.launcher3.graphics.DrawableFactory;
|
||||||
import com.android.launcher3.shortcuts.DeepShortcutView;
|
import com.android.launcher3.shortcuts.DeepShortcutView;
|
||||||
|
import com.android.launcher3.util.MultiValueAlpha;
|
||||||
|
import com.android.launcher3.util.MultiValueAlpha.AlphaProperty;
|
||||||
import com.android.quickstep.util.ClipAnimationHelper;
|
import com.android.quickstep.util.ClipAnimationHelper;
|
||||||
import com.android.quickstep.util.MultiValueUpdateListener;
|
import com.android.quickstep.util.MultiValueUpdateListener;
|
||||||
import com.android.quickstep.util.RemoteAnimationProvider;
|
import com.android.quickstep.util.RemoteAnimationProvider;
|
||||||
@@ -105,8 +108,9 @@ public class LauncherAppTransitionManagerImpl extends LauncherAppTransitionManag
|
|||||||
// Progress = 0: All apps is fully pulled up, Progress = 1: All apps is fully pulled down.
|
// Progress = 0: All apps is fully pulled up, Progress = 1: All apps is fully pulled down.
|
||||||
public static final float ALL_APPS_PROGRESS_OFF_SCREEN = 1.3059858f;
|
public static final float ALL_APPS_PROGRESS_OFF_SCREEN = 1.3059858f;
|
||||||
|
|
||||||
private final DragLayer mDragLayer;
|
|
||||||
private final Launcher mLauncher;
|
private final Launcher mLauncher;
|
||||||
|
private final DragLayer mDragLayer;
|
||||||
|
private final AlphaProperty mDragLayerAlpha;
|
||||||
|
|
||||||
private final Handler mHandler;
|
private final Handler mHandler;
|
||||||
private final boolean mIsRtl;
|
private final boolean mIsRtl;
|
||||||
@@ -142,6 +146,7 @@ public class LauncherAppTransitionManagerImpl extends LauncherAppTransitionManag
|
|||||||
public LauncherAppTransitionManagerImpl(Context context) {
|
public LauncherAppTransitionManagerImpl(Context context) {
|
||||||
mLauncher = Launcher.getLauncher(context);
|
mLauncher = Launcher.getLauncher(context);
|
||||||
mDragLayer = mLauncher.getDragLayer();
|
mDragLayer = mLauncher.getDragLayer();
|
||||||
|
mDragLayerAlpha = mDragLayer.getAlphaProperty(ALPHA_INDEX_TRANSITIONS);
|
||||||
mHandler = new Handler(Looper.getMainLooper());
|
mHandler = new Handler(Looper.getMainLooper());
|
||||||
mIsRtl = Utilities.isRtl(mLauncher.getResources());
|
mIsRtl = Utilities.isRtl(mLauncher.getResources());
|
||||||
mDeviceProfile = mLauncher.getDeviceProfile();
|
mDeviceProfile = mLauncher.getDeviceProfile();
|
||||||
@@ -325,16 +330,15 @@ public class LauncherAppTransitionManagerImpl extends LauncherAppTransitionManag
|
|||||||
appsView.setLayerType(View.LAYER_TYPE_NONE, null);
|
appsView.setLayerType(View.LAYER_TYPE_NONE, null);
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
View contentView = mLauncher.getDragLayer();
|
mDragLayerAlpha.setValue(alphas[0]);
|
||||||
contentView.setAlpha(alphas[0]);
|
ObjectAnimator alpha =
|
||||||
contentView.setTranslationY(trans[0]);
|
ObjectAnimator.ofFloat(mDragLayerAlpha, MultiValueAlpha.VALUE, alphas);
|
||||||
|
|
||||||
ObjectAnimator alpha = ObjectAnimator.ofFloat(contentView, View.ALPHA, alphas);
|
|
||||||
alpha.setDuration(217);
|
alpha.setDuration(217);
|
||||||
alpha.setInterpolator(LINEAR);
|
alpha.setInterpolator(LINEAR);
|
||||||
launcherAnimator.play(alpha);
|
launcherAnimator.play(alpha);
|
||||||
|
|
||||||
ObjectAnimator transY = ObjectAnimator.ofFloat(contentView, View.TRANSLATION_Y, trans);
|
mDragLayer.setTranslationY(trans[0]);
|
||||||
|
ObjectAnimator transY = ObjectAnimator.ofFloat(mDragLayer, View.TRANSLATION_Y, trans);
|
||||||
transY.setInterpolator(AGGRESSIVE_EASE);
|
transY.setInterpolator(AGGRESSIVE_EASE);
|
||||||
transY.setDuration(350);
|
transY.setDuration(350);
|
||||||
launcherAnimator.play(transY);
|
launcherAnimator.play(transY);
|
||||||
@@ -342,11 +346,9 @@ public class LauncherAppTransitionManagerImpl extends LauncherAppTransitionManag
|
|||||||
mDragLayer.getScrim().hideSysUiScrim(true);
|
mDragLayer.getScrim().hideSysUiScrim(true);
|
||||||
// Pause page indicator animations as they lead to layer trashing.
|
// Pause page indicator animations as they lead to layer trashing.
|
||||||
mLauncher.getWorkspace().getPageIndicator().pauseAnimations();
|
mLauncher.getWorkspace().getPageIndicator().pauseAnimations();
|
||||||
contentView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
|
mDragLayer.setLayerType(View.LAYER_TYPE_HARDWARE, null);
|
||||||
|
|
||||||
endListener = () -> {
|
endListener = this::resetContentView;
|
||||||
resetContentView(contentView);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
return new Pair<>(launcherAnimator, endListener);
|
return new Pair<>(launcherAnimator, endListener);
|
||||||
}
|
}
|
||||||
@@ -700,14 +702,13 @@ public class LauncherAppTransitionManagerImpl extends LauncherAppTransitionManag
|
|||||||
} else {
|
} else {
|
||||||
AnimatorSet workspaceAnimator = new AnimatorSet();
|
AnimatorSet workspaceAnimator = new AnimatorSet();
|
||||||
|
|
||||||
View contentView = mLauncher.getRootView();
|
mDragLayer.setTranslationY(-mWorkspaceTransY);;
|
||||||
|
workspaceAnimator.play(ObjectAnimator.ofFloat(mDragLayer, View.TRANSLATION_Y,
|
||||||
contentView.setTranslationY(-mWorkspaceTransY);;
|
|
||||||
workspaceAnimator.play(ObjectAnimator.ofFloat(contentView, View.TRANSLATION_Y,
|
|
||||||
-mWorkspaceTransY, 0));
|
-mWorkspaceTransY, 0));
|
||||||
|
|
||||||
contentView.setAlpha(0);
|
mDragLayerAlpha.setValue(0);
|
||||||
workspaceAnimator.play(ObjectAnimator.ofFloat(contentView, View.ALPHA, 0, 1f));
|
workspaceAnimator.play(ObjectAnimator.ofFloat(
|
||||||
|
mDragLayerAlpha, MultiValueAlpha.VALUE, 0, 1f));
|
||||||
|
|
||||||
workspaceAnimator.setStartDelay(LAUNCHER_RESUME_START_DELAY);
|
workspaceAnimator.setStartDelay(LAUNCHER_RESUME_START_DELAY);
|
||||||
workspaceAnimator.setDuration(333);
|
workspaceAnimator.setDuration(333);
|
||||||
@@ -717,25 +718,24 @@ public class LauncherAppTransitionManagerImpl extends LauncherAppTransitionManag
|
|||||||
|
|
||||||
// Pause page indicator animations as they lead to layer trashing.
|
// Pause page indicator animations as they lead to layer trashing.
|
||||||
mLauncher.getWorkspace().getPageIndicator().pauseAnimations();
|
mLauncher.getWorkspace().getPageIndicator().pauseAnimations();
|
||||||
contentView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
|
mDragLayer.setLayerType(View.LAYER_TYPE_HARDWARE, null);
|
||||||
|
|
||||||
workspaceAnimator.addListener(new AnimatorListenerAdapter() {
|
workspaceAnimator.addListener(new AnimatorListenerAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void onAnimationEnd(Animator animation) {
|
public void onAnimationEnd(Animator animation) {
|
||||||
resetContentView(contentView);
|
resetContentView();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
anim.play(workspaceAnimator);
|
anim.play(workspaceAnimator);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void resetContentView(View v) {
|
private void resetContentView() {
|
||||||
v.setLayerType(View.LAYER_TYPE_NONE, null);
|
|
||||||
|
|
||||||
mLauncher.getWorkspace().getPageIndicator().skipAnimationsToEnd();
|
mLauncher.getWorkspace().getPageIndicator().skipAnimationsToEnd();
|
||||||
v.setAlpha(1f);
|
mDragLayerAlpha.setValue(1f);
|
||||||
v.setTranslationY(0f);
|
mDragLayer.setLayerType(View.LAYER_TYPE_NONE, null);
|
||||||
mLauncher.getDragLayer().getScrim().hideSysUiScrim(false);
|
mDragLayer.setTranslationY(0f);
|
||||||
|
mDragLayer.getScrim().hideSysUiScrim(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean hasControlRemoteAppTransitionPermission() {
|
private boolean hasControlRemoteAppTransitionPermission() {
|
||||||
|
|||||||
@@ -41,6 +41,8 @@ import com.android.launcher3.LauncherState;
|
|||||||
import com.android.launcher3.allapps.AllAppsTransitionController;
|
import com.android.launcher3.allapps.AllAppsTransitionController;
|
||||||
import com.android.launcher3.allapps.DiscoveryBounce;
|
import com.android.launcher3.allapps.DiscoveryBounce;
|
||||||
import com.android.launcher3.anim.AnimatorPlaybackController;
|
import com.android.launcher3.anim.AnimatorPlaybackController;
|
||||||
|
import com.android.launcher3.dragndrop.DragLayer;
|
||||||
|
import com.android.launcher3.util.MultiValueAlpha.AlphaProperty;
|
||||||
import com.android.quickstep.util.LayoutUtils;
|
import com.android.quickstep.util.LayoutUtils;
|
||||||
import com.android.quickstep.util.RemoteAnimationProvider;
|
import com.android.quickstep.util.RemoteAnimationProvider;
|
||||||
import com.android.quickstep.util.RemoteAnimationTargetSet;
|
import com.android.quickstep.util.RemoteAnimationTargetSet;
|
||||||
@@ -103,6 +105,8 @@ public interface ActivityControlHelper<T extends BaseDraggingActivity> {
|
|||||||
|
|
||||||
boolean supportsLongSwipe(T activity);
|
boolean supportsLongSwipe(T activity);
|
||||||
|
|
||||||
|
AlphaProperty getAlphaProperty(T activity);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Must return a non-null controller is supportsLongSwipe was true.
|
* Must return a non-null controller is supportsLongSwipe was true.
|
||||||
*/
|
*/
|
||||||
@@ -298,6 +302,11 @@ public interface ActivityControlHelper<T extends BaseDraggingActivity> {
|
|||||||
}
|
}
|
||||||
return new LongSwipeHelper(activity, targetSet);
|
return new LongSwipeHelper(activity, targetSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AlphaProperty getAlphaProperty(Launcher activity) {
|
||||||
|
return activity.getDragLayer().getAlphaProperty(DragLayer.ALPHA_INDEX_SWIPE_UP);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class FallbackActivityControllerHelper implements ActivityControlHelper<RecentsActivity> {
|
class FallbackActivityControllerHelper implements ActivityControlHelper<RecentsActivity> {
|
||||||
@@ -451,6 +460,11 @@ public interface ActivityControlHelper<T extends BaseDraggingActivity> {
|
|||||||
RemoteAnimationTargetSet targetSet) {
|
RemoteAnimationTargetSet targetSet) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AlphaProperty getAlphaProperty(RecentsActivity activity) {
|
||||||
|
return activity.getDragLayer().getAlphaProperty(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
interface LayoutListener {
|
interface LayoutListener {
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import static com.android.quickstep.TouchConsumer.INTERACTION_NORMAL;
|
|||||||
import static com.android.quickstep.TouchConsumer.INTERACTION_QUICK_SCRUB;
|
import static com.android.quickstep.TouchConsumer.INTERACTION_QUICK_SCRUB;
|
||||||
|
|
||||||
import android.animation.Animator;
|
import android.animation.Animator;
|
||||||
|
import android.animation.AnimatorListenerAdapter;
|
||||||
import android.animation.ObjectAnimator;
|
import android.animation.ObjectAnimator;
|
||||||
import android.annotation.TargetApi;
|
import android.annotation.TargetApi;
|
||||||
import android.app.ActivityManager.RunningTaskInfo;
|
import android.app.ActivityManager.RunningTaskInfo;
|
||||||
@@ -58,6 +59,8 @@ import com.android.launcher3.logging.UserEventDispatcher;
|
|||||||
import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Direction;
|
import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Direction;
|
||||||
import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch;
|
import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch;
|
||||||
import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType;
|
import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType;
|
||||||
|
import com.android.launcher3.util.MultiValueAlpha;
|
||||||
|
import com.android.launcher3.util.MultiValueAlpha.AlphaProperty;
|
||||||
import com.android.launcher3.util.TraceHelper;
|
import com.android.launcher3.util.TraceHelper;
|
||||||
import com.android.quickstep.ActivityControlHelper.ActivityInitListener;
|
import com.android.quickstep.ActivityControlHelper.ActivityInitListener;
|
||||||
import com.android.quickstep.ActivityControlHelper.AnimationFactory;
|
import com.android.quickstep.ActivityControlHelper.AnimationFactory;
|
||||||
@@ -368,15 +371,15 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity> {
|
|||||||
mStateCallback.setState(STATE_ACTIVITY_MULTIPLIER_COMPLETE | STATE_LAUNCHER_DRAWN);
|
mStateCallback.setState(STATE_ACTIVITY_MULTIPLIER_COMPLETE | STATE_LAUNCHER_DRAWN);
|
||||||
} else {
|
} else {
|
||||||
TraceHelper.beginSection("WTS-init");
|
TraceHelper.beginSection("WTS-init");
|
||||||
View rootView = activity.getRootView();
|
View dragLayer = activity.getDragLayer();
|
||||||
rootView.setAlpha(0);
|
mActivityControlHelper.getAlphaProperty(activity).setValue(0);
|
||||||
rootView.getViewTreeObserver().addOnDrawListener(new OnDrawListener() {
|
dragLayer.getViewTreeObserver().addOnDrawListener(new OnDrawListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDraw() {
|
public void onDraw() {
|
||||||
TraceHelper.endSection("WTS-init", "Launcher frame is drawn");
|
TraceHelper.endSection("WTS-init", "Launcher frame is drawn");
|
||||||
rootView.post(() ->
|
dragLayer.post(() ->
|
||||||
rootView.getViewTreeObserver().removeOnDrawListener(this));
|
dragLayer.getViewTreeObserver().removeOnDrawListener(this));
|
||||||
if (activity != mActivity) {
|
if (activity != mActivity) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -398,15 +401,22 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void launcherFrameDrawn() {
|
private void launcherFrameDrawn() {
|
||||||
View rootView = mActivity.getRootView();
|
AlphaProperty property = mActivityControlHelper.getAlphaProperty(mActivity);
|
||||||
if (rootView.getAlpha() < 1) {
|
if (property.getValue() < 1) {
|
||||||
if (mGestureStarted) {
|
if (mGestureStarted) {
|
||||||
final MultiStateCallback callback = mStateCallback;
|
final MultiStateCallback callback = mStateCallback;
|
||||||
rootView.animate().alpha(1)
|
ObjectAnimator animator = ObjectAnimator.ofFloat(
|
||||||
.setDuration(getFadeInDuration())
|
property, MultiValueAlpha.VALUE, 1);
|
||||||
.withEndAction(() -> callback.setState(STATE_ACTIVITY_MULTIPLIER_COMPLETE));
|
animator.setDuration(getFadeInDuration()).addListener(
|
||||||
|
new AnimatorListenerAdapter() {
|
||||||
|
@Override
|
||||||
|
public void onAnimationEnd(Animator animation) {
|
||||||
|
callback.setState(STATE_ACTIVITY_MULTIPLIER_COMPLETE);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
animator.start();
|
||||||
} else {
|
} else {
|
||||||
rootView.setAlpha(1);
|
property.setValue(1);
|
||||||
mStateCallback.setState(STATE_ACTIVITY_MULTIPLIER_COMPLETE);
|
mStateCallback.setState(STATE_ACTIVITY_MULTIPLIER_COMPLETE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -682,6 +692,7 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity> {
|
|||||||
private void invalidateHandlerWithLauncher() {
|
private void invalidateHandlerWithLauncher() {
|
||||||
mLauncherTransitionController = null;
|
mLauncherTransitionController = null;
|
||||||
mLayoutListener.finish();
|
mLayoutListener.finish();
|
||||||
|
mActivityControlHelper.getAlphaProperty(mActivity).setValue(1);
|
||||||
|
|
||||||
mRecentsView.setRunningTaskHidden(false);
|
mRecentsView.setRunningTaskHidden(false);
|
||||||
mRecentsView.setRunningTaskIconScaledDown(false /* isScaledDown */, false /* animate */);
|
mRecentsView.setRunningTaskIconScaledDown(false /* isScaledDown */, false /* animate */);
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ public class RecentsRootView extends BaseDragLayer<RecentsActivity> {
|
|||||||
private final Point mLastKnownSize = new Point(10, 10);
|
private final Point mLastKnownSize = new Point(10, 10);
|
||||||
|
|
||||||
public RecentsRootView(Context context, AttributeSet attrs) {
|
public RecentsRootView(Context context, AttributeSet attrs) {
|
||||||
super(context, attrs);
|
super(context, attrs, 1 /* alphaChannelCount */);
|
||||||
mActivity = (RecentsActivity) BaseActivity.fromContext(context);
|
mActivity = (RecentsActivity) BaseActivity.fromContext(context);
|
||||||
setSystemUiVisibility(SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
|
setSystemUiVisibility(SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
|
||||||
| SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
|
| SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
|
||||||
|
|||||||
@@ -22,10 +22,13 @@ import static android.content.pm.ActivityInfo.CONFIG_SCREEN_SIZE;
|
|||||||
import static com.android.launcher3.LauncherAnimUtils.SPRING_LOADED_EXIT_DELAY;
|
import static com.android.launcher3.LauncherAnimUtils.SPRING_LOADED_EXIT_DELAY;
|
||||||
import static com.android.launcher3.LauncherState.ALL_APPS;
|
import static com.android.launcher3.LauncherState.ALL_APPS;
|
||||||
import static com.android.launcher3.LauncherState.NORMAL;
|
import static com.android.launcher3.LauncherState.NORMAL;
|
||||||
|
import static com.android.launcher3.dragndrop.DragLayer.ALPHA_INDEX_LAUNCHER_LOAD;
|
||||||
import static com.android.launcher3.logging.LoggerUtils.newContainerTarget;
|
import static com.android.launcher3.logging.LoggerUtils.newContainerTarget;
|
||||||
|
|
||||||
import android.animation.Animator;
|
import android.animation.Animator;
|
||||||
|
import android.animation.AnimatorListenerAdapter;
|
||||||
import android.animation.AnimatorSet;
|
import android.animation.AnimatorSet;
|
||||||
|
import android.animation.ObjectAnimator;
|
||||||
import android.animation.ValueAnimator;
|
import android.animation.ValueAnimator;
|
||||||
import android.annotation.TargetApi;
|
import android.annotation.TargetApi;
|
||||||
import android.app.ActivityOptions;
|
import android.app.ActivityOptions;
|
||||||
@@ -103,6 +106,8 @@ import com.android.launcher3.util.ActivityResultInfo;
|
|||||||
import com.android.launcher3.util.ComponentKey;
|
import com.android.launcher3.util.ComponentKey;
|
||||||
import com.android.launcher3.util.ItemInfoMatcher;
|
import com.android.launcher3.util.ItemInfoMatcher;
|
||||||
import com.android.launcher3.util.MultiHashMap;
|
import com.android.launcher3.util.MultiHashMap;
|
||||||
|
import com.android.launcher3.util.MultiValueAlpha;
|
||||||
|
import com.android.launcher3.util.MultiValueAlpha.AlphaProperty;
|
||||||
import com.android.launcher3.util.PackageManagerHelper;
|
import com.android.launcher3.util.PackageManagerHelper;
|
||||||
import com.android.launcher3.util.PackageUserKey;
|
import com.android.launcher3.util.PackageUserKey;
|
||||||
import com.android.launcher3.util.PendingRequestArgs;
|
import com.android.launcher3.util.PendingRequestArgs;
|
||||||
@@ -308,7 +313,7 @@ public class Launcher extends BaseDraggingActivity
|
|||||||
if (!internalStateHandled) {
|
if (!internalStateHandled) {
|
||||||
// If we are not binding synchronously, show a fade in animation when
|
// If we are not binding synchronously, show a fade in animation when
|
||||||
// the first page bind completes.
|
// the first page bind completes.
|
||||||
mLauncherView.setAlpha(0);
|
mDragLayer.getAlphaProperty(ALPHA_INDEX_LAUNCHER_LOAD).setValue(0);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Pages bound synchronously.
|
// Pages bound synchronously.
|
||||||
@@ -2086,9 +2091,18 @@ public class Launcher extends BaseDraggingActivity
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void finishFirstPageBind(final ViewOnDrawExecutor executor) {
|
public void finishFirstPageBind(final ViewOnDrawExecutor executor) {
|
||||||
if (mLauncherView.getAlpha() < 1) {
|
AlphaProperty property = mDragLayer.getAlphaProperty(ALPHA_INDEX_LAUNCHER_LOAD);
|
||||||
mLauncherView.animate().alpha(1).withEndAction(
|
if (property.getValue() < 1) {
|
||||||
executor == null ? null : executor::onLoadAnimationCompleted).start();
|
ObjectAnimator anim = ObjectAnimator.ofFloat(property, MultiValueAlpha.VALUE, 1);
|
||||||
|
if (executor != null) {
|
||||||
|
anim.addListener(new AnimatorListenerAdapter() {
|
||||||
|
@Override
|
||||||
|
public void onAnimationEnd(Animator animation) {
|
||||||
|
executor.onLoadAnimationCompleted();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
anim.start();
|
||||||
} else if (executor != null) {
|
} else if (executor != null) {
|
||||||
executor.onLoadAnimationCompleted();
|
executor.onLoadAnimationCompleted();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import static com.android.launcher3.LauncherAnimUtils.SPRING_LOADED_TRANSITION_M
|
|||||||
import static com.android.launcher3.LauncherState.ALL_APPS;
|
import static com.android.launcher3.LauncherState.ALL_APPS;
|
||||||
import static com.android.launcher3.LauncherState.NORMAL;
|
import static com.android.launcher3.LauncherState.NORMAL;
|
||||||
import static com.android.launcher3.LauncherState.SPRING_LOADED;
|
import static com.android.launcher3.LauncherState.SPRING_LOADED;
|
||||||
|
import static com.android.launcher3.dragndrop.DragLayer.ALPHA_INDEX_OVERLAY;
|
||||||
|
|
||||||
import android.animation.Animator;
|
import android.animation.Animator;
|
||||||
import android.animation.AnimatorListenerAdapter;
|
import android.animation.AnimatorListenerAdapter;
|
||||||
@@ -1174,7 +1175,7 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
|
|||||||
// different effects based on device performance. On at least one relatively high-end
|
// different effects based on device performance. On at least one relatively high-end
|
||||||
// device I've tried, translating the launcher causes things to get quite laggy.
|
// device I've tried, translating the launcher causes things to get quite laggy.
|
||||||
mLauncher.getDragLayer().setTranslationX(transX);
|
mLauncher.getDragLayer().setTranslationX(transX);
|
||||||
mLauncher.getDragLayer().setAlpha(alpha);
|
mLauncher.getDragLayer().getAlphaProperty(ALPHA_INDEX_OVERLAY).setValue(alpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -62,6 +62,12 @@ import java.util.ArrayList;
|
|||||||
*/
|
*/
|
||||||
public class DragLayer extends BaseDragLayer<Launcher> {
|
public class DragLayer extends BaseDragLayer<Launcher> {
|
||||||
|
|
||||||
|
public static final int ALPHA_INDEX_OVERLAY = 0;
|
||||||
|
public static final int ALPHA_INDEX_LAUNCHER_LOAD = 1;
|
||||||
|
public static final int ALPHA_INDEX_TRANSITIONS = 2;
|
||||||
|
public static final int ALPHA_INDEX_SWIPE_UP = 3;
|
||||||
|
private static final int ALPHA_CHANNEL_COUNT = 4;
|
||||||
|
|
||||||
public static final int ANIMATION_END_DISAPPEAR = 0;
|
public static final int ANIMATION_END_DISAPPEAR = 0;
|
||||||
public static final int ANIMATION_END_REMAIN_VISIBLE = 2;
|
public static final int ANIMATION_END_REMAIN_VISIBLE = 2;
|
||||||
|
|
||||||
@@ -90,7 +96,7 @@ public class DragLayer extends BaseDragLayer<Launcher> {
|
|||||||
* @param attrs The attributes set containing the Workspace's customization values.
|
* @param attrs The attributes set containing the Workspace's customization values.
|
||||||
*/
|
*/
|
||||||
public DragLayer(Context context, AttributeSet attrs) {
|
public DragLayer(Context context, AttributeSet attrs) {
|
||||||
super(context, attrs);
|
super(context, attrs, ALPHA_CHANNEL_COUNT);
|
||||||
|
|
||||||
// Disable multitouch across the workspace/all apps/customize tray
|
// Disable multitouch across the workspace/all apps/customize tray
|
||||||
setMotionEventSplittingEnabled(false);
|
setMotionEventSplittingEnabled(false);
|
||||||
|
|||||||
@@ -0,0 +1,101 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2018 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.android.launcher3.util;
|
||||||
|
|
||||||
|
import android.util.Property;
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Utility class to handle separating a single value as a factor of multiple values
|
||||||
|
*/
|
||||||
|
public class MultiValueAlpha {
|
||||||
|
|
||||||
|
public static final Property<AlphaProperty, Float> VALUE =
|
||||||
|
new Property<AlphaProperty, Float>(Float.TYPE, "value") {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Float get(AlphaProperty alphaProperty) {
|
||||||
|
return alphaProperty.mValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void set(AlphaProperty object, Float value) {
|
||||||
|
object.setValue(value);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
private final View mView;
|
||||||
|
private final AlphaProperty[] mMyProperties;
|
||||||
|
|
||||||
|
private int mValidMask;
|
||||||
|
|
||||||
|
public MultiValueAlpha(View view, int size) {
|
||||||
|
mView = view;
|
||||||
|
mMyProperties = new AlphaProperty[size];
|
||||||
|
|
||||||
|
mValidMask = 0;
|
||||||
|
for (int i = 0; i < size; i++) {
|
||||||
|
int myMask = 1 << i;
|
||||||
|
mValidMask |= myMask;
|
||||||
|
mMyProperties[i] = new AlphaProperty(myMask);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public AlphaProperty getProperty(int index) {
|
||||||
|
return mMyProperties[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
public class AlphaProperty {
|
||||||
|
|
||||||
|
private final int mMyMask;
|
||||||
|
|
||||||
|
private float mValue = 1;
|
||||||
|
// Factor of all other alpha channels, only valid if mMyMask is present in mValidMask.
|
||||||
|
private float mOthers = 1;
|
||||||
|
|
||||||
|
AlphaProperty(int myMask) {
|
||||||
|
mMyMask = myMask;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValue(float value) {
|
||||||
|
if (mValue == value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((mValidMask & mMyMask) == 0) {
|
||||||
|
// Our cache value is not correct, recompute it.
|
||||||
|
mOthers = 1;
|
||||||
|
for (AlphaProperty prop : mMyProperties) {
|
||||||
|
if (prop != this) {
|
||||||
|
mOthers *= prop.mValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Since we have changed our value, all other caches except our own need to be
|
||||||
|
// recomputed. Change mValidMask to indicate the new valid caches (only our own).
|
||||||
|
mValidMask = mMyMask;
|
||||||
|
mValue = value;
|
||||||
|
|
||||||
|
mView.setAlpha(mOthers * mValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getValue() {
|
||||||
|
return mValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -30,6 +30,8 @@ import com.android.launcher3.BaseActivity;
|
|||||||
import com.android.launcher3.BaseDraggingActivity;
|
import com.android.launcher3.BaseDraggingActivity;
|
||||||
import com.android.launcher3.InsettableFrameLayout;
|
import com.android.launcher3.InsettableFrameLayout;
|
||||||
import com.android.launcher3.Utilities;
|
import com.android.launcher3.Utilities;
|
||||||
|
import com.android.launcher3.util.MultiValueAlpha;
|
||||||
|
import com.android.launcher3.util.MultiValueAlpha.AlphaProperty;
|
||||||
import com.android.launcher3.util.TouchController;
|
import com.android.launcher3.util.TouchController;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -45,17 +47,18 @@ public abstract class BaseDragLayer<T extends BaseDraggingActivity> extends Inse
|
|||||||
protected final Rect mHitRect = new Rect();
|
protected final Rect mHitRect = new Rect();
|
||||||
|
|
||||||
protected final T mActivity;
|
protected final T mActivity;
|
||||||
|
private final MultiValueAlpha mMultiValueAlpha;
|
||||||
|
|
||||||
protected TouchController[] mControllers;
|
protected TouchController[] mControllers;
|
||||||
protected TouchController mActiveController;
|
protected TouchController mActiveController;
|
||||||
private TouchCompleteListener mTouchCompleteListener;
|
private TouchCompleteListener mTouchCompleteListener;
|
||||||
|
|
||||||
public BaseDragLayer(Context context, AttributeSet attrs) {
|
public BaseDragLayer(Context context, AttributeSet attrs, int alphaChannelCount) {
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
mActivity = (T) BaseActivity.fromContext(context);
|
mActivity = (T) BaseActivity.fromContext(context);
|
||||||
|
mMultiValueAlpha = new MultiValueAlpha(this, alphaChannelCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean isEventOverView(View view, MotionEvent ev) {
|
public boolean isEventOverView(View view, MotionEvent ev) {
|
||||||
getDescendantRectRelativeToSelf(view, mHitRect);
|
getDescendantRectRelativeToSelf(view, mHitRect);
|
||||||
return mHitRect.contains((int) ev.getX(), (int) ev.getY());
|
return mHitRect.contains((int) ev.getX(), (int) ev.getY());
|
||||||
@@ -276,6 +279,10 @@ public abstract class BaseDragLayer<T extends BaseDraggingActivity> extends Inse
|
|||||||
return new LayoutParams(p);
|
return new LayoutParams(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public AlphaProperty getAlphaProperty(int index) {
|
||||||
|
return mMultiValueAlpha.getProperty(index);
|
||||||
|
}
|
||||||
|
|
||||||
public static class LayoutParams extends InsettableFrameLayout.LayoutParams {
|
public static class LayoutParams extends InsettableFrameLayout.LayoutParams {
|
||||||
public int x, y;
|
public int x, y;
|
||||||
public boolean customPosition = false;
|
public boolean customPosition = false;
|
||||||
|
|||||||
Reference in new issue
Block a user