Merge "Update the pending app icon to match new specs" into udc-dev am: 3c98169752
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/22462578 Change-Id: Iab6c4e4e70814593eebb4d8c9ffdaceda01b5ea2 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -872,7 +872,9 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
|
||||
if (mIcon instanceof PreloadIconDrawable) {
|
||||
preloadIconDrawable = (PreloadIconDrawable) mIcon;
|
||||
preloadIconDrawable.setLevel(progressLevel);
|
||||
preloadIconDrawable.setIsDisabled(!info.isAppStartable());
|
||||
preloadIconDrawable.setIsDisabled(ENABLE_DOWNLOAD_APP_UX_V2.get()
|
||||
? info.getProgressLevel() == 0
|
||||
: !info.isAppStartable());
|
||||
} else {
|
||||
preloadIconDrawable = makePreloadIcon();
|
||||
setIcon(preloadIconDrawable);
|
||||
@@ -897,8 +899,9 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
|
||||
final PreloadIconDrawable preloadDrawable = newPendingIcon(getContext(), info);
|
||||
|
||||
preloadDrawable.setLevel(progressLevel);
|
||||
preloadDrawable.setIsDisabled(!info.isAppStartable());
|
||||
|
||||
preloadDrawable.setIsDisabled(ENABLE_DOWNLOAD_APP_UX_V2.get()
|
||||
? info.getProgressLevel() == 0
|
||||
: !info.isAppStartable());
|
||||
return preloadDrawable;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,16 +27,11 @@ import android.animation.ObjectAnimator;
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.ColorFilter;
|
||||
import android.graphics.Matrix;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Path;
|
||||
import android.graphics.PathMeasure;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.PorterDuffColorFilter;
|
||||
import android.graphics.Rect;
|
||||
import android.os.SystemClock;
|
||||
import android.util.Property;
|
||||
|
||||
import com.android.launcher3.R;
|
||||
@@ -47,10 +42,6 @@ import com.android.launcher3.icons.FastBitmapDrawable;
|
||||
import com.android.launcher3.icons.GraphicsUtils;
|
||||
import com.android.launcher3.model.data.ItemInfoWithIcon;
|
||||
import com.android.launcher3.util.Themes;
|
||||
import com.android.launcher3.util.window.RefreshRateTracker;
|
||||
|
||||
import java.util.WeakHashMap;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* Extension of {@link FastBitmapDrawable} which shows a progress bar around the icon.
|
||||
@@ -91,14 +82,6 @@ public class PreloadIconDrawable extends FastBitmapDrawable {
|
||||
private static final int PRELOAD_ACCENT_COLOR_INDEX = 0;
|
||||
private static final int PRELOAD_BACKGROUND_COLOR_INDEX = 1;
|
||||
|
||||
private static final int ALPHA_DURATION_MILLIS = 3000;
|
||||
private static final int OVERLAY_ALPHA_RANGE = 191;
|
||||
private static final long WAVE_MOTION_DELAY_FACTOR_MILLIS = 100;
|
||||
private static final WeakHashMap<Integer, PorterDuffColorFilter> COLOR_FILTER_MAP =
|
||||
new WeakHashMap<>();
|
||||
public static final Function<Integer, PorterDuffColorFilter> FILTER_FACTORY =
|
||||
currArgb -> new PorterDuffColorFilter(currArgb, PorterDuff.Mode.SRC_ATOP);
|
||||
|
||||
private final Matrix mTmpMatrix = new Matrix();
|
||||
private final PathMeasure mPathMeasure = new PathMeasure();
|
||||
|
||||
@@ -119,7 +102,6 @@ public class PreloadIconDrawable extends FastBitmapDrawable {
|
||||
private float mTrackLength;
|
||||
|
||||
private boolean mRanFinishAnimation;
|
||||
private final int mRefreshRateMillis;
|
||||
|
||||
// Progress of the internal state. [0, 1] indicates the fraction of completed progress,
|
||||
// [1, (1 + COMPLETE_ANIM_FRACTION)] indicates the progress of zoom animation.
|
||||
@@ -138,7 +120,6 @@ public class PreloadIconDrawable extends FastBitmapDrawable {
|
||||
IconPalette.getPreloadProgressColor(context, info.bitmap.color),
|
||||
getPreloadColors(context),
|
||||
Utilities.isDarkTheme(context),
|
||||
getRefreshRateMillis(context),
|
||||
GraphicsUtils.getShapePath(context, DEFAULT_PATH_SIZE));
|
||||
}
|
||||
|
||||
@@ -147,7 +128,6 @@ public class PreloadIconDrawable extends FastBitmapDrawable {
|
||||
int indicatorColor,
|
||||
int[] preloadColors,
|
||||
boolean isDarkMode,
|
||||
int refreshRateMillis,
|
||||
Path shapePath) {
|
||||
super(info.bitmap);
|
||||
mItem = info;
|
||||
@@ -162,13 +142,14 @@ public class PreloadIconDrawable extends FastBitmapDrawable {
|
||||
mSystemAccentColor = preloadColors[PRELOAD_ACCENT_COLOR_INDEX];
|
||||
mSystemBackgroundColor = preloadColors[PRELOAD_BACKGROUND_COLOR_INDEX];
|
||||
mIsDarkMode = isDarkMode;
|
||||
mRefreshRateMillis = refreshRateMillis;
|
||||
|
||||
// If it's a pending app we will animate scale and alpha when it's no longer pending.
|
||||
mIconScaleMultiplier.updateValue(info.getProgressLevel() == 0 ? 0 : 1);
|
||||
|
||||
setLevel(info.getProgressLevel());
|
||||
setIsStartable(info.isAppStartable());
|
||||
if (!ENABLE_DOWNLOAD_APP_UX_V2.get()) {
|
||||
setIsStartable(info.isAppStartable());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -223,20 +204,16 @@ public class PreloadIconDrawable extends FastBitmapDrawable {
|
||||
: SMALL_SCALE;
|
||||
canvas.scale(scale, scale, bounds.exactCenterX(), bounds.exactCenterY());
|
||||
|
||||
ColorFilter filter = getOverlayFilter();
|
||||
mPaint.setColorFilter(filter);
|
||||
super.drawInternal(canvas, bounds);
|
||||
canvas.restoreToCount(saveCount);
|
||||
|
||||
if (ENABLE_DOWNLOAD_APP_UX_V2.get() && filter != null) {
|
||||
reschedule();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateFilter() {
|
||||
if (!ENABLE_DOWNLOAD_APP_UX_V2.get()) {
|
||||
setAlpha(mIsDisabled ? DISABLED_ICON_ALPHA : MAX_PAINT_ALPHA);
|
||||
} else {
|
||||
super.updateFilter();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -317,7 +294,7 @@ public class PreloadIconDrawable extends FastBitmapDrawable {
|
||||
/**
|
||||
* Sets the internal progress and updates the UI accordingly
|
||||
* for progress <= 0:
|
||||
* - icon with pending motion
|
||||
* - icon is pending
|
||||
* - progress track is not visible
|
||||
* - progress bar is not visible
|
||||
* for progress < 1:
|
||||
@@ -367,11 +344,6 @@ public class PreloadIconDrawable extends FastBitmapDrawable {
|
||||
|
||||
return preloadColors;
|
||||
}
|
||||
|
||||
private static int getRefreshRateMillis(Context context) {
|
||||
return RefreshRateTracker.getSingleFrameMs(context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a FastBitmapDrawable with the icon.
|
||||
*/
|
||||
@@ -388,55 +360,9 @@ public class PreloadIconDrawable extends FastBitmapDrawable {
|
||||
mIndicatorColor,
|
||||
new int[] {mSystemAccentColor, mSystemBackgroundColor},
|
||||
mIsDarkMode,
|
||||
mRefreshRateMillis,
|
||||
mShapePath);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setVisible(boolean visible, boolean restart) {
|
||||
if (!visible) {
|
||||
unscheduleSelf(mInvalidateRunnable);
|
||||
}
|
||||
return super.setVisible(visible, restart);
|
||||
}
|
||||
|
||||
private void reschedule() {
|
||||
unscheduleSelf(mInvalidateRunnable);
|
||||
if (!isVisible()) {
|
||||
return;
|
||||
}
|
||||
final long upTime = SystemClock.uptimeMillis();
|
||||
scheduleSelf(mInvalidateRunnable,
|
||||
upTime - ((upTime % mRefreshRateMillis)) + mRefreshRateMillis);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a color filter to be used as an overlay on the pending icon with cascading motion
|
||||
* based on its position.
|
||||
*/
|
||||
private ColorFilter getOverlayFilter() {
|
||||
if (!ENABLE_DOWNLOAD_APP_UX_V2.get() || mInternalStateProgress > 0) {
|
||||
// If the download has started, we do no need to animate
|
||||
return null;
|
||||
}
|
||||
long waveMotionDelay = (mItem.cellX * WAVE_MOTION_DELAY_FACTOR_MILLIS)
|
||||
+ (mItem.cellY * WAVE_MOTION_DELAY_FACTOR_MILLIS);
|
||||
long time = SystemClock.uptimeMillis();
|
||||
int alpha = (int) Utilities.mapBoundToRange(
|
||||
(int) ((time + waveMotionDelay) % ALPHA_DURATION_MILLIS),
|
||||
0,
|
||||
ALPHA_DURATION_MILLIS,
|
||||
0,
|
||||
OVERLAY_ALPHA_RANGE * 2,
|
||||
LINEAR);
|
||||
if (alpha > OVERLAY_ALPHA_RANGE) {
|
||||
alpha = (OVERLAY_ALPHA_RANGE - (alpha % OVERLAY_ALPHA_RANGE));
|
||||
}
|
||||
int overlayColor = mIsDarkMode ? 0 : 255;
|
||||
int currArgb = Color.argb(alpha, overlayColor, overlayColor, overlayColor);
|
||||
return COLOR_FILTER_MAP.computeIfAbsent(currArgb, FILTER_FACTORY);
|
||||
}
|
||||
|
||||
protected static class PreloadIconConstantState extends FastBitmapConstantState {
|
||||
|
||||
protected final ItemInfoWithIcon mInfo;
|
||||
@@ -444,7 +370,6 @@ public class PreloadIconDrawable extends FastBitmapDrawable {
|
||||
protected final int[] mPreloadColors;
|
||||
protected final boolean mIsDarkMode;
|
||||
protected final int mLevel;
|
||||
protected final int mRefreshRateMillis;
|
||||
private final Path mShapePath;
|
||||
|
||||
public PreloadIconConstantState(
|
||||
@@ -454,7 +379,6 @@ public class PreloadIconDrawable extends FastBitmapDrawable {
|
||||
int indicatorColor,
|
||||
int[] preloadColors,
|
||||
boolean isDarkMode,
|
||||
int refreshRateMillis,
|
||||
Path shapePath) {
|
||||
super(bitmap, iconColor);
|
||||
mInfo = info;
|
||||
@@ -462,7 +386,6 @@ public class PreloadIconDrawable extends FastBitmapDrawable {
|
||||
mPreloadColors = preloadColors;
|
||||
mIsDarkMode = isDarkMode;
|
||||
mLevel = info.getProgressLevel();
|
||||
mRefreshRateMillis = refreshRateMillis;
|
||||
mShapePath = shapePath;
|
||||
}
|
||||
|
||||
@@ -473,7 +396,6 @@ public class PreloadIconDrawable extends FastBitmapDrawable {
|
||||
mIndicatorColor,
|
||||
mPreloadColors,
|
||||
mIsDarkMode,
|
||||
mRefreshRateMillis,
|
||||
mShapePath);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user