Skip to content

Commit

Permalink
feat : add option toggle label in dock
Browse files Browse the repository at this point in the history
  • Loading branch information
MrSluffy authored and nulldrf committed Feb 14, 2025
1 parent 2ab4cce commit bde423b
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,12 @@ class PreferenceManager2 private constructor(private val context: Context) :
onSet = { reloadHelper.reloadIcons() },
)

val enableLabelInDock = preference(
key = booleanPreferencesKey(name = "enable_label_dock"),
defaultValue = false,
onSet = { reloadHelper.reloadGrid() },
)

val doubleTapGestureHandler = serializablePreference<GestureHandlerConfig>(
key = stringPreferencesKey("double_tap_gesture_handler"),
defaultValue = GestureHandlerConfig.Sleep,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ fun HotseatBackgroundSettings(prefs: PreferenceManager, prefs2: PreferenceManage

@Composable
fun GridSettings(prefs: PreferenceManager, prefs2: PreferenceManager2) {
SwitchPreference(
adapter = prefs2.enableLabelInDock.getAdapter(),
label = stringResource(id = R.string.show_labels),
)
SliderPreference(
label = stringResource(id = R.string.dock_icons),
adapter = prefs.hotseatColumns.getAdapter(),
Expand Down Expand Up @@ -171,6 +175,7 @@ fun ColumnScope.DockPreferencesPreview(modifier: Modifier = Modifier) {
prefs.hotseatQsbStrokeWidth.getAdapter(),
prefs2.hotseatBottomFactor.getAdapter(),
prefs2.strokeColorStyle.getAdapter(),
prefs2.enableLabelInDock.getAdapter(),
prefs.hotseatBG.getAdapter(),
prefs.hotseatBGHorizontalInsetLeft.getAdapter(),
prefs.hotseatBGVerticalInsetTop.getAdapter(),
Expand Down
10 changes: 8 additions & 2 deletions src/com/android/launcher3/BubbleTextView.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
import com.android.launcher3.util.ShortcutUtil;
import com.android.launcher3.views.ActivityContext;
import com.android.launcher3.views.FloatingIconViewCompanion;
import com.patrykmichalik.opto.core.PreferenceExtensionsKt;

import java.text.NumberFormat;
import java.util.HashMap;
Expand All @@ -95,6 +96,7 @@
import app.lawnchair.LawnchairApp;
import app.lawnchair.font.FontManager;
import app.lawnchair.preferences.PreferenceManager;
import app.lawnchair.preferences2.PreferenceManager2;
import app.lawnchair.util.LawnchairUtilsKt;

/**
Expand Down Expand Up @@ -224,6 +226,8 @@ public enum RunningAppState {

private boolean mEnableIconUpdateAnimation = false;

private final PreferenceManager2 pref2;

public BubbleTextView(Context context) {
this(context, null, 0);
}
Expand All @@ -236,6 +240,7 @@ public BubbleTextView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
mActivity = ActivityContext.lookupContext(context);
FastBitmapDrawable.setFlagHoverEnabled(LawnchairApp.isRecentsEnabled() && enableCursorHoverStates());
pref2 = PreferenceManager2.getInstance(context);

TypedArray a = context.obtainStyledAttributes(attrs,
R.styleable.BubbleTextView, defStyle, 0);
Expand Down Expand Up @@ -844,8 +849,9 @@ public boolean shouldTextBeVisible() {
// Text should be visible everywhere but the hotseat.
Object tag = getParent() instanceof FolderIcon ? ((View) getParent()).getTag() : getTag();
ItemInfo info = tag instanceof ItemInfo ? (ItemInfo) tag : null;
return info == null || (info.container != LauncherSettings.Favorites.CONTAINER_HOTSEAT
&& info.container != LauncherSettings.Favorites.CONTAINER_HOTSEAT_PREDICTION);
return info == null || ((info.container != LauncherSettings.Favorites.CONTAINER_HOTSEAT
&& info.container != LauncherSettings.Favorites.CONTAINER_HOTSEAT_PREDICTION)
&& !PreferenceExtensionsKt.firstBlocking(pref2.getEnableLabelInDock()));
}

public void setTextVisibility(boolean visible) {
Expand Down
2 changes: 1 addition & 1 deletion src/com/android/launcher3/CellLayout.java
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,7 @@ public boolean addViewToCellLayout(View child, int index, int childId,
// Hotseat icons - remove text
if (child instanceof BubbleTextView) {
BubbleTextView bubbleChild = (BubbleTextView) child;
bubbleChild.setTextVisibility(mContainerType != HOTSEAT);
bubbleChild.setTextVisibility(PreferenceExtensionsKt.firstBlocking(pref.getEnableLabelInDock()));
}

child.setScaleX(DEFAULT_SCALE);
Expand Down
5 changes: 5 additions & 0 deletions src/com/android/launcher3/DeviceProfile.java
Original file line number Diff line number Diff line change
Expand Up @@ -933,7 +933,12 @@ private void calculateAndSetWorkspaceVerticalPadding(Context context,
private void updateHotseatSizes(int hotseatIconSizePx) {
// Ensure there is enough space for folder icons, which have a slightly larger
// radius.
int iconTextHeight = Utilities.calculateTextHeight(iconTextSizePx);
var isLabelInDock = PreferenceExtensionsKt.firstBlocking(preferenceManager2.getEnableLabelInDock());

hotseatCellHeightPx = getIconSizeWithOverlap(hotseatIconSizePx * 2) - hotseatIconSizePx / 2;
hotseatCellHeightPx += isLabelInDock ? iconTextHeight : 0;
hotseatQsbSpace += isLabelInDock ? iconTextHeight : 0;

var space = Math.abs(hotseatCellHeightPx / 2) - 16;

Expand Down

0 comments on commit bde423b

Please sign in to comment.