summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3
diff options
context:
space:
mode:
authorTony Mak <tonymak@google.com>2018-01-11 15:29:50 +0000
committerTony Mak <tonymak@google.com>2018-01-11 15:55:24 +0000
commit7ccbefcc569ac341bae84bf4c18bae44dcedd80d (patch)
tree9f49c20277c8147b7c0c9de986d13d994a25ef21 /src/com/android/launcher3
parentb5d047ca14698fff562a12f1ef012134b1a5a7ee (diff)
downloadandroid_packages_apps_Trebuchet-7ccbefcc569ac341bae84bf4c18bae44dcedd80d.tar.gz
android_packages_apps_Trebuchet-7ccbefcc569ac341bae84bf4c18bae44dcedd80d.tar.bz2
android_packages_apps_Trebuchet-7ccbefcc569ac341bae84bf4c18bae44dcedd80d.zip
Fix work tab is gone when leaving search mode
1. onSearchResultsChanged is not called if the query is empty. Introduce onClearSearchResult and restore the tab there 2. rebindAdapters should only perform the actual logic if showTabs != mShowTabs, except the first time when we init the layout in onFinishInflate. Fix: 71737947 Change-Id: I5485d6be0fc33b73aa6e0709be66cef8d43b4dbd
Diffstat (limited to 'src/com/android/launcher3')
-rw-r--r--src/com/android/launcher3/allapps/AllAppsContainerView.java27
-rw-r--r--src/com/android/launcher3/allapps/search/AppsSearchContainerLayout.java1
2 files changed, 17 insertions, 11 deletions
diff --git a/src/com/android/launcher3/allapps/AllAppsContainerView.java b/src/com/android/launcher3/allapps/AllAppsContainerView.java
index a40f8b380..b88efddf9 100644
--- a/src/com/android/launcher3/allapps/AllAppsContainerView.java
+++ b/src/com/android/launcher3/allapps/AllAppsContainerView.java
@@ -27,7 +27,6 @@ import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.Selection;
import android.text.SpannableStringBuilder;
-import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.KeyEvent;
import android.view.LayoutInflater;
@@ -149,9 +148,7 @@ public class AllAppsContainerView extends RelativeLayout implements DragSource,
*/
public void setApps(List<AppInfo> apps) {
boolean hasWorkProfileApp = hasWorkProfileApp(apps);
- if (mUsingTabs != hasWorkProfileApp) {
- rebindAdapters(hasWorkProfileApp);
- }
+ rebindAdapters(hasWorkProfileApp);
mComponentToAppMap.clear();
addOrUpdateApps(apps);
}
@@ -261,7 +258,7 @@ public class AllAppsContainerView extends RelativeLayout implements DragSource,
});
mHeader = findViewById(R.id.all_apps_header);
- rebindAdapters(mUsingTabs);
+ rebindAdapters(mUsingTabs, true /* force */);
mSearchContainer = findViewById(R.id.search_container_all_apps);
mSearchUiManager = (SearchUiManager) mSearchContainer;
@@ -385,9 +382,14 @@ public class AllAppsContainerView extends RelativeLayout implements DragSource,
}
private void rebindAdapters(boolean showTabs) {
- if (showTabs != mUsingTabs) {
- replaceRVContainer(showTabs);
+ rebindAdapters(showTabs, false /* force */);
+ }
+
+ private void rebindAdapters(boolean showTabs, boolean force) {
+ if (showTabs == mUsingTabs && !force) {
+ return;
}
+ replaceRVContainer(showTabs);
mUsingTabs = showTabs;
if (mUsingTabs) {
@@ -529,13 +531,16 @@ public class AllAppsContainerView extends RelativeLayout implements DragSource,
for (int i = 0; i < mAH.length; i++) {
mAH[i].adapter.setLastSearchQuery(query);
}
- boolean hasQuery = !TextUtils.isEmpty(query);
- if (mUsingTabs && hasQuery) {
+ if (mUsingTabs) {
mSearchModeWhileUsingTabs = true;
rebindAdapters(false); // hide tabs
- } else if (mSearchModeWhileUsingTabs && !hasQuery) {
- mSearchModeWhileUsingTabs = false;
+ }
+ }
+
+ public void onClearSearchResult() {
+ if (mSearchModeWhileUsingTabs) {
rebindAdapters(true); // show tabs
+ mSearchModeWhileUsingTabs = false;
}
}
diff --git a/src/com/android/launcher3/allapps/search/AppsSearchContainerLayout.java b/src/com/android/launcher3/allapps/search/AppsSearchContainerLayout.java
index e65a2c4ea..ed41f133a 100644
--- a/src/com/android/launcher3/allapps/search/AppsSearchContainerLayout.java
+++ b/src/com/android/launcher3/allapps/search/AppsSearchContainerLayout.java
@@ -184,6 +184,7 @@ public class AppsSearchContainerLayout extends FrameLayout
mSearchQueryBuilder.clear();
mSearchQueryBuilder.clearSpans();
Selection.setSelection(mSearchQueryBuilder, 0);
+ mAppsView.onClearSearchResult();
}
@Override