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

Commit 186796eb 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 46987756
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -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>
+11 −0
Original line number Diff line number Diff line
@@ -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>
+13 −2
Original line number Diff line number Diff line
@@ -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);
        if (mShouldShowLabel) {
            setText(info.title);
        }
        if (info.contentDescription != null) {
            setContentDescription(info.isDisabled()
                    ? getContext().getString(R.string.disabled_app_label, info.contentDescription)
+20 −2
Original line number Diff line number Diff line
@@ -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.
     */