From 996bfae0b259b3cf3fb0ef1b581b117f573b47bf Mon Sep 17 00:00:00 2001 From: Neha Jain Date: Wed, 14 Jun 2023 17:45:18 +0000 Subject: [PATCH] Revert "Put the "floating" in ENABLE_FLOATING_SEARCH_BAR." Revert submission 23624636-draglayer-inline-qsb Reason for revert: b/287172381 Reverted changes: /q/submissionid:23624636-draglayer-inline-qsb (cherry picked from https://googleplex-android-review.googlesource.com/q/commit:92784b5bf646e2fd872f693839319849d08659d2) Merged-In: Ie4f9606baa724f543f034e0d5ca7ac4aa07bf747 Change-Id: Ie4f9606baa724f543f034e0d5ca7ac4aa07bf747 --- .../allapps/TaskbarAllAppsContainerView.java | 4 +- .../allapps/TaskbarAllAppsController.java | 7 -- .../uioverrides/states/AllAppsState.java | 21 +--- .../uioverrides/states/OverviewState.java | 27 +--- .../android/quickstep/AbsSwipeUpHandler.java | 4 - .../AnimatorControllerWithResistance.java | 2 +- src/com/android/launcher3/DeviceProfile.java | 4 +- src/com/android/launcher3/LauncherState.java | 28 +---- .../allapps/ActivityAllAppsContainerView.java | 117 +++++++----------- .../allapps/AllAppsTransitionController.java | 7 +- .../allapps/LauncherAllAppsContainerView.java | 40 ------ .../launcher3/allapps/SearchUiManager.java | 8 -- .../launcher3/allapps/WorkModeSwitch.java | 3 +- .../search/AllAppsSearchUiDelegate.java | 18 +-- .../anim/KeyboardInsetAnimationCallback.java | 30 +---- .../launcher3/config/FeatureFlags.java | 3 +- .../launcher3/statemanager/StateManager.java | 4 - .../states/StateAnimationConfig.java | 6 +- .../touch/AllAppsSwipeController.java | 17 +-- 19 files changed, 75 insertions(+), 275 deletions(-) diff --git a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsContainerView.java b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsContainerView.java index 5d91acd3e1..b4b83f6f24 100644 --- a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsContainerView.java +++ b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsContainerView.java @@ -47,9 +47,9 @@ public class TaskbarAllAppsContainerView extends } @Override - protected View inflateSearchBar() { + protected View inflateSearchBox() { if (isSearchSupported()) { - return super.inflateSearchBar(); + return super.inflateSearchBox(); } // Remove top padding of header, since we do not have any search diff --git a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsController.java b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsController.java index 02d9d95b02..4b6acc5fde 100644 --- a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsController.java +++ b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsController.java @@ -181,13 +181,6 @@ public final class TaskbarAllAppsController { } private void cleanUpOverlay() { - // Floating search bar is added to the drag layer in ActivityAllAppsContainerView onAttach; - // removed here as this is a special case that we remove the all apps panel. - if (mAppsView != null && mOverlayContext != null - && mAppsView.getSearchUiDelegate().isSearchBarFloating()) { - mOverlayContext.getDragLayer().removeView(mAppsView.getSearchView()); - mAppsView.getSearchUiDelegate().onDestroySearchBar(); - } if (mSearchSessionController != null) { mSearchSessionController.onDestroy(); mSearchSessionController = null; diff --git a/quickstep/src/com/android/launcher3/uioverrides/states/AllAppsState.java b/quickstep/src/com/android/launcher3/uioverrides/states/AllAppsState.java index 6ebcf8c115..f6a25ce761 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/states/AllAppsState.java +++ b/quickstep/src/com/android/launcher3/uioverrides/states/AllAppsState.java @@ -20,7 +20,6 @@ import static com.android.launcher3.logging.StatsLogManager.LAUNCHER_STATE_ALLAP import android.content.Context; -import com.android.launcher3.DeviceProfile; import com.android.launcher3.Launcher; import com.android.launcher3.LauncherState; import com.android.launcher3.R; @@ -105,23 +104,9 @@ public class AllAppsState extends LauncherState { @Override public int getVisibleElements(Launcher launcher) { - int elements = ALL_APPS_CONTENT | FLOATING_SEARCH_BAR; - // Only add HOTSEAT_ICONS for tablets in ALL_APPS state. - if (launcher.getDeviceProfile().isTablet) { - elements |= HOTSEAT_ICONS; - } - return elements; - } - - @Override - public int getFloatingSearchBarRestingMarginBottom(Launcher launcher) { - return 0; - } - - @Override - public boolean shouldFloatingSearchBarUsePillWhenUnfocused(Launcher launcher) { - DeviceProfile dp = launcher.getDeviceProfile(); - return dp.isPhone && !dp.isLandscape; + // Don't add HOTSEAT_ICONS for non-tablets in ALL_APPS state. + return launcher.getDeviceProfile().isTablet ? ALL_APPS_CONTENT | HOTSEAT_ICONS + : ALL_APPS_CONTENT; } @Override diff --git a/quickstep/src/com/android/launcher3/uioverrides/states/OverviewState.java b/quickstep/src/com/android/launcher3/uioverrides/states/OverviewState.java index 396d0abeb0..3f0b54e618 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/states/OverviewState.java +++ b/quickstep/src/com/android/launcher3/uioverrides/states/OverviewState.java @@ -107,32 +107,7 @@ public class OverviewState extends LauncherState { @Override public int getVisibleElements(Launcher launcher) { - int elements = CLEAR_ALL_BUTTON | OVERVIEW_ACTIONS; - DeviceProfile dp = launcher.getDeviceProfile(); - boolean showFloatingSearch; - if (dp.isPhone) { - // Only show search in phone overview in portrait mode. - showFloatingSearch = !dp.isLandscape; - } else { - // Only show search in tablet overview if taskbar is not visible. - showFloatingSearch = !dp.isTaskbarPresent || isTaskbarStashed(launcher); - } - if (showFloatingSearch) { - elements |= FLOATING_SEARCH_BAR; - } - return elements; - } - - @Override - public int getFloatingSearchBarRestingMarginBottom(Launcher launcher) { - return areElementsVisible(launcher, FLOATING_SEARCH_BAR) ? 0 - : super.getFloatingSearchBarRestingMarginBottom(launcher); - } - - @Override - public boolean shouldFloatingSearchBarUsePillWhenUnfocused(Launcher launcher) { - DeviceProfile dp = launcher.getDeviceProfile(); - return dp.isPhone && !dp.isLandscape; + return CLEAR_ALL_BUTTON | OVERVIEW_ACTIONS; } @Override diff --git a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java index 87fbcaee26..0bf82cf4f1 100644 --- a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java +++ b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java @@ -811,10 +811,6 @@ public abstract class AbsSwipeUpHandler, VibratorWrapper.INSTANCE.get(mContext).vibrate(OVERVIEW_HAPTIC); maybeUpdateRecentsAttachedState(true); - if (mActivity != null) { - mActivity.getAppsView().getSearchUiManager().prepareToFocusEditText(mIsInAllAppsRegion); - } - // Draw active task below Launcher so that All Apps can appear over it. runActionOnRemoteHandles(remoteTargetHandle -> remoteTargetHandle.getTaskViewSimulator().setDrawsBelowRecents(isInAllAppsRegion)); diff --git a/quickstep/src/com/android/quickstep/util/AnimatorControllerWithResistance.java b/quickstep/src/com/android/quickstep/util/AnimatorControllerWithResistance.java index cb35ec8455..df9830a93f 100644 --- a/quickstep/src/com/android/quickstep/util/AnimatorControllerWithResistance.java +++ b/quickstep/src/com/android/quickstep/util/AnimatorControllerWithResistance.java @@ -56,7 +56,7 @@ public class AnimatorControllerWithResistance { private enum RecentsResistanceParams { FROM_APP(0.75f, 0.5f, 1f, false), - FROM_APP_TO_ALL_APPS(1f, 0.6f, 0.8f, false), + FROM_APP_TO_ALL_APPS(0.75f, 0.5f, 0.8f, false), FROM_APP_TABLET(1f, 0.7f, 1f, true), FROM_APP_TO_ALL_APPS_TABLET(1f, 0.5f, 0.5f, false), FROM_OVERVIEW(1f, 0.75f, 0.5f, false); diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java index e19e903ba4..1ddca32e63 100644 --- a/src/com/android/launcher3/DeviceProfile.java +++ b/src/com/android/launcher3/DeviceProfile.java @@ -546,9 +546,7 @@ public class DeviceProfile { overviewTaskIconDrawableSizeGridPx = res.getDimensionPixelSize(R.dimen.task_thumbnail_icon_drawable_size_grid); overviewTaskThumbnailTopMarginPx = overviewTaskIconSizePx + overviewTaskMarginPx; - // 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); + overviewActionsTopMarginPx = 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 035b9c8d33..05471ada48 100644 --- a/src/com/android/launcher3/LauncherState.java +++ b/src/com/android/launcher3/LauncherState.java @@ -66,7 +66,6 @@ public abstract class LauncherState implements BaseState { 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); @@ -203,33 +202,8 @@ public abstract class LauncherState implements BaseState { return 0; } - /** - * How far from the bottom of the screen the floating search bar should rest in this - * state when the IME is not present. - *

- * To hide offscreen, use a negative value. - *

- * 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 floating search bar should use the pill UI when not focused. */ - public boolean shouldFloatingSearchBarUsePillWhenUnfocused(Launcher launcher) { - return false; - } - public int getVisibleElements(Launcher launcher) { - 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; + return HOTSEAT_ICONS | WORKSPACE_PAGE_INDICATOR | VERTICAL_SWIPE_INDICATOR; } /** diff --git a/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java b/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java index ab96841b3c..1802e8b734 100644 --- a/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java +++ b/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java @@ -232,10 +232,6 @@ public class ActivityAllAppsContainerView 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()}. @@ -262,13 +258,11 @@ public class ActivityAllAppsContainerView mFastScroller = findViewById(R.id.fast_scroller); mFastScroller.setPopupView(findViewById(R.id.fast_scroller_popup)); - 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); - } + // Add the search box above everything else. + mSearchContainer = inflateSearchBox(); + addView(mSearchContainer); mSearchUiManager = (SearchUiManager) mSearchContainer; + mSearchUiDelegate.onInitializeSearchBox(); } @Override @@ -299,13 +293,6 @@ public class ActivityAllAppsContainerView @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); } @@ -327,7 +314,7 @@ public class ActivityAllAppsContainerView * 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()); @@ -437,7 +424,7 @@ public class ActivityAllAppsContainerView * 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); } @@ -447,7 +434,7 @@ public class ActivityAllAppsContainerView * * @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) { @@ -510,9 +497,6 @@ public class ActivityAllAppsContainerView // 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); } @@ -570,6 +554,7 @@ public class ActivityAllAppsContainerView mActivityContext.getStatsLogManager().logger() .log(LAUNCHER_ALLAPPS_TAP_ON_PERSONAL_TAB); } + mActivityContext.hideKeyboard(); }); findViewById(R.id.tab_work) .setOnClickListener((View view) -> { @@ -577,24 +562,24 @@ public class ActivityAllAppsContainerView mActivityContext.getStatsLogManager().logger() .log(LAUNCHER_ALLAPPS_TAP_ON_WORK_TAB); } + mActivityContext.hideKeyboard(); }); setDeviceManagementResources(); - if (mHeader.isSetUp()) { - onActivePageChanged(mViewPager.getNextPage()); - } + onActivePageChanged(mViewPager.getNextPage()); } else { mAH.get(AdapterHolder.MAIN).setup(findViewById(R.id.apps_list_view), null); mAH.get(AdapterHolder.WORK).mRecyclerView = null; } setupHeader(); - if (isSearchBarFloating()) { + if (isSearchBarOnBottom()) { // Keep the scroller above the search bar. RelativeLayout.LayoutParams scrollerLayoutParams = (LayoutParams) mFastScroller.getLayoutParams(); - scrollerLayoutParams.bottomMargin = mSearchContainer.getHeight() - + getResources().getDimensionPixelSize( - R.dimen.fastscroll_bottom_margin_floating_search); + 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); } mAllAppsStore.registerIconContainer(mAH.get(AdapterHolder.MAIN).mRecyclerView); @@ -646,9 +631,11 @@ public class ActivityAllAppsContainerView removeCustomRules(getSearchRecyclerView()); if (!isSearchSupported()) { layoutWithoutSearchContainer(rvContainer, showTabs); - } else if (isSearchBarFloating()) { + } else if (isSearchBarOnBottom()) { alignParentTop(rvContainer, showTabs); alignParentTop(getSearchRecyclerView(), /* tabs= */ false); + layoutAboveSearchContainer(rvContainer); + layoutAboveSearchContainer(getSearchRecyclerView()); } else { layoutBelowSearchContainer(rvContainer, showTabs); layoutBelowSearchContainer(getSearchRecyclerView(), /* tabs= */ false); @@ -679,7 +666,7 @@ public class ActivityAllAppsContainerView removeCustomRules(mHeader); if (!isSearchSupported()) { layoutWithoutSearchContainer(mHeader, false /* includeTabsMargin */); - } else if (isSearchBarFloating()) { + } else if (isSearchBarOnBottom()) { alignParentTop(mHeader, false /* includeTabsMargin */); } else { layoutBelowSearchContainer(mHeader, false /* includeTabsMargin */); @@ -719,36 +706,16 @@ public class ActivityAllAppsContainerView } /** - * @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 floating search bar should appear as a small pill when not focused. - *

- * 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 floating search bar should rest when the - * IME is not present. - *

- * To hide offscreen, use a negative value. - *

- * 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. - *

- * 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; + * 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; } private void layoutBelowSearchContainer(View v, boolean includeTabsMargin) { @@ -768,6 +735,15 @@ public class ActivityAllAppsContainerView 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; @@ -821,10 +797,10 @@ public class ActivityAllAppsContainerView } /** - * Inflates the search bar + * Inflates the search box */ - protected View inflateSearchBar() { - return mSearchUiDelegate.inflateSearchBar(); + protected View inflateSearchBox() { + return mSearchUiDelegate.inflateSearchBox(); } /** The adapter provider for the main section. */ @@ -1004,7 +980,7 @@ public class ActivityAllAppsContainerView /** * 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); } @@ -1051,7 +1027,7 @@ public class ActivityAllAppsContainerView setPadding(grid.workspacePadding.left, 0, grid.workspacePadding.right, 0); } else { int topPadding = grid.allAppsTopPadding; - if (isSearchBarFloating() && !grid.isTablet) { + if (isSearchBarOnBottom() && !grid.isTablet) { topPadding += getResources().getDimensionPixelSize( R.dimen.all_apps_additional_top_padding_floating_search); } @@ -1290,7 +1266,7 @@ public class ActivityAllAppsContainerView final FloatingHeaderView headerView = getFloatingHeaderView(); if (hasBottomSheet) { // Start adding header protection if search bar or tabs will attach to the top. - if (!isSearchBarFloating() || mUsingTabs) { + if (!FeatureFlags.ENABLE_FLOATING_SEARCH_BAR.get() || mUsingTabs) { mTmpRectF.set( leftWithScale, topWithScale, @@ -1346,7 +1322,7 @@ public class ActivityAllAppsContainerView /** Returns the position of the bottom edge of the header */ public int getHeaderBottom() { int bottom = (int) getTranslationY() + mHeader.getClipTop(); - if (isSearchBarFloating()) { + if (isSearchBarOnBottom()) { if (mActivityContext.getDeviceProfile().isTablet) { return bottom + mBottomSheetBackground.getTop(); } @@ -1417,9 +1393,6 @@ public class ActivityAllAppsContainerView 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 0d7b736cc8..6ca084a3b7 100644 --- a/src/com/android/launcher3/allapps/AllAppsTransitionController.java +++ b/src/com/android/launcher3/allapps/AllAppsTransitionController.java @@ -22,7 +22,6 @@ import static com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY; 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; @@ -235,11 +234,7 @@ public class AllAppsTransitionController */ public void setProgress(float progress) { mProgress = progress; - 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); + getAppsViewProgressTranslationY().setValue(mProgress * mShiftRange); 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 bdba1538c6..aefedae641 100644 --- a/src/com/android/launcher3/allapps/LauncherAllAppsContainerView.java +++ b/src/com/android/launcher3/allapps/LauncherAllAppsContainerView.java @@ -22,7 +22,6 @@ import android.view.WindowInsets; 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 @@ -54,43 +53,4 @@ public class LauncherAllAppsContainerView extends ActivityAllAppsContainerView 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 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 bfd89678df..2174936654 100644 --- a/src/com/android/launcher3/allapps/SearchUiManager.java +++ b/src/com/android/launcher3/allapps/SearchUiManager.java @@ -48,14 +48,6 @@ public interface SearchUiManager { @Nullable 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 28a331276f..f84876b52c 100644 --- a/src/com/android/launcher3/allapps/WorkModeSwitch.java +++ b/src/com/android/launcher3/allapps/WorkModeSwitch.java @@ -36,6 +36,7 @@ import com.android.launcher3.Insettable; 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; @@ -104,7 +105,7 @@ public class WorkModeSwitch extends LinearLayout implements Insettable, if (lp != null) { int bottomMargin = getResources().getDimensionPixelSize(R.dimen.work_fab_margin_bottom); DeviceProfile dp = ActivityContext.lookupContext(getContext()).getDeviceProfile(); - if (mActivityContext.getAppsView().isSearchBarFloating()) { + if (FeatureFlags.ENABLE_FLOATING_SEARCH_BAR.get()) { bottomMargin += dp.hotseatQsbHeight; } diff --git a/src/com/android/launcher3/allapps/search/AllAppsSearchUiDelegate.java b/src/com/android/launcher3/allapps/search/AllAppsSearchUiDelegate.java index 49cecca19f..abec16e45c 100644 --- a/src/com/android/launcher3/allapps/search/AllAppsSearchUiDelegate.java +++ b/src/com/android/launcher3/allapps/search/AllAppsSearchUiDelegate.java @@ -49,13 +49,8 @@ public class AllAppsSearchUiDelegate { // Do nothing. } - /** 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() { + /** Invoked when the search box has been added to All Apps. */ + public void onInitializeSearchBox() { // Do nothing. } @@ -64,16 +59,11 @@ public class AllAppsSearchUiDelegate { return LayoutInflater.from(mAppsView.getContext()); } - /** Inflate the search bar for All Apps. */ - public View inflateSearchBar() { + /** Inflate the search box for All Apps. */ + public View inflateSearchBox() { 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 39386fa2ac..b911928e36 100644 --- a/src/com/android/launcher3/anim/KeyboardInsetAnimationCallback.java +++ b/src/com/android/launcher3/anim/KeyboardInsetAnimationCallback.java @@ -44,30 +44,14 @@ public class KeyboardInsetAnimationCallback extends WindowInsetsAnimation.Callba 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(); } @@ -78,7 +62,6 @@ public class KeyboardInsetAnimationCallback extends WindowInsetsAnimation.Callba 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(); } @@ -107,10 +90,6 @@ public class KeyboardInsetAnimationCallback extends WindowInsetsAnimation.Callba mView.setTranslationY(translationY); } - if (mView instanceof KeyboardInsetListener) { - ((KeyboardInsetListener) mView).onKeyboardAlphaChanged(animation.getAlpha()); - } - return windowInsets; } @@ -119,7 +98,7 @@ public class KeyboardInsetAnimationCallback extends WindowInsetsAnimation.Callba if (mView instanceof KeyboardInsetListener) { ((KeyboardInsetListener) mView).onTranslationEnd(); } - mKeyboardTranslationState = KeyboardTranslationState.SYSTEM; + super.onEnd(animation); } /** @@ -131,13 +110,6 @@ public class KeyboardInsetAnimationCallback extends WindowInsetsAnimation.Callba */ void onTranslationStart(); - /** - * Called from {@link KeyboardInsetAnimationCallback#onProgress} - * - * @param alpha the current IME alpha - */ - default void onKeyboardAlphaChanged(float alpha) {} - /** * Called from {@link KeyboardInsetAnimationCallback#onEnd} */ diff --git a/src/com/android/launcher3/config/FeatureFlags.java b/src/com/android/launcher3/config/FeatureFlags.java index 02bbd242c3..f1b4be4f7b 100644 --- a/src/com/android/launcher3/config/FeatureFlags.java +++ b/src/com/android/launcher3/config/FeatureFlags.java @@ -116,8 +116,7 @@ public final class FeatureFlags { // TODO(Block 4): Cleanup flags public static final BooleanFlag ENABLE_FLOATING_SEARCH_BAR = getReleaseFlag(268388460, "ENABLE_FLOATING_SEARCH_BAR", DISABLED, - "Allow search bar to persist and animate across states, and attach to" - + " the keyboard from the bottom of the screen"); + "Keep All Apps search bar at the bottom (but above keyboard if open)"); 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 b1586dcd5d..198dad3c89 100644 --- a/src/com/android/launcher3/statemanager/StateManager.java +++ b/src/com/android/launcher3/statemanager/StateManager.java @@ -76,10 +76,6 @@ public class StateManager> { 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 0d9e01035e..d1e816bec6 100644 --- a/src/com/android/launcher3/states/StateAnimationConfig.java +++ b/src/com/android/launcher3/states/StateAnimationConfig.java @@ -66,8 +66,7 @@ public class StateAnimationConfig { 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_KEYBOARD_FADE + ANIM_ALL_APPS_BOTTOM_SHEET_FADE }) @Retention(RetentionPolicy.SOURCE) public @interface AnimType {} @@ -91,9 +90,8 @@ public class StateAnimationConfig { 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 = 21; + private static final int ANIM_TYPES_COUNT = 20; 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 ad812f0a7d..b672bde45d 100644 --- a/src/com/android/launcher3/touch/AllAppsSwipeController.java +++ b/src/com/android/launcher3/touch/AllAppsSwipeController.java @@ -22,12 +22,10 @@ import static com.android.app.animation.Interpolators.FINAL_FRAME; 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; @@ -295,15 +293,20 @@ public class AllAppsSwipeController extends AbstractStateChangeTouchController { config.setInterpolator(ANIM_WORKSPACE_SCALE, INSTANT); config.setInterpolator(ANIM_WORKSPACE_TRANSLATE, INSTANT); } else { - // Pop the background panel, keyboard, and content in at full opacity at the threshold. + // 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. config.setInterpolator(ANIM_ALL_APPS_BOTTOM_SHEET_FADE, thresholdInterpolator(threshold, INSTANT)); - config.setInterpolator(ANIM_ALL_APPS_KEYBOARD_FADE, - thresholdInterpolator(threshold, INSTANT)); - config.setInterpolator(ANIM_ALL_APPS_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_VERTICAL_PROGRESS, - thresholdInterpolator(threshold, mapToProgress(LINEAR, threshold, 1f))); + thresholdInterpolator(threshold, ALL_APPS_VERTICAL_PROGRESS_MANUAL)); } }