Merge "Quick fix from ag/12914139" into ub-launcher3-master
diff --git a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
index 8286d87..6cf3c7a 100644
--- a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
+++ b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
@@ -1555,11 +1555,6 @@
mGestureEndCallback = gestureEndCallback;
}
- @Override
- public long getStartTouchTime() {
- return mTouchTimeMs;
- }
-
protected void linkRecentsViewScroll() {
SurfaceTransactionApplier.create(mRecentsView, applier -> {
mTransformParams.setSyncTransactionApplier(applier);
diff --git a/quickstep/src/com/android/quickstep/GestureState.java b/quickstep/src/com/android/quickstep/GestureState.java
index f788996..8d67ee6 100644
--- a/quickstep/src/com/android/quickstep/GestureState.java
+++ b/quickstep/src/com/android/quickstep/GestureState.java
@@ -142,6 +142,9 @@
private Set<Integer> mPreviouslyAppearedTaskIds = new HashSet<>();
private int mLastStartedTaskId = -1;
+ /** The time when the swipe up gesture is triggered. */
+ private long mSwipeUpStartTimeMs;
+
public GestureState(OverviewComponentObserver componentObserver, int gestureId) {
mHomeIntent = componentObserver.getHomeIntent();
mOverviewIntent = componentObserver.getOverviewIntent();
@@ -343,6 +346,14 @@
mStateCallback.setState(STATE_RECENTS_ANIMATION_ENDED);
}
+ void setSwipeUpStartTimeMs(long uptimeMs) {
+ mSwipeUpStartTimeMs = uptimeMs;
+ }
+
+ long getSwipeUpStartTimeMs() {
+ return mSwipeUpStartTimeMs;
+ }
+
public void dump(PrintWriter pw) {
pw.println("GestureState:");
pw.println(" gestureID=" + mGestureId);
diff --git a/quickstep/src/com/android/quickstep/RecentsAnimationCallbacks.java b/quickstep/src/com/android/quickstep/RecentsAnimationCallbacks.java
index f319b94..a21c714 100644
--- a/quickstep/src/com/android/quickstep/RecentsAnimationCallbacks.java
+++ b/quickstep/src/com/android/quickstep/RecentsAnimationCallbacks.java
@@ -160,12 +160,5 @@
* Callback made when a task started from the recents is ready for an app transition.
*/
default void onTaskAppeared(RemoteAnimationTargetCompat appearedTaskTarget) {}
-
- /**
- * The time in milliseconds of the touch event that starts the recents animation.
- */
- default long getStartTouchTime() {
- return 0;
- }
}
}
diff --git a/quickstep/src/com/android/quickstep/TaskAnimationManager.java b/quickstep/src/com/android/quickstep/TaskAnimationManager.java
index 797797f..6f2f86e 100644
--- a/quickstep/src/com/android/quickstep/TaskAnimationManager.java
+++ b/quickstep/src/com/android/quickstep/TaskAnimationManager.java
@@ -119,7 +119,7 @@
}
}
});
- final long eventTime = listener.getStartTouchTime();
+ final long eventTime = gestureState.getSwipeUpStartTimeMs();
mCallbacks.addListener(gestureState);
mCallbacks.addListener(listener);
UI_HELPER_EXECUTOR.execute(() -> ActivityManagerWrapper.getInstance()
diff --git a/quickstep/src/com/android/quickstep/TouchInteractionService.java b/quickstep/src/com/android/quickstep/TouchInteractionService.java
index eebb0de..c95ff02 100644
--- a/quickstep/src/com/android/quickstep/TouchInteractionService.java
+++ b/quickstep/src/com/android/quickstep/TouchInteractionService.java
@@ -45,6 +45,7 @@
import android.os.Bundle;
import android.os.IBinder;
import android.os.Looper;
+import android.os.SystemClock;
import android.util.Log;
import android.view.Choreographer;
import android.view.InputEvent;
@@ -447,6 +448,7 @@
// onConsumerInactive and wipe the previous gesture state
GestureState prevGestureState = new GestureState(mGestureState);
GestureState newGestureState = createGestureState(mGestureState);
+ newGestureState.setSwipeUpStartTimeMs(SystemClock.uptimeMillis());
mConsumer.onConsumerAboutToBeSwitched();
mGestureState = newGestureState;
mConsumer = newConsumer(prevGestureState, mGestureState, event);
diff --git a/res/layout/search_result_play_item.xml b/res/layout/search_result_play_item.xml
index cdb793c..d70c56a 100644
--- a/res/layout/search_result_play_item.xml
+++ b/res/layout/search_result_play_item.xml
@@ -16,7 +16,7 @@
<com.android.launcher3.views.SearchResultPlayItem xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:padding="8dp"
+ android:padding="4dp"
android:orientation="horizontal">
<View
android:id="@+id/icon"
@@ -31,13 +31,18 @@
android:layout_gravity="start|center_vertical"
android:layout_weight="1"
android:orientation="vertical"
- android:padding="8dp">
+ android:paddingTop="4dp"
+ android:paddingBottom="4dp"
+ android:paddingStart="8dp"
+ android:paddingEnd="8dp">
<TextView
android:id="@+id/title_view"
style="@style/TextHeadline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
+ android:maxLines="1"
+ android:ellipsize="end"
android:textAlignment="viewStart"
android:textColor="?android:attr/textColorPrimary"
android:textSize="16sp" />
diff --git a/res/layout/search_result_suggest.xml b/res/layout/search_result_suggest.xml
index a3227cb..1d8c803 100644
--- a/res/layout/search_result_suggest.xml
+++ b/res/layout/search_result_suggest.xml
@@ -21,12 +21,12 @@
android:gravity="start|center_vertical"
android:textAlignment="viewStart"
android:textColor="?android:attr/textColorPrimary"
- android:textSize="16sp"
+ android:textSize="18sp"
android:padding="@dimen/dynamic_grid_edge_margin"
launcher:iconDisplay="hero_app"
android:drawableTint="?android:attr/textColorPrimary"
launcher:customIcon="@drawable/ic_allapps_search"
- launcher:iconSizeOverride="24dp"
+ launcher:iconSizeOverride="48dp"
launcher:matchTextInsetWithQuery="true"
launcher:layoutHorizontal="true"
android:drawablePadding="@dimen/dynamic_grid_icon_drawable_padding"
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index ab8d7a5..699734c 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -1829,7 +1829,7 @@
mTouchInProgress = true;
break;
case MotionEvent.ACTION_UP:
- mLastTouchUpTime = ev.getEventTime();
+ mLastTouchUpTime = SystemClock.uptimeMillis();
// Follow through
case MotionEvent.ACTION_CANCEL:
mTouchInProgress = false;
diff --git a/src/com/android/launcher3/allapps/AllAppsInsetTransitionController.java b/src/com/android/launcher3/allapps/AllAppsInsetTransitionController.java
index d7af5f1..08d573f 100644
--- a/src/com/android/launcher3/allapps/AllAppsInsetTransitionController.java
+++ b/src/com/android/launcher3/allapps/AllAppsInsetTransitionController.java
@@ -29,13 +29,15 @@
import androidx.annotation.RequiresApi;
import androidx.core.os.BuildCompat;
+import com.android.launcher3.util.UiThreadHelper;
+
/**
* Handles IME over all apps to be synchronously transitioning along with the passed in
* root inset.
*/
public class AllAppsInsetTransitionController {
- private static final boolean DEBUG = false;
+ private static final boolean DEBUG = true;
private static final String TAG = "AllAppsInsetTransitionController";
private static final Interpolator LINEAR = new LinearInterpolator();
@@ -53,6 +55,13 @@
private float mDown, mCurrent;
private View mApps;
+ // Only purpose of these states is to keep track of fast fling transition
+ enum State {
+ RESET, DRAG_START_BOTTOM, FLING_END_TOP,
+ DRAG_START_TOP, FLING_END_BOTTOM
+ }
+ private State mState;
+
public AllAppsInsetTransitionController(float allAppsHeight, View appsView) {
mAllAppsHeight = allAppsHeight;
mApps = appsView;
@@ -64,6 +73,11 @@
WindowInsets insets = mApps.getRootWindowInsets();
if (insets == null) return;
+ boolean imeVisible = insets.isVisible(WindowInsets.Type.ime());
+
+ if (DEBUG) {
+ Log.d(TAG, "\nhide imeVisible=" + imeVisible);
+ }
if (insets.isVisible(WindowInsets.Type.ime())) {
mApps.getWindowInsetsController().hide(WindowInsets.Type.ime());
}
@@ -78,20 +92,23 @@
@RequiresApi(api = Build.VERSION_CODES.R)
public void onDragStart(float progress) {
if (!BuildCompat.isAtLeastR()) return;
- onAnimationEnd(progress);
+ // Until getRootWindowInsets().isVisible(...) method returns correct value,
+ // only support InsetController based IME transition during swipe up and
+ // NOT swipe down
+ if (Float.compare(progress, 0f) == 0) return;
+
+ setState(true, false, progress);
mDown = progress * mAllAppsHeight;
// Below two values are sometimes incorrect. Possibly a platform bug
- mDownInsetBottom = mApps.getRootWindowInsets().getInsets(WindowInsets.Type.ime()).bottom;
- mShownAtDown = mApps.getRootWindowInsets().isVisible(WindowInsets.Type.ime());
+ // mDownInsetBottom = mApps.getRootWindowInsets().getInsets(WindowInsets.Type.ime()).bottom;
+ // mShownAtDown = mApps.getRootWindowInsets().isVisible(WindowInsets.Type.ime());
- // override this value based on what it should actually be.
- mShownAtDown = Float.compare(progress, 1f) == 0 ? false : true;
- mDownInsetBottom = mShownAtDown ? mShownInsetBottom : mHiddenInsetBottom;
if (DEBUG) {
- Log.d(TAG, "\nonDragStart mDownInsets=" + mDownInsetBottom
- + " mShownAtDown =" + mShownAtDown);
+ Log.d(TAG, "\nonDragStart progress=" + progress
+ + " mDownInsets=" + mDownInsetBottom
+ + " mShownAtDown=" + mShownAtDown);
}
mApps.getWindowInsetsController().controlWindowInsetsAnimation(
@@ -103,37 +120,63 @@
if (DEBUG) {
Log.d(TAG, "Listener.onReady " + (mCurrentRequest == this));
}
- if (mCurrentRequest == this) {
- mAnimationController = controller;
- } else {
- controller.finish(mShownAtDown);
+ if (controller != null) {
+ if (mCurrentRequest == this && !handleFinishOnFling(controller)) {
+ mAnimationController = controller;
+ } else {
+ controller.finish(false /* just don't show */);
+ }
}
}
@Override
public void onFinished(WindowInsetsAnimationController controller) {
// when screen lock happens, then this method get called
- mAnimationController.finish(false);
- mAnimationController = null;
if (DEBUG) {
- Log.d(TAG, "Listener.onFinished ctrl=" + controller);
+ Log.d(TAG, "Listener.onFinished ctrl=" + controller
+ + " mAnimationController=" + mAnimationController);
+ }
+ if (mAnimationController != null) {
+ mAnimationController.finish(true);
+ mAnimationController = null;
}
}
@Override
public void onCancelled(@Nullable WindowInsetsAnimationController controller) {
+ if (DEBUG) {
+ Log.d(TAG, "Listener.onCancelled ctrl=" + controller
+ + " mAnimationController=" + mAnimationController);
+ }
+ if (mState == State.DRAG_START_BOTTOM) {
+ mApps.getWindowInsetsController().show(WindowInsets.Type.ime());
+ }
mAnimationController = null;
if (controller != null) {
- controller.finish(mShownAtDown);
+ controller.finish(true);
}
- if (DEBUG) {
- Log.d(TAG, "Listener.onCancelled ctrl=" + controller);
- }
+
}
});
}
/**
+ * If IME bounds after touch sequence finishes, call finish.
+ */
+ private boolean handleFinishOnFling(WindowInsetsAnimationController controller) {
+ if (!BuildCompat.isAtLeastR()) return false;
+
+ if (mState == State.FLING_END_TOP) {
+ controller.finish(true);
+ return true;
+ } else if (mState == State.FLING_END_BOTTOM) {
+ controller.finish(false);
+ return true;
+ }
+ return false;
+ }
+
+ /**
* Handles the translation using the progress.
*
* @param progress value between 0..1
@@ -153,18 +196,17 @@
int inset = (int) (mDownInsetBottom + (mDown - mCurrent) - shift);
- if (DEBUG) {
- Log.d(TAG, "updateInset mCurrent=" + mCurrent + " mDown="
- + mDown + " hidden=" + mHiddenInsetBottom
- + " shown=" + mShownInsetBottom
- + " mDownInsets.bottom=" + mDownInsetBottom + " inset:" + inset
- + " shift: " + shift);
- }
final int start = mShownAtDown ? mShownInsetBottom : mHiddenInsetBottom;
final int end = mShownAtDown ? mHiddenInsetBottom : mShownInsetBottom;
inset = Math.max(inset, mHiddenInsetBottom);
inset = Math.min(inset, mShownInsetBottom);
- Log.d(TAG, "updateInset inset:" + inset);
+ if (DEBUG || false) {
+ Log.d(TAG, "updateInset mCurrent=" + mCurrent + " mDown="
+ + mDown + " hidden=" + mHiddenInsetBottom
+ + " shown=" + mShownInsetBottom
+ + " mDownInsets.bottom=" + mDownInsetBottom + " inset=" + inset
+ + " shift= " + shift);
+ }
mAnimationController.setInsetsAndAlpha(
Insets.of(0, 0, 0, inset),
@@ -179,19 +221,60 @@
@RequiresApi(api = 30)
public void onAnimationEnd(float progress) {
if (DEBUG) {
+ Log.d(TAG, "onAnimationEnd progress=" + progress
+ + " mAnimationController=" + mAnimationController);
+ }
+ if (mState == null) {
+ // only called when launcher restarting.
+ UiThreadHelper.hideKeyboardAsync(mApps.getContext(), mApps.getWindowToken());
+ }
+ setState(false, true, progress);
+ if (mAnimationController == null) {
+ return;
+ }
+
+ /* handle finish */
+ if (mState == State.FLING_END_TOP) {
+ mAnimationController.finish(true /* show */);
+ } else {
+ if (Float.compare(progress, 1f) == 0 /* bottom */) {
+ mAnimationController.finish(false /* gone */);
+ } else {
+ mAnimationController.finish(mShownAtDown);
+ }
+ }
+ /* handle finish */
+
+ if (DEBUG) {
Log.d(TAG, "endTranslation progress=" + progress
+ " mAnimationController=" + mAnimationController);
}
-
- if (mAnimationController == null) return;
-
- if (Float.compare(progress, 1f) == 0 /* bottom */) {
- mAnimationController.finish(false /* gone */);
- }
- if (Float.compare(progress, 0f) == 0 /* top */) {
- mAnimationController.finish(true /* show */);
- }
mAnimationController = null;
mCurrentRequest = null;
+ setState(false, false, progress);
+ }
+
+ private void setState(boolean start, boolean end, float progress) {
+ State state = State.RESET;
+ if (start && end) {
+ throw new IllegalStateException("drag start and end cannot happen in same call");
+ }
+ if (start) {
+ if (Float.compare(progress, 1f) == 0) {
+ state = State.DRAG_START_BOTTOM;
+ } else if (Float.compare(progress, 0f) == 0) {
+ state = State.DRAG_START_TOP;
+ }
+ } else if (end) {
+ if (Float.compare(progress, 1f) == 0 && mState == State.DRAG_START_TOP) {
+ state = State.FLING_END_BOTTOM;
+ } else if (Float.compare(progress, 0f) == 0 && mState == State.DRAG_START_BOTTOM) {
+ state = State.FLING_END_TOP;
+ }
+ }
+ if (DEBUG) {
+ Log.d(TAG, "setState " + mState + " -> " + state);
+ }
+ mState = state;
}
}
diff --git a/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java b/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java
index 9fd53e2..57c0ad9 100644
--- a/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java
+++ b/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java
@@ -266,7 +266,7 @@
if (FeatureFlags.ENABLE_DEVICE_SEARCH.get() && BuildCompat.isAtLeastR()
&& (mToState == ALL_APPS || mToState == NORMAL)) {
mLauncher.getAllAppsController().getInsetController().onDragStart(
- mToState == ALL_APPS ? 0 : 1);
+ mFromState == NORMAL ? 1f : 0f);
}
}
diff --git a/src/com/android/launcher3/views/SearchSettingsRowView.java b/src/com/android/launcher3/views/SearchSettingsRowView.java
index 30f686c..f0884f8 100644
--- a/src/com/android/launcher3/views/SearchSettingsRowView.java
+++ b/src/com/android/launcher3/views/SearchSettingsRowView.java
@@ -81,7 +81,6 @@
Bundle bundle = searchTarget.getExtras();
mIntent = bundle.getParcelable("intent");
showIfAvailable(mTitleView, bundle.getString("title"));
- showIfAvailable(mDescriptionView, bundle.getString("description"));
ArrayList<String> breadcrumbs = bundle.getStringArrayList("breadcrumbs");
//TODO: implement RTL friendly breadcrumbs view
showIfAvailable(mBreadcrumbsView, breadcrumbs != null
diff --git a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java
index e118481..d3fc89e 100644
--- a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java
+++ b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java
@@ -234,25 +234,11 @@
return mDevice;
}
- private boolean hasSystemUiObject(String resId) {
- return mDevice.hasObject(By.res(SYSTEMUI_PACKAGE, resId));
- }
-
@Before
public void setUp() throws Exception {
- Log.d(TAG, "Before disabling battery defender");
- mDevice.executeShellCommand("setprop vendor.battery.defender.disable 1");
- Log.d(TAG, "Before enabling stay awake");
- mDevice.executeShellCommand("settings put global stay_on_while_plugged_in 3");
- for (int i = 0; i < 10 && hasSystemUiObject("keyguard_status_view"); ++i) {
- Log.d(TAG, "Before unlocking the phone");
- mDevice.executeShellCommand("input keyevent 82");
- mDevice.waitForIdle();
- }
- Assert.assertTrue("Keyguard still visible",
+ Assert.assertTrue("Keyguard is visible",
mDevice.wait(
Until.gone(By.res(SYSTEMUI_PACKAGE, "keyguard_status_view")), 60000));
- Log.d(TAG, "Keyguard is not visible");
final String launcherPackageName = mDevice.getLauncherPackageName();
try {