From 1f06427266c0cb5de4561fc7c620ff542f625300 Mon Sep 17 00:00:00 2001 From: Winson Date: Mon, 18 Jul 2016 17:18:02 -0700 Subject: Initial changes to tweak layout. - Adding DeviceProfile callback for when the launcher layout changes due to insets. This is necessary since there are now different layouts depending on which side the navigation bar is on - Consolidating hotseat and other layout into the device profile launcher layout logic - Making the all apps icons match the workspace icon height - Tweaking caret drawable to draw to the bounds specified to simplify layout in each orientation - Fixing minor issue with page indicator shifting in landscape - Centering overview buttons to the workspace page Bug: 30021487 Change-Id: I1866bce00b2948f3edd06168c0f88d81207e3f13 --- src/com/android/launcher3/BubbleTextView.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'src/com/android/launcher3/BubbleTextView.java') diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java index 33e4e2a67..00ec4c2ff 100644 --- a/src/com/android/launcher3/BubbleTextView.java +++ b/src/com/android/launcher3/BubbleTextView.java @@ -24,6 +24,7 @@ import android.content.res.Resources.Theme; import android.content.res.TypedArray; import android.graphics.Bitmap; import android.graphics.Canvas; +import android.graphics.Paint; import android.graphics.Region; import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; @@ -66,6 +67,7 @@ public class BubbleTextView extends TextView private final Launcher mLauncher; private Drawable mIcon; + private final boolean mCenterVertically; private final Drawable mBackground; private OnLongClickListener mOnLongClickListener; private final CheckLongPressHelper mLongPressHelper; @@ -119,9 +121,11 @@ public class BubbleTextView extends TextView if (display == DISPLAY_WORKSPACE) { setTextSize(TypedValue.COMPLEX_UNIT_PX, grid.iconTextSizePx); } else if (display == DISPLAY_ALL_APPS) { - setTextSize(TypedValue.COMPLEX_UNIT_SP, grid.allAppsIconTextSizeSp); + setTextSize(TypedValue.COMPLEX_UNIT_PX, grid.allAppsIconTextSizePx); + setCompoundDrawablePadding(grid.allAppsIconDrawablePaddingPx); defaultIconSize = grid.allAppsIconSizePx; } + mCenterVertically = a.getBoolean(R.styleable.BubbleTextView_centerVertically, false); mIconSize = a.getDimensionPixelSize(R.styleable.BubbleTextView_iconSizeOverride, defaultIconSize); @@ -427,6 +431,19 @@ public class BubbleTextView extends TextView mSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop(); } + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + if (mCenterVertically) { + Paint.FontMetrics fm = getPaint().getFontMetrics(); + int cellHeightPx = mIconSize + getCompoundDrawablePadding() + + (int) Math.ceil(fm.bottom - fm.top); + int height = MeasureSpec.getSize(heightMeasureSpec); + setPadding(getPaddingLeft(), (height - cellHeightPx) / 2, getPaddingRight(), + getPaddingBottom()); + } + super.onMeasure(widthMeasureSpec, heightMeasureSpec); + } + @Override protected void onDetachedFromWindow() { super.onDetachedFromWindow(); -- cgit v1.2.3