Animate icon update from loading state.

Test: manual

Fixing b/129983531. Having app icons pop in without any animation from a solid placeholder color can look janky. Added a sequential fade in, fade out animation.

Preview: https://drive.google.com/file/d/11NgEja7vzm3f3aH3WbEQljUWGKuuK00_/view?usp=sharing
Change-Id: If77e8f480b02d5b7d29f89afa44450c83a68a276
This commit is contained in:
Schneider Victor-tulias
2020-09-18 11:16:30 -07:00
parent a8e2ad2c1f
commit 350b462f24
2 changed files with 51 additions and 6 deletions

View File

@@ -33,6 +33,8 @@ import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.util.Property;
import androidx.annotation.Nullable;
import com.android.launcher3.graphics.PlaceHolderIconDrawable;
import com.android.launcher3.icons.BitmapInfo;
import com.android.launcher3.model.data.ItemInfoWithIcon;
@@ -54,6 +56,8 @@ public class FastBitmapDrawable extends Drawable {
protected Bitmap mBitmap;
protected final int mIconColor;
@Nullable private ColorFilter mColorFilter;
private boolean mIsPressed;
private boolean mIsDisabled;
private float mDisabledAlpha = 1f;
@@ -115,7 +119,8 @@ public class FastBitmapDrawable extends Drawable {
@Override
public void setColorFilter(ColorFilter cf) {
// No op
mColorFilter = cf;
updateFilter();
}
@Override
@@ -265,7 +270,7 @@ public class FastBitmapDrawable extends Drawable {
* Updates the paint to reflect the current brightness and saturation.
*/
protected void updateFilter() {
mPaint.setColorFilter(mIsDisabled ? getDisabledColorFilter() : null);
mPaint.setColorFilter(mIsDisabled ? getDisabledColorFilter() : mColorFilter);
invalidateSelf();
}