Fix cropped folder name text in arabic
Centralize the folder name within folder footer using gravity property
instead of adding padding to the folder name view. Padding as calculated
was cropping the folder name to the text line height, which was
insuficient in some cases, as eveidenced by the linked bug.
Bug: b/358006967
Test: Open a folder on home screen with arabic system language.
Verify that the folder name displays correctly.
Flag: EXEMPT bugfix
Change-Id: I4436c224f7f6541f447e3a5354ff870cf4d50698
diff --git a/res/layout/user_folder_icon_normalized.xml b/res/layout/user_folder_icon_normalized.xml
index 43a8aac..002e7b7 100644
--- a/res/layout/user_folder_icon_normalized.xml
+++ b/res/layout/user_folder_icon_normalized.xml
@@ -40,12 +40,11 @@
<com.android.launcher3.folder.FolderNameEditText
android:id="@+id/folder_name"
android:layout_width="0dp"
- android:layout_height="wrap_content"
- android:layout_gravity="center_vertical"
+ android:layout_height="match_parent"
style="@style/TextHeadline"
android:layout_weight="1"
android:background="@android:color/transparent"
- android:gravity="center_horizontal"
+ android:gravity="center"
android:hint="@string/folder_hint_text"
android:imeOptions="flagNoExtractUi"
android:importantForAutofill="no"
diff --git a/src/com/android/launcher3/folder/Folder.java b/src/com/android/launcher3/folder/Folder.java
index 7bec768..5defef3 100644
--- a/src/com/android/launcher3/folder/Folder.java
+++ b/src/com/android/launcher3/folder/Folder.java
@@ -317,10 +317,7 @@
| InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS
| InputType.TYPE_TEXT_FLAG_CAP_WORDS);
mFolderName.forceDisableSuggestions(true);
- mFolderName.setPadding(mFolderName.getPaddingLeft(),
- (getFooterHeight() - mFolderName.getLineHeight()) / 2,
- mFolderName.getPaddingRight(),
- (getFooterHeight() - mFolderName.getLineHeight()) / 2);
+
mKeyboardInsetAnimationCallback = new KeyboardInsetAnimationCallback(this);
setWindowInsetsAnimationCallback(mKeyboardInsetAnimationCallback);
diff --git a/src/com/android/launcher3/folder/FolderPagedView.java b/src/com/android/launcher3/folder/FolderPagedView.java
index 9dc2d24..fe26194 100644
--- a/src/com/android/launcher3/folder/FolderPagedView.java
+++ b/src/com/android/launcher3/folder/FolderPagedView.java
@@ -373,8 +373,9 @@
// Update footer
mPageIndicator.setVisibility(getPageCount() > 1 ? View.VISIBLE : View.GONE);
// Set the gravity as LEFT or RIGHT instead of START, as START depends on the actual text.
- mFolder.getFolderName().setGravity(getPageCount() > 1
- ? (mIsRtl ? Gravity.RIGHT : Gravity.LEFT) : Gravity.CENTER_HORIZONTAL);
+ int horizontalGravity = getPageCount() > 1
+ ? (mIsRtl ? Gravity.RIGHT : Gravity.LEFT) : Gravity.CENTER_HORIZONTAL;
+ mFolder.getFolderName().setGravity(horizontalGravity | Gravity.CENTER_VERTICAL);
}
public int getDesiredWidth() {