Fix bugs related to swipe up to home animation.

- Added ConstantState support for FolderAdaptiveIcon and
  ShiftedBitmapDrawable.
- Quick fix for NPE in Workspace#mapOverCellLayout while I investigate
  further.

Bug: 128460496
Change-Id: I5ec02e25dcf9f17aeb37928e675a033bdc8819ae
This commit is contained in:
Jon Miranda
2019-03-12 17:19:30 -07:00
committed by Jonathan Miranda
parent 29cde586f9
commit 0c3692d5ef
3 changed files with 70 additions and 3 deletions

View File

@@ -3084,6 +3084,10 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
}
private boolean mapOverCellLayout(boolean recurse, CellLayout layout, ItemOperator op) {
// TODO(b/128460496) Potential race condition where layout is not yet loaded
if (layout == null) {
return false;
}
ShortcutAndWidgetContainer container = layout.getShortcutsAndWidgets();
// map over all the shortcuts on the workspace
final int itemCount = container.getChildCount();

View File

@@ -19,11 +19,8 @@ package com.android.launcher3.dragndrop;
import android.annotation.TargetApi;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.PixelFormat;
import android.graphics.Point;
import android.graphics.drawable.AdaptiveIconDrawable;
import android.graphics.drawable.ColorDrawable;
@@ -49,11 +46,15 @@ public class FolderAdaptiveIcon extends AdaptiveIconDrawable {
private final Drawable mBadge;
private final Path mMask;
private final ConstantState mConstantState;
private FolderAdaptiveIcon(Drawable bg, Drawable fg, Drawable badge, Path mask) {
super(bg, fg);
mBadge = badge;
mMask = mask;
mConstantState = new MyConstantState(bg.getConstantState(), fg.getConstantState(),
badge.getConstantState(), mask);
}
@Override
@@ -134,4 +135,35 @@ public class FolderAdaptiveIcon extends AdaptiveIconDrawable {
return new FolderAdaptiveIcon(new ColorDrawable(bg.getBgColor()), foreground, badge, mask);
}
@Override
public ConstantState getConstantState() {
return mConstantState;
}
private static class MyConstantState extends ConstantState {
private final ConstantState mBg;
private final ConstantState mFg;
private final ConstantState mBadge;
private final Path mMask;
MyConstantState(ConstantState bg, ConstantState fg, ConstantState badge, Path mask) {
mBg = bg;
mFg = fg;
mBadge = badge;
mMask = mask;
}
@Override
public Drawable newDrawable() {
return new FolderAdaptiveIcon(mBg.newDrawable(), mFg.newDrawable(),
mBadge.newDrawable(), mMask);
}
@Override
public int getChangingConfigurations() {
return mBg.getChangingConfigurations() & mFg.getChangingConfigurations()
& mBadge.getChangingConfigurations();
}
}
}

View File

@@ -32,10 +32,14 @@ public class ShiftedBitmapDrawable extends Drawable {
private float mShiftX;
private float mShiftY;
private final ConstantState mConstantState;
public ShiftedBitmapDrawable(Bitmap bitmap, float shiftX, float shiftY) {
mBitmap = bitmap;
mShiftX = shiftX;
mShiftY = shiftY;
mConstantState = new MyConstantState(mBitmap, mShiftX, mShiftY);
}
public float getShiftX() {
@@ -71,4 +75,31 @@ public class ShiftedBitmapDrawable extends Drawable {
public int getOpacity() {
return PixelFormat.TRANSLUCENT;
}
@Override
public ConstantState getConstantState() {
return mConstantState;
}
private static class MyConstantState extends ConstantState {
private final Bitmap mBitmap;
private float mShiftX;
private float mShiftY;
MyConstantState(Bitmap bitmap, float shiftX, float shiftY) {
mBitmap = bitmap;
mShiftX = shiftX;
mShiftY = shiftY;
}
@Override
public Drawable newDrawable() {
return new ShiftedBitmapDrawable(mBitmap, mShiftX, mShiftY);
}
@Override
public int getChangingConfigurations() {
return 0;
}
}
}