Put the "floating" in ENABLE_FLOATING_SEARCH_BAR.
This means adding the search view to the drag layer, so it can
persist and animate across Launcher states (i.e. Home, All Apps,
Overview, Overview from App).
Some high level things:
- LauncherState now has a flag indicating if the floating
search bar should be visible, as well as a method indicating
how high it should rest when the keyboard is not showing. By
default the height is set negative if the flag is not present,
so the search bar will rest off screen in that state.
- LauncherState also has a new method indicating if the search
bar should show as a pill when not focused. Currently this is
done in phone portrait mode in all apps and overview.
- SearchUiManager now has a method for gestures to hint that
the search bar will be focused or unfocused soon, e.g. for
the app -> overview case, we hint that it will be focused
when crossing the threshold, and unfocused if retracting.
This allows the search bar to animate during the gesture
and take or release focus after the state change completes.
- AllAppsTransitionController lets the apps panel translate in
from the bottom of the screen, for example when coming from
an app and we don't want to pop it in halfway up the screen.
Instead it can slide in gracefully from behind the keyboard
and floating search bar.
- KeyboardInsetAnimationCallback can now notify listeners of
keyboard alpha changes during controlled animations. And
StateAnimationConfig has a new animation type to control
the keyboard alpha during the all apps transition.
- This new ANIM_ALL_APPS_KEYBOARD_FADE is used to pop the
keyboard in at the threshold for going from an app to all apps.
Note that its position moves linearly before this, so the
search bar starts moving up accordingly before the keyboard
alpha is non-0.
Fix: 266761289
Fix: 268845147
Fix: 267683921
Fix: 265849321
Fix: 266446733
Fix: 269301440
Bug: 275635606
Bug: 259619990
Bug: 261866704
Test: Manual with all the state transitions on phone and tablet
(also folding/unfolding foldable).
Flag: ENABLE_FLOATING_SEARCH_BAR, ENABLE_ALL_APPS_FROM_OVERVIEW
(latter just for the background app interpolator changes).
Change-Id: I6f06552e95747348a62260279626cf407bf145b0
diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java
index 22d393a..bafcb9f 100644
--- a/src/com/android/launcher3/DeviceProfile.java
+++ b/src/com/android/launcher3/DeviceProfile.java
@@ -546,7 +546,9 @@
overviewTaskIconDrawableSizeGridPx =
res.getDimensionPixelSize(R.dimen.task_thumbnail_icon_drawable_size_grid);
overviewTaskThumbnailTopMarginPx = overviewTaskIconSizePx + overviewTaskMarginPx;
- overviewActionsTopMarginPx = res.getDimensionPixelSize(R.dimen.overview_actions_top_margin);
+ // Don't add margin with floating search bar to minimize risk of overlapping.
+ overviewActionsTopMarginPx = FeatureFlags.ENABLE_FLOATING_SEARCH_BAR.get() ? 0
+ : res.getDimensionPixelSize(R.dimen.overview_actions_top_margin);
overviewPageSpacing = res.getDimensionPixelSize(R.dimen.overview_page_spacing);
overviewActionsButtonSpacing = res.getDimensionPixelSize(
R.dimen.overview_actions_button_spacing);
diff --git a/src/com/android/launcher3/LauncherState.java b/src/com/android/launcher3/LauncherState.java
index 05471ad..035b9c8 100644
--- a/src/com/android/launcher3/LauncherState.java
+++ b/src/com/android/launcher3/LauncherState.java
@@ -66,6 +66,7 @@
public static final int CLEAR_ALL_BUTTON = 1 << 4;
public static final int WORKSPACE_PAGE_INDICATOR = 1 << 5;
public static final int SPLIT_PLACHOLDER_VIEW = 1 << 6;
+ public static final int FLOATING_SEARCH_BAR = 1 << 7;
// Flag indicating workspace has multiple pages visible.
public static final int FLAG_MULTI_PAGE = BaseState.getFlag(0);
@@ -202,8 +203,33 @@
return 0;
}
+ /**
+ * How far from the bottom of the screen the <em>floating</em> search bar should rest in this
+ * state when the IME is not present.
+ * <p>
+ * To hide offscreen, use a negative value.
+ * <p>
+ * Note: if the provided value is non-negative but less than the current bottom insets, the
+ * insets will be applied. As such, you can use 0 to default to this.
+ */
+ public int getFloatingSearchBarRestingMarginBottom(Launcher launcher) {
+ DeviceProfile dp = launcher.getDeviceProfile();
+ return areElementsVisible(launcher, FLOATING_SEARCH_BAR) ? dp.getQsbOffsetY()
+ : -dp.hotseatQsbHeight;
+ }
+
+ /** Whether the <em>floating</em> search bar should use the pill UI when not focused. */
+ public boolean shouldFloatingSearchBarUsePillWhenUnfocused(Launcher launcher) {
+ return false;
+ }
+
public int getVisibleElements(Launcher launcher) {
- return HOTSEAT_ICONS | WORKSPACE_PAGE_INDICATOR | VERTICAL_SWIPE_INDICATOR;
+ int elements = HOTSEAT_ICONS | WORKSPACE_PAGE_INDICATOR | VERTICAL_SWIPE_INDICATOR;
+ // Floating search bar is visible in normal state except in landscape on phones.
+ if (!(launcher.getDeviceProfile().isPhone && launcher.getDeviceProfile().isLandscape)) {
+ elements |= FLOATING_SEARCH_BAR;
+ }
+ return elements;
}
/**
diff --git a/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java b/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java
index 898009d..a4dbe78 100644
--- a/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java
+++ b/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java
@@ -229,6 +229,10 @@
return new AllAppsSearchUiDelegate(this);
}
+ public AllAppsSearchUiDelegate getSearchUiDelegate() {
+ return mSearchUiDelegate;
+ }
+
/**
* Initializes the view hierarchy and internal variables. Any initialization which actually uses
* these members should be done in {@link #onFinishInflate()}.
@@ -255,11 +259,13 @@
mFastScroller = findViewById(R.id.fast_scroller);
mFastScroller.setPopupView(findViewById(R.id.fast_scroller_popup));
- // Add the search box above everything else.
- mSearchContainer = inflateSearchBox();
- addView(mSearchContainer);
+ mSearchContainer = inflateSearchBar();
+ if (!isSearchBarFloating()) {
+ // Add the search box above everything else in this container (if the flag is enabled,
+ // it's added to drag layer in onAttach instead).
+ addView(mSearchContainer);
+ }
mSearchUiManager = (SearchUiManager) mSearchContainer;
- mSearchUiDelegate.onInitializeSearchBox();
}
@Override
@@ -290,6 +296,13 @@
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
+ if (isSearchBarFloating()) {
+ // Note: for Taskbar this is removed in TaskbarAllAppsController#cleanUpOverlay when the
+ // panel is closed. Can't do so in onDetach because we are also a child of drag layer
+ // so can't remove its views during that dispatch.
+ mActivityContext.getDragLayer().addView(mSearchContainer);
+ mSearchUiDelegate.onInitializeSearchBar();
+ }
mActivityContext.addOnDeviceProfileChangeListener(this);
}
@@ -311,7 +324,7 @@
* Temporarily force the bottom sheet to be visible on non-tablets.
*
* @param force {@code true} means bottom sheet will be visible on phones until {@code reset()}.
- **/
+ */
public void forceBottomSheetVisible(boolean force) {
mForceBottomSheetVisible = force;
updateBackgroundVisibility(mActivityContext.getDeviceProfile());
@@ -421,7 +434,7 @@
* A-Z apps list.
*
* @param animate Whether to animate the header during the reset (e.g. switching profile tabs).
- **/
+ */
public void reset(boolean animate) {
reset(animate, true);
}
@@ -431,7 +444,7 @@
*
* @param animate Whether to animate the header during the reset (e.g. switching profile tabs).
* @param exitSearch Whether to force exit the search state and return to A-Z apps list.
- **/
+ */
public void reset(boolean animate, boolean exitSearch) {
for (int i = 0; i < mAH.size(); i++) {
if (mAH.get(i).mRecyclerView != null) {
@@ -494,6 +507,9 @@
// Will be called at the end of the animation.
return;
}
+ if (currentActivePage != SEARCH) {
+ mActivityContext.hideKeyboard();
+ }
if (mAH.get(currentActivePage).mRecyclerView != null) {
mAH.get(currentActivePage).mRecyclerView.bindFastScrollbar(mFastScroller);
}
@@ -551,7 +567,6 @@
mActivityContext.getStatsLogManager().logger()
.log(LAUNCHER_ALLAPPS_TAP_ON_PERSONAL_TAB);
}
- mActivityContext.hideKeyboard();
});
findViewById(R.id.tab_work)
.setOnClickListener((View view) -> {
@@ -559,24 +574,24 @@
mActivityContext.getStatsLogManager().logger()
.log(LAUNCHER_ALLAPPS_TAP_ON_WORK_TAB);
}
- mActivityContext.hideKeyboard();
});
setDeviceManagementResources();
- onActivePageChanged(mViewPager.getNextPage());
+ if (mHeader.isSetUp()) {
+ onActivePageChanged(mViewPager.getNextPage());
+ }
} else {
mAH.get(AdapterHolder.MAIN).setup(findViewById(R.id.apps_list_view), null);
mAH.get(AdapterHolder.WORK).mRecyclerView = null;
}
setupHeader();
- if (isSearchBarOnBottom()) {
+ if (isSearchBarFloating()) {
// Keep the scroller above the search bar.
RelativeLayout.LayoutParams scrollerLayoutParams =
(LayoutParams) mFastScroller.getLayoutParams();
- scrollerLayoutParams.addRule(RelativeLayout.ABOVE, R.id.search_container_all_apps);
- scrollerLayoutParams.removeRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
- scrollerLayoutParams.bottomMargin = getResources().getDimensionPixelSize(
- R.dimen.fastscroll_bottom_margin_floating_search);
+ scrollerLayoutParams.bottomMargin = mSearchContainer.getHeight()
+ + getResources().getDimensionPixelSize(
+ R.dimen.fastscroll_bottom_margin_floating_search);
}
mAllAppsStore.registerIconContainer(mAH.get(AdapterHolder.MAIN).mRecyclerView);
@@ -628,11 +643,9 @@
removeCustomRules(getSearchRecyclerView());
if (!isSearchSupported()) {
layoutWithoutSearchContainer(rvContainer, showTabs);
- } else if (isSearchBarOnBottom()) {
+ } else if (isSearchBarFloating()) {
alignParentTop(rvContainer, showTabs);
alignParentTop(getSearchRecyclerView(), /* tabs= */ false);
- layoutAboveSearchContainer(rvContainer);
- layoutAboveSearchContainer(getSearchRecyclerView());
} else {
layoutBelowSearchContainer(rvContainer, showTabs);
layoutBelowSearchContainer(getSearchRecyclerView(), /* tabs= */ false);
@@ -663,7 +676,7 @@
removeCustomRules(mHeader);
if (!isSearchSupported()) {
layoutWithoutSearchContainer(mHeader, false /* includeTabsMargin */);
- } else if (isSearchBarOnBottom()) {
+ } else if (isSearchBarFloating()) {
alignParentTop(mHeader, false /* includeTabsMargin */);
} else {
layoutBelowSearchContainer(mHeader, false /* includeTabsMargin */);
@@ -703,16 +716,36 @@
}
/**
- * It is up to the search container view created by {@link #inflateSearchBox()} to use the
- * floating search bar flag to move itself to the bottom of this container. This method checks
- * if that had been done; otherwise the flag will be ignored.
- *
- * @return true if the search bar is at the bottom of the container (as opposed to the top).
- **/
- private boolean isSearchBarOnBottom() {
- return FeatureFlags.ENABLE_FLOATING_SEARCH_BAR.get()
- && ((RelativeLayout.LayoutParams) mSearchContainer.getLayoutParams()).getRule(
- ALIGN_PARENT_BOTTOM) == RelativeLayout.TRUE;
+ * @return true if the search bar is floating above this container (at the bottom of the screen)
+ */
+ protected boolean isSearchBarFloating() {
+ return mSearchUiDelegate.isSearchBarFloating();
+ }
+
+ /**
+ * Whether the <em>floating</em> search bar should appear as a small pill when not focused.
+ * <p>
+ * Note: This method mirrors one in LauncherState. For subclasses that use Launcher, it likely
+ * makes sense to use that method to derive an appropriate value for the current/target state.
+ */
+ public boolean shouldFloatingSearchBarBePillWhenUnfocused() {
+ return false;
+ }
+
+ /**
+ * How far from the bottom of the screen the <em>floating</em> search bar should rest when the
+ * IME is not present.
+ * <p>
+ * To hide offscreen, use a negative value.
+ * <p>
+ * Note: if the provided value is non-negative but less than the current bottom insets, the
+ * insets will be applied. As such, you can use 0 to default to this.
+ * <p>
+ * Note: This method mirrors one in LauncherState. For subclasses that use Launcher, it likely
+ * makes sense to use that method to derive an appropriate value for the current/target state.
+ */
+ public int getFloatingSearchBarRestingMarginBottom() {
+ return 0;
}
private void layoutBelowSearchContainer(View v, boolean includeTabsMargin) {
@@ -732,15 +765,6 @@
layoutParams.topMargin = topMargin;
}
- private void layoutAboveSearchContainer(View v) {
- if (!(v.getLayoutParams() instanceof RelativeLayout.LayoutParams)) {
- return;
- }
-
- RelativeLayout.LayoutParams layoutParams = (LayoutParams) v.getLayoutParams();
- layoutParams.addRule(RelativeLayout.ABOVE, R.id.search_container_all_apps);
- }
-
private void alignParentTop(View v, boolean includeTabsMargin) {
if (!(v.getLayoutParams() instanceof RelativeLayout.LayoutParams)) {
return;
@@ -794,10 +818,10 @@
}
/**
- * Inflates the search box
+ * Inflates the search bar
*/
- protected View inflateSearchBox() {
- return mSearchUiDelegate.inflateSearchBox();
+ protected View inflateSearchBar() {
+ return mSearchUiDelegate.inflateSearchBar();
}
/** The adapter provider for the main section. */
@@ -977,7 +1001,7 @@
/**
* The container for A-Z apps (the ViewPager for main+work tabs, or main RV). This is currently
* hidden while searching.
- **/
+ */
public ViewGroup getAppsRecyclerViewContainer() {
return mViewPager != null ? mViewPager : findViewById(R.id.apps_list_view);
}
@@ -1024,7 +1048,7 @@
setPadding(grid.workspacePadding.left, 0, grid.workspacePadding.right, 0);
} else {
int topPadding = grid.allAppsTopPadding;
- if (isSearchBarOnBottom() && !grid.isTablet) {
+ if (isSearchBarFloating() && !grid.isTablet) {
topPadding += getResources().getDimensionPixelSize(
R.dimen.all_apps_additional_top_padding_floating_search);
}
@@ -1236,7 +1260,7 @@
final FloatingHeaderView headerView = getFloatingHeaderView();
if (hasBottomSheet) {
// Start adding header protection if search bar or tabs will attach to the top.
- if (!FeatureFlags.ENABLE_FLOATING_SEARCH_BAR.get() || mUsingTabs) {
+ if (!isSearchBarFloating() || mUsingTabs) {
mTmpRectF.set(
leftWithScale,
topWithScale,
@@ -1292,7 +1316,7 @@
/** Returns the position of the bottom edge of the header */
public int getHeaderBottom() {
int bottom = (int) getTranslationY() + mHeader.getClipTop();
- if (isSearchBarOnBottom()) {
+ if (isSearchBarFloating()) {
if (mActivityContext.getDeviceProfile().isTablet) {
return bottom + mBottomSheetBackground.getTop();
}
@@ -1363,6 +1387,9 @@
if (isWork() && mWorkManager.getWorkModeSwitch() != null) {
bottomOffset = mInsets.bottom + mWorkManager.getWorkModeSwitch().getHeight();
}
+ if (isSearchBarFloating()) {
+ bottomOffset += mSearchContainer.getHeight();
+ }
mRecyclerView.setPadding(mPadding.left, mPadding.top, mPadding.right,
mPadding.bottom + bottomOffset);
}
diff --git a/src/com/android/launcher3/allapps/AllAppsTransitionController.java b/src/com/android/launcher3/allapps/AllAppsTransitionController.java
index 6ca084a..0d7b736 100644
--- a/src/com/android/launcher3/allapps/AllAppsTransitionController.java
+++ b/src/com/android/launcher3/allapps/AllAppsTransitionController.java
@@ -22,6 +22,7 @@
import static com.android.launcher3.LauncherAnimUtils.VIEW_TRANSLATE_Y;
import static com.android.launcher3.LauncherState.ALL_APPS;
import static com.android.launcher3.LauncherState.ALL_APPS_CONTENT;
+import static com.android.launcher3.LauncherState.BACKGROUND_APP;
import static com.android.launcher3.LauncherState.NORMAL;
import static com.android.launcher3.anim.PropertySetter.NO_ANIM_PROPERTY_SETTER;
import static com.android.launcher3.states.StateAnimationConfig.ANIM_ALL_APPS_BOTTOM_SHEET_FADE;
@@ -234,7 +235,11 @@
*/
public void setProgress(float progress) {
mProgress = progress;
- getAppsViewProgressTranslationY().setValue(mProgress * mShiftRange);
+ boolean fromBackground =
+ mLauncher.getStateManager().getCurrentStableState() == BACKGROUND_APP;
+ // Allow apps panel to shift the full screen if coming from another app.
+ float shiftRange = fromBackground ? mLauncher.getDeviceProfile().heightPx : mShiftRange;
+ getAppsViewProgressTranslationY().setValue(mProgress * shiftRange);
mLauncher.onAllAppsTransition(1 - progress);
boolean hasScrim = progress < NAV_BAR_COLOR_FORCE_UPDATE_THRESHOLD
diff --git a/src/com/android/launcher3/allapps/LauncherAllAppsContainerView.java b/src/com/android/launcher3/allapps/LauncherAllAppsContainerView.java
index aefedae..bdba153 100644
--- a/src/com/android/launcher3/allapps/LauncherAllAppsContainerView.java
+++ b/src/com/android/launcher3/allapps/LauncherAllAppsContainerView.java
@@ -22,6 +22,7 @@
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherState;
import com.android.launcher3.Utilities;
+import com.android.launcher3.statemanager.StateManager;
/**
* AllAppsContainerView with launcher specific callbacks
@@ -53,4 +54,43 @@
public boolean isInAllApps() {
return mActivityContext.getStateManager().isInStableState(LauncherState.ALL_APPS);
}
+
+ @Override
+ public boolean shouldFloatingSearchBarBePillWhenUnfocused() {
+ if (!isSearchBarFloating()) {
+ return false;
+ }
+ Launcher launcher = mActivityContext;
+ StateManager<LauncherState> manager = launcher.getStateManager();
+ if (manager.isInTransition() && manager.getTargetState() != null) {
+ return manager.getTargetState().shouldFloatingSearchBarUsePillWhenUnfocused(launcher);
+ }
+ return manager.getCurrentStableState()
+ .shouldFloatingSearchBarUsePillWhenUnfocused(launcher);
+ }
+
+ @Override
+ public int getFloatingSearchBarRestingMarginBottom() {
+ if (!isSearchBarFloating()) {
+ return super.getFloatingSearchBarRestingMarginBottom();
+ }
+ Launcher launcher = mActivityContext;
+ StateManager<LauncherState> stateManager = launcher.getStateManager();
+
+ // We want to rest at the current state's resting position, unless we are in transition and
+ // the target state's resting position is higher (that way if we are closing the keyboard,
+ // we can stop translating at that point).
+ int currentStateMarginBottom = stateManager.getCurrentStableState()
+ .getFloatingSearchBarRestingMarginBottom(launcher);
+ int targetStateMarginBottom = -1;
+ if (stateManager.isInTransition() && stateManager.getTargetState() != null) {
+ targetStateMarginBottom = stateManager.getTargetState()
+ .getFloatingSearchBarRestingMarginBottom(launcher);
+ if (targetStateMarginBottom < 0) {
+ // Go ahead and move offscreen.
+ return targetStateMarginBottom;
+ }
+ }
+ return Math.max(targetStateMarginBottom, currentStateMarginBottom);
+ }
}
diff --git a/src/com/android/launcher3/allapps/SearchUiManager.java b/src/com/android/launcher3/allapps/SearchUiManager.java
index 2174936..bfd8967 100644
--- a/src/com/android/launcher3/allapps/SearchUiManager.java
+++ b/src/com/android/launcher3/allapps/SearchUiManager.java
@@ -49,6 +49,14 @@
ExtendedEditText getEditText();
/**
+ * Hint to the edit text that it is about to be focused or unfocused. This can be used to start
+ * animating the edit box accordingly, e.g. after a gesture completes.
+ *
+ * @param focused true if the edit text is about to be focused, false if it will be unfocused
+ */
+ default void prepareToFocusEditText(boolean focused) {}
+
+ /**
* Sets whether EditText background should be visible
* @param maxAlpha defines the maximum alpha the background should animates to
*/
diff --git a/src/com/android/launcher3/allapps/WorkModeSwitch.java b/src/com/android/launcher3/allapps/WorkModeSwitch.java
index 8c2fb19..e60752e 100644
--- a/src/com/android/launcher3/allapps/WorkModeSwitch.java
+++ b/src/com/android/launcher3/allapps/WorkModeSwitch.java
@@ -36,7 +36,6 @@
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.anim.KeyboardInsetAnimationCallback;
-import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.logging.StatsLogManager;
import com.android.launcher3.model.StringCache;
import com.android.launcher3.views.ActivityContext;
@@ -108,7 +107,7 @@
if (lp != null) {
int bottomMargin = getResources().getDimensionPixelSize(R.dimen.work_fab_margin_bottom);
DeviceProfile dp = ActivityContext.lookupContext(getContext()).getDeviceProfile();
- if (FeatureFlags.ENABLE_FLOATING_SEARCH_BAR.get()) {
+ if (mActivityContext.getAppsView().isSearchBarFloating()) {
bottomMargin += dp.hotseatQsbHeight;
}
diff --git a/src/com/android/launcher3/allapps/search/AllAppsSearchUiDelegate.java b/src/com/android/launcher3/allapps/search/AllAppsSearchUiDelegate.java
index abec16e..49cecca 100644
--- a/src/com/android/launcher3/allapps/search/AllAppsSearchUiDelegate.java
+++ b/src/com/android/launcher3/allapps/search/AllAppsSearchUiDelegate.java
@@ -49,8 +49,13 @@
// Do nothing.
}
- /** Invoked when the search box has been added to All Apps. */
- public void onInitializeSearchBox() {
+ /** Invoked when the search bar has been added to All Apps. */
+ public void onInitializeSearchBar() {
+ // Do nothing.
+ }
+
+ /** Invoked when the search bar has been removed from All Apps. */
+ public void onDestroySearchBar() {
// Do nothing.
}
@@ -59,11 +64,16 @@
return LayoutInflater.from(mAppsView.getContext());
}
- /** Inflate the search box for All Apps. */
- public View inflateSearchBox() {
+ /** Inflate the search bar for All Apps. */
+ public View inflateSearchBar() {
return getLayoutInflater().inflate(R.layout.search_container_all_apps, mAppsView, false);
}
+ /** Whether the search box is floating above the apps surface (inset by the IME). */
+ public boolean isSearchBarFloating() {
+ return false;
+ }
+
/** Creates the adapter provider for the main section. */
public SearchAdapterProvider<?> createMainAdapterProvider() {
return new DefaultSearchAdapterProvider(mActivityContext);
diff --git a/src/com/android/launcher3/anim/KeyboardInsetAnimationCallback.java b/src/com/android/launcher3/anim/KeyboardInsetAnimationCallback.java
index b911928..39386fa 100644
--- a/src/com/android/launcher3/anim/KeyboardInsetAnimationCallback.java
+++ b/src/com/android/launcher3/anim/KeyboardInsetAnimationCallback.java
@@ -44,14 +44,30 @@
private float mInitialTranslation;
private float mTerminalTranslation;
+ private KeyboardTranslationState mKeyboardTranslationState = KeyboardTranslationState.SYSTEM;
+
+ /** Current state of the keyboard. */
+ public enum KeyboardTranslationState {
+ // We are not controlling the keyboard, and it may or may not be translating.
+ SYSTEM,
+ // We are about to gain control of the keyboard, but the current state may be transient.
+ MANUAL_PREPARED,
+ // We are manually translating the keyboard.
+ MANUAL_ONGOING
+ }
public KeyboardInsetAnimationCallback(View view) {
super(DISPATCH_MODE_STOP);
mView = view;
}
+ public KeyboardTranslationState getKeyboardTranslationState() {
+ return mKeyboardTranslationState;
+ }
+
@Override
public void onPrepare(WindowInsetsAnimation animation) {
+ mKeyboardTranslationState = KeyboardTranslationState.MANUAL_PREPARED;
mInitialTranslation = mView.getTranslationY();
}
@@ -62,6 +78,7 @@
mTerminalTranslation = mView.getTranslationY();
// Reset the translation in case the view is drawn before onProgress gets called.
mView.setTranslationY(mInitialTranslation);
+ mKeyboardTranslationState = KeyboardTranslationState.MANUAL_ONGOING;
if (mView instanceof KeyboardInsetListener) {
((KeyboardInsetListener) mView).onTranslationStart();
}
@@ -90,6 +107,10 @@
mView.setTranslationY(translationY);
}
+ if (mView instanceof KeyboardInsetListener) {
+ ((KeyboardInsetListener) mView).onKeyboardAlphaChanged(animation.getAlpha());
+ }
+
return windowInsets;
}
@@ -98,7 +119,7 @@
if (mView instanceof KeyboardInsetListener) {
((KeyboardInsetListener) mView).onTranslationEnd();
}
- super.onEnd(animation);
+ mKeyboardTranslationState = KeyboardTranslationState.SYSTEM;
}
/**
@@ -111,6 +132,13 @@
void onTranslationStart();
/**
+ * Called from {@link KeyboardInsetAnimationCallback#onProgress}
+ *
+ * @param alpha the current IME alpha
+ */
+ default void onKeyboardAlphaChanged(float alpha) {}
+
+ /**
* Called from {@link KeyboardInsetAnimationCallback#onEnd}
*/
void onTranslationEnd();
diff --git a/src/com/android/launcher3/config/FeatureFlags.java b/src/com/android/launcher3/config/FeatureFlags.java
index e4a9d58..d4fe7ae 100644
--- a/src/com/android/launcher3/config/FeatureFlags.java
+++ b/src/com/android/launcher3/config/FeatureFlags.java
@@ -116,7 +116,8 @@
// TODO(Block 4): Cleanup flags
public static final BooleanFlag ENABLE_FLOATING_SEARCH_BAR =
getReleaseFlag(268388460, "ENABLE_FLOATING_SEARCH_BAR", DISABLED,
- "Keep All Apps search bar at the bottom (but above keyboard if open)");
+ "Allow search bar to persist and animate across states, and attach to"
+ + " the keyboard from the bottom of the screen");
public static final BooleanFlag ENABLE_ALL_APPS_FROM_OVERVIEW =
getDebugFlag(275132633, "ENABLE_ALL_APPS_FROM_OVERVIEW", DISABLED,
diff --git a/src/com/android/launcher3/statemanager/StateManager.java b/src/com/android/launcher3/statemanager/StateManager.java
index 198dad3..b1586dc 100644
--- a/src/com/android/launcher3/statemanager/StateManager.java
+++ b/src/com/android/launcher3/statemanager/StateManager.java
@@ -76,6 +76,10 @@
return mState;
}
+ public STATE_TYPE getTargetState() {
+ return (STATE_TYPE) mConfig.targetState;
+ }
+
public STATE_TYPE getCurrentStableState() {
return mCurrentStableState;
}
diff --git a/src/com/android/launcher3/states/StateAnimationConfig.java b/src/com/android/launcher3/states/StateAnimationConfig.java
index d1e816b..0d9e010 100644
--- a/src/com/android/launcher3/states/StateAnimationConfig.java
+++ b/src/com/android/launcher3/states/StateAnimationConfig.java
@@ -66,7 +66,8 @@
ANIM_WORKSPACE_PAGE_TRANSLATE_X,
ANIM_OVERVIEW_SPLIT_SELECT_FLOATING_TASK_TRANSLATE_OFFSCREEN,
ANIM_OVERVIEW_SPLIT_SELECT_INSTRUCTIONS_FADE,
- ANIM_ALL_APPS_BOTTOM_SHEET_FADE
+ ANIM_ALL_APPS_BOTTOM_SHEET_FADE,
+ ANIM_ALL_APPS_KEYBOARD_FADE
})
@Retention(RetentionPolicy.SOURCE)
public @interface AnimType {}
@@ -90,8 +91,9 @@
public static final int ANIM_OVERVIEW_SPLIT_SELECT_FLOATING_TASK_TRANSLATE_OFFSCREEN = 17;
public static final int ANIM_OVERVIEW_SPLIT_SELECT_INSTRUCTIONS_FADE = 18;
public static final int ANIM_ALL_APPS_BOTTOM_SHEET_FADE = 19;
+ public static final int ANIM_ALL_APPS_KEYBOARD_FADE = 20;
- private static final int ANIM_TYPES_COUNT = 20;
+ private static final int ANIM_TYPES_COUNT = 21;
protected final Interpolator[] mInterpolators = new Interpolator[ANIM_TYPES_COUNT];
diff --git a/src/com/android/launcher3/touch/AllAppsSwipeController.java b/src/com/android/launcher3/touch/AllAppsSwipeController.java
index b672bde..ad812f0 100644
--- a/src/com/android/launcher3/touch/AllAppsSwipeController.java
+++ b/src/com/android/launcher3/touch/AllAppsSwipeController.java
@@ -22,10 +22,12 @@
import static com.android.app.animation.Interpolators.INSTANT;
import static com.android.app.animation.Interpolators.LINEAR;
import static com.android.app.animation.Interpolators.clampToProgress;
+import static com.android.app.animation.Interpolators.mapToProgress;
import static com.android.launcher3.LauncherState.ALL_APPS;
import static com.android.launcher3.LauncherState.NORMAL;
import static com.android.launcher3.states.StateAnimationConfig.ANIM_ALL_APPS_BOTTOM_SHEET_FADE;
import static com.android.launcher3.states.StateAnimationConfig.ANIM_ALL_APPS_FADE;
+import static com.android.launcher3.states.StateAnimationConfig.ANIM_ALL_APPS_KEYBOARD_FADE;
import static com.android.launcher3.states.StateAnimationConfig.ANIM_DEPTH;
import static com.android.launcher3.states.StateAnimationConfig.ANIM_HOTSEAT_FADE;
import static com.android.launcher3.states.StateAnimationConfig.ANIM_HOTSEAT_SCALE;
@@ -293,20 +295,15 @@
config.setInterpolator(ANIM_WORKSPACE_SCALE, INSTANT);
config.setInterpolator(ANIM_WORKSPACE_TRANSLATE, INSTANT);
} else {
- // Remove scrim for this transition.
- config.setInterpolator(ANIM_SCRIM_FADE, progress -> 0);
-
- // For now, pop the background panel in at full opacity at the threshold.
+ // Pop the background panel, keyboard, and content in at full opacity at the threshold.
config.setInterpolator(ANIM_ALL_APPS_BOTTOM_SHEET_FADE,
thresholdInterpolator(threshold, INSTANT));
-
- // Fade the apps in when the scrim normally does, so it's apparent sooner what is
- // happening (in this case we are fading them on top of the background panel).
- config.setInterpolator(ANIM_ALL_APPS_FADE,
- thresholdInterpolator(threshold, SCRIM_FADE_MANUAL));
+ config.setInterpolator(ANIM_ALL_APPS_KEYBOARD_FADE,
+ thresholdInterpolator(threshold, INSTANT));
+ config.setInterpolator(ANIM_ALL_APPS_FADE, thresholdInterpolator(threshold, INSTANT));
config.setInterpolator(ANIM_VERTICAL_PROGRESS,
- thresholdInterpolator(threshold, ALL_APPS_VERTICAL_PROGRESS_MANUAL));
+ thresholdInterpolator(threshold, mapToProgress(LINEAR, threshold, 1f)));
}
}