Align workspace and hotseat icons in landscape

Fix: 311381639
Test: Verified on device
Flag: NONE
Change-Id: I4e2c74f59e8492042c3c7f8eccc98921d92d685f
This commit is contained in:
fbaron
2024-01-29 10:35:17 -08:00
committed by Federico Baron
parent ac7c1e3736
commit fc6bbcfed2
5 changed files with 27 additions and 19 deletions
@@ -29,6 +29,7 @@ import android.animation.AnimatorListenerAdapter;
import android.animation.ObjectAnimator;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
@@ -633,6 +634,20 @@ public class FolderIcon extends FrameLayout implements FolderListener, IconLabel
}
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
boolean shouldCenterIcon = mActivity.getDeviceProfile().iconCenterVertically;
if (shouldCenterIcon) {
int iconSize = mActivity.getDeviceProfile().iconSizePx;
Paint.FontMetrics fm = mFolderName.getPaint().getFontMetrics();
int cellHeightPx = iconSize + mFolderName.getCompoundDrawablePadding()
+ (int) Math.ceil(fm.bottom - fm.top);
setPadding(getPaddingLeft(), (MeasureSpec.getSize(heightMeasureSpec)
- cellHeightPx) / 2, getPaddingRight(), getPaddingBottom());
}
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
/** Sets the visibility of the icon's title text */
public void setTextVisible(boolean visible) {
if (visible) {