Loading quickstep/src/com/android/quickstep/AnimatedFloat.java +6 −0 Original line number Original line Diff line number Diff line Loading @@ -77,6 +77,12 @@ public class AnimatedFloat { } } } } public void finishAnimation() { if (mValueAnimator != null && mValueAnimator.isRunning()) { mValueAnimator.end(); } } public ObjectAnimator getCurrentAnimation() { public ObjectAnimator getCurrentAnimation() { return mValueAnimator; return mValueAnimator; } } Loading quickstep/src/com/android/quickstep/BaseSwipeInteractionHandler.java +1 −0 Original line number Original line Diff line number Diff line Loading @@ -23,6 +23,7 @@ import com.android.quickstep.TouchConsumer.InteractionType; public abstract class BaseSwipeInteractionHandler extends InternalStateHandler { public abstract class BaseSwipeInteractionHandler extends InternalStateHandler { protected Runnable mGestureEndCallback; protected Runnable mGestureEndCallback; protected boolean mIsGoingToHome; public void setGestureEndCallback(Runnable gestureEndCallback) { public void setGestureEndCallback(Runnable gestureEndCallback) { mGestureEndCallback = gestureEndCallback; mGestureEndCallback = gestureEndCallback; Loading quickstep/src/com/android/quickstep/DeferredTouchConsumer.java 0 → 100644 +99 −0 Original line number Original line Diff line number Diff line /* * 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.quickstep; import android.annotation.TargetApi; import android.os.Build; import android.view.Choreographer; import android.view.MotionEvent; import android.view.VelocityTracker; /** * A TouchConsumer which defers all events on the UIThread until the consumer is created. */ @TargetApi(Build.VERSION_CODES.P) public class DeferredTouchConsumer implements TouchConsumer { private final VelocityTracker mVelocityTracker; private final DeferredTouchProvider mTouchProvider; private MotionEventQueue mMyQueue; private TouchConsumer mTarget; public DeferredTouchConsumer(DeferredTouchProvider touchProvider) { mVelocityTracker = VelocityTracker.obtain(); mTouchProvider = touchProvider; } @Override public void accept(MotionEvent event) { mTarget.accept(event); } @Override public void reset() { mTarget.reset(); } @Override public void updateTouchTracking(int interactionType) { mTarget.updateTouchTracking(interactionType); } @Override public void onQuickScrubEnd() { mTarget.onQuickScrubEnd(); } @Override public void onQuickScrubProgress(float progress) { mTarget.onQuickScrubProgress(progress); } @Override public void preProcessMotionEvent(MotionEvent ev) { mVelocityTracker.addMovement(ev); } @Override public Choreographer getIntrimChoreographer(MotionEventQueue queue) { mMyQueue = queue; return null; } @Override public void deferInit() { mTarget = mTouchProvider.createTouchConsumer(mVelocityTracker); mTarget.getIntrimChoreographer(mMyQueue); } @Override public boolean forceToLauncherConsumer() { return mTarget.forceToLauncherConsumer(); } @Override public boolean deferNextEventToMainThread() { // If our target is still null, defer the next target as well TouchConsumer target = mTarget; return target == null ? true : target.deferNextEventToMainThread(); } public interface DeferredTouchProvider { TouchConsumer createTouchConsumer(VelocityTracker tracker); } } quickstep/src/com/android/quickstep/MotionEventQueue.java +15 −2 Original line number Original line Diff line number Diff line Loading @@ -53,6 +53,8 @@ public class MotionEventQueue { ACTION_VIRTUAL | (4 << ACTION_POINTER_INDEX_SHIFT); ACTION_VIRTUAL | (4 << ACTION_POINTER_INDEX_SHIFT); private static final int ACTION_RESET = private static final int ACTION_RESET = ACTION_VIRTUAL | (5 << ACTION_POINTER_INDEX_SHIFT); ACTION_VIRTUAL | (5 << ACTION_POINTER_INDEX_SHIFT); private static final int ACTION_DEFER_INIT = ACTION_VIRTUAL | (6 << ACTION_POINTER_INDEX_SHIFT); private final EventArray mEmptyArray = new EventArray(); private final EventArray mEmptyArray = new EventArray(); private final Object mExecutionLock = new Object(); private final Object mExecutionLock = new Object(); Loading @@ -76,10 +78,10 @@ public class MotionEventQueue { public MotionEventQueue(Choreographer choreographer, TouchConsumer consumer) { public MotionEventQueue(Choreographer choreographer, TouchConsumer consumer) { mMainChoreographer = choreographer; mMainChoreographer = choreographer; mConsumer = consumer; mConsumer = consumer; mCurrentChoreographer = mMainChoreographer; mCurrentChoreographer = mMainChoreographer; mCurrentRunnable = mMainFrameCallback; mCurrentRunnable = mMainFrameCallback; setInterimChoreographerLocked(consumer.getIntrimChoreographer(this)); setInterimChoreographer(consumer.getIntrimChoreographer(this)); } } public void setInterimChoreographer(Choreographer choreographer) { public void setInterimChoreographer(Choreographer choreographer) { Loading Loading @@ -156,6 +158,9 @@ public class MotionEventQueue { case ACTION_RESET: case ACTION_RESET: mConsumer.reset(); mConsumer.reset(); break; break; case ACTION_DEFER_INIT: mConsumer.deferInit(); break; default: default: Log.e(TAG, "Invalid virtual event: " + event.getAction()); Log.e(TAG, "Invalid virtual event: " + event.getAction()); } } Loading Loading @@ -204,6 +209,14 @@ public class MotionEventQueue { queueVirtualAction(ACTION_RESET, 0); queueVirtualAction(ACTION_RESET, 0); } } public void deferInit() { queueVirtualAction(ACTION_DEFER_INIT, 0); } public TouchConsumer getConsumer() { return mConsumer; } private static class EventArray extends ArrayList<MotionEvent> { private static class EventArray extends ArrayList<MotionEvent> { public int lastEventAction = ACTION_CANCEL; public int lastEventAction = ACTION_CANCEL; Loading quickstep/src/com/android/quickstep/NavBarSwipeInteractionHandler.java +3 −2 Original line number Original line Diff line number Diff line Loading @@ -319,13 +319,14 @@ public class NavBarSwipeInteractionHandler extends BaseSwipeInteractionHandler i /** Animates to the given progress, where 0 is the current app and 1 is overview. */ /** Animates to the given progress, where 0 is the current app and 1 is overview. */ private void animateToProgress(float progress, long duration) { private void animateToProgress(float progress, long duration) { mIsGoingToHome = Float.compare(progress, 1) == 0; ObjectAnimator anim = mCurrentShift.animateToValue(progress).setDuration(duration); ObjectAnimator anim = mCurrentShift.animateToValue(progress).setDuration(duration); anim.setInterpolator(Interpolators.SCROLL); anim.setInterpolator(Interpolators.SCROLL); anim.addListener(new AnimationSuccessListener() { anim.addListener(new AnimationSuccessListener() { @Override @Override public void onAnimationSuccess(Animator animator) { public void onAnimationSuccess(Animator animator) { mStateCallback.setState((Float.compare(mCurrentShift.value, 0) == 0) mStateCallback.setState(mIsGoingToHome ? STATE_SCALED_SNAPSHOT_APP : STATE_SCALED_SNAPSHOT_RECENTS); ? STATE_SCALED_SNAPSHOT_RECENTS : STATE_SCALED_SNAPSHOT_APP); } } }); }); anim.start(); anim.start(); Loading Loading
quickstep/src/com/android/quickstep/AnimatedFloat.java +6 −0 Original line number Original line Diff line number Diff line Loading @@ -77,6 +77,12 @@ public class AnimatedFloat { } } } } public void finishAnimation() { if (mValueAnimator != null && mValueAnimator.isRunning()) { mValueAnimator.end(); } } public ObjectAnimator getCurrentAnimation() { public ObjectAnimator getCurrentAnimation() { return mValueAnimator; return mValueAnimator; } } Loading
quickstep/src/com/android/quickstep/BaseSwipeInteractionHandler.java +1 −0 Original line number Original line Diff line number Diff line Loading @@ -23,6 +23,7 @@ import com.android.quickstep.TouchConsumer.InteractionType; public abstract class BaseSwipeInteractionHandler extends InternalStateHandler { public abstract class BaseSwipeInteractionHandler extends InternalStateHandler { protected Runnable mGestureEndCallback; protected Runnable mGestureEndCallback; protected boolean mIsGoingToHome; public void setGestureEndCallback(Runnable gestureEndCallback) { public void setGestureEndCallback(Runnable gestureEndCallback) { mGestureEndCallback = gestureEndCallback; mGestureEndCallback = gestureEndCallback; Loading
quickstep/src/com/android/quickstep/DeferredTouchConsumer.java 0 → 100644 +99 −0 Original line number Original line Diff line number Diff line /* * 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.quickstep; import android.annotation.TargetApi; import android.os.Build; import android.view.Choreographer; import android.view.MotionEvent; import android.view.VelocityTracker; /** * A TouchConsumer which defers all events on the UIThread until the consumer is created. */ @TargetApi(Build.VERSION_CODES.P) public class DeferredTouchConsumer implements TouchConsumer { private final VelocityTracker mVelocityTracker; private final DeferredTouchProvider mTouchProvider; private MotionEventQueue mMyQueue; private TouchConsumer mTarget; public DeferredTouchConsumer(DeferredTouchProvider touchProvider) { mVelocityTracker = VelocityTracker.obtain(); mTouchProvider = touchProvider; } @Override public void accept(MotionEvent event) { mTarget.accept(event); } @Override public void reset() { mTarget.reset(); } @Override public void updateTouchTracking(int interactionType) { mTarget.updateTouchTracking(interactionType); } @Override public void onQuickScrubEnd() { mTarget.onQuickScrubEnd(); } @Override public void onQuickScrubProgress(float progress) { mTarget.onQuickScrubProgress(progress); } @Override public void preProcessMotionEvent(MotionEvent ev) { mVelocityTracker.addMovement(ev); } @Override public Choreographer getIntrimChoreographer(MotionEventQueue queue) { mMyQueue = queue; return null; } @Override public void deferInit() { mTarget = mTouchProvider.createTouchConsumer(mVelocityTracker); mTarget.getIntrimChoreographer(mMyQueue); } @Override public boolean forceToLauncherConsumer() { return mTarget.forceToLauncherConsumer(); } @Override public boolean deferNextEventToMainThread() { // If our target is still null, defer the next target as well TouchConsumer target = mTarget; return target == null ? true : target.deferNextEventToMainThread(); } public interface DeferredTouchProvider { TouchConsumer createTouchConsumer(VelocityTracker tracker); } }
quickstep/src/com/android/quickstep/MotionEventQueue.java +15 −2 Original line number Original line Diff line number Diff line Loading @@ -53,6 +53,8 @@ public class MotionEventQueue { ACTION_VIRTUAL | (4 << ACTION_POINTER_INDEX_SHIFT); ACTION_VIRTUAL | (4 << ACTION_POINTER_INDEX_SHIFT); private static final int ACTION_RESET = private static final int ACTION_RESET = ACTION_VIRTUAL | (5 << ACTION_POINTER_INDEX_SHIFT); ACTION_VIRTUAL | (5 << ACTION_POINTER_INDEX_SHIFT); private static final int ACTION_DEFER_INIT = ACTION_VIRTUAL | (6 << ACTION_POINTER_INDEX_SHIFT); private final EventArray mEmptyArray = new EventArray(); private final EventArray mEmptyArray = new EventArray(); private final Object mExecutionLock = new Object(); private final Object mExecutionLock = new Object(); Loading @@ -76,10 +78,10 @@ public class MotionEventQueue { public MotionEventQueue(Choreographer choreographer, TouchConsumer consumer) { public MotionEventQueue(Choreographer choreographer, TouchConsumer consumer) { mMainChoreographer = choreographer; mMainChoreographer = choreographer; mConsumer = consumer; mConsumer = consumer; mCurrentChoreographer = mMainChoreographer; mCurrentChoreographer = mMainChoreographer; mCurrentRunnable = mMainFrameCallback; mCurrentRunnable = mMainFrameCallback; setInterimChoreographerLocked(consumer.getIntrimChoreographer(this)); setInterimChoreographer(consumer.getIntrimChoreographer(this)); } } public void setInterimChoreographer(Choreographer choreographer) { public void setInterimChoreographer(Choreographer choreographer) { Loading Loading @@ -156,6 +158,9 @@ public class MotionEventQueue { case ACTION_RESET: case ACTION_RESET: mConsumer.reset(); mConsumer.reset(); break; break; case ACTION_DEFER_INIT: mConsumer.deferInit(); break; default: default: Log.e(TAG, "Invalid virtual event: " + event.getAction()); Log.e(TAG, "Invalid virtual event: " + event.getAction()); } } Loading Loading @@ -204,6 +209,14 @@ public class MotionEventQueue { queueVirtualAction(ACTION_RESET, 0); queueVirtualAction(ACTION_RESET, 0); } } public void deferInit() { queueVirtualAction(ACTION_DEFER_INIT, 0); } public TouchConsumer getConsumer() { return mConsumer; } private static class EventArray extends ArrayList<MotionEvent> { private static class EventArray extends ArrayList<MotionEvent> { public int lastEventAction = ACTION_CANCEL; public int lastEventAction = ACTION_CANCEL; Loading
quickstep/src/com/android/quickstep/NavBarSwipeInteractionHandler.java +3 −2 Original line number Original line Diff line number Diff line Loading @@ -319,13 +319,14 @@ public class NavBarSwipeInteractionHandler extends BaseSwipeInteractionHandler i /** Animates to the given progress, where 0 is the current app and 1 is overview. */ /** Animates to the given progress, where 0 is the current app and 1 is overview. */ private void animateToProgress(float progress, long duration) { private void animateToProgress(float progress, long duration) { mIsGoingToHome = Float.compare(progress, 1) == 0; ObjectAnimator anim = mCurrentShift.animateToValue(progress).setDuration(duration); ObjectAnimator anim = mCurrentShift.animateToValue(progress).setDuration(duration); anim.setInterpolator(Interpolators.SCROLL); anim.setInterpolator(Interpolators.SCROLL); anim.addListener(new AnimationSuccessListener() { anim.addListener(new AnimationSuccessListener() { @Override @Override public void onAnimationSuccess(Animator animator) { public void onAnimationSuccess(Animator animator) { mStateCallback.setState((Float.compare(mCurrentShift.value, 0) == 0) mStateCallback.setState(mIsGoingToHome ? STATE_SCALED_SNAPSHOT_APP : STATE_SCALED_SNAPSHOT_RECENTS); ? STATE_SCALED_SNAPSHOT_RECENTS : STATE_SCALED_SNAPSHOT_APP); } } }); }); anim.start(); anim.start(); Loading