diff options
author | Joey <joey@lineageos.org> | 2018-10-10 08:27:37 +0200 |
---|---|---|
committer | Bruno Martins <bgcngm@gmail.com> | 2018-11-13 11:42:00 +0000 |
commit | 530e3021529a8dc0740add3480545bd0cb8e66c9 (patch) | |
tree | bd23df63644da795dc1b062d0766900340d582b4 /src/com/android/launcher3 | |
parent | ab03bb7d28000730fb7ea84664351d43c374a9af (diff) | |
download | android_packages_apps_Trebuchet-530e3021529a8dc0740add3480545bd0cb8e66c9.tar.gz android_packages_apps_Trebuchet-530e3021529a8dc0740add3480545bd0cb8e66c9.tar.bz2 android_packages_apps_Trebuchet-530e3021529a8dc0740add3480545bd0cb8e66c9.zip |
Trebuchet: add toggle for desktop and drawer labels
Change-Id: I98063b7adaf22029c4bfa50d2cac730f3612e121
Signed-off-by: Joey <joey@lineageos.org>
Diffstat (limited to 'src/com/android/launcher3')
-rw-r--r-- | src/com/android/launcher3/BubbleTextView.java | 14 | ||||
-rw-r--r-- | src/com/android/launcher3/SettingsActivity.java | 14 |
2 files changed, 24 insertions, 4 deletions
diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java index fb7c0ced4..6e52be968 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.Canvas; @@ -65,6 +66,8 @@ 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 static final Property<BubbleTextView, Float> BADGE_SCALE_PROPERTY = new Property<BubbleTextView, Float>(Float.TYPE, "badgeScale") { @@ -126,6 +129,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) { @@ -146,19 +151,24 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver, R.styleable.BubbleTextView, defStyle, 0); mLayoutHorizontal = a.getBoolean(R.styleable.BubbleTextView_layoutHorizontal, 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); @@ -235,7 +245,9 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver, mBadgeColor = IconPalette.getMutedColor(info.iconColor, 0.54f); 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 0b67a2fb3..990c1b358 100644 --- a/src/com/android/launcher3/SettingsActivity.java +++ b/src/com/android/launcher3/SettingsActivity.java @@ -78,6 +78,8 @@ public class SettingsActivity extends Activity { public static final String KEY_MINUS_ONE = "pref_enable_minus_one"; private static final String KEY_GRID_SIZE = "pref_grid_size"; + 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) { @@ -243,9 +245,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, getDefaultGridSize())); - mShouldRestart = true; + switch (key) { + case KEY_GRID_SIZE: + mGridPref.setSummary(mPrefs.getString(KEY_GRID_SIZE, getDefaultGridSize())); + mShouldRestart = true; + break; + case KEY_SHOW_DESKTOP_LABELS: + case KEY_SHOW_DRAWER_LABELS: + mShouldRestart = true; + break; } } |