Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 530e3021 authored by Joey's avatar Joey Committed by Bruno Martins
Browse files

Trebuchet: add toggle for desktop and drawer labels



Change-Id: I98063b7adaf22029c4bfa50d2cac730f3612e121
Signed-off-by: default avatarJoey <joey@lineageos.org>
parent ab03bb7d
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -38,4 +38,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>
+12 −0
Original line number Diff line number Diff line
@@ -62,4 +62,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>
+13 −1
Original line number Diff line number Diff line
@@ -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);
        if (mShouldShowLabel) {
            setText(info.title);
        }
        if (info.contentDescription != null) {
            setContentDescription(info.isDisabled()
                    ? getContext().getString(R.string.disabled_app_label, info.contentDescription)
+11 −3
Original line number Diff line number Diff line
@@ -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)) {
            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;
            }
        }