diff options
author | Winson <winsonc@google.com> | 2016-07-18 17:18:02 -0700 |
---|---|---|
committer | Winson <winsonc@google.com> | 2016-07-20 10:17:08 -0700 |
commit | 1f06427266c0cb5de4561fc7c620ff542f625300 (patch) | |
tree | 59869923b1a0affd0521eda603a85ccb64bbea53 /src/com/android/launcher3/pageindicators | |
parent | 5b3ace8e56988eb493a3423f9e25b29909fa50bf (diff) | |
download | android_packages_apps_Trebuchet-1f06427266c0cb5de4561fc7c620ff542f625300.tar.gz android_packages_apps_Trebuchet-1f06427266c0cb5de4561fc7c620ff542f625300.tar.bz2 android_packages_apps_Trebuchet-1f06427266c0cb5de4561fc7c620ff542f625300.zip |
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
Diffstat (limited to 'src/com/android/launcher3/pageindicators')
3 files changed, 31 insertions, 26 deletions
diff --git a/src/com/android/launcher3/pageindicators/CaretDrawable.java b/src/com/android/launcher3/pageindicators/CaretDrawable.java index 8971323ba..e5d128e24 100644 --- a/src/com/android/launcher3/pageindicators/CaretDrawable.java +++ b/src/com/android/launcher3/pageindicators/CaretDrawable.java @@ -36,7 +36,6 @@ public class CaretDrawable extends Drawable { private Paint mPaint = new Paint(); private Path mPath = new Path(); - private int mInset; public CaretDrawable(Context context) { final Resources res = context.getResources(); @@ -47,8 +46,6 @@ public class CaretDrawable extends Drawable { mPaint.setStyle(Paint.Style.STROKE); mPaint.setStrokeCap(Paint.Cap.SQUARE); mPaint.setStrokeJoin(Paint.Join.MITER); - - mInset = res.getDimensionPixelSize(R.dimen.all_apps_caret_inset); } @Override @@ -57,10 +54,10 @@ public class CaretDrawable extends Drawable { return; } - final float width = getBounds().width(); - final float height = getBounds().height(); - final float left = getBounds().left; - final float top = getBounds().top; + final float width = getBounds().width() - mPaint.getStrokeWidth(); + final float height = getBounds().height() - mPaint.getStrokeWidth(); + final float left = getBounds().left + (mPaint.getStrokeWidth() / 2); + final float top = getBounds().top + (mPaint.getStrokeWidth() / 2); final float verticalInset = (height / 4); final float caretHeight = (height - (verticalInset * 2)); @@ -95,9 +92,4 @@ public class CaretDrawable extends Drawable { public void setColorFilter(ColorFilter cf) { // no-op } - - @Override - public void setBounds(int left, int top, int right, int bottom) { - super.setBounds(left + mInset, top + mInset, right - mInset, bottom - mInset); - } } diff --git a/src/com/android/launcher3/pageindicators/PageIndicatorCaretLandscape.java b/src/com/android/launcher3/pageindicators/PageIndicatorCaretLandscape.java index 807520183..1eee59e0c 100644 --- a/src/com/android/launcher3/pageindicators/PageIndicatorCaretLandscape.java +++ b/src/com/android/launcher3/pageindicators/PageIndicatorCaretLandscape.java @@ -16,13 +16,19 @@ package com.android.launcher3.pageindicators; import android.content.Context; +import android.content.res.Resources; import android.graphics.Canvas; +import android.graphics.Paint; +import android.graphics.Rect; import android.util.AttributeSet; import com.android.launcher3.Launcher; +import com.android.launcher3.R; /** - * Simply draws the caret drawable in the center. Used for the landscape layout. + * Simply draws the caret drawable bottom-right aligned in the view. This ensures that we can have + * a view with as large an area as we want (for touching) while maintaining a caret of size + * all_apps_caret_size. Used only for the landscape layout. */ public class PageIndicatorCaretLandscape extends PageIndicator { // all apps pull up handle drawable. @@ -38,7 +44,11 @@ public class PageIndicatorCaretLandscape extends PageIndicator { public PageIndicatorCaretLandscape(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); - setCaretDrawable(new CaretDrawable(context)); + int caretSize = context.getResources().getDimensionPixelSize(R.dimen.all_apps_caret_size); + CaretDrawable caretDrawable = new CaretDrawable(context); + caretDrawable.setBounds(0, 0, caretSize, caretSize); + setCaretDrawable(caretDrawable); + Launcher l = (Launcher) context; setOnTouchListener(l.getHapticFeedbackTouchListener()); setOnClickListener(l); @@ -46,15 +56,12 @@ public class PageIndicatorCaretLandscape extends PageIndicator { } @Override - protected void onLayout(boolean changed, int left, int top, int right, int bottom) { - super.onLayout(changed, left, top, right, bottom); - int size = bottom - top; - int l = (right - left) / 2 - size / 2; - getCaretDrawable().setBounds(l, 0, l + size, size); - } - - @Override protected void onDraw(Canvas canvas) { + Rect drawableBounds = getCaretDrawable().getBounds(); + int count = canvas.save(); + canvas.translate(getWidth() - drawableBounds.width(), + getHeight() - drawableBounds.height()); getCaretDrawable().draw(canvas); + canvas.restoreToCount(count); } } diff --git a/src/com/android/launcher3/pageindicators/PageIndicatorLineCaret.java b/src/com/android/launcher3/pageindicators/PageIndicatorLineCaret.java index f18c7994b..45df3690f 100644 --- a/src/com/android/launcher3/pageindicators/PageIndicatorLineCaret.java +++ b/src/com/android/launcher3/pageindicators/PageIndicatorLineCaret.java @@ -63,6 +63,8 @@ public class PageIndicatorLineCaret extends PageIndicator { private final int mLineHeight; private final Rect mTouchHitRect = new Rect(); private final int mTouchExtensionHeight; + private final int mCaretSizePx; + private final int mCaretWorkspaceOffsetPx; private static final Property<PageIndicatorLineCaret, Integer> PAINT_ALPHA = new Property<PageIndicatorLineCaret, Integer>(Integer.class, "paint_alpha") { @@ -123,14 +125,18 @@ public class PageIndicatorLineCaret extends PageIndicator { public PageIndicatorLineCaret(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); + + Resources res = context.getResources(); mLinePaint = new Paint(); mLinePaint.setAlpha(0); + mCaretSizePx = res.getDimensionPixelSize(R.dimen.all_apps_caret_size); + mCaretWorkspaceOffsetPx = res.getDimensionPixelSize( + R.dimen.all_apps_caret_workspace_offset); mLauncher = (Launcher) context; setOnTouchListener(mLauncher.getHapticFeedbackTouchListener()); setOnClickListener(mLauncher); setOnFocusChangeListener(mLauncher.mFocusHandler); - Resources res = context.getResources(); setCaretDrawable(new CaretDrawable(context)); mLineHeight = res.getDimensionPixelSize(R.dimen.dynamic_grid_page_indicator_line_height); mTouchExtensionHeight = res.getDimensionPixelSize( @@ -140,9 +146,9 @@ public class PageIndicatorLineCaret extends PageIndicator { @Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { super.onLayout(changed, left, top, right, bottom); - int size = bottom - top; - int l = (right - left) / 2 - size / 2; - getCaretDrawable().setBounds(l, 0, l + size, size); + // Top/center align the caret in the page indicator space + int l = (right - left) / 2 - mCaretSizePx / 2; + getCaretDrawable().setBounds(l, mCaretWorkspaceOffsetPx, l + mCaretSizePx, mCaretSizePx); // The touch area is expanded below this view by #mTouchExtensionHeight // which extends to the top of the hotseat. |