Merge "Hide clear-all button from accessibility" into ub-launcher3-edmonton
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index fde22eb..b7c5793 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -72,7 +72,7 @@
android:stateNotNeeded="true"
android:windowSoftInputMode="adjustPan"
android:screenOrientation="unspecified"
- android:configChanges="keyboard|keyboardHidden|navigation"
+ android:configChanges="keyboard|keyboardHidden|mcc|mnc|navigation|orientation|screenSize|screenLayout|smallestScreenSize"
android:resizeableActivity="true"
android:resumeWhilePausing="true"
android:taskAffinity=""
diff --git a/quickstep/AndroidManifest.xml b/quickstep/AndroidManifest.xml
index ac38906..778866d 100644
--- a/quickstep/AndroidManifest.xml
+++ b/quickstep/AndroidManifest.xml
@@ -54,7 +54,7 @@
android:stateNotNeeded="true"
android:theme="@style/LauncherTheme"
android:screenOrientation="unspecified"
- android:configChanges="keyboard|keyboardHidden|navigation|orientation|screenSize|screenLayout|smallestScreenSize"
+ android:configChanges="keyboard|keyboardHidden|mcc|mnc|navigation|orientation|screenSize|screenLayout|smallestScreenSize"
android:resizeableActivity="true"
android:resumeWhilePausing="true"
android:taskAffinity="" />
diff --git a/quickstep/src/com/android/launcher3/LauncherAppTransitionManagerImpl.java b/quickstep/src/com/android/launcher3/LauncherAppTransitionManagerImpl.java
index 80ee577..2e31ef2 100644
--- a/quickstep/src/com/android/launcher3/LauncherAppTransitionManagerImpl.java
+++ b/quickstep/src/com/android/launcher3/LauncherAppTransitionManagerImpl.java
@@ -127,13 +127,6 @@
private RemoteAnimationProvider mRemoteAnimationProvider;
- private final AnimatorListenerAdapter mReapplyStateListener = new AnimatorListenerAdapter() {
- @Override
- public void onAnimationEnd(Animator animation) {
- mLauncher.getStateManager().reapplyState();
- }
- };
-
private final AnimatorListenerAdapter mForceInvisibleListener = new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animation) {
@@ -260,7 +253,13 @@
launcherAnim.setDuration(RECENTS_LAUNCH_DURATION);
// Make sure recents gets fixed up by resetting task alphas and scales, etc.
- windowAnimEndListener = mReapplyStateListener;
+ windowAnimEndListener = new AnimatorListenerAdapter() {
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ mLauncher.getStateManager().moveToRestState();
+ mLauncher.getStateManager().reapplyState();
+ }
+ };
} else {
AnimatorPlaybackController controller =
mLauncher.getStateManager()
diff --git a/quickstep/src/com/android/quickstep/QuickScrubController.java b/quickstep/src/com/android/quickstep/QuickScrubController.java
index 28b06fb..abb479d 100644
--- a/quickstep/src/com/android/quickstep/QuickScrubController.java
+++ b/quickstep/src/com/android/quickstep/QuickScrubController.java
@@ -63,6 +63,7 @@
private final BaseActivity mActivity;
private boolean mInQuickScrub;
+ private boolean mWaitingForTaskLaunch;
private int mQuickScrubSection;
private boolean mStartedFromHome;
private boolean mFinishedTransitionToQuickScrub;
@@ -79,11 +80,11 @@
}
public void onQuickScrubStart(boolean startingFromHome, ActivityControlHelper controlHelper) {
+ prepareQuickScrub(TAG);
mInQuickScrub = true;
mStartedFromHome = startingFromHome;
mQuickScrubSection = 0;
mFinishedTransitionToQuickScrub = false;
- mOnFinishedTransitionToQuickScrubRunnable = null;
mActivityControlHelper = controlHelper;
snapToNextTaskIfAvailable();
@@ -99,11 +100,17 @@
Runnable launchTaskRunnable = () -> {
TaskView taskView = mRecentsView.getPageAt(page);
if (taskView != null) {
+ mWaitingForTaskLaunch = true;
taskView.launchTask(true, (result) -> {
if (!result) {
taskView.notifyTaskLaunchFailed(TAG);
breakOutOfQuickScrub();
+ } else {
+ mActivity.getUserEventDispatcher().logTaskLaunchOrDismiss(Touch.DRAGDROP,
+ LauncherLogProto.Action.Direction.NONE, page,
+ TaskUtils.getComponentKeyForTask(taskView.getTask().key));
}
+ mWaitingForTaskLaunch = false;
}, taskView.getHandler());
} else {
breakOutOfQuickScrub();
@@ -123,9 +130,19 @@
mOnFinishedTransitionToQuickScrubRunnable = launchTaskRunnable;
}
}
- mActivity.getUserEventDispatcher().logTaskLaunchOrDismiss(Touch.DRAGDROP,
- LauncherLogProto.Action.Direction.NONE, page,
- TaskUtils.getComponentKeyForTask(mRecentsView.getPageAt(page).getTask().key));
+ }
+
+ /**
+ * Initializes the UI for quick scrub, returns true if success.
+ */
+ public boolean prepareQuickScrub(String tag) {
+ if (mWaitingForTaskLaunch || mInQuickScrub) {
+ Log.d(tag, "Waiting for last scrub to finish, will skip this interaction");
+ return false;
+ }
+ mOnFinishedTransitionToQuickScrubRunnable = null;
+ mRecentsView.setNextPageSwitchRunnable(null);
+ return true;
}
/**
@@ -166,9 +183,11 @@
public void onFinishedTransitionToQuickScrub() {
mFinishedTransitionToQuickScrub = true;
- if (mOnFinishedTransitionToQuickScrubRunnable != null) {
- mOnFinishedTransitionToQuickScrubRunnable.run();
- mOnFinishedTransitionToQuickScrubRunnable = null;
+ Runnable action = mOnFinishedTransitionToQuickScrubRunnable;
+ // Clear the runnable before executing it, to prevent potential recursion.
+ mOnFinishedTransitionToQuickScrubRunnable = null;
+ if (action != null) {
+ action.run();
}
}
diff --git a/quickstep/src/com/android/quickstep/TaskUtils.java b/quickstep/src/com/android/quickstep/TaskUtils.java
index d7fad43..2b0c98f 100644
--- a/quickstep/src/com/android/quickstep/TaskUtils.java
+++ b/quickstep/src/com/android/quickstep/TaskUtils.java
@@ -98,12 +98,13 @@
if (v.getTag() instanceof ItemInfo) {
ItemInfo itemInfo = (ItemInfo) v.getTag();
ComponentName componentName = itemInfo.getTargetComponent();
+ int userId = itemInfo.user.getIdentifier();
if (componentName != null) {
for (int i = 0; i < recentsView.getChildCount(); i++) {
TaskView taskView = recentsView.getPageAt(i);
if (recentsView.isTaskViewVisible(taskView)) {
- Task task = taskView.getTask();
- if (componentName.equals(task.key.getComponent())) {
+ Task.TaskKey key = taskView.getTask().key;
+ if (componentName.equals(key.getComponent()) && userId == key.userId) {
return taskView;
}
}
diff --git a/quickstep/src/com/android/quickstep/TouchInteractionService.java b/quickstep/src/com/android/quickstep/TouchInteractionService.java
index 458f9f5..aecb66c 100644
--- a/quickstep/src/com/android/quickstep/TouchInteractionService.java
+++ b/quickstep/src/com/android/quickstep/TouchInteractionService.java
@@ -349,12 +349,20 @@
return;
}
if (interactionType == INTERACTION_QUICK_SCRUB) {
+ if (!mQuickScrubController.prepareQuickScrub(TAG)) {
+ mInvalidated = true;
+ return;
+ }
OverviewCallbacks.get(mActivity).closeAllWindows();
ActivityManagerWrapper.getInstance()
.closeSystemWindows(CLOSE_SYSTEM_WINDOWS_REASON_RECENTS);
mStartPending = true;
Runnable action = () -> {
+ if (!mQuickScrubController.prepareQuickScrub(TAG)) {
+ mInvalidated = true;
+ return;
+ }
mActivityHelper.onQuickInteractionStart(mActivity, null, true);
mQuickScrubController.onQuickScrubProgress(mLastProgress);
mStartPending = false;
@@ -384,7 +392,7 @@
@Override
public void onQuickScrubProgress(float progress) {
mLastProgress = progress;
- if (mInvalidated || mEndPending) {
+ if (mInvalidated || mStartPending) {
return;
}
mQuickScrubController.onQuickScrubProgress(progress);
diff --git a/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java b/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java
index 807dae8..84b2176 100644
--- a/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java
+++ b/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java
@@ -109,6 +109,8 @@
private static final int STATE_CAPTURE_SCREENSHOT = 1 << 14;
private static final int STATE_SCREENSHOT_CAPTURED = 1 << 15;
+ private static final int STATE_RESUME_LAST_TASK = 1 << 16;
+
private static final int LAUNCHER_UI_STATES =
STATE_LAUNCHER_PRESENT | STATE_LAUNCHER_DRAWN | STATE_ACTIVITY_MULTIPLIER_COMPLETE
| STATE_LAUNCHER_STARTED;
@@ -139,6 +141,7 @@
"STATE_QUICK_SCRUB_END",
"STATE_CAPTURE_SCREENSHOT",
"STATE_SCREENSHOT_CAPTURED",
+ "STATE_RESUME_LAST_TASK",
};
public static final long MAX_SWIPE_DURATION = 350;
@@ -187,6 +190,7 @@
private boolean mGestureStarted;
private int mLogAction = Touch.SWIPE;
private float mCurrentQuickScrubProgress;
+ private boolean mQuickScrubBlocked;
private @InteractionType int mInteractionType = INTERACTION_NORMAL;
@@ -239,9 +243,12 @@
mStateCallback.addCallback(STATE_LAUNCHER_STARTED | STATE_APP_CONTROLLER_RECEIVED,
this::sendRemoteAnimationsToAnimationFactory);
- mStateCallback.addCallback(STATE_LAUNCHER_PRESENT | STATE_APP_CONTROLLER_RECEIVED
- | STATE_SCALED_CONTROLLER_APP,
+
+ mStateCallback.addCallback(STATE_LAUNCHER_PRESENT | STATE_SCALED_CONTROLLER_APP,
+ this::resumeLastTaskForQuickstep);
+ mStateCallback.addCallback(STATE_RESUME_LAST_TASK | STATE_APP_CONTROLLER_RECEIVED,
this::resumeLastTask);
+
mStateCallback.addCallback(STATE_LAUNCHER_PRESENT | STATE_APP_CONTROLLER_RECEIVED
| STATE_ACTIVITY_MULTIPLIER_COMPLETE
| STATE_CAPTURE_SCREENSHOT,
@@ -258,9 +265,6 @@
| STATE_GESTURE_COMPLETED,
this::setupLauncherUiAfterSwipeUpAnimation);
- mStateCallback.addCallback(STATE_LAUNCHER_PRESENT | STATE_SCALED_CONTROLLER_APP,
- this::reset);
-
mStateCallback.addCallback(STATE_HANDLER_INVALIDATED, this::invalidateHandler);
mStateCallback.addCallback(STATE_LAUNCHER_PRESENT | STATE_HANDLER_INVALIDATED,
this::invalidateHandlerWithLauncher);
@@ -657,9 +661,15 @@
}
@UiThread
+ private void resumeLastTaskForQuickstep() {
+ setStateOnUiThread(STATE_RESUME_LAST_TASK);
+ doLogGesture(false /* toLauncher */);
+ reset();
+ }
+
+ @UiThread
private void resumeLastTask() {
mRecentsAnimationWrapper.finish(false /* toHome */, null);
- doLogGesture(false /* toLauncher */);
}
public void reset() {
@@ -760,6 +770,11 @@
}
private void onQuickScrubStart() {
+ if (!mQuickScrubController.prepareQuickScrub(TAG)) {
+ mQuickScrubBlocked = true;
+ setStateOnUiThread(STATE_RESUME_LAST_TASK | STATE_HANDLER_INVALIDATED);
+ return;
+ }
if (mLauncherTransitionController != null) {
mLauncherTransitionController.getAnimationPlayer().end();
mLauncherTransitionController = null;
@@ -793,12 +808,16 @@
}
private void onFinishedTransitionToQuickScrub() {
+ if (mQuickScrubBlocked) {
+ return;
+ }
mQuickScrubController.onFinishedTransitionToQuickScrub();
}
public void onQuickScrubProgress(float progress) {
mCurrentQuickScrubProgress = progress;
- if (Looper.myLooper() != Looper.getMainLooper() || mQuickScrubController == null) {
+ if (Looper.myLooper() != Looper.getMainLooper() || mQuickScrubController == null
+ || mQuickScrubBlocked) {
return;
}
mQuickScrubController.onQuickScrubProgress(progress);
@@ -809,6 +828,9 @@
}
private void switchToFinalAppAfterQuickScrub() {
+ if (mQuickScrubBlocked) {
+ return;
+ }
mQuickScrubController.onQuickScrubEnd();
// Normally this is handled in reset(), but since we are still scrubbing after the
diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java
index 4a8c628..f038eff 100644
--- a/quickstep/src/com/android/quickstep/views/RecentsView.java
+++ b/quickstep/src/com/android/quickstep/views/RecentsView.java
@@ -1309,4 +1309,20 @@
public void revealClearAllButton() {
scrollTo(mIsRtl ? 0 : computeMaxScrollX(), 0);
}
+
+ @Override
+ public void addChildrenForAccessibility(ArrayList<View> outChildren) {
+ if (FLIP_RECENTS) {
+ for (int i = getChildCount() - 1; i >= 0; --i) {
+ outChildren.add(getChildAt(i));
+ }
+ } else {
+ super.addChildrenForAccessibility(outChildren);
+ }
+ }
+
+ @Override
+ protected boolean isPageOrderFlipped() {
+ return FLIP_RECENTS;
+ }
}
diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java
index a98867d..a71fbf1 100644
--- a/src/com/android/launcher3/PagedView.java
+++ b/src/com/android/launcher3/PagedView.java
@@ -1510,17 +1510,24 @@
return ScrollView.class.getName();
}
+ protected boolean isPageOrderFlipped() {
+ return false;
+ }
+
/* Accessibility */
@SuppressWarnings("deprecation")
@Override
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
super.onInitializeAccessibilityNodeInfo(info);
+ final boolean pagesFlipped = isPageOrderFlipped();
info.setScrollable(getPageCount() > 1);
if (getCurrentPage() < getPageCount() - 1) {
- info.addAction(AccessibilityNodeInfo.ACTION_SCROLL_FORWARD);
+ info.addAction(pagesFlipped ? AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD
+ : AccessibilityNodeInfo.ACTION_SCROLL_FORWARD);
}
if (getCurrentPage() > 0) {
- info.addAction(AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD);
+ info.addAction(pagesFlipped ? AccessibilityNodeInfo.ACTION_SCROLL_FORWARD
+ : AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD);
}
// Accessibility-wise, PagedView doesn't support long click, so disabling it.
@@ -1544,24 +1551,40 @@
event.setScrollable(getPageCount() > 1);
}
+ private boolean accessibilityScrollLeft() {
+ if (getCurrentPage() > 0) {
+ scrollLeft();
+ return true;
+ }
+ return false;
+ }
+
+ private boolean accessibilityScrollRight() {
+ if (getCurrentPage() < getPageCount() - 1) {
+ scrollRight();
+ return true;
+ }
+ return false;
+ }
+
@Override
public boolean performAccessibilityAction(int action, Bundle arguments) {
if (super.performAccessibilityAction(action, arguments)) {
return true;
}
+ final boolean pagesFlipped = isPageOrderFlipped();
switch (action) {
case AccessibilityNodeInfo.ACTION_SCROLL_FORWARD: {
- if (getCurrentPage() < getPageCount() - 1) {
- scrollRight();
+ if (pagesFlipped ? accessibilityScrollLeft() : accessibilityScrollRight()) {
return true;
}
} break;
case AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD: {
- if (getCurrentPage() > 0) {
- scrollLeft();
+ if (pagesFlipped ? accessibilityScrollRight() : accessibilityScrollLeft()) {
return true;
}
- } break;
+ }
+ break;
}
return false;
}