Skip to content

Commit

Permalink
Fix alignment of app drawer folders when multiline app names enabled (L…
Browse files Browse the repository at this point in the history
…awnchairLauncher#1833)

* Fix alignment of app drawer folders when multiline app names enabled

The FolderIcon container's height is already set to allAppsCellHeightPx
in AllAppsGridAdapter, so use match_parent to set the correct height on
the FolderIcon. Then vertically align by matching BubbleTextView's
onMeasure implementation.

* Only adjust padding of folders in the app drawer
  • Loading branch information
Shingyx authored and suphon-t committed Dec 2, 2019
1 parent e02faab commit 29a1f92
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lawnchair/res/layout/all_apps_folder_icon.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/folder_icon"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center"
android:orientation="vertical"
android:paddingLeft="@dimen/dynamic_grid_cell_padding_x"
Expand Down
22 changes: 17 additions & 5 deletions src/com/android/launcher3/folder/FolderIcon.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,20 @@
import android.animation.ObjectAnimator;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.os.Parcelable;
import android.support.annotation.NonNull;
import android.util.AttributeSet;
import android.util.Log;
import android.util.Property;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.ViewGroup;
import android.widget.FrameLayout;

import ch.deletescape.lawnchair.LawnchairLauncher;
import ch.deletescape.lawnchair.LawnchairUtilsKt;
import ch.deletescape.lawnchair.gestures.BlankGestureHandler;
Expand All @@ -56,7 +54,6 @@
import com.android.launcher3.DropTarget.DragObject;
import com.android.launcher3.FolderInfo;
import com.android.launcher3.FolderInfo.FolderListener;
import com.android.launcher3.IconCache.ItemInfoUpdateReceiver;
import com.android.launcher3.ItemInfo;
import com.android.launcher3.ItemInfoWithIcon;
import com.android.launcher3.Launcher;
Expand All @@ -81,7 +78,6 @@
import com.android.launcher3.util.PackageUserKey;
import com.android.launcher3.util.Thunk;
import com.android.launcher3.widget.PendingAddShortcutInfo;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;
Expand Down Expand Up @@ -657,6 +653,22 @@ protected boolean verifyDrawable(@NonNull Drawable who) {
return mPreviewItemManager.verifyDrawable(who) || super.verifyDrawable(who);
}

@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
if (!mInfo.useIconMode(mLauncher) && isInAppDrawer()) {
DeviceProfile grid = mLauncher.getDeviceProfile();
int drawablePadding = grid.allAppsIconDrawablePaddingPx;

Paint.FontMetrics fm = mFolderName.getPaint().getFontMetrics();
int cellHeightPx = mFolderName.getIconSize() + drawablePadding +
(int) Math.ceil(fm.bottom - fm.top);
int height = MeasureSpec.getSize(heightMeasureSpec);
setPadding(getPaddingLeft(), (height - cellHeightPx) / 2, getPaddingRight(),
getPaddingBottom());
}
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}

@Override
public void onItemsChanged(boolean animate) {
if (mInfo.isCoverMode()) {
Expand Down

0 comments on commit 29a1f92

Please sign in to comment.