[Search] Hide A-Z list when search is entered from QSB
preview attached to bug report
Bug: 201781284
Test: manual
Change-Id: I572360d2d49b38577a7d77115aede4c3269d42e9
diff --git a/quickstep/res/values/strings.xml b/quickstep/res/values/strings.xml
index 52bd48b..6af0d60 100644
--- a/quickstep/res/values/strings.xml
+++ b/quickstep/res/values/strings.xml
@@ -53,8 +53,6 @@
<!-- Accessibility title for the row of all-apps containing app predictions. [CHAR LIMIT=50] -->
<string name="title_app_suggestions">App suggestions</string>
- <!-- Label for the header text of the All Apps section in All Apps view, used to separate Predicted Apps and Actions section from All Apps section. [CHAR_LIMIT=50] -->
- <string name="all_apps_label">All apps</string>
<!-- Text of the tip when user lands in all apps view for the first time, indicating where the tip toast points to is the predicted apps section. [CHAR_LIMIT=50] -->
<string name="all_apps_prediction_tip">Your predicted apps</string>
diff --git a/res/layout/all_apps.xml b/res/layout/all_apps.xml
index 9ac6ed0..a34baef 100644
--- a/res/layout/all_apps.xml
+++ b/res/layout/all_apps.xml
@@ -42,10 +42,19 @@
<include layout="@layout/floating_header_content" />
<include layout="@layout/all_apps_personal_work_tabs" />
+
+ <Button
+ android:id="@+id/all_apps_button"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:text="@string/all_apps_label"
+ android:background="@drawable/padded_rounded_action_button"
+ android:visibility="gone"/>
+
</com.android.launcher3.allapps.FloatingHeaderView>
- <include
- layout="@layout/search_container_all_apps"/>
+ <include layout="@layout/search_container_all_apps" />
<include layout="@layout/all_apps_fast_scroller" />
</com.android.launcher3.allapps.LauncherAllAppsContainerView>
\ No newline at end of file
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index b1294b4..4d137c8 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -103,6 +103,7 @@
<dimen name="all_apps_tabs_vertical_padding">6dp</dimen>
<dimen name="all_apps_divider_height">2dp</dimen>
<dimen name="all_apps_divider_width">128dp</dimen>
+ <dimen name="all_apps_content_fade_in_offset">150dp</dimen>
<dimen name="all_apps_tip_bottom_margin">8dp</dimen>
<!-- The size of corner radius of the arrow in the arrow toast. -->
diff --git a/res/values/strings.xml b/res/values/strings.xml
index f315725..d7a1506 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1,5 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
+<?xml version="1.0" encoding="utf-8"?><!--
/*
* Copyright (C) 2008 The Android Open Source Project
*
@@ -132,6 +131,8 @@
<string name="all_apps_search_market_message">Search for more apps</string>
<!-- Label for an icon representing any generic app. [CHAR_LIMIT=50] -->
<string name="label_application">App</string>
+ <!-- Label for the header text of the All Apps section in All Apps view, used to separate Predicted Apps and Actions section from All Apps section. [CHAR_LIMIT=50] -->
+ <string name="all_apps_label">All apps</string>
<!-- Popup items -->
<!-- Text to display as the header above notifications. [CHAR_LIMIT=30] -->
@@ -193,7 +194,7 @@
<string name="msg_no_phone_permission"><xliff:g id="app_name" example="Launcher3">%1$s</xliff:g> is not allowed to make phone calls</string>
<!-- Widgets: -->
- <skip />
+ <skip />
<!-- Error text that lets a user know that the widget can't load. -->
<string name="gadget_error_text">Can\'t load widget</string>
@@ -308,7 +309,7 @@
<!-- Text announced by accessibility when the popup containing the list of widgets is closed. [CHAR_LIMIT=100] -->
<string name="widgets_list_closed">Widgets list closed</string>
-<!-- Strings for accessibility actions -->
+ <!-- Strings for accessibility actions -->
<!-- Accessibility action to add an app to workspace. [CHAR_LIMIT=30] -->
<string name="action_add_to_workspace">Add to Home screen</string>
diff --git a/src/com/android/launcher3/allapps/FloatingHeaderView.java b/src/com/android/launcher3/allapps/FloatingHeaderView.java
index debb5b2..3ca0303 100644
--- a/src/com/android/launcher3/allapps/FloatingHeaderView.java
+++ b/src/com/android/launcher3/allapps/FloatingHeaderView.java
@@ -47,6 +47,7 @@
ValueAnimator.AnimatorUpdateListener, PluginListener<AllAppsRow>, Insettable,
OnHeightUpdatedListener {
+ private static final long ALL_APPS_CONTENT_ANIM_DURATION = 150;
private final Rect mRVClip = new Rect(0, 0, Integer.MAX_VALUE, Integer.MAX_VALUE);
private final Rect mHeaderClip = new Rect(0, 0, Integer.MAX_VALUE, Integer.MAX_VALUE);
private final ValueAnimator mAnimator = ValueAnimator.ofInt(0, 0);
@@ -108,6 +109,14 @@
// enabled or disabled, and represent the current set of all rows.
private FloatingHeaderRow[] mAllRows = FloatingHeaderRow.NO_ROWS;
+
+ // members for handling suggestion state
+ private final ValueAnimator mAllAppsContentAnimator = ValueAnimator.ofFloat(0, 0);
+ private View mAllAppsButton;
+ private int mAllAppsContentFadeInOffset;
+ private boolean mInSuggestionMode = false;
+
+
public FloatingHeaderView(@NonNull Context context) {
this(context, null);
}
@@ -118,12 +127,20 @@
.getDimensionPixelSize(R.dimen.all_apps_header_top_padding);
mHeaderProtectionSupported = context.getResources().getBoolean(
R.bool.config_header_protection_supported);
+ mAllAppsContentFadeInOffset = context.getResources()
+ .getDimensionPixelSize(R.dimen.all_apps_content_fade_in_offset);
+ mAllAppsContentAnimator.setDuration(ALL_APPS_CONTENT_ANIM_DURATION);
+ mAllAppsContentAnimator.addUpdateListener(this::onAllAppsContentAnimationUpdate);
}
@Override
protected void onFinishInflate() {
super.onFinishInflate();
mTabLayout = findViewById(R.id.tabs);
+ mAllAppsButton = findViewById(R.id.all_apps_button);
+ if (mAllAppsButton != null) {
+ mAllAppsButton.setOnClickListener(this::onAllAppsButtonClicked);
+ }
// Find all floating header rows.
ArrayList<FloatingHeaderRow> rows = new ArrayList<>();
@@ -312,6 +329,7 @@
}
mTabLayout.setTranslationY(mTranslationY);
+ setSuggestionMode(false);
int clipHeight = mHeaderTopPadding - getPaddingBottom();
mRVClip.top = mTabsHidden ? clipHeight : 0;
@@ -347,6 +365,7 @@
mTranslationY = 0;
applyVerticalMove();
}
+ setSuggestionMode(false);
mHeaderCollapsed = false;
mSnappedScrolledY = -mMaxTranslation;
mCurrentRV.scrollToTop();
@@ -442,6 +461,38 @@
}
return Math.max(getHeight() - getPaddingTop() + mTranslationY, 0);
}
+
+ /**
+ * When suggestion mode is enabled, hides AllApps content view and shows AllApps button.
+ */
+ public void setSuggestionMode(boolean isSuggestMode) {
+ if (mInSuggestionMode == isSuggestMode || mAllAppsButton == null) return;
+ if (!FeatureFlags.ENABLE_ONE_SEARCH.get()) return;
+ AllAppsContainerView allApps = (AllAppsContainerView) getParent();
+ mInSuggestionMode = isSuggestMode;
+ if (isSuggestMode) {
+ mTabLayout.setVisibility(GONE);
+ mAllAppsButton.setVisibility(VISIBLE);
+ allApps.getContentView().setVisibility(GONE);
+ } else {
+ mTabLayout.setVisibility(mTabsHidden ? GONE : VISIBLE);
+ mAllAppsButton.setVisibility(GONE);
+ allApps.getContentView().setVisibility(VISIBLE);
+ }
+ }
+
+ private void onAllAppsButtonClicked(View view) {
+ setSuggestionMode(false);
+ mAllAppsContentAnimator.start();
+ }
+
+ private void onAllAppsContentAnimationUpdate(ValueAnimator valueAnimator) {
+ float prog = valueAnimator.getAnimatedFraction();
+ View allAppsList = ((AllAppsContainerView) getParent()).getContentView();
+ allAppsList.setAlpha(255 * prog);
+ allAppsList.setTranslationY((1 - prog) * mAllAppsContentFadeInOffset);
+ }
+
}