summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaj Yengisetty <rajesh@cyngn.com>2015-03-03 19:13:57 (GMT)
committerRaj Yengisetty <rajesh@cyngn.com>2015-03-06 23:37:44 (GMT)
commit022da8535300e5ead0a5a2ceb875dbc603a1f0c8 (patch)
treef269bad44c44beabaa50b9a9c80701f667218ac5
parent369851799cfc890ddbc8af777f7f662f6304dd65 (diff)
downloadandroid_packages_apps_Trebuchet-022da8535300e5ead0a5a2ceb875dbc603a1f0c8.zip
android_packages_apps_Trebuchet-022da8535300e5ead0a5a2ceb875dbc603a1f0c8.tar.gz
android_packages_apps_Trebuchet-022da8535300e5ead0a5a2ceb875dbc603a1f0c8.tar.bz2
App Drawer: Add toggle functionality to change back to legacy app drawer
Change-Id: I4a78832188e27ae0b5a25b6a81ce000b6ffcd1f1
-rw-r--r--res/values/cm_strings.xml6
-rw-r--r--res/values/preferences_defaults.xml1
-rw-r--r--src/com/android/launcher3/AppDrawerListAdapter.java23
-rw-r--r--src/com/android/launcher3/Launcher.java34
-rw-r--r--src/com/android/launcher3/OverviewSettingsPanel.java1
-rw-r--r--src/com/android/launcher3/list/SettingsPinnedHeaderAdapter.java46
-rw-r--r--src/com/android/launcher3/settings/SettingsProvider.java1
7 files changed, 102 insertions, 10 deletions
diff --git a/res/values/cm_strings.xml b/res/values/cm_strings.xml
index 1a447d9..2fbaa1a 100644
--- a/res/values/cm_strings.xml
+++ b/res/values/cm_strings.xml
@@ -74,4 +74,10 @@
<!-- Dialog -->
<string name="dialog_confirm">Confirm</string>
+
+ <!-- Drawer type -->
+ <string name="drawer_type">Layout</string>
+
+ <string name="drawer_type_drawer">Vertical</string>
+ <string name="drawer_type_pager">Paged</string>
</resources>
diff --git a/res/values/preferences_defaults.xml b/res/values/preferences_defaults.xml
index 13fb8cc..f802251 100644
--- a/res/values/preferences_defaults.xml
+++ b/res/values/preferences_defaults.xml
@@ -14,4 +14,5 @@
<bool name="preferences_interface_general_icons_large_default">@bool/config_largeIcons</bool>
<string name="preferences_interface_general_icons_text_font_family_default">sans-serif-condensed</string>
<integer name="preferences_interface_general_icons_text_font_style_default">0</integer>
+ <integer name="preferences_interface_drawer_type_default">1</integer>
</resources>
diff --git a/src/com/android/launcher3/AppDrawerListAdapter.java b/src/com/android/launcher3/AppDrawerListAdapter.java
index 52e35ff..ad6b350 100644
--- a/src/com/android/launcher3/AppDrawerListAdapter.java
+++ b/src/com/android/launcher3/AppDrawerListAdapter.java
@@ -50,6 +50,29 @@ public class AppDrawerListAdapter extends RecyclerView.Adapter<AppDrawerListAdap
private LinearLayout.LayoutParams mIconParams;
private Rect mIconRect;
+ public enum DrawerType {
+ Drawer(0),
+ Pager(1);
+
+ private final int mValue;
+ private DrawerType(int value) {
+ mValue = value;
+ }
+
+ public int getValue() {
+ return mValue;
+ }
+
+ public static DrawerType getModeForValue(int value) {
+ switch (value) {
+ case 1:
+ return Pager;
+ default :
+ return Drawer;
+ }
+ }
+ }
+
public static class ViewHolder extends RecyclerView.ViewHolder {
public AutoFitTextView mTextView;
public ViewGroup mLayout;
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 56a757b..e36ec93 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -395,6 +395,7 @@ public class Launcher extends Activity
// Preferences
private boolean mHideIconLabels;
+ private AppDrawerListAdapter.DrawerType mDrawerType;
private Runnable mBuildLayersRunnable = new Runnable() {
public void run() {
@@ -569,6 +570,10 @@ public class Launcher extends Activity
mHideIconLabels = SettingsProvider.getBoolean(this,
SettingsProvider.SETTINGS_UI_HOMESCREEN_HIDE_ICON_LABELS,
R.bool.preferences_interface_homescreen_hide_icon_labels_default);
+ mDrawerType = AppDrawerListAdapter.DrawerType.getModeForValue(
+ SettingsProvider.getInt(this,
+ SettingsProvider.SETTINGS_UI_DRAWER_TYPE,
+ R.integer.preferences_interface_drawer_type_default));
// Determine the dynamic grid properties
Point smallestSize = new Point();
@@ -1263,6 +1268,13 @@ public class Launcher extends Activity
return false;
}
+ public void updateDrawerType() {
+ mDrawerType = AppDrawerListAdapter.DrawerType.getModeForValue(
+ SettingsProvider.getInt(this,
+ SettingsProvider.SETTINGS_UI_DRAWER_TYPE,
+ R.integer.preferences_interface_drawer_type_default));
+ }
+
public void onClickSortModeButton(View v) {
final PopupMenu popupMenu = new PopupMenu(this, v);
final Menu menu = popupMenu.getMenu();
@@ -3626,7 +3638,7 @@ public class Launcher extends Activity
}
boolean material = Utilities.isLmpOrAbove();
-
+ boolean drawer = mDrawerType == AppDrawerListAdapter.DrawerType.Drawer;
final Resources res = getResources();
final int duration = res.getInteger(R.integer.config_appsCustomizeZoomInTime);
@@ -3639,7 +3651,7 @@ public class Launcher extends Activity
final View fromView = mWorkspace;
final View toView;
- if (contentType == AppsCustomizePagedView.ContentType.Applications) {
+ if (drawer && contentType == AppsCustomizePagedView.ContentType.Applications) {
toView = findViewById(R.id.app_drawer_container);
} else {
toView = mAppsCustomizeTabHost;
@@ -3675,7 +3687,11 @@ public class Launcher extends Activity
if (isWidgetTray) {
revealView.setBackground(res.getDrawable(R.drawable.quantum_panel_dark));
} else {
- revealView.setBackgroundColor(res.getColor(R.color.app_drawer_background));
+ if (drawer) {
+ revealView.setBackgroundColor(res.getColor(R.color.app_drawer_background));
+ } else {
+ revealView.setBackground(res.getDrawable(R.drawable.quantum_panel));
+ }
}
// Hide the real page background, and swap in the fake one
@@ -3901,6 +3917,7 @@ public class Launcher extends Activity
}
boolean material = Utilities.isLmpOrAbove();
+ boolean drawer = mDrawerType == AppDrawerListAdapter.DrawerType.Drawer;
final Resources res = getResources();
final int duration = res.getInteger(R.integer.config_appsCustomizeZoomOutTime);
@@ -3913,7 +3930,8 @@ public class Launcher extends Activity
res.getInteger(R.integer.config_appsCustomizeZoomScaleFactor);
final View fromView;
- if (mAppsCustomizeContent.getContentType() != AppsCustomizePagedView.ContentType.Widgets) {
+ if (drawer && mAppsCustomizeContent.getContentType()
+ != AppsCustomizePagedView.ContentType.Widgets) {
fromView = (FrameLayout) findViewById(R.id.app_drawer_container);
} else {
fromView = mAppsCustomizeTabHost;
@@ -3969,8 +3987,12 @@ public class Launcher extends Activity
if (isWidgetTray) {
revealView.setBackground(res.getDrawable(R.drawable.quantum_panel_dark));
} else {
- revealView.setBackgroundColor(res.getColor(
- R.color.app_drawer_background));
+ if (drawer) {
+ revealView.setBackgroundColor(res.getColor(
+ R.color.app_drawer_background));
+ } else {
+ revealView.setBackground(res.getDrawable(R.drawable.quantum_panel));
+ }
}
int width = revealView.getMeasuredWidth();
diff --git a/src/com/android/launcher3/OverviewSettingsPanel.java b/src/com/android/launcher3/OverviewSettingsPanel.java
index 2403d23..acc700a 100644
--- a/src/com/android/launcher3/OverviewSettingsPanel.java
+++ b/src/com/android/launcher3/OverviewSettingsPanel.java
@@ -49,6 +49,7 @@ public class OverviewSettingsPanel {
res.getString(R.string.grid_size_text)};
String[] valuesDrawer = new String[] {
+ res.getString(R.string.drawer_type),
res.getString(R.string.scroll_effect_text),
res.getString(R.string.drawer_sorting_text),
res.getString(R.string.icon_labels)};
diff --git a/src/com/android/launcher3/list/SettingsPinnedHeaderAdapter.java b/src/com/android/launcher3/list/SettingsPinnedHeaderAdapter.java
index 8a77502..fdb3831 100644
--- a/src/com/android/launcher3/list/SettingsPinnedHeaderAdapter.java
+++ b/src/com/android/launcher3/list/SettingsPinnedHeaderAdapter.java
@@ -14,6 +14,7 @@ import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.TextView;
+import com.android.launcher3.AppDrawerListAdapter;
import com.android.launcher3.AppsCustomizePagedView;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.Launcher;
@@ -131,14 +132,17 @@ public class SettingsPinnedHeaderAdapter extends PinnedHeaderListAdapter {
case OverviewSettingsPanel.DRAWER_SETTINGS_POSITION:
switch (position) {
case 0:
+ updateDrawerTypeSettingsItem(v);
+ break;
+ case 1:
state = mLauncher.getAppsCustomizeTransitionEffect();
state = mapEffectToValue(state);
((TextView) v.findViewById(R.id.item_state)).setText(state);
break;
- case 1:
+ case 2:
updateDrawerSortSettingsItem(v);
break;
- case 2:
+ case 3:
current = SettingsProvider.getBoolean(mContext,
SettingsProvider.SETTINGS_UI_DRAWER_HIDE_ICON_LABELS,
R.bool.preferences_interface_drawer_hide_icon_labels_default);
@@ -201,6 +205,24 @@ public class SettingsPinnedHeaderAdapter extends PinnedHeaderListAdapter {
((TextView) v.findViewById(R.id.item_state)).setText(state);
}
+ public void updateDrawerTypeSettingsItem(View v) {
+ String state = "";
+ AppDrawerListAdapter.DrawerType type =
+ AppDrawerListAdapter.DrawerType.getModeForValue(
+ SettingsProvider.getInt(mLauncher,
+ SettingsProvider.SETTINGS_UI_DRAWER_TYPE,
+ R.integer.preferences_interface_drawer_type_default));
+ switch (type) {
+ case Drawer:
+ state = mLauncher.getResources().getString(R.string.drawer_type_drawer);
+ break;
+ case Pager:
+ state = mLauncher.getResources().getString(R.string.drawer_type_pager);
+ break;
+ }
+ ((TextView) v.findViewById(R.id.item_state)).setText(state);
+ }
+
public void updateDynamicGridSizeSettingsItem(View v) {
DeviceProfile.GridSize gridSize = DeviceProfile.GridSize.getModeForValue(
SettingsProvider.getIntCustomDefault(mLauncher,
@@ -287,12 +309,15 @@ public class SettingsPinnedHeaderAdapter extends PinnedHeaderListAdapter {
case OverviewSettingsPanel.DRAWER_SETTINGS_POSITION:
switch (position) {
case 0:
- mLauncher.onClickTransitionEffectButton(v, true);
+ onClickDrawerTypeButton();
break;
case 1:
- onClickSortButton();
+ mLauncher.onClickTransitionEffectButton(v, true);
break;
case 2:
+ onClickSortButton();
+ break;
+ case 3:
onIconLabelsBooleanChanged(v,
SettingsProvider.SETTINGS_UI_DRAWER_HIDE_ICON_LABELS,
R.bool.preferences_interface_drawer_hide_icon_labels_default);
@@ -370,4 +395,17 @@ public class SettingsPinnedHeaderAdapter extends PinnedHeaderListAdapter {
notifyDataSetChanged();
}
+
+ private void onClickDrawerTypeButton() {
+ int type = SettingsProvider.getInt(mLauncher,
+ SettingsProvider.SETTINGS_UI_DRAWER_TYPE,
+ R.integer.preferences_interface_drawer_type_default);
+
+ type = (type + 1) % AppDrawerListAdapter.DrawerType.values().length;
+ SettingsProvider.putInt(mLauncher, SettingsProvider.SETTINGS_UI_DRAWER_TYPE, type);
+
+ mLauncher.updateDrawerType();
+
+ notifyDataSetChanged();
+ }
}
diff --git a/src/com/android/launcher3/settings/SettingsProvider.java b/src/com/android/launcher3/settings/SettingsProvider.java
index 044c5a0..4d09ed9 100644
--- a/src/com/android/launcher3/settings/SettingsProvider.java
+++ b/src/com/android/launcher3/settings/SettingsProvider.java
@@ -43,6 +43,7 @@ public final class SettingsProvider {
public static final String SETTINGS_UI_GENERAL_ICONS_TEXT_FONT_FAMILY = "ui_general_icons_text_font";
public static final String SETTINGS_UI_GENERAL_ICONS_TEXT_FONT_STYLE = "ui_general_icons_text_font_style";
public static final String SETTINGS_UI_DRAWER_SORT_MODE = "ui_drawer_sort_mode";
+ public static final String SETTINGS_UI_DRAWER_TYPE = "ui_drawer_type";
public static SharedPreferences get(Context context) {
return context.getSharedPreferences(SETTINGS_KEY, Context.MODE_MULTI_PROCESS);