summaryrefslogtreecommitdiffstats
path: root/src/com
diff options
context:
space:
mode:
Diffstat (limited to 'src/com')
-rw-r--r--src/com/android/launcher3/DeviceProfile.java32
-rw-r--r--src/com/android/launcher3/Utilities.java24
-rw-r--r--src/com/android/launcher3/allapps/AllAppsContainerView.java31
-rw-r--r--src/com/android/launcher3/allapps/AllAppsRecyclerView.java24
-rw-r--r--src/com/android/launcher3/allapps/AllAppsTransitionController.java9
-rw-r--r--src/com/android/launcher3/folder/FolderAnimationManager.java9
-rw-r--r--src/com/android/launcher3/folder/FolderIcon.java2
-rw-r--r--src/com/android/launcher3/folder/PreviewItemManager.java9
-rw-r--r--src/com/android/launcher3/graphics/GradientView.java87
-rw-r--r--src/com/android/launcher3/graphics/ScrimView.java115
-rw-r--r--src/com/android/launcher3/popup/PopupContainerWithArrow.java9
-rw-r--r--src/com/android/launcher3/widget/WidgetsBottomSheet.java4
12 files changed, 122 insertions, 233 deletions
diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java
index cb4ad55c7..031bfe115 100644
--- a/src/com/android/launcher3/DeviceProfile.java
+++ b/src/com/android/launcher3/DeviceProfile.java
@@ -63,6 +63,8 @@ public class DeviceProfile {
*/
private static final float MAX_HORIZONTAL_PADDING_PERCENT = 0.14f;
+ private static final float TALL_DEVICE_ASPECT_RATIO_THRESHOLD = 1.82f;
+
// Overview mode
private final int overviewModeMinIconZoneHeightPx;
private final int overviewModeMaxIconZoneHeightPx;
@@ -108,7 +110,6 @@ public class DeviceProfile {
public int folderChildIconSizePx;
public int folderChildTextSizePx;
public int folderChildDrawablePaddingPx;
- public final int folderChildDrawablePaddingOriginalPx;
// Hotseat
public int hotseatCellHeightPx;
@@ -174,7 +175,8 @@ public class DeviceProfile {
defaultWidgetPadding = AppWidgetHostView.getDefaultPaddingForWidget(context, cn, null);
edgeMarginPx = res.getDimensionPixelSize(R.dimen.dynamic_grid_edge_margin);
desiredWorkspaceLeftRightMarginPx = isVerticalBarLayout() ? 0 : edgeMarginPx;
- cellLayoutPaddingLeftRightPx = isVerticalBarLayout() ? 0 : edgeMarginPx;
+ cellLayoutPaddingLeftRightPx =
+ res.getDimensionPixelSize(R.dimen.dynamic_grid_cell_layout_padding);
pageIndicatorSizePx = res.getDimensionPixelSize(
R.dimen.dynamic_grid_min_page_indicator_size);
pageIndicatorLandGutterPx = res.getDimensionPixelSize(
@@ -221,9 +223,6 @@ public class DeviceProfile {
hotseatLandRightNavBarGutterPx = res.getDimensionPixelSize(
R.dimen.dynamic_grid_hotseat_land_right_nav_bar_gutter_width);
- folderChildDrawablePaddingOriginalPx =
- res.getDimensionPixelSize(R.dimen.folder_child_icon_drawable_padding);
-
// Determine sizes.
widthPx = width;
heightPx = height;
@@ -239,17 +238,18 @@ public class DeviceProfile {
updateAvailableDimensions(dm, res);
// Now that we have all of the variables calculated, we can tune certain sizes.
- if (!isVerticalBarLayout()) {
+ float aspectRatio = ((float) Math.max(availableWidthPx, availableHeightPx))
+ / Math.min(availableWidthPx, availableHeightPx);
+ boolean isTallDevice = Float.compare(aspectRatio, TALL_DEVICE_ASPECT_RATIO_THRESHOLD) >= 0;
+ if (!isVerticalBarLayout() && isPhone && isTallDevice) {
// We increase the page indicator size when there is extra space.
// ie. For a display with a large aspect ratio, we can keep the icons on the workspace
// in portrait mode closer together by increasing the page indicator size.
- int newPageIndicatorSizePx = getCellSize().y - iconSizePx - iconTextSizePx
- - iconDrawablePaddingOriginalPx;
- if (newPageIndicatorSizePx > pageIndicatorSizePx) {
- pageIndicatorSizePx = newPageIndicatorSizePx;
- // Recalculate the available dimensions using the new page indicator size.
- updateAvailableDimensions(dm, res);
- }
+ // Note: This calculation was created after noticing a pattern in the design spec.
+ pageIndicatorSizePx = getCellSize().y - iconSizePx - iconDrawablePaddingPx;
+
+ // Recalculate the available dimensions using the new page indicator size.
+ updateAvailableDimensions(dm, res);
}
computeAllAppsButtonSize(context);
@@ -403,15 +403,15 @@ public class DeviceProfile {
folderChildIconSizePx = (int) (Utilities.pxFromDp(inv.iconSize, dm) * scale);
folderChildTextSizePx =
(int) (res.getDimensionPixelSize(R.dimen.folder_child_text_size) * scale);
- folderChildDrawablePaddingPx = (int) (folderChildDrawablePaddingOriginalPx * scale);
int textHeight = Utilities.calculateTextHeight(folderChildTextSizePx);
int cellPaddingX = (int) (res.getDimensionPixelSize(R.dimen.folder_cell_x_padding) * scale);
int cellPaddingY = (int) (res.getDimensionPixelSize(R.dimen.folder_cell_y_padding) * scale);
folderCellWidthPx = folderChildIconSizePx + 2 * cellPaddingX;
- folderCellHeightPx = folderChildIconSizePx + 2 * cellPaddingY + textHeight
- + folderChildDrawablePaddingPx;
+ folderCellHeightPx = folderChildIconSizePx + 2 * cellPaddingY + textHeight;
+ folderChildDrawablePaddingPx = Math.max(0,
+ (folderCellHeightPx - folderChildIconSizePx - textHeight) / 3);
}
public void updateInsets(Rect insets) {
diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java
index 9100fe28d..3aa2db000 100644
--- a/src/com/android/launcher3/Utilities.java
+++ b/src/com/android/launcher3/Utilities.java
@@ -28,7 +28,6 @@ import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.ResolveInfo;
import android.content.res.Resources;
import android.graphics.Bitmap;
-import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Matrix;
import android.graphics.Paint;
@@ -654,27 +653,4 @@ public final class Utilities {
return hashSet;
}
- /**
- * @return creates a new alpha mask bitmap out of an existing bitmap
- */
- public static Bitmap convertToAlphaMask(Bitmap b, int applyAlpha) {
- Bitmap a = Bitmap.createBitmap(b.getWidth(), b.getHeight(), Bitmap.Config.ALPHA_8);
- Canvas c = new Canvas(a);
- Paint paint = new Paint();
- paint.setAlpha(applyAlpha);
- c.drawBitmap(b, 0f, 0f, paint);
- return a;
- }
-
- /**
- * @return a new white 1x1 bitmap with ALPHA_8
- */
- public static Bitmap createOnePixBitmap() {
- Bitmap a = Bitmap.createBitmap(1, 1, Bitmap.Config.ALPHA_8);
- Canvas c = new Canvas(a);
- Paint paint = new Paint();
- paint.setColor(Color.WHITE);
- c.drawPaint(paint);
- return a;
- }
}
diff --git a/src/com/android/launcher3/allapps/AllAppsContainerView.java b/src/com/android/launcher3/allapps/AllAppsContainerView.java
index 20951921c..0083d47f2 100644
--- a/src/com/android/launcher3/allapps/AllAppsContainerView.java
+++ b/src/com/android/launcher3/allapps/AllAppsContainerView.java
@@ -21,7 +21,6 @@ import android.graphics.Rect;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.InsetDrawable;
import android.support.v7.widget.LinearLayoutManager;
-import android.support.v7.widget.RecyclerView;
import android.text.Selection;
import android.text.SpannableStringBuilder;
import android.util.AttributeSet;
@@ -227,7 +226,6 @@ public class AllAppsContainerView extends BaseContainerView implements DragSourc
mAppsRecyclerView.setHasFixedSize(true);
if (FeatureFlags.LAUNCHER3_PHYSICS) {
mAppsRecyclerView.setSpringAnimationHandler(mSpringAnimationHandler);
- mAppsRecyclerView.addOnScrollListener(new SpringMotionOnScrollListener());
}
mSearchContainer = findViewById(R.id.search_container_all_apps);
@@ -403,33 +401,4 @@ public class AllAppsContainerView extends BaseContainerView implements DragSourc
public SpringAnimationHandler getSpringAnimationHandler() {
return mSpringAnimationHandler;
}
-
- public class SpringMotionOnScrollListener extends RecyclerView.OnScrollListener {
-
- private int mScrollState = RecyclerView.SCROLL_STATE_IDLE;
-
- @Override
- public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
- if (mScrollState == RecyclerView.SCROLL_STATE_DRAGGING || (dx == 0 && dy == 0)) {
- if (mSpringAnimationHandler.isRunning()){
- mSpringAnimationHandler.skipToEnd();
- }
- return;
- }
-
- // We only start the spring animation when we fling and hit the top/bottom, to ensure
- // that all of the animations start at the same time.
- if (dy < 0 && !mAppsRecyclerView.canScrollVertically(-1)) {
- mSpringAnimationHandler.animateToFinalPosition(0, 1);
- } else if (dy > 0 && !mAppsRecyclerView.canScrollVertically(1)) {
- mSpringAnimationHandler.animateToFinalPosition(0, -1);
- }
- }
-
- @Override
- public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
- super.onScrollStateChanged(recyclerView, newState);
- mScrollState = newState;
- }
- }
}
diff --git a/src/com/android/launcher3/allapps/AllAppsRecyclerView.java b/src/com/android/launcher3/allapps/AllAppsRecyclerView.java
index 25144584e..701402b02 100644
--- a/src/com/android/launcher3/allapps/AllAppsRecyclerView.java
+++ b/src/com/android/launcher3/allapps/AllAppsRecyclerView.java
@@ -103,7 +103,10 @@ public class AllAppsRecyclerView extends BaseRecyclerView implements LogContaine
}
public void setSpringAnimationHandler(SpringAnimationHandler springAnimationHandler) {
- mSpringAnimationHandler = springAnimationHandler;
+ if (FeatureFlags.LAUNCHER3_PHYSICS) {
+ mSpringAnimationHandler = springAnimationHandler;
+ addOnScrollListener(new SpringMotionOnScrollListener());
+ }
}
@Override
@@ -485,6 +488,25 @@ public class AllAppsRecyclerView extends BaseRecyclerView implements LogContaine
y + mEmptySearchBackground.getIntrinsicHeight());
}
+ private class SpringMotionOnScrollListener extends RecyclerView.OnScrollListener {
+
+ @Override
+ public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
+ if (mOverScrollHelper.isInOverScroll()) {
+ // OverScroll will handle animating the springs.
+ return;
+ }
+
+ // We only start the spring animation when we hit the top/bottom, to ensure
+ // that all of the animations start at the same time.
+ if (dy < 0 && !canScrollVertically(-1)) {
+ mSpringAnimationHandler.animateToFinalPosition(0, 1);
+ } else if (dy > 0 && !canScrollVertically(1)) {
+ mSpringAnimationHandler.animateToFinalPosition(0, -1);
+ }
+ }
+ }
+
private class OverScrollHelper implements VerticalPullDetector.Listener {
private static final float MAX_RELEASE_VELOCITY = 5000; // px / s
diff --git a/src/com/android/launcher3/allapps/AllAppsTransitionController.java b/src/com/android/launcher3/allapps/AllAppsTransitionController.java
index 0859e0658..44e0a0474 100644
--- a/src/com/android/launcher3/allapps/AllAppsTransitionController.java
+++ b/src/com/android/launcher3/allapps/AllAppsTransitionController.java
@@ -25,7 +25,6 @@ import com.android.launcher3.Workspace;
import com.android.launcher3.anim.SpringAnimationHandler;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.graphics.GradientView;
-import com.android.launcher3.graphics.ScrimView;
import com.android.launcher3.userevent.nano.LauncherLogProto.Action;
import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType;
import com.android.launcher3.util.SystemUiController;
@@ -100,7 +99,6 @@ public class AllAppsTransitionController implements TouchController, VerticalPul
private boolean mIsTranslateWithoutWorkspace = false;
private AnimatorSet mDiscoBounceAnimation;
private GradientView mGradientView;
- private ScrimView mScrimView;
private SpringAnimationHandler mSpringAnimationHandler;
@@ -302,13 +300,6 @@ public class AllAppsTransitionController implements TouchController, VerticalPul
mGradientView.setVisibility(View.VISIBLE);
}
mGradientView.setProgress(progress);
-
- // scrim
- if (mScrimView == null) {
- mScrimView = (ScrimView) mLauncher.findViewById(R.id.scrim_bg);
- mScrimView.setVisibility(View.VISIBLE);
- }
- mScrimView.setProgress(progress);
}
/**
diff --git a/src/com/android/launcher3/folder/FolderAnimationManager.java b/src/com/android/launcher3/folder/FolderAnimationManager.java
index d7f5c2b64..69705d594 100644
--- a/src/com/android/launcher3/folder/FolderAnimationManager.java
+++ b/src/com/android/launcher3/folder/FolderAnimationManager.java
@@ -120,7 +120,6 @@ public class FolderAnimationManager {
final DragLayer.LayoutParams lp = (DragLayer.LayoutParams) mFolder.getLayoutParams();
FolderIcon.PreviewLayoutRule rule = mFolderIcon.getLayoutRule();
final List<BubbleTextView> itemsInPreview = mFolderIcon.getPreviewItems();
- BubbleTextView btv = itemsInPreview.get(0);
// Match position of the FolderIcon
final Rect folderIconPos = new Rect();
@@ -132,7 +131,7 @@ public class FolderAnimationManager {
// Match size/scale of icons in the preview
float previewScale = rule.scaleForItem(0, itemsInPreview.size());
float previewSize = rule.getIconSize() * previewScale;
- float initialScale = previewSize / btv.getIconSize()
+ float initialScale = previewSize / itemsInPreview.get(0).getIconSize()
* scaleRelativeToDragLayer;
final float finalScale = 1f;
float scale = mIsOpening ? initialScale : finalScale;
@@ -149,12 +148,10 @@ public class FolderAnimationManager {
previewItemOffsetX = (int) (lp.width * initialScale - initialSize - previewItemOffsetX);
}
- // Note that we do not include btv.getPaddingLeft() in the calculation, since it is
- // handled in addPreviewItemAnimators as part of iconOffsetX.
final int paddingOffsetX = (int) ((mFolder.getPaddingLeft() + mContent.getPaddingLeft())
* initialScale);
- final int paddingOffsetY = (int) ((mFolder.getPaddingTop() + mContent.getPaddingTop()
- + btv.getPaddingTop()) * initialScale);
+ final int paddingOffsetY = (int) ((mFolder.getPaddingTop() + mContent.getPaddingTop())
+ * initialScale);
int initialX = folderIconPos.left + mPreviewBackground.getOffsetX() - paddingOffsetX
- previewItemOffsetX;
diff --git a/src/com/android/launcher3/folder/FolderIcon.java b/src/com/android/launcher3/folder/FolderIcon.java
index c63eeb345..84ec18410 100644
--- a/src/com/android/launcher3/folder/FolderIcon.java
+++ b/src/com/android/launcher3/folder/FolderIcon.java
@@ -446,6 +446,8 @@ public class FolderIcon extends FrameLayout implements FolderListener {
if (!mBackgroundIsVisible) return;
+ mPreviewItemManager.recomputePreviewDrawingParams();
+
if (!mBackground.drawingDelegated()) {
mBackground.drawBackground(canvas);
}
diff --git a/src/com/android/launcher3/folder/PreviewItemManager.java b/src/com/android/launcher3/folder/PreviewItemManager.java
index bb2320774..2ecb54ca8 100644
--- a/src/com/android/launcher3/folder/PreviewItemManager.java
+++ b/src/com/android/launcher3/folder/PreviewItemManager.java
@@ -90,8 +90,11 @@ public class PreviewItemManager {
return animateDrawable;
}
- private void computePreviewDrawingParams(Drawable d) {
- computePreviewDrawingParams(d.getIntrinsicWidth(), mIcon.getMeasuredWidth());
+ public void recomputePreviewDrawingParams() {
+ if (mReferenceDrawable != null) {
+ computePreviewDrawingParams(mReferenceDrawable.getIntrinsicWidth(),
+ mIcon.getMeasuredWidth());
+ }
}
private void computePreviewDrawingParams(int drawableSize, int totalSize) {
@@ -143,8 +146,6 @@ public class PreviewItemManager {
}
public void draw(Canvas canvas) {
- computePreviewDrawingParams(mReferenceDrawable);
-
float firstPageItemsTransX = 0;
if (mShouldSlideInFirstPage) {
drawParams(canvas, mCurrentPageParams, mCurrentPageItemsTransX);
diff --git a/src/com/android/launcher3/graphics/GradientView.java b/src/com/android/launcher3/graphics/GradientView.java
index 9dd950454..678396df1 100644
--- a/src/com/android/launcher3/graphics/GradientView.java
+++ b/src/com/android/launcher3/graphics/GradientView.java
@@ -18,13 +18,14 @@ package com.android.launcher3.graphics;
import android.content.Context;
import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
+import android.graphics.LinearGradient;
import android.graphics.Paint;
import android.graphics.RadialGradient;
import android.graphics.RectF;
import android.graphics.Shader;
+import android.support.v4.graphics.ColorUtils;
import android.util.AttributeSet;
import android.view.View;
import android.view.animation.AccelerateInterpolator;
@@ -34,6 +35,7 @@ import com.android.launcher3.Launcher;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.dynamicui.WallpaperColorInfo;
+import com.android.launcher3.util.Themes;
/**
* Draws a translucent radial gradient background from an initial state with progress 0.0 to a
@@ -42,44 +44,44 @@ import com.android.launcher3.dynamicui.WallpaperColorInfo;
public class GradientView extends View implements WallpaperColorInfo.OnChangeListener {
private static final int DEFAULT_COLOR = Color.WHITE;
- private static final float GRADIENT_ALPHA_MASK_LENGTH_DP = 300;
+ private static final int ALPHA_MASK_HEIGHT_DP = 500;
+ private static final int ALPHA_MASK_WIDTH_DP = 2;
+ private static final int ALPHA_COLORS = 0xBF;
private static final boolean DEBUG = false;
- private final Bitmap mFinalGradientMask;
private final Bitmap mAlphaGradientMask;
+ private boolean mShowScrim = true;
private int mColor1 = DEFAULT_COLOR;
private int mColor2 = DEFAULT_COLOR;
private int mWidth;
private int mHeight;
private final RectF mAlphaMaskRect = new RectF();
private final RectF mFinalMaskRect = new RectF();
- private final Paint mPaint = new Paint();
+ private final Paint mPaintWithScrim = new Paint();
+ private final Paint mPaintNoScrim = new Paint();
private float mProgress;
- private final int mMaskHeight;
+ private final int mMaskHeight, mMaskWidth;
private final Context mAppContext;
private final Paint mDebugPaint = DEBUG ? new Paint() : null;
private final Interpolator mAccelerator = new AccelerateInterpolator();
private final float mAlphaStart;
private final WallpaperColorInfo mWallpaperColorInfo;
+ private final int mScrimColor;
public GradientView(Context context, AttributeSet attrs) {
super(context, attrs);
this.mAppContext = context.getApplicationContext();
- this.mMaskHeight = Utilities.pxFromDp(GRADIENT_ALPHA_MASK_LENGTH_DP,
+ this.mMaskHeight = Utilities.pxFromDp(ALPHA_MASK_HEIGHT_DP,
+ mAppContext.getResources().getDisplayMetrics());
+ this.mMaskWidth = Utilities.pxFromDp(ALPHA_MASK_WIDTH_DP,
mAppContext.getResources().getDisplayMetrics());
Launcher launcher = Launcher.getLauncher(context);
this.mAlphaStart = launcher.getDeviceProfile().isVerticalBarLayout() ? 0 : 100;
+ this.mScrimColor = Themes.getAttrColor(context, R.attr.allAppsScrimColor);
this.mWallpaperColorInfo = WallpaperColorInfo.getInstance(launcher);
updateColors();
-
- int finalAlpha = 0xBF;
- mFinalGradientMask = Utilities.convertToAlphaMask(
- Utilities.createOnePixBitmap(), finalAlpha);
- Bitmap alphaMaskFromResource = BitmapFactory.decodeResource(context.getResources(),
- R.drawable.all_apps_alpha_mask);
- mAlphaGradientMask = Utilities.convertToAlphaMask(
- alphaMaskFromResource, finalAlpha);
+ mAlphaGradientMask = createDitheredAlphaMask();
}
@Override
@@ -101,8 +103,10 @@ public class GradientView extends View implements WallpaperColorInfo.OnChangeLis
}
private void updateColors() {
- this.mColor1 = mWallpaperColorInfo.getMainColor();
- this.mColor2 = mWallpaperColorInfo.getSecondaryColor();
+ this.mColor1 = ColorUtils.setAlphaComponent(mWallpaperColorInfo.getMainColor(),
+ ALPHA_COLORS);
+ this.mColor2 = ColorUtils.setAlphaComponent(mWallpaperColorInfo.getSecondaryColor(),
+ ALPHA_COLORS);
if (mWidth + mHeight > 0) {
createRadialShader();
}
@@ -122,34 +126,53 @@ public class GradientView extends View implements WallpaperColorInfo.OnChangeLis
private void createRadialShader() {
final float gradientCenterY = 1.05f;
float radius = Math.max(mHeight, mWidth) * gradientCenterY;
-
float posScreenBottom = (radius - mHeight) / radius; // center lives below screen
- RadialGradient shader = new RadialGradient(
+
+ RadialGradient shaderNoScrim = new RadialGradient(
mWidth * 0.5f,
mHeight * gradientCenterY,
radius,
new int[] {mColor1, mColor1, mColor2},
new float[] {0f, posScreenBottom, 1f},
Shader.TileMode.CLAMP);
- mPaint.setShader(shader);
+ mPaintNoScrim.setShader(shaderNoScrim);
+
+ int color1 = ColorUtils.compositeColors(mScrimColor,mColor1);
+ int color2 = ColorUtils.compositeColors(mScrimColor,mColor2);
+ RadialGradient shaderWithScrim = new RadialGradient(
+ mWidth * 0.5f,
+ mHeight * gradientCenterY,
+ radius,
+ new int[] { color1, color1, color2 },
+ new float[] {0f, posScreenBottom, 1f},
+ Shader.TileMode.CLAMP);
+ mPaintWithScrim.setShader(shaderWithScrim);
}
public void setProgress(float progress) {
+ setProgress(progress, true);
+ }
+
+ public void setProgress(float progress, boolean showScrim) {
this.mProgress = progress;
+ this.mShowScrim = showScrim;
invalidate();
}
@Override
protected void onDraw(Canvas canvas) {
+ Paint paint = mShowScrim ? mPaintWithScrim : mPaintNoScrim;
+
float head = 0.29f;
float linearProgress = head + (mProgress * (1f - head));
float startMaskY = (1f - linearProgress) * mHeight - mMaskHeight * linearProgress;
float interpolatedAlpha = (255 - mAlphaStart) * mAccelerator.getInterpolation(mProgress);
- mPaint.setAlpha((int) (mAlphaStart + interpolatedAlpha));
- mAlphaMaskRect.set(0, startMaskY, mWidth, startMaskY + mMaskHeight);
- mFinalMaskRect.set(0, startMaskY + mMaskHeight, mWidth, mHeight);
- canvas.drawBitmap(mAlphaGradientMask, null, mAlphaMaskRect, mPaint);
- canvas.drawBitmap(mFinalGradientMask, null, mFinalMaskRect, mPaint);
+ paint.setAlpha((int) (mAlphaStart + interpolatedAlpha));
+ float div = (float) Math.floor(startMaskY + mMaskHeight);
+ mAlphaMaskRect.set(0, startMaskY, mWidth, div);
+ mFinalMaskRect.set(0, div, mWidth, mHeight);
+ canvas.drawBitmap(mAlphaGradientMask, null, mAlphaMaskRect, paint);
+ canvas.drawRect(mFinalMaskRect, paint);
if (DEBUG) {
mDebugPaint.setColor(0xFF00FF00);
@@ -157,4 +180,20 @@ public class GradientView extends View implements WallpaperColorInfo.OnChangeLis
canvas.drawLine(0, startMaskY + mMaskHeight, mWidth, startMaskY + mMaskHeight, mDebugPaint);
}
}
+
+ public Bitmap createDitheredAlphaMask() {
+ Bitmap dst = Bitmap.createBitmap(mMaskWidth, mMaskHeight, Bitmap.Config.ALPHA_8);
+ Canvas c = new Canvas(dst);
+ Paint paint = new Paint(Paint.DITHER_FLAG);
+ LinearGradient lg = new LinearGradient(0, 0, 0, mMaskHeight,
+ new int[]{
+ 0x00FFFFFF,
+ ColorUtils.setAlphaComponent(Color.WHITE, (int) (0xFF * 0.95)),
+ 0xFFFFFFFF},
+ new float[]{0f, 0.8f, 1f},
+ Shader.TileMode.CLAMP);
+ paint.setShader(lg);
+ c.drawRect(0, 0, mMaskWidth, mMaskHeight, paint);
+ return dst;
+ }
} \ No newline at end of file
diff --git a/src/com/android/launcher3/graphics/ScrimView.java b/src/com/android/launcher3/graphics/ScrimView.java
deleted file mode 100644
index 6d1f30a41..000000000
--- a/src/com/android/launcher3/graphics/ScrimView.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.launcher3.graphics;
-
-import android.content.Context;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.graphics.Canvas;
-import android.graphics.Color;
-import android.graphics.Paint;
-import android.graphics.RectF;
-import android.support.v4.graphics.ColorUtils;
-import android.util.AttributeSet;
-import android.view.View;
-import android.view.animation.AccelerateInterpolator;
-import android.view.animation.Interpolator;
-
-import com.android.launcher3.Launcher;
-import com.android.launcher3.R;
-import com.android.launcher3.Utilities;
-import com.android.launcher3.util.Themes;
-
-public class ScrimView extends View {
-
- private static final boolean DEBUG = false;
-
- private static final int MASK_HEIGHT_DP = 300;
- private static final float MASK_START_LENGTH_FACTOR = 1f;
- private static final boolean APPLY_ALPHA = true;
-
- private final Bitmap mFinalScrimMask;
- private final Bitmap mAlphaScrimMask;
-
- private final int mMaskHeight;
- private int mVisibleHeight;
- private final int mHeadStart;
-
- private final RectF mAlphaMaskRect = new RectF();
- private final RectF mFinalMaskRect = new RectF();
- private final Paint mPaint = new Paint();
- private float mProgress;
- private final Interpolator mAccelerator = new AccelerateInterpolator();
- private final Paint mDebugPaint = DEBUG ? new Paint() : null;
- private final int mAlphaStart;
-
- public ScrimView(Context context, AttributeSet attrs) {
- super(context, attrs);
- mMaskHeight = Utilities.pxFromDp(MASK_HEIGHT_DP, getResources().getDisplayMetrics());
- mHeadStart = (int) (mMaskHeight * MASK_START_LENGTH_FACTOR);
- mAlphaStart = Launcher.getLauncher(context)
- .getDeviceProfile().isVerticalBarLayout() ? 0 : 55;
-
- int scrimColor = Themes.getAttrColor(context, R.attr.allAppsScrimColor);
- int scrimAlpha = Color.alpha(scrimColor);
- mPaint.setColor(scrimColor);
- mFinalScrimMask = Utilities.convertToAlphaMask(
- Utilities.createOnePixBitmap(), scrimAlpha);
- Bitmap alphaMaskFromResource = BitmapFactory.decodeResource(getResources(),
- R.drawable.all_apps_alpha_mask);
- mAlphaScrimMask = Utilities.convertToAlphaMask(alphaMaskFromResource, scrimAlpha);
- }
-
- @Override
- protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
- super.onMeasure(widthMeasureSpec, heightMeasureSpec);
- int width = MeasureSpec.getSize(widthMeasureSpec);
- mVisibleHeight = MeasureSpec.getSize(heightMeasureSpec);
- setMeasuredDimension(width, mVisibleHeight * 2);
- setProgress(mProgress);
- }
-
- public void setProgress(float progress) {
- mProgress = progress;
- float initialY = mVisibleHeight - mHeadStart;
- float fullTranslationY = mVisibleHeight;
- float linTranslationY = initialY - progress * fullTranslationY;
- setTranslationY(linTranslationY);
-
- if (APPLY_ALPHA) {
- int alpha = mAlphaStart + (int) ((255f - mAlphaStart)
- * mAccelerator.getInterpolation(progress));
- mPaint.setAlpha(alpha);
- invalidate();
- }
- }
-
- @Override
- protected void onDraw(Canvas canvas) {
- mAlphaMaskRect.set(0, 0, getWidth(), mMaskHeight);
- mFinalMaskRect.set(0, mMaskHeight, getWidth(), getHeight());
- canvas.drawBitmap(mAlphaScrimMask, null, mAlphaMaskRect, mPaint);
- canvas.drawBitmap(mFinalScrimMask, null, mFinalMaskRect, mPaint);
-
- if (DEBUG) {
- mDebugPaint.setColor(0xFF0000FF);
- canvas.drawLine(0, mAlphaMaskRect.top, getWidth(), mAlphaMaskRect.top, mDebugPaint);
- canvas.drawLine(0, mAlphaMaskRect.bottom, getWidth(), mAlphaMaskRect.bottom, mDebugPaint);
- }
- }
-
-}
diff --git a/src/com/android/launcher3/popup/PopupContainerWithArrow.java b/src/com/android/launcher3/popup/PopupContainerWithArrow.java
index f5f7ddb31..c3e2d8b89 100644
--- a/src/com/android/launcher3/popup/PopupContainerWithArrow.java
+++ b/src/com/android/launcher3/popup/PopupContainerWithArrow.java
@@ -402,9 +402,14 @@ public class PopupContainerWithArrow extends AbstractFloatingView implements Dra
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
super.onLayout(changed, l, t, r, b);
+ enforceContainedWithinScreen(l, r);
+
+ }
+
+ private void enforceContainedWithinScreen(int left, int right) {
DragLayer dragLayer = mLauncher.getDragLayer();
- if (getTranslationX() + l < 0 ||
- getTranslationX() + l + getMeasuredWidth() > dragLayer.getWidth()) {
+ if (getTranslationX() + left < 0 ||
+ getTranslationX() + right > dragLayer.getWidth()) {
// If we are still off screen, center horizontally too.
mGravity |= Gravity.CENTER_HORIZONTAL;
}
diff --git a/src/com/android/launcher3/widget/WidgetsBottomSheet.java b/src/com/android/launcher3/widget/WidgetsBottomSheet.java
index a754375ae..b2fb09157 100644
--- a/src/com/android/launcher3/widget/WidgetsBottomSheet.java
+++ b/src/com/android/launcher3/widget/WidgetsBottomSheet.java
@@ -276,7 +276,9 @@ public class WidgetsBottomSheet extends AbstractFloatingView implements Insettab
public void setTranslationY(float translationY) {
super.setTranslationY(translationY);
if (mGradientBackground == null) return;
- mGradientBackground.setProgress((mTranslationYClosed - translationY) / mTranslationYRange);
+ float p = (mTranslationYClosed - translationY) / mTranslationYRange;
+ boolean showScrim = p <= 0;
+ mGradientBackground.setProgress(p, showScrim);
}
@Override