From ecfa0ff337cf2feae19e651470c1ca05926430f2 Mon Sep 17 00:00:00 2001 From: cretin45 Date: Mon, 30 Nov 2015 16:38:47 -0800 Subject: Trebuchet: Add app drawer settings Change-Id: I040420608de64bedc6e9832268796cdf801f5c21 --- .../launcher3/allapps/AllAppsContainerView.java | 39 ++++++++++++++-------- .../launcher3/allapps/AllAppsGridAdapter.java | 8 ++--- 2 files changed, 28 insertions(+), 19 deletions(-) (limited to 'src/com/android/launcher3/allapps') diff --git a/src/com/android/launcher3/allapps/AllAppsContainerView.java b/src/com/android/launcher3/allapps/AllAppsContainerView.java index 0a94be766..b82cd2d0a 100644 --- a/src/com/android/launcher3/allapps/AllAppsContainerView.java +++ b/src/com/android/launcher3/allapps/AllAppsContainerView.java @@ -48,6 +48,7 @@ import com.android.launcher3.LauncherTransitionable; import com.android.launcher3.R; import com.android.launcher3.Utilities; import com.android.launcher3.Workspace; +import com.android.launcher3.settings.SettingsProvider; import com.android.launcher3.util.ComponentKey; import com.android.launcher3.util.Thunk; @@ -189,12 +190,9 @@ public class AllAppsContainerView extends BaseContainerView implements DragSourc Resources res = context.getResources(); mLauncher = (Launcher) context; - mSectionNamesMargin = mSectionStrategy == SECTION_STRATEGY_GRID ? - res.getDimensionPixelSize(R.dimen.all_apps_grid_view_start_margin) : - res.getDimensionPixelSize(R.dimen.all_apps_grid_view_start_margin_with_sections); mApps = new AlphabeticalAppsList(context); mAdapter = new AllAppsGridAdapter(mLauncher, mApps, this, mLauncher, - this, mSectionStrategy, mGridTheme); + this); mApps.setAdapter(mAdapter); mLayoutManager = mAdapter.getLayoutManager(); mItemDecoration = mAdapter.getItemDecoration(); @@ -254,23 +252,35 @@ public class AllAppsContainerView extends BaseContainerView implements DragSourc } private void updateScrubber() { - if (userScrubber()) { + if (useScrubber()) { mScrubber.updateSections(); } } - public void setSectionStrategy(int sectionStrategy) { - Resources res = getResources(); - mSectionStrategy = sectionStrategy; - mSectionNamesMargin = mSectionStrategy == SECTION_STRATEGY_GRID ? + public List getApps() { + return mApps.getApps(); + } + + private void updateSectionStrategy() { + Context context = getContext(); + Resources res = context.getResources(); + boolean useCompactGrid = SettingsProvider.getBoolean(context, + SettingsProvider.SETTINGS_UI_DRAWER_STYLE_USE_COMPACT, + R.bool.preferences_interface_drawer_compact_default); + mSectionStrategy = useCompactGrid ? SECTION_STRATEGY_GRID : SECTION_STRATEGY_RAGGED; + mSectionNamesMargin = useCompactGrid ? res.getDimensionPixelSize(R.dimen.all_apps_grid_view_start_margin) : res.getDimensionPixelSize(R.dimen.all_apps_grid_view_start_margin_with_sections); mAdapter.setSectionStrategy(mSectionStrategy); mAppsRecyclerView.setSectionStrategy(mSectionStrategy); } - public void setGridTheme(int gridTheme) { - mGridTheme = gridTheme; + private void updateGridTheme() { + Context context = getContext(); + boolean useDarkColor= SettingsProvider.getBoolean(context, + SettingsProvider.SETTINGS_UI_DRAWER_DARK, + R.bool.preferences_interface_drawer_dark_default); + mGridTheme = useDarkColor ? GRID_THEME_DARK : GRID_THEME_LIGHT; mAdapter.setGridTheme(mGridTheme); updateBackgroundAndPaddings(true); } @@ -365,14 +375,15 @@ public class AllAppsContainerView extends BaseContainerView implements DragSourc // Load the all apps recycler view mAppsRecyclerView = (AllAppsRecyclerView) findViewById(R.id.apps_list_view); mAppsRecyclerView.setApps(mApps); - mAppsRecyclerView.setSectionStrategy(mSectionStrategy); mAppsRecyclerView.setLayoutManager(mLayoutManager); mAppsRecyclerView.setAdapter(mAdapter); mAppsRecyclerView.setHasFixedSize(true); if (mItemDecoration != null) { mAppsRecyclerView.addItemDecoration(mItemDecoration); } - + setScroller(); + updateGridTheme(); + updateSectionStrategy(); updateBackgroundAndPaddings(); } @@ -442,7 +453,7 @@ public class AllAppsContainerView extends BaseContainerView implements DragSourc // names) int startInset = Math.max(mSectionNamesMargin, mAppsRecyclerView.getMaxScrollbarWidth()); int topBottomPadding = mRecyclerViewTopBottomPadding; - final boolean useScubber = userScrubber(); + final boolean useScubber = useScrubber(); if (isRtl) { mAppsRecyclerView.setPadding(padding.left + mAppsRecyclerView.getMaxScrollbarWidth(), topBottomPadding, padding.right + startInset, useScubber ? diff --git a/src/com/android/launcher3/allapps/AllAppsGridAdapter.java b/src/com/android/launcher3/allapps/AllAppsGridAdapter.java index 17d106731..a736f7770 100644 --- a/src/com/android/launcher3/allapps/AllAppsGridAdapter.java +++ b/src/com/android/launcher3/allapps/AllAppsGridAdapter.java @@ -361,7 +361,7 @@ public class AllAppsGridAdapter extends RecyclerView.Adapter