Loading quickstep/src/com/android/quickstep/ActivityControlHelper.java +14 −6 Original line number Diff line number Diff line Loading @@ -46,6 +46,7 @@ import com.android.launcher3.Launcher; import com.android.launcher3.LauncherAppState; import com.android.launcher3.LauncherInitListener; import com.android.launcher3.LauncherState; import com.android.launcher3.R; import com.android.launcher3.allapps.AllAppsTransitionController; import com.android.launcher3.allapps.DiscoveryBounce; import com.android.launcher3.anim.AnimatorPlaybackController; Loading Loading @@ -82,7 +83,8 @@ public interface ActivityControlHelper<T extends BaseDraggingActivity> { void onQuickInteractionStart(T activity, @Nullable RunningTaskInfo taskInfo, boolean activityVisible); float getTranslationYForQuickScrub(T activity); float getTranslationYForQuickScrub(TransformedRect targetRect, DeviceProfile dp, Context context); void executeOnWindowAvailable(T activity, Runnable action); Loading Loading @@ -151,10 +153,15 @@ public interface ActivityControlHelper<T extends BaseDraggingActivity> { } @Override public float getTranslationYForQuickScrub(Launcher activity) { LauncherRecentsView recentsView = activity.getOverviewPanel(); return recentsView.computeTranslationYForFactor( FastOverviewState.OVERVIEW_TRANSLATION_FACTOR); public float getTranslationYForQuickScrub(TransformedRect targetRect, DeviceProfile dp, Context context) { // The padding calculations are exactly same as that of RecentsView.setInsets int topMargin = context.getResources() .getDimensionPixelSize(R.dimen.task_thumbnail_top_margin); int paddingTop = targetRect.rect.top - topMargin - dp.getInsets().top; int paddingBottom = dp.availableHeightPx + dp.getInsets().top - targetRect.rect.bottom; return FastOverviewState.OVERVIEW_TRANSLATION_FACTOR * (paddingBottom - paddingTop); } @Override Loading Loading @@ -380,7 +387,8 @@ public interface ActivityControlHelper<T extends BaseDraggingActivity> { } @Override public float getTranslationYForQuickScrub(RecentsActivity activity) { public float getTranslationYForQuickScrub(TransformedRect targetRect, DeviceProfile dp, Context context) { return 0; } Loading quickstep/src/com/android/quickstep/DeferredTouchConsumer.java +15 −0 Original line number Diff line number Diff line Loading @@ -63,6 +63,16 @@ public class DeferredTouchConsumer implements TouchConsumer { mTarget.onQuickScrubProgress(progress); } @Override public void onQuickStep(MotionEvent ev) { mTarget.onQuickStep(ev); } @Override public void onCommand(int command) { mTarget.onCommand(command); } @Override public void preProcessMotionEvent(MotionEvent ev) { mVelocityTracker.addMovement(ev); Loading Loading @@ -92,6 +102,11 @@ public class DeferredTouchConsumer implements TouchConsumer { return target == null ? true : target.deferNextEventToMainThread(); } @Override public void onShowOverviewFromAltTab() { mTarget.onShowOverviewFromAltTab(); } public interface DeferredTouchProvider { TouchConsumer createTouchConsumer(VelocityTracker tracker); Loading quickstep/src/com/android/quickstep/MotionEventQueue.java +11 −0 Original line number Diff line number Diff line Loading @@ -55,6 +55,8 @@ public class MotionEventQueue { ACTION_VIRTUAL | (6 << ACTION_POINTER_INDEX_SHIFT); private static final int ACTION_QUICK_STEP = ACTION_VIRTUAL | (7 << ACTION_POINTER_INDEX_SHIFT); private static final int ACTION_COMMAND = ACTION_VIRTUAL | (8 << ACTION_POINTER_INDEX_SHIFT); private final EventArray mEmptyArray = new EventArray(); private final Object mExecutionLock = new Object(); Loading Loading @@ -165,6 +167,9 @@ public class MotionEventQueue { case ACTION_QUICK_STEP: mConsumer.onQuickStep(event); break; case ACTION_COMMAND: mConsumer.onCommand(event.getSource()); break; default: Log.e(TAG, "Invalid virtual event: " + event.getAction()); } Loading Loading @@ -222,6 +227,12 @@ public class MotionEventQueue { queueVirtualAction(ACTION_DEFER_INIT, 0); } public void onCommand(int command) { MotionEvent ev = MotionEvent.obtain(0, 0, ACTION_COMMAND, 0, 0, 0); ev.setSource(command); queueNoPreProcess(ev); } public TouchConsumer getConsumer() { return mConsumer; } Loading quickstep/src/com/android/quickstep/OtherActivityTouchConsumer.java +64 −26 Original line number Diff line number Diff line Loading @@ -37,6 +37,7 @@ import android.os.Build; import android.os.Bundle; import android.os.Looper; import android.os.SystemClock; import android.util.SparseArray; import android.view.Choreographer; import android.view.Display; import android.view.MotionEvent; Loading Loading @@ -69,6 +70,7 @@ public class OtherActivityTouchConsumer extends ContextWrapper implements TouchC private static final long LAUNCHER_DRAW_TIMEOUT_MS = 150; private final SparseArray<RecentsAnimationState> mAnimationStates = new SparseArray<>(); private final RunningTaskInfo mRunningTask; private final RecentsModel mRecentsModel; private final Intent mHomeIntent; Loading Loading @@ -212,8 +214,9 @@ public class OtherActivityTouchConsumer extends ContextWrapper implements TouchC private void startTouchTrackingForWindowAnimation(long touchTimeMs) { // Create the shared handler RecentsAnimationState animationState = new RecentsAnimationState(); final WindowTransformSwipeHandler handler = new WindowTransformSwipeHandler( mRunningTask, this, touchTimeMs, mActivityControlHelper); animationState.id, mRunningTask, this, touchTimeMs, mActivityControlHelper); // Preload the plan mRecentsModel.loadTasks(mRunningTask.id, null); Loading @@ -237,31 +240,7 @@ public class OtherActivityTouchConsumer extends ContextWrapper implements TouchC public void onHandleAssistData(Bundle bundle) { mRecentsModel.preloadAssistData(mRunningTask.id, bundle); } }, new RecentsAnimationListener() { public void onAnimationStart( RecentsAnimationControllerCompat controller, RemoteAnimationTargetCompat[] apps, Rect homeContentInsets, Rect minimizedHomeBounds) { if (mInteractionHandler == handler) { TraceHelper.partitionSection("RecentsController", "Received"); handler.onRecentsAnimationStart(controller, new RemoteAnimationTargetSet(apps, MODE_CLOSING), homeContentInsets, minimizedHomeBounds); } else { TraceHelper.endSection("RecentsController", "Finishing no handler"); controller.finish(false /* toHome */); } } public void onAnimationCanceled() { TraceHelper.endSection("RecentsController", "Cancelled: " + mInteractionHandler); if (mInteractionHandler == handler) { handler.onRecentsAnimationCanceled(); } } }, null, null); }, animationState, null, null); if (Looper.myLooper() != Looper.getMainLooper()) { startActivity.run(); Loading @@ -277,6 +256,14 @@ public class OtherActivityTouchConsumer extends ContextWrapper implements TouchC } } @Override public void onCommand(int command) { RecentsAnimationState state = mAnimationStates.get(command); if (state != null) { state.execute(); } } /** * Called when the gesture has ended. Does not correlate to the completion of the interaction as * the animation can still be running. Loading Loading @@ -398,4 +385,55 @@ public class OtherActivityTouchConsumer extends ContextWrapper implements TouchC // TODO: Consider also check if the eventQueue is using mainThread of not. return mInteractionHandler != null; } private class RecentsAnimationState implements RecentsAnimationListener { private final int id; private RecentsAnimationControllerCompat mController; private RemoteAnimationTargetSet mTargets; private Rect mHomeContentInsets; private Rect mMinimizedHomeBounds; private boolean mCancelled; public RecentsAnimationState() { id = mAnimationStates.size(); mAnimationStates.put(id, this); } @Override public void onAnimationStart( RecentsAnimationControllerCompat controller, RemoteAnimationTargetCompat[] apps, Rect homeContentInsets, Rect minimizedHomeBounds) { mController = controller; mTargets = new RemoteAnimationTargetSet(apps, MODE_CLOSING); mHomeContentInsets = homeContentInsets; mMinimizedHomeBounds = minimizedHomeBounds; mEventQueue.onCommand(id); } @Override public void onAnimationCanceled() { mCancelled = true; mEventQueue.onCommand(id); } public void execute() { if (mInteractionHandler == null || mInteractionHandler.id != id) { if (!mCancelled && mController != null) { TraceHelper.endSection("RecentsController", "Finishing no handler"); mController.finish(false /* toHome */); } } else if (mCancelled) { TraceHelper.endSection("RecentsController", "Cancelled: " + mInteractionHandler); mInteractionHandler.onRecentsAnimationCanceled(); } else { TraceHelper.partitionSection("RecentsController", "Received"); mInteractionHandler.onRecentsAnimationStart(mController, mTargets, mHomeContentInsets, mMinimizedHomeBounds); } } } } quickstep/src/com/android/quickstep/RecentsAnimationWrapper.java +21 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,8 @@ import com.android.launcher3.util.TraceHelper; import com.android.launcher3.util.UiThreadHelper; import com.android.quickstep.util.RemoteAnimationTargetSet; import com.android.systemui.shared.system.RecentsAnimationControllerCompat; import java.util.ArrayList; import java.util.concurrent.ExecutorService; /** Loading @@ -27,6 +29,10 @@ import java.util.concurrent.ExecutorService; */ public class RecentsAnimationWrapper { // A list of callbacks to run when we receive the recents animation target. There are different // than the state callbacks as these run on the current worker thread. private final ArrayList<Runnable> mCallbacks = new ArrayList<>(); public RemoteAnimationTargetSet targetSet; private RecentsAnimationControllerCompat mController; Loading @@ -46,6 +52,21 @@ public class RecentsAnimationWrapper { if (mInputConsumerEnabled) { enableInputConsumer(); } if (!mCallbacks.isEmpty()) { for (Runnable action : new ArrayList<>(mCallbacks)) { action.run(); } mCallbacks.clear(); } } public synchronized void runOnInit(Runnable action) { if (targetSet == null) { mCallbacks.add(action); } else { action.run(); } } /** Loading Loading
quickstep/src/com/android/quickstep/ActivityControlHelper.java +14 −6 Original line number Diff line number Diff line Loading @@ -46,6 +46,7 @@ import com.android.launcher3.Launcher; import com.android.launcher3.LauncherAppState; import com.android.launcher3.LauncherInitListener; import com.android.launcher3.LauncherState; import com.android.launcher3.R; import com.android.launcher3.allapps.AllAppsTransitionController; import com.android.launcher3.allapps.DiscoveryBounce; import com.android.launcher3.anim.AnimatorPlaybackController; Loading Loading @@ -82,7 +83,8 @@ public interface ActivityControlHelper<T extends BaseDraggingActivity> { void onQuickInteractionStart(T activity, @Nullable RunningTaskInfo taskInfo, boolean activityVisible); float getTranslationYForQuickScrub(T activity); float getTranslationYForQuickScrub(TransformedRect targetRect, DeviceProfile dp, Context context); void executeOnWindowAvailable(T activity, Runnable action); Loading Loading @@ -151,10 +153,15 @@ public interface ActivityControlHelper<T extends BaseDraggingActivity> { } @Override public float getTranslationYForQuickScrub(Launcher activity) { LauncherRecentsView recentsView = activity.getOverviewPanel(); return recentsView.computeTranslationYForFactor( FastOverviewState.OVERVIEW_TRANSLATION_FACTOR); public float getTranslationYForQuickScrub(TransformedRect targetRect, DeviceProfile dp, Context context) { // The padding calculations are exactly same as that of RecentsView.setInsets int topMargin = context.getResources() .getDimensionPixelSize(R.dimen.task_thumbnail_top_margin); int paddingTop = targetRect.rect.top - topMargin - dp.getInsets().top; int paddingBottom = dp.availableHeightPx + dp.getInsets().top - targetRect.rect.bottom; return FastOverviewState.OVERVIEW_TRANSLATION_FACTOR * (paddingBottom - paddingTop); } @Override Loading Loading @@ -380,7 +387,8 @@ public interface ActivityControlHelper<T extends BaseDraggingActivity> { } @Override public float getTranslationYForQuickScrub(RecentsActivity activity) { public float getTranslationYForQuickScrub(TransformedRect targetRect, DeviceProfile dp, Context context) { return 0; } Loading
quickstep/src/com/android/quickstep/DeferredTouchConsumer.java +15 −0 Original line number Diff line number Diff line Loading @@ -63,6 +63,16 @@ public class DeferredTouchConsumer implements TouchConsumer { mTarget.onQuickScrubProgress(progress); } @Override public void onQuickStep(MotionEvent ev) { mTarget.onQuickStep(ev); } @Override public void onCommand(int command) { mTarget.onCommand(command); } @Override public void preProcessMotionEvent(MotionEvent ev) { mVelocityTracker.addMovement(ev); Loading Loading @@ -92,6 +102,11 @@ public class DeferredTouchConsumer implements TouchConsumer { return target == null ? true : target.deferNextEventToMainThread(); } @Override public void onShowOverviewFromAltTab() { mTarget.onShowOverviewFromAltTab(); } public interface DeferredTouchProvider { TouchConsumer createTouchConsumer(VelocityTracker tracker); Loading
quickstep/src/com/android/quickstep/MotionEventQueue.java +11 −0 Original line number Diff line number Diff line Loading @@ -55,6 +55,8 @@ public class MotionEventQueue { ACTION_VIRTUAL | (6 << ACTION_POINTER_INDEX_SHIFT); private static final int ACTION_QUICK_STEP = ACTION_VIRTUAL | (7 << ACTION_POINTER_INDEX_SHIFT); private static final int ACTION_COMMAND = ACTION_VIRTUAL | (8 << ACTION_POINTER_INDEX_SHIFT); private final EventArray mEmptyArray = new EventArray(); private final Object mExecutionLock = new Object(); Loading Loading @@ -165,6 +167,9 @@ public class MotionEventQueue { case ACTION_QUICK_STEP: mConsumer.onQuickStep(event); break; case ACTION_COMMAND: mConsumer.onCommand(event.getSource()); break; default: Log.e(TAG, "Invalid virtual event: " + event.getAction()); } Loading Loading @@ -222,6 +227,12 @@ public class MotionEventQueue { queueVirtualAction(ACTION_DEFER_INIT, 0); } public void onCommand(int command) { MotionEvent ev = MotionEvent.obtain(0, 0, ACTION_COMMAND, 0, 0, 0); ev.setSource(command); queueNoPreProcess(ev); } public TouchConsumer getConsumer() { return mConsumer; } Loading
quickstep/src/com/android/quickstep/OtherActivityTouchConsumer.java +64 −26 Original line number Diff line number Diff line Loading @@ -37,6 +37,7 @@ import android.os.Build; import android.os.Bundle; import android.os.Looper; import android.os.SystemClock; import android.util.SparseArray; import android.view.Choreographer; import android.view.Display; import android.view.MotionEvent; Loading Loading @@ -69,6 +70,7 @@ public class OtherActivityTouchConsumer extends ContextWrapper implements TouchC private static final long LAUNCHER_DRAW_TIMEOUT_MS = 150; private final SparseArray<RecentsAnimationState> mAnimationStates = new SparseArray<>(); private final RunningTaskInfo mRunningTask; private final RecentsModel mRecentsModel; private final Intent mHomeIntent; Loading Loading @@ -212,8 +214,9 @@ public class OtherActivityTouchConsumer extends ContextWrapper implements TouchC private void startTouchTrackingForWindowAnimation(long touchTimeMs) { // Create the shared handler RecentsAnimationState animationState = new RecentsAnimationState(); final WindowTransformSwipeHandler handler = new WindowTransformSwipeHandler( mRunningTask, this, touchTimeMs, mActivityControlHelper); animationState.id, mRunningTask, this, touchTimeMs, mActivityControlHelper); // Preload the plan mRecentsModel.loadTasks(mRunningTask.id, null); Loading @@ -237,31 +240,7 @@ public class OtherActivityTouchConsumer extends ContextWrapper implements TouchC public void onHandleAssistData(Bundle bundle) { mRecentsModel.preloadAssistData(mRunningTask.id, bundle); } }, new RecentsAnimationListener() { public void onAnimationStart( RecentsAnimationControllerCompat controller, RemoteAnimationTargetCompat[] apps, Rect homeContentInsets, Rect minimizedHomeBounds) { if (mInteractionHandler == handler) { TraceHelper.partitionSection("RecentsController", "Received"); handler.onRecentsAnimationStart(controller, new RemoteAnimationTargetSet(apps, MODE_CLOSING), homeContentInsets, minimizedHomeBounds); } else { TraceHelper.endSection("RecentsController", "Finishing no handler"); controller.finish(false /* toHome */); } } public void onAnimationCanceled() { TraceHelper.endSection("RecentsController", "Cancelled: " + mInteractionHandler); if (mInteractionHandler == handler) { handler.onRecentsAnimationCanceled(); } } }, null, null); }, animationState, null, null); if (Looper.myLooper() != Looper.getMainLooper()) { startActivity.run(); Loading @@ -277,6 +256,14 @@ public class OtherActivityTouchConsumer extends ContextWrapper implements TouchC } } @Override public void onCommand(int command) { RecentsAnimationState state = mAnimationStates.get(command); if (state != null) { state.execute(); } } /** * Called when the gesture has ended. Does not correlate to the completion of the interaction as * the animation can still be running. Loading Loading @@ -398,4 +385,55 @@ public class OtherActivityTouchConsumer extends ContextWrapper implements TouchC // TODO: Consider also check if the eventQueue is using mainThread of not. return mInteractionHandler != null; } private class RecentsAnimationState implements RecentsAnimationListener { private final int id; private RecentsAnimationControllerCompat mController; private RemoteAnimationTargetSet mTargets; private Rect mHomeContentInsets; private Rect mMinimizedHomeBounds; private boolean mCancelled; public RecentsAnimationState() { id = mAnimationStates.size(); mAnimationStates.put(id, this); } @Override public void onAnimationStart( RecentsAnimationControllerCompat controller, RemoteAnimationTargetCompat[] apps, Rect homeContentInsets, Rect minimizedHomeBounds) { mController = controller; mTargets = new RemoteAnimationTargetSet(apps, MODE_CLOSING); mHomeContentInsets = homeContentInsets; mMinimizedHomeBounds = minimizedHomeBounds; mEventQueue.onCommand(id); } @Override public void onAnimationCanceled() { mCancelled = true; mEventQueue.onCommand(id); } public void execute() { if (mInteractionHandler == null || mInteractionHandler.id != id) { if (!mCancelled && mController != null) { TraceHelper.endSection("RecentsController", "Finishing no handler"); mController.finish(false /* toHome */); } } else if (mCancelled) { TraceHelper.endSection("RecentsController", "Cancelled: " + mInteractionHandler); mInteractionHandler.onRecentsAnimationCanceled(); } else { TraceHelper.partitionSection("RecentsController", "Received"); mInteractionHandler.onRecentsAnimationStart(mController, mTargets, mHomeContentInsets, mMinimizedHomeBounds); } } } }
quickstep/src/com/android/quickstep/RecentsAnimationWrapper.java +21 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,8 @@ import com.android.launcher3.util.TraceHelper; import com.android.launcher3.util.UiThreadHelper; import com.android.quickstep.util.RemoteAnimationTargetSet; import com.android.systemui.shared.system.RecentsAnimationControllerCompat; import java.util.ArrayList; import java.util.concurrent.ExecutorService; /** Loading @@ -27,6 +29,10 @@ import java.util.concurrent.ExecutorService; */ public class RecentsAnimationWrapper { // A list of callbacks to run when we receive the recents animation target. There are different // than the state callbacks as these run on the current worker thread. private final ArrayList<Runnable> mCallbacks = new ArrayList<>(); public RemoteAnimationTargetSet targetSet; private RecentsAnimationControllerCompat mController; Loading @@ -46,6 +52,21 @@ public class RecentsAnimationWrapper { if (mInputConsumerEnabled) { enableInputConsumer(); } if (!mCallbacks.isEmpty()) { for (Runnable action : new ArrayList<>(mCallbacks)) { action.run(); } mCallbacks.clear(); } } public synchronized void runOnInit(Runnable action) { if (targetSet == null) { mCallbacks.add(action); } else { action.run(); } } /** Loading