Simplifying drag preview generation

> Fixing wrong icon normalization when dragging a folder icon
> Reusing the preview bitmap for creating dragOutline
> Generating drag outline on the background thread

Bug: 35428783
Change-Id: I01e724ba63404302090ee1e562f6c2fc7147ba2f
This commit is contained in:
Sunny Goyal
2017-09-26 12:43:16 -07:00
parent f00c5b5fd4
commit aa3a2baab6
8 changed files with 151 additions and 225 deletions
@@ -28,12 +28,15 @@ import android.graphics.PorterDuffXfermode;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.drawable.AdaptiveIconDrawable;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.util.Log;
import com.android.launcher3.LauncherAppState;
import com.android.launcher3.Utilities;
import com.android.launcher3.dragndrop.FolderAdaptiveIcon;
import java.io.File;
import java.io.FileOutputStream;
import java.nio.ByteBuffer;
@@ -231,12 +234,17 @@ public class IconNormalizer {
*/
public synchronized float getScale(@NonNull Drawable d, @Nullable RectF outBounds,
@Nullable Path path, @Nullable boolean[] outMaskShape) {
if (Utilities.ATLEAST_OREO && d instanceof AdaptiveIconDrawable &&
mAdaptiveIconScale != SCALE_NOT_INITIALIZED) {
if (outBounds != null) {
outBounds.set(mAdaptiveIconBounds);
if (Utilities.ATLEAST_OREO && d instanceof AdaptiveIconDrawable) {
if (mAdaptiveIconScale != SCALE_NOT_INITIALIZED) {
if (outBounds != null) {
outBounds.set(mAdaptiveIconBounds);
}
return mAdaptiveIconScale;
}
if (d instanceof FolderAdaptiveIcon) {
// Since we just want the scale, avoid heavy drawing operations
d = new AdaptiveIconDrawable(new ColorDrawable(Color.BLACK), null);
}
return mAdaptiveIconScale;
}
int width = d.getIntrinsicWidth();
int height = d.getIntrinsicHeight();