diff options
author | Tony Wickham <twickham@google.com> | 2018-05-02 16:21:21 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2018-05-02 16:21:21 +0000 |
commit | f325b19de384da8666af558f65933e0243508349 (patch) | |
tree | f64bea04a8b3b3aec2015350f27e669265b4d9ac | |
parent | 7a5d4ae64fe43c12018174f9b5983f08a06b41e8 (diff) | |
parent | f47e5ce3cf7e3eb4d481aea765784a8c6c19f47e (diff) | |
download | packages_apps_Trebuchet-f325b19de384da8666af558f65933e0243508349.tar.gz packages_apps_Trebuchet-f325b19de384da8666af558f65933e0243508349.tar.bz2 packages_apps_Trebuchet-f325b19de384da8666af558f65933e0243508349.zip |
Merge "Gracefully handle some edge cases in quick scrub" into ub-launcher3-edmonton
4 files changed, 46 insertions, 14 deletions
diff --git a/quickstep/src/com/android/quickstep/ActivityControlHelper.java b/quickstep/src/com/android/quickstep/ActivityControlHelper.java index 88cd376a7..8a6abb2d5 100644 --- a/quickstep/src/com/android/quickstep/ActivityControlHelper.java +++ b/quickstep/src/com/android/quickstep/ActivityControlHelper.java @@ -263,7 +263,7 @@ public interface ActivityControlHelper<T extends BaseDraggingActivity> { @Override public RecentsView getVisibleRecentsView() { Launcher launcher = getVisibleLaucher(); - return launcher != null && launcher.isInState(OVERVIEW) + return launcher != null && launcher.getStateManager().getState().overviewUi ? launcher.getOverviewPanel() : null; } diff --git a/quickstep/src/com/android/quickstep/QuickScrubController.java b/quickstep/src/com/android/quickstep/QuickScrubController.java index ea9d009e3..7bb9877e9 100644 --- a/quickstep/src/com/android/quickstep/QuickScrubController.java +++ b/quickstep/src/com/android/quickstep/QuickScrubController.java @@ -16,6 +16,7 @@ package com.android.quickstep; +import android.util.Log; import android.view.HapticFeedbackConstants; import com.android.launcher3.Alarm; @@ -45,6 +46,7 @@ public class QuickScrubController implements OnAlarmListener { 0.05f, 0.35f, 0.65f, 0.95f }; + private static final String TAG = "QuickScrubController"; private static final boolean ENABLE_AUTO_ADVANCE = true; private static final long AUTO_ADVANCE_DELAY = 500; private static final int QUICKSCRUB_SNAP_DURATION_PER_PAGE = 325; @@ -58,6 +60,8 @@ public class QuickScrubController implements OnAlarmListener { private int mQuickScrubSection; private boolean mStartedFromHome; private boolean mFinishedTransitionToQuickScrub; + private Runnable mOnFinishedTransitionToQuickScrubRunnable; + private ActivityControlHelper mActivityControlHelper; public QuickScrubController(BaseActivity activity, RecentsView recentsView) { mActivity = activity; @@ -68,11 +72,13 @@ public class QuickScrubController implements OnAlarmListener { } } - public void onQuickScrubStart(boolean startingFromHome) { + public void onQuickScrubStart(boolean startingFromHome, ActivityControlHelper controlHelper) { mInQuickScrub = true; mStartedFromHome = startingFromHome; mQuickScrubSection = 0; mFinishedTransitionToQuickScrub = false; + mOnFinishedTransitionToQuickScrubRunnable = null; + mActivityControlHelper = controlHelper; snapToNextTaskIfAvailable(); mActivity.getUserEventDispatcher().resetActionDurationMillis(); @@ -85,13 +91,18 @@ public class QuickScrubController implements OnAlarmListener { } int page = mRecentsView.getNextPage(); Runnable launchTaskRunnable = () -> { - TaskView taskView = ((TaskView) mRecentsView.getPageAt(page)); + TaskView taskView = mRecentsView.getPageAt(page); if (taskView != null) { - taskView.launchTask(true); + taskView.launchTask(true, (result) -> { + if (!result) { + taskView.notifyTaskLaunchFailed(TAG); + breakOutOfQuickScrub(); + } + }, taskView.getHandler()); } else { - // Break out of quick scrub so user can interact with launcher. - mActivity.onBackPressed(); + breakOutOfQuickScrub(); } + mActivityControlHelper = null; }; int snapDuration = Math.abs(page - mRecentsView.getPageNearestToCenterOfScreen()) * QUICKSCRUB_END_SNAP_DURATION_PER_PAGE; @@ -100,13 +111,27 @@ public class QuickScrubController implements OnAlarmListener { mRecentsView.setNextPageSwitchRunnable(launchTaskRunnable); } else { // No page move needed, just launch it - launchTaskRunnable.run(); + if (mFinishedTransitionToQuickScrub) { + launchTaskRunnable.run(); + } else { + mOnFinishedTransitionToQuickScrubRunnable = launchTaskRunnable; + } } mActivity.getUserEventDispatcher().logActionOnControl(Touch.DRAGDROP, ControlType.QUICK_SCRUB_BUTTON, null, mStartedFromHome ? ContainerType.WORKSPACE : ContainerType.APP); } + /** + * Attempts to go to normal overview or back to home, so UI doesn't prevent user interaction. + */ + private void breakOutOfQuickScrub() { + if (mRecentsView.getChildCount() == 0 || mActivityControlHelper == null + || !mActivityControlHelper.switchToRecentsIfVisible()) { + mActivity.onBackPressed(); + } + } + public void onQuickScrubProgress(float progress) { int quickScrubSection = 0; for (float threshold : QUICK_SCRUB_THRESHOLDS) { @@ -135,6 +160,10 @@ public class QuickScrubController implements OnAlarmListener { public void onFinishedTransitionToQuickScrub() { mFinishedTransitionToQuickScrub = true; + if (mOnFinishedTransitionToQuickScrubRunnable != null) { + mOnFinishedTransitionToQuickScrubRunnable.run(); + mOnFinishedTransitionToQuickScrubRunnable = null; + } } public void snapToNextTaskIfAvailable() { @@ -166,6 +195,12 @@ public class QuickScrubController implements OnAlarmListener { @Override public void onAlarm(Alarm alarm) { int currPage = mRecentsView.getNextPage(); + boolean recentsVisible = mActivityControlHelper != null + && mActivityControlHelper.getVisibleRecentsView() != null; + if (!recentsVisible) { + Log.w(TAG, "Failed to auto advance; recents not visible"); + return; + } if (mQuickScrubSection == QUICK_SCRUB_THRESHOLDS.length && currPage < mRecentsView.getPageCount() - 1) { goToPageWithHaptic(currPage + 1); diff --git a/quickstep/src/com/android/quickstep/TouchInteractionService.java b/quickstep/src/com/android/quickstep/TouchInteractionService.java index 25649fa61..c9afcb571 100644 --- a/quickstep/src/com/android/quickstep/TouchInteractionService.java +++ b/quickstep/src/com/android/quickstep/TouchInteractionService.java @@ -21,9 +21,7 @@ import static android.view.MotionEvent.ACTION_MOVE; import static android.view.MotionEvent.ACTION_POINTER_DOWN; import static android.view.MotionEvent.ACTION_POINTER_UP; import static android.view.MotionEvent.ACTION_UP; - -import static com.android.systemui.shared.system.ActivityManagerWrapper - .CLOSE_SYSTEM_WINDOWS_REASON_RECENTS; +import static com.android.systemui.shared.system.ActivityManagerWrapper.CLOSE_SYSTEM_WINDOWS_REASON_RECENTS; import static com.android.systemui.shared.system.NavigationBarCompat.HIT_TARGET_NONE; import android.annotation.TargetApi; @@ -348,8 +346,8 @@ public class TouchInteractionService extends Service { mStartPending = true; Runnable action = () -> { - mQuickScrubController.onQuickScrubStart( - mActivityHelper.onQuickInteractionStart(mActivity, true)); + mQuickScrubController.onQuickScrubStart(mActivityHelper.onQuickInteractionStart( + mActivity, true), mActivityHelper); mQuickScrubController.onQuickScrubProgress(mLastProgress); mStartPending = false; diff --git a/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java b/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java index ec50e6778..027f2e9df 100644 --- a/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java +++ b/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java @@ -64,7 +64,6 @@ import com.android.quickstep.ActivityControlHelper.AnimationFactory; import com.android.quickstep.ActivityControlHelper.LayoutListener; import com.android.quickstep.TouchConsumer.InteractionType; import com.android.quickstep.util.ClipAnimationHelper; -import com.android.quickstep.util.RemoteAnimationProvider; import com.android.quickstep.util.RemoteAnimationTargetSet; import com.android.quickstep.util.SysuiEventLogger; import com.android.quickstep.views.RecentsView; @@ -767,7 +766,7 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity> { } mActivityControlHelper.onQuickInteractionStart(mActivity, false); - mQuickScrubController.onQuickScrubStart(false); + mQuickScrubController.onQuickScrubStart(false, mActivityControlHelper); // Inform the last progress in case we skipped before. mQuickScrubController.onQuickScrubProgress(mCurrentQuickScrubProgress); |