diff options
-rw-r--r-- | res/values/lineage_strings.xml | 4 | ||||
-rw-r--r-- | res/xml/launcher_preferences.xml | 11 | ||||
-rw-r--r-- | src/com/android/launcher3/BubbleTextView.java | 15 | ||||
-rw-r--r-- | src/com/android/launcher3/InvariantDeviceProfile.java | 22 |
4 files changed, 48 insertions, 4 deletions
diff --git a/res/values/lineage_strings.xml b/res/values/lineage_strings.xml index 02a8834a7..0a875a66a 100644 --- a/res/values/lineage_strings.xml +++ b/res/values/lineage_strings.xml @@ -28,4 +28,8 @@ <!-- Folder titles --> <string name="google_folder_title" translatable="false">Google</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 9f9aacb33..5e6903d14 100644 --- a/res/xml/launcher_preferences.xml +++ b/res/xml/launcher_preferences.xml @@ -56,4 +56,15 @@ android:title="Developer Options" android:fragment="com.android.launcher3.settings.DeveloperOptionsFragment"/> + <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" /> </androidx.preference.PreferenceScreen> diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java index b1132494a..4f5b2ab25 100644 --- a/src/com/android/launcher3/BubbleTextView.java +++ b/src/com/android/launcher3/BubbleTextView.java @@ -16,12 +16,15 @@ package com.android.launcher3; +import static com.android.launcher3.InvariantDeviceProfile.KEY_SHOW_DESKTOP_LABELS; +import static com.android.launcher3.InvariantDeviceProfile.KEY_SHOW_DRAWER_LABELS; import static com.android.launcher3.icons.GraphicsUtils.setColorAlphaBound; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; 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; @@ -72,7 +75,6 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver, private static final int[] STATE_PRESSED = new int[] {android.R.attr.state_pressed}; - private static final Property<BubbleTextView, Float> DOT_SCALE_PROPERTY = new Property<BubbleTextView, Float>(Float.TYPE, "dotScale") { @Override @@ -133,6 +135,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) { @@ -152,6 +156,8 @@ 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); final int defaultIconSize; if (display == DISPLAY_WORKSPACE) { @@ -159,11 +165,13 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver, setTextSize(TypedValue.COMPLEX_UNIT_PX, grid.iconTextSizePx); setCompoundDrawablePadding(grid.iconDrawablePaddingPx); defaultIconSize = grid.iconSizePx; + mShouldShowLabel = prefs.getBoolean(KEY_SHOW_DESKTOP_LABELS, true); } else if (display == DISPLAY_ALL_APPS) { DeviceProfile grid = mActivity.getDeviceProfile(); 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) { DeviceProfile grid = mActivity.getDeviceProfile(); setTextSize(TypedValue.COMPLEX_UNIT_PX, grid.folderChildTextSizePx); @@ -171,6 +179,7 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver, defaultIconSize = grid.folderChildIconSizePx; } else { defaultIconSize = mActivity.getDeviceProfile().iconSizePx; + mShouldShowLabel = prefs.getBoolean(KEY_SHOW_DESKTOP_LABELS, true); } mCenterVertically = a.getBoolean(R.styleable.BubbleTextView_centerVertically, false); @@ -281,7 +290,9 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver, mDotParams.color = 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/InvariantDeviceProfile.java b/src/com/android/launcher3/InvariantDeviceProfile.java index 8a8a2fbe5..5ac22da29 100644 --- a/src/com/android/launcher3/InvariantDeviceProfile.java +++ b/src/com/android/launcher3/InvariantDeviceProfile.java @@ -26,6 +26,8 @@ import android.content.BroadcastReceiver; import android.content.ComponentName; import android.content.Context; import android.content.Intent; +import android.content.SharedPreferences; +import android.content.SharedPreferences.OnSharedPreferenceChangeListener; import android.content.res.Configuration; import android.content.res.Resources; import android.content.res.TypedArray; @@ -58,7 +60,7 @@ import java.util.Collections; import androidx.annotation.Nullable; import androidx.annotation.VisibleForTesting; -public class InvariantDeviceProfile { +public class InvariantDeviceProfile implements OnSharedPreferenceChangeListener { public static final String TAG = "IDP"; // We do not need any synchronization for this variable as its only written on UI thread. @@ -72,6 +74,8 @@ public class InvariantDeviceProfile { public static final int CHANGE_FLAG_GRID = 1 << 0; public static final int CHANGE_FLAG_ICON_PARAMS = 1 << 1; + public static final String KEY_SHOW_DESKTOP_LABELS = "pref_desktop_show_labels"; + public static final String KEY_SHOW_DRAWER_LABELS = "pref_drawer_show_labels"; public static final String KEY_ICON_PATH_REF = "pref_icon_shape_path"; // Constants that affects the interpolation curve between statically defined device profile @@ -123,6 +127,8 @@ public class InvariantDeviceProfile { private ConfigMonitor mConfigMonitor; private OverlayMonitor mOverlayMonitor; + private Context mContext; + @VisibleForTesting public InvariantDeviceProfile() {} @@ -144,7 +150,12 @@ public class InvariantDeviceProfile { @TargetApi(23) private InvariantDeviceProfile(Context context) { - initGrid(context, Utilities.getPrefs(context).getString(KEY_IDP_GRID_NAME, null)); + mContext = context; + + SharedPreferences prefs = Utilities.getPrefs(context); + prefs.registerOnSharedPreferenceChangeListener(this); + + initGrid(context, prefs.getString(KEY_IDP_GRID_NAME, null)); mConfigMonitor = new ConfigMonitor(context, APPLY_CONFIG_AT_RUNTIME.get() ? this::onConfigChanged : this::killProcess); mOverlayMonitor = new OverlayMonitor(context); @@ -160,6 +171,13 @@ public class InvariantDeviceProfile { } } + @Override + public void onSharedPreferenceChanged(SharedPreferences prefs, String key) { + if (KEY_SHOW_DESKTOP_LABELS.equals(key) || KEY_SHOW_DRAWER_LABELS.equals(key)) { + apply(mContext, CHANGE_FLAG_ICON_PARAMS); + } + } + /** * Retrieve system defined or RRO overriden icon shape. */ |