diff options
Diffstat (limited to 'src/com/android/launcher3')
8 files changed, 152 insertions, 35 deletions
diff --git a/src/com/android/launcher3/BaseContainerView.java b/src/com/android/launcher3/BaseContainerView.java index ac2afa944..0f1585a4a 100644 --- a/src/com/android/launcher3/BaseContainerView.java +++ b/src/com/android/launcher3/BaseContainerView.java @@ -17,6 +17,7 @@ package com.android.launcher3; import android.content.Context; +import android.content.res.Resources; import android.graphics.Rect; import android.util.AttributeSet; import android.util.Log; @@ -25,6 +26,8 @@ import android.view.ViewStub; import android.widget.LinearLayout; import android.widget.TextView; +import com.android.launcher3.settings.SettingsProvider; + /** * A base container view, which supports resizing. */ @@ -100,9 +103,13 @@ public abstract class BaseContainerView extends LinearLayout implements Insettab }); } - public final void setUseScrubber(boolean use) { - mUseScrubber = use; - if (use) { + public final void setScroller() { + Context context = getContext(); + boolean useHorizontalScroller= SettingsProvider.getBoolean(context, + SettingsProvider.SETTINGS_UI_USE_HORIZONTAL_SCRUBBER, + R.bool.preferences_interface_use_horizontal_scrubber_default); + mUseScrubber = useHorizontalScroller; + if (mUseScrubber) { ViewStub stub = (ViewStub) findViewById(R.id.scrubber_container_stub); mScrubberContainerView = stub.inflate(); if (mScrubberContainerView == null) { @@ -128,7 +135,7 @@ public abstract class BaseContainerView extends LinearLayout implements Insettab } } - public final boolean userScrubber() { + public final boolean useScrubber() { return mUseScrubber; } diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java index c15f07de9..32b3a0217 100644 --- a/src/com/android/launcher3/BubbleTextView.java +++ b/src/com/android/launcher3/BubbleTextView.java @@ -133,9 +133,12 @@ public class BubbleTextView extends TextView defaultIconSize = grid.allAppsIconSizePx; } boolean useCompactDrawer = SettingsProvider.getBoolean(context, - SettingsProvider.SETTINGS_UI_DRAWER_COMPACT, + SettingsProvider.SETTINGS_UI_DRAWER_STYLE_USE_COMPACT, R.bool.preferences_interface_drawer_compact_default); - if (!useCompactDrawer) { + boolean useLargeIcons = SettingsProvider.getBoolean(context, + SettingsProvider.SETTINGS_UI_GENERAL_ICONS_LARGE, + R.bool.preferences_interface_general_icons_large_default); + if (!useLargeIcons && !useCompactDrawer) { defaultIconSize = getResources() .getDimensionPixelSize(R.dimen.all_apps_icon_size_ragged); } diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index 8f3bbf578..fd6ab26e4 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -1551,11 +1551,6 @@ public class Launcher extends Activity mAppsView.setSearchBarController(mAppsView.newDefaultAppSearchController()); } - mAppsView.setUseScrubber(mUseScrubber); - mAppsView.setSectionStrategy(AllAppsContainerView.SECTION_STRATEGY_RAGGED); - mAppsView.setGridTheme(AllAppsContainerView.GRID_THEME_DARK); - mWidgetsView.setUseScrubber(false); - // Setup the drag controller (drop targets have to be added in reverse order in priority) dragController.setDragScoller(mWorkspace); dragController.setScrollView(mDragLayer); @@ -1832,6 +1827,23 @@ public class Launcher extends Activity mAppsView.reset(); } + public void reloadAppDrawer() { + List<AppInfo> addedApps = mAppsView.getApps(); + mDragLayer.removeView(mAppsView); + mAppsView = (AllAppsContainerView)LayoutInflater + .from(this).inflate(R.layout.all_apps, mDragLayer, false); + mDragLayer.addView(mAppsView, mDragLayer.getChildCount() - 1); + mAppsView.setVisibility(View.INVISIBLE); + if (mLauncherCallbacks != null && mLauncherCallbacks.getAllAppsSearchBarController() != null) { + mAppsView.setSearchBarController(mLauncherCallbacks.getAllAppsSearchBarController()); + } else { + mAppsView.setSearchBarController(mAppsView.newDefaultAppSearchController()); + } + mAppsView.addApps(addedApps); + tryAndUpdatePredictedApps(); + mAppsView.reset(); + } + /** * Replaces currently added fragments in the launcher layout with a * {@link DynamicGridSizeFragment}. diff --git a/src/com/android/launcher3/OverviewSettingsPanel.java b/src/com/android/launcher3/OverviewSettingsPanel.java index f608b2609..cac40e6a4 100644 --- a/src/com/android/launcher3/OverviewSettingsPanel.java +++ b/src/com/android/launcher3/OverviewSettingsPanel.java @@ -39,7 +39,10 @@ public class OverviewSettingsPanel { res.getString(R.string.grid_size_text)}; String[] valuesDrawer = new String[] { - res.getString(R.string.icon_labels)}; + res.getString(R.string.icon_labels), + res.getString(R.string.app_drawer_style), + res.getString(R.string.app_drawer_color), + res.getString(R.string.fast_scroller_type)}; String[] valuesApp = new String[] { res.getString(R.string.larger_icons_text)/*, 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<AppInfo> 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<AllAppsGridAdapter. public AllAppsGridAdapter(Launcher launcher, AlphabeticalAppsList apps, View.OnTouchListener touchListener, View.OnClickListener iconClickListener, - View.OnLongClickListener iconLongClickListener, int sectionStrategy, int gridTheme) { + View.OnLongClickListener iconLongClickListener) { Resources res = launcher.getResources(); mLauncher = launcher; mApps = apps; @@ -374,8 +374,6 @@ public class AllAppsGridAdapter extends RecyclerView.Adapter<AllAppsGridAdapter. mTouchListener = touchListener; mIconClickListener = iconClickListener; mIconLongClickListener = iconLongClickListener; - mSectionStrategy = sectionStrategy; - mGridTheme = gridTheme; mSectionNamesMargin = mSectionStrategy == AllAppsContainerView.SECTION_STRATEGY_GRID ? res.getDimensionPixelSize(R.dimen.all_apps_grid_view_start_margin) : @@ -607,8 +605,8 @@ public class AllAppsGridAdapter extends RecyclerView.Adapter<AllAppsGridAdapter. mSectionTextPaint.setColor(mLauncher.getResources().getColor(sectionTextColorId)); Resources res = mLauncher.getResources(); mAllAppsTextColor = mGridTheme == AllAppsContainerView.GRID_THEME_DARK ? - res.getColor(R.color.all_apps_grid_section_text_color_dark) : - res.getColor(R.color.all_apps_grid_section_text_color); + res.getColor(R.color.quantum_panel_text_color_dark) : + res.getColor(R.color.quantum_panel_text_color); } /** diff --git a/src/com/android/launcher3/list/SettingsPinnedHeaderAdapter.java b/src/com/android/launcher3/list/SettingsPinnedHeaderAdapter.java index 533e64d20..89ea1574a 100644 --- a/src/com/android/launcher3/list/SettingsPinnedHeaderAdapter.java +++ b/src/com/android/launcher3/list/SettingsPinnedHeaderAdapter.java @@ -1,13 +1,10 @@ package com.android.launcher3.list; import android.content.Context; -import android.content.Intent; -import android.content.SharedPreferences; import android.content.res.Configuration; import android.content.res.Resources; import android.database.Cursor; import android.graphics.Typeface; -import android.util.Log; import android.util.TypedValue; import android.view.Gravity; import android.view.LayoutInflater; @@ -137,6 +134,30 @@ public class SettingsPinnedHeaderAdapter extends PinnedHeaderListAdapter { : res.getString(R.string.icon_labels_show); ((TextView) v.findViewById(R.id.item_state)).setText(state); break; + case 1: + current = SettingsProvider.getBoolean(mContext, + SettingsProvider.SETTINGS_UI_DRAWER_STYLE_USE_COMPACT, + R.bool.preferences_interface_drawer_compact_default); + state = current ? res.getString(R.string.app_drawer_style_compact) + : res.getString(R.string.app_drawer_style_sections); + ((TextView) v.findViewById(R.id.item_state)).setText(state); + break; + case 2: + current = SettingsProvider.getBoolean(mContext, + SettingsProvider.SETTINGS_UI_DRAWER_DARK, + R.bool.preferences_interface_drawer_dark_default); + state = current ? res.getString(R.string.app_drawer_color_dark) + : res.getString(R.string.app_drawer_color_light); + ((TextView) v.findViewById(R.id.item_state)).setText(state); + break; + case 3: + current = SettingsProvider.getBoolean(mContext, + SettingsProvider.SETTINGS_UI_USE_HORIZONTAL_SCRUBBER, + R.bool.preferences_interface_use_horizontal_scrubber_default); + state = current ? res.getString(R.string.fast_scroller_type_horizontal) + : res.getString(R.string.fast_scroller_type_vertical); + ((TextView) v.findViewById(R.id.item_state)).setText(state); + break; default: ((TextView) v.findViewById(R.id.item_state)).setText(""); } @@ -240,6 +261,24 @@ public class SettingsPinnedHeaderAdapter extends PinnedHeaderListAdapter { R.bool.preferences_interface_drawer_hide_icon_labels_default); mLauncher.setReloadLauncher(false); break; + case 1: + onDrawerStyleBooleanChanged(v, + SettingsProvider.SETTINGS_UI_DRAWER_STYLE_USE_COMPACT, + R.bool.preferences_interface_drawer_compact_default); + mLauncher.reloadAppDrawer(); + break; + case 2: + onDrawerColorBooleanChanged(v, + SettingsProvider.SETTINGS_UI_DRAWER_DARK, + R.bool.preferences_interface_drawer_dark_default); + mLauncher.reloadAppDrawer(); + break; + case 3: + onScrollerTypeBooleanChanged(v, + SettingsProvider.SETTINGS_UI_USE_HORIZONTAL_SCRUBBER, + R.bool.preferences_interface_use_horizontal_scrubber_default); + mLauncher.reloadAppDrawer(); + break; } break; default: @@ -309,4 +348,46 @@ public class SettingsPinnedHeaderAdapter extends PinnedHeaderListAdapter { R.string.icon_labels_hide); ((TextView) v.findViewById(R.id.item_state)).setText(state); } + + private void onDrawerStyleBooleanChanged(View v, String key, int res) { + boolean current = SettingsProvider.getBoolean( + mContext, key, res); + + // Set new state + SettingsProvider.putBoolean(mContext, key, !current); + SettingsProvider.putBoolean(mContext, SettingsProvider.SETTINGS_CHANGED, true); + + String state = current ? mLauncher.getResources().getString( + R.string.app_drawer_style_sections) : mLauncher.getResources().getString( + R.string.app_drawer_style_compact); + ((TextView) v.findViewById(R.id.item_state)).setText(state); + } + + private void onDrawerColorBooleanChanged(View v, String key, int res) { + boolean current = SettingsProvider.getBoolean( + mContext, key, res); + + // Set new state + SettingsProvider.putBoolean(mContext, key, !current); + SettingsProvider.putBoolean(mContext, SettingsProvider.SETTINGS_CHANGED, true); + + String state = current ? mLauncher.getResources().getString( + R.string.app_drawer_color_light) : mLauncher.getResources().getString( + R.string.app_drawer_color_dark); + ((TextView) v.findViewById(R.id.item_state)).setText(state); + } + + private void onScrollerTypeBooleanChanged(View v, String key, int res) { + boolean current = SettingsProvider.getBoolean( + mContext, key, res); + + // Set new state + SettingsProvider.putBoolean(mContext, key, !current); + SettingsProvider.putBoolean(mContext, SettingsProvider.SETTINGS_CHANGED, true); + + String state = current ? mLauncher.getResources().getString( + R.string.fast_scroller_type_vertical) : mLauncher.getResources().getString( + R.string.fast_scroller_type_horizontal); + ((TextView) v.findViewById(R.id.item_state)).setText(state); + } }
\ No newline at end of file diff --git a/src/com/android/launcher3/settings/SettingsProvider.java b/src/com/android/launcher3/settings/SettingsProvider.java index a90478cdf..76a49d2de 100644 --- a/src/com/android/launcher3/settings/SettingsProvider.java +++ b/src/com/android/launcher3/settings/SettingsProvider.java @@ -31,7 +31,9 @@ public final class SettingsProvider { public static final String SETTINGS_UI_HOMESCREEN_ROWS = "ui_homescreen_rows"; public static final String SETTINGS_UI_HOMESCREEN_COLUMNS = "ui_homescreen_columns"; public static final String SETTINGS_UI_DRAWER_HIDE_ICON_LABELS = "ui_drawer_hide_icon_labels"; - public static final String SETTINGS_UI_DRAWER_COMPACT = "ui_drawer_compact"; + public static final String SETTINGS_UI_DRAWER_STYLE_USE_COMPACT = "ui_drawer_style_compact"; + public static final String SETTINGS_UI_DRAWER_DARK = "ui_drawer_dark"; + public static final String SETTINGS_UI_USE_HORIZONTAL_SCRUBBER = "ui_horizontal_scrubber"; public static final String SETTINGS_UI_GENERAL_ICONS_LARGE = "ui_general_icons_large"; public static SharedPreferences get(Context context) { |