From 386a7b2c40429d94c718b2bf752a22e417eebe4a Mon Sep 17 00:00:00 2001 From: Stefan Andonian Date: Fri, 14 Mar 2025 23:34:06 -0700 Subject: [PATCH] If Folders would show extremely cropped title, hide title. This is an edge case, not standard behavior. This only happens when the text / display size is at the highest level, and when a folder has 10+ page indicator dots. Bug: 394355070 Test: Verified manually that this works well, and looks great in LTR mode and RTL mode. Flag: com.android.launcher3.enable_launcher_visual_refresh Change-Id: Id31aad47b94d20d9945495366d5381de27282153 --- res/values/dimens.xml | 2 +- src/com/android/launcher3/folder/Folder.java | 26 +++++++++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/res/values/dimens.xml b/res/values/dimens.xml index a15c130076..4d0379d462 100644 --- a/res/values/dimens.xml +++ b/res/values/dimens.xml @@ -315,7 +315,7 @@ 4dp 10dp - + 100dp 9dp 6dp diff --git a/src/com/android/launcher3/folder/Folder.java b/src/com/android/launcher3/folder/Folder.java index 967af053fb..996c5e7f55 100644 --- a/src/com/android/launcher3/folder/Folder.java +++ b/src/com/android/launcher3/folder/Folder.java @@ -18,6 +18,7 @@ package com.android.launcher3.folder; import static android.text.TextUtils.isEmpty; +import static com.android.launcher3.Flags.enableLauncherVisualRefresh; import static com.android.launcher3.LauncherAnimUtils.SPRING_LOADED_EXIT_DELAY; import static com.android.launcher3.LauncherState.EDIT_MODE; import static com.android.launcher3.LauncherState.NORMAL; @@ -299,6 +300,13 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo mContent.setFolder(this); mPageIndicator = findViewById(R.id.folder_page_indicator); + if (enableLauncherVisualRefresh()) { + MarginLayoutParams params = ((MarginLayoutParams) mPageIndicator.getLayoutParams()); + int horizontalMargin = getContext().getResources() + .getDimensionPixelSize(R.dimen.folder_footer_horiz_padding); + params.setMarginStart(horizontalMargin); + params.setMarginEnd(horizontalMargin); + } mFooter = findViewById(R.id.folder_footer); mFooterHeight = dp.folderFooterHeightPx; mFolderName = findViewById(R.id.folder_name); @@ -312,7 +320,6 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo | InputType.TYPE_TEXT_FLAG_CAP_WORDS); mFolderName.forceDisableSuggestions(true); - mKeyboardInsetAnimationCallback = new KeyboardInsetAnimationCallback(this); setWindowInsetsAnimationCallback(mKeyboardInsetAnimationCallback); } @@ -1269,6 +1276,23 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo setMeasuredDimension(folderWidth, folderHeight); } + /** + * If the Folder Title has less than 100dp of available width, we hide it. The reason we do this + * calculation in onSizeChange is because this callback is called 1x when the folder is opened. + *

+ * The PageIndicator and the Folder Title share the same horizontal linear layout, but both + * are dynamically sized. Therefore, we are setting visibility of the folder title AFTER the + * layout is measured. + */ + @Override + protected void onSizeChanged(int w, int h, int oldw, int oldh) { + super.onSizeChanged(w, h, oldw, oldh); + int minTitleWidth = getResources().getDimensionPixelSize(R.dimen.folder_title_min_width); + if (enableLauncherVisualRefresh() && mFolderName.getMeasuredWidth() < minTitleWidth) { + mFolderName.setVisibility(View.GONE); + } + } + /** * Rearranges the children based on their rank. */