feat: Improve drawer search animations and state (#7054)

This commit improves the app drawer search state system to do the following things to match Pixel Launcher:

* Activate zero state only if these conditions are met:
  - The drawer search bar is tapped
  - The dock search bar is tapped, and matchHotseatQsbStyle is on or AppSearch is the current provider
  - The query is cleared
* Improves the search bar animation state to only remove the background and padding when the search bar has focus or has query
* Fixes the search bar end icon animation on tap
* Adds a back state handler in LawnchairLauncher so when back button is pressed, it exits search instead of exiting the app drawer, matching the intention of shouldBackExitSearch.
This commit is contained in:
TheSuperDragon authored and GitHub committed 2026-07-30 13:19:58 +08:00
1 parent 3c2ab9f18a
commit 83a1bd1a3f
10 files changed
+147 -34

No files matched your search

@@ -77,6 +77,7 @@ import com.android.launcher3.DeviceProfile;
import com.android.launcher3.DeviceProfile.OnDeviceProfileChangeListener;
import com.android.launcher3.DragSource;
import com.android.launcher3.DropTarget.DragObject;
import com.android.launcher3.ExtendedEditText;
import com.android.launcher3.Flags;
import com.android.launcher3.Insettable;
import com.android.launcher3.InsettableFrameLayout;
@@ -195,6 +196,7 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
/** {@code true} when rendered view is in search state instead of the scroll state. */
private boolean mIsSearching;
private boolean mSearchExitInProgress;
boolean showFastScroller;
private boolean mRebindAdaptersAfterSearchAnimation;
private int mNavBarScrimHeight = 0;
@@ -468,6 +470,7 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
if (!mSearchTransitionController.isRunning() && goingToSearch == isSearching()) {
return;
}
mSearchExitInProgress = !goingToSearch;
mFastScroller.setVisibility(goingToSearch ? INVISIBLE : VISIBLE);
if (goingToSearch) {
// Fade out the button to pause work apps.
@@ -489,12 +492,14 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
if (goingToSearch) {
mSearchUiDelegate.onAnimateToSearchStateCompleted();
mSearchExitInProgress = false;
} else {
setSearchResults(null);
if (mViewPager != null) {
mViewPager.setCurrentPage(previousPage);
}
onActivePageChanged(previousPage);
mSearchExitInProgress = false;
}
});
}
@@ -908,8 +913,25 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
}
boolean bgVisible = mSearchUiManager.getBackgroundVisibility();
if (scrolledOffset == 0 && !isSearching()) {
bgVisible = true;
if (scrolledOffset == 0) {
if (!isSearching()) {
bgVisible = true;
}
// LC-Note: Match Pixel Launcher behavior by focusing
// and showing the keyboard on scroll to top
if (PreferenceCacheExtensionsKt.firstCached(pref2.getAutoShowKeyboardInDrawer())) {
boolean isControllerAnimating = mAllAppsTransitionController != null
&& (mAllAppsTransitionController.getProgress() > 0f
|| mAllAppsTransitionController.getAllAppScale().isAnimating());
boolean isSearchTransitioning = mSearchTransitionController.isRunning()
|| mSearchExitInProgress;
if (!isControllerAnimating && !isSearchTransitioning) {
ExtendedEditText editText = mSearchUiManager.getEditText();
if (editText != null && !editText.isFocused()) {
editText.showKeyboard();
}
}
}
} else if (scrolledOffset > mHeaderThreshold) {
bgVisible = false;
}