diff options
author | Joey Rizzoli <joey@lineageos.org> | 2017-11-10 21:45:09 +0100 |
---|---|---|
committer | Arne Coucheron <arco68@gmail.com> | 2018-01-19 00:27:13 +0100 |
commit | 6a4b5ff6292360a34f6a6b33cb51f83d5ce82661 (patch) | |
tree | 3799b978ff269e9dbe2fb0c13ddcd82af186c3b6 | |
parent | 97105a6eb4de7a9ec0509b5c60c05ab0f4aef08c (diff) | |
download | android_packages_apps_Trebuchet-6a4b5ff6292360a34f6a6b33cb51f83d5ce82661.tar.gz android_packages_apps_Trebuchet-6a4b5ff6292360a34f6a6b33cb51f83d5ce82661.tar.bz2 android_packages_apps_Trebuchet-6a4b5ff6292360a34f6a6b33cb51f83d5ce82661.zip |
Trebuchet: add toggle for desktop and drawer labels
Signed-off-by: Joey Rizzoli <joey@lineageos.org>
-rw-r--r-- | res/values/lineage_strings.xml | 4 | ||||
-rw-r--r-- | res/xml/launcher_preferences.xml | 12 | ||||
-rw-r--r-- | src/com/android/launcher3/BubbleTextView.java | 15 | ||||
-rw-r--r-- | src/com/android/launcher3/SettingsActivity.java | 16 |
4 files changed, 43 insertions, 4 deletions
diff --git a/res/values/lineage_strings.xml b/res/values/lineage_strings.xml index c96dc5af2..af71c9f64 100644 --- a/res/values/lineage_strings.xml +++ b/res/values/lineage_strings.xml @@ -36,4 +36,8 @@ <string name="grid_size_columns">Columns</string> <string name="grid_size_custom_positive">Set</string> <string name="grid_size_custom_message">Select custom columns and rows count</string> + + <!-- Hide labels --> + <string name="desktop_show_labels">Show icon labels on desktop</string> + <string name="drawer_show_labels">Show icon labels in drawer</string> </resources> diff --git a/res/xml/launcher_preferences.xml b/res/xml/launcher_preferences.xml index 2281ab5ad..f4663935d 100644 --- a/res/xml/launcher_preferences.xml +++ b/res/xml/launcher_preferences.xml @@ -71,4 +71,16 @@ android:key="pref_grid_size" android:title="@string/grid_size_text" android:persistent="true" /> + + <SwitchPreference + android:key="pref_desktop_show_labels" + android:title="@string/desktop_show_labels" + android:defaultValue="true" + android:persistent="true" /> + + <SwitchPreference + android:key="pref_drawer_show_labels" + android:title="@string/drawer_show_labels" + android:defaultValue="true" + android:persistent="true" /> </PreferenceScreen> diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java index ac842f92e..8a137b767 100644 --- a/src/com/android/launcher3/BubbleTextView.java +++ b/src/com/android/launcher3/BubbleTextView.java @@ -18,6 +18,7 @@ package com.android.launcher3; import android.animation.ObjectAnimator; import android.content.Context; +import android.content.SharedPreferences; import android.content.res.ColorStateList; import android.content.res.TypedArray; import android.graphics.Bitmap; @@ -67,6 +68,9 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver { private static final int[] STATE_PRESSED = new int[] {android.R.attr.state_pressed}; + private static final String KEY_SHOW_DESKTOP_LABELS = "pref_desktop_show_labels"; + private static final String KEY_SHOW_DRAWER_LABELS = "pref_drawer_show_labels"; + private final Launcher mLauncher; private Drawable mIcon; private final boolean mCenterVertically; @@ -127,6 +131,8 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver { @ViewDebug.ExportedProperty(category = "launcher") private boolean mDisableRelayout = false; + private boolean mShouldShowLabel; + private IconLoadRequest mIconLoadRequest; public BubbleTextView(Context context) { @@ -149,19 +155,24 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver { mDeferShadowGenerationOnTouch = a.getBoolean(R.styleable.BubbleTextView_deferShadowGeneration, false); + SharedPreferences prefs = Utilities.getPrefs(context.getApplicationContext()); + int display = a.getInteger(R.styleable.BubbleTextView_iconDisplay, DISPLAY_WORKSPACE); int defaultIconSize = grid.iconSizePx; if (display == DISPLAY_WORKSPACE) { setTextSize(TypedValue.COMPLEX_UNIT_PX, grid.iconTextSizePx); setCompoundDrawablePadding(grid.iconDrawablePaddingPx); + mShouldShowLabel = prefs.getBoolean(KEY_SHOW_DESKTOP_LABELS, true); } else if (display == DISPLAY_ALL_APPS) { setTextSize(TypedValue.COMPLEX_UNIT_PX, grid.allAppsIconTextSizePx); setCompoundDrawablePadding(grid.allAppsIconDrawablePaddingPx); defaultIconSize = grid.allAppsIconSizePx; + mShouldShowLabel = prefs.getBoolean(KEY_SHOW_DRAWER_LABELS, true); } else if (display == DISPLAY_FOLDER) { setTextSize(TypedValue.COMPLEX_UNIT_PX, grid.folderChildTextSizePx); setCompoundDrawablePadding(grid.folderChildDrawablePaddingPx); defaultIconSize = grid.folderChildIconSizePx; + mShouldShowLabel = prefs.getBoolean(KEY_SHOW_DESKTOP_LABELS, true); } mCenterVertically = a.getBoolean(R.styleable.BubbleTextView_centerVertically, false); @@ -220,7 +231,9 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver { FastBitmapDrawable iconDrawable = DrawableFactory.get(getContext()).newIcon(icon, info); iconDrawable.setIsDisabled(info.isDisabled()); setIcon(iconDrawable); - setText(info.title); + if (mShouldShowLabel) { + setText(info.title); + } if (info.contentDescription != null) { setContentDescription(info.isDisabled() ? getContext().getString(R.string.disabled_app_label, info.contentDescription) diff --git a/src/com/android/launcher3/SettingsActivity.java b/src/com/android/launcher3/SettingsActivity.java index 4adac74bd..93fedf46d 100644 --- a/src/com/android/launcher3/SettingsActivity.java +++ b/src/com/android/launcher3/SettingsActivity.java @@ -59,6 +59,10 @@ public class SettingsActivity extends Activity { // Grid size private static final String KEY_GRID_SIZE = "pref_grid_size"; + // Hide labels + private static final String KEY_SHOW_DESKTOP_LABELS = "pref_desktop_show_labels"; + private static final String KEY_SHOW_DRAWER_LABELS = "pref_drawer_show_labels"; + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -169,9 +173,15 @@ public class SettingsActivity extends Activity { @Override public void onSharedPreferenceChanged(SharedPreferences prefs, String key) { - if (KEY_GRID_SIZE.equals(key)) { - mGridPref.setSummary(mPrefs.getString(KEY_GRID_SIZE, getDefaulGridSize())); - mShouldRestart = true; + switch (key) { + case KEY_GRID_SIZE: + mGridPref.setSummary(mPrefs.getString(KEY_GRID_SIZE, getDefaulGridSize())); + mShouldRestart = true; + break; + case KEY_SHOW_DESKTOP_LABELS: + case KEY_SHOW_DRAWER_LABELS: + mShouldRestart = true; + break; } } |