Fixes #2198 Disable searchbar in appdrawer

Add option to disable searchbar in appdrawer in
Settings->App Drawer
This commit is contained in:
Siju S committed 2021-10-25 16:27:10 +05:30
1 parent c847a6a41d
commit 5e2b41744f
4 files changed
+25 -1

No files matched your search

+1
View File
@@ -167,4 +167,5 @@
<string name="colors">Colors</string>
<string name="dynamic">Dynamic</string>
<string name="all_apps_search_market_message">Search for More Apps</string>
<string name="hide_app_search_bar">Hide search bar</string>
</resources>
@@ -66,6 +66,7 @@ class PreferenceManager private constructor(private val context: Context) : Base
val smartSpaceEnable = BoolPref("pref_smartSpaceEnable", true, restart)
val minusOneEnable = BoolPref("pref_enableMinusOne", true, recreate)
val useFuzzySearch = BoolPref("pref_useFuzzySearch", false)
val hideAppSearchBar = BoolPref("pref_hideAppSearchBar", false)
// TODO: Add the ability to manually delete empty pages.
val allowEmptyPages = BoolPref("pref_allowEmptyPages", false)
@@ -59,6 +59,10 @@ fun AppDrawerPreferences() {
SuggestionsPreference()
}
PreferenceGroup(heading = stringResource(id = R.string.pref_category_search)) {
SwitchPreference(
label = stringResource(id = R.string.hide_app_search_bar),
adapter = prefs.hideAppSearchBar.getAdapter()
)
SwitchPreference(
adapter = prefs.searchAutoShowKeyboard.getAdapter(),
label = stringResource(id = R.string.pref_search_auto_show_keyboard),
@@ -78,6 +78,7 @@ import com.android.launcher3.views.ScrimView;
import com.android.launcher3.workprofile.PersonalWorkSlidingTabStrip.OnActivePageChangedListener;
import app.lawnchair.allapps.LawnchairAlphabeticalAppsList;
import app.lawnchair.preferences.PreferenceManager;
import app.lawnchair.theme.color.ColorTokens;
import app.lawnchair.ui.StretchRecyclerViewContainer;
@@ -105,7 +106,9 @@ public class AllAppsContainerView extends StretchRecyclerViewContainer implement
new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
updateHeaderScroll(((AllAppsRecyclerView) recyclerView).getCurrentScrollY());
if (!mHideSearchbar) {
updateHeaderScroll(((AllAppsRecyclerView) recyclerView).getCurrentScrollY());
}
}
};
@@ -138,6 +141,7 @@ public class AllAppsContainerView extends StretchRecyclerViewContainer implement
private final float mHeaderThreshold;
private ScrimView mScrimView;
private int mHeaderColor;
private boolean mHideSearchbar;
public AllAppsContainerView(Context context) {
this(context, null);
@@ -379,10 +383,24 @@ public class AllAppsContainerView extends StretchRecyclerViewContainer implement
rebindAdapters(mUsingTabs, true /* force */);
mSearchContainer = findViewById(R.id.search_container_all_apps);
setupSearchVisibility();
mSearchUiManager = (SearchUiManager) mSearchContainer;
mSearchUiManager.initializeSearch(this);
}
private void setupSearchVisibility() {
PreferenceManager prefs = PreferenceManager.getInstance(getContext());
prefs.getHideAppSearchBar().subscribeValues(this, enabled -> {
mHideSearchbar = enabled;
if (enabled) {
mSearchContainer.setVisibility(View.INVISIBLE);
}
else {
mSearchContainer.setVisibility(View.VISIBLE);
}
});
}
public SearchUiManager getSearchUiManager() {
return mSearchUiManager;
}