summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcretin45 <cretin45@gmail.com>2015-11-30 16:38:47 -0800
committerTom Powell <zifnab@zifnab06.net>2017-03-26 15:52:42 -0700
commit24e7616996e5cf03a0522fadc0d60da654ebb765 (patch)
tree0c6beab5f509f2e7c2120c419feffb47ada33b52
parent9c9418bc626d36dce33f2ac6513e7407f07298d4 (diff)
downloadandroid_packages_apps_Trebuchet-24e7616996e5cf03a0522fadc0d60da654ebb765.tar.gz
android_packages_apps_Trebuchet-24e7616996e5cf03a0522fadc0d60da654ebb765.tar.bz2
android_packages_apps_Trebuchet-24e7616996e5cf03a0522fadc0d60da654ebb765.zip
Trebuchet: Add app drawer settings
Change-Id: I040420608de64bedc6e9832268796cdf801f5c21
-rw-r--r--res/values/cm_strings.xml11
-rw-r--r--res/values/preferences_defaults.xml2
-rw-r--r--src/com/android/launcher3/BaseContainerView.java15
-rw-r--r--src/com/android/launcher3/BubbleTextView.java7
-rw-r--r--src/com/android/launcher3/Launcher.java22
-rw-r--r--src/com/android/launcher3/OverviewSettingsPanel.java5
-rw-r--r--src/com/android/launcher3/allapps/AllAppsContainerView.java39
-rw-r--r--src/com/android/launcher3/allapps/AllAppsGridAdapter.java8
-rw-r--r--src/com/android/launcher3/list/SettingsPinnedHeaderAdapter.java87
-rw-r--r--src/com/android/launcher3/settings/SettingsProvider.java4
10 files changed, 165 insertions, 35 deletions
diff --git a/res/values/cm_strings.xml b/res/values/cm_strings.xml
index 9072824ce..7a2b84a73 100644
--- a/res/values/cm_strings.xml
+++ b/res/values/cm_strings.xml
@@ -60,6 +60,17 @@
<!-- Protected apps -->
<string name="protected_app_settings">Protected apps</string>
+ <!-- Drawer settings -->
+ <string name="app_drawer_style">Drawer style</string>
+ <string name="app_drawer_style_compact">Compact</string>
+ <string name="app_drawer_style_sections">Sections</string>
+ <string name="app_drawer_color">Drawer color</string>
+ <string name="app_drawer_color_dark">Dark</string>
+ <string name="app_drawer_color_light">Light</string>
+ <string name="fast_scroller_type">Fast scroller</string>
+ <string name="fast_scroller_type_horizontal">Horizontal</string>
+ <string name="fast_scroller_type_vertical">Vertical</string>
+
<!-- Search Manager doesn't exist -->
<string name="search_activity_not_found">A search activity could not be found!</string>
</resources>
diff --git a/res/values/preferences_defaults.xml b/res/values/preferences_defaults.xml
index 9eb5ca58f..494846aed 100644
--- a/res/values/preferences_defaults.xml
+++ b/res/values/preferences_defaults.xml
@@ -5,5 +5,7 @@
<bool name="preferences_interface_homescreen_hide_icon_labels_default">false</bool>
<bool name="preferences_interface_drawer_hide_icon_labels_default">false</bool>
<bool name="preferences_interface_drawer_compact_default">false</bool>
+ <bool name="preferences_interface_drawer_dark_default">true</bool>
<bool name="preferences_interface_general_icons_large_default">false</bool>
+ <bool name="preferences_interface_use_horizontal_scrubber_default">true</bool>
</resources>
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) {