mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-03-04 18:06:48 +00:00
Add icon when launching widgets in split
* Load the icon in the BG (though it should be cached), then run the animation in the FG Test: Initiating split contextually with a widget shows icon Bug: 293935354 Flag: ENABLE_SPLIT_FROM_WORKSPACE_TO_WORKSPACE Change-Id: Iab1f1e9965479b0f84c74c2a5ae6e272b9a5db3a
This commit is contained in:
@@ -19,6 +19,7 @@ package com.android.quickstep.util;
|
||||
import static com.android.launcher3.config.FeatureFlags.ENABLE_SPLIT_FROM_DESKTOP_TO_WORKSPACE;
|
||||
import static com.android.launcher3.config.FeatureFlags.ENABLE_SPLIT_FROM_FULLSCREEN_WITH_KEYBOARD_SHORTCUTS;
|
||||
import static com.android.launcher3.config.FeatureFlags.ENABLE_SPLIT_FROM_WORKSPACE_TO_WORKSPACE;
|
||||
import static com.android.launcher3.util.Executors.MODEL_EXECUTOR;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
@@ -30,15 +31,19 @@ import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.RectF;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.UserHandle;
|
||||
import android.view.View;
|
||||
|
||||
import com.android.launcher3.DeviceProfile;
|
||||
import com.android.launcher3.Launcher;
|
||||
import com.android.launcher3.LauncherAppState;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.anim.PendingAnimation;
|
||||
import com.android.launcher3.icons.BitmapInfo;
|
||||
import com.android.launcher3.icons.IconCache;
|
||||
import com.android.launcher3.model.data.PackageItemInfo;
|
||||
import com.android.launcher3.model.data.WorkspaceItemInfo;
|
||||
import com.android.quickstep.views.FloatingTaskView;
|
||||
import com.android.quickstep.views.RecentsView;
|
||||
@@ -52,12 +57,13 @@ public class SplitToWorkspaceController {
|
||||
private final SplitSelectStateController mController;
|
||||
|
||||
private final int mHalfDividerSize;
|
||||
private final IconCache mIconCache;
|
||||
|
||||
public SplitToWorkspaceController(Launcher launcher, SplitSelectStateController controller) {
|
||||
mLauncher = launcher;
|
||||
mDP = mLauncher.getDeviceProfile();
|
||||
mController = controller;
|
||||
|
||||
mIconCache = LauncherAppState.getInstanceNoCreate().getIconCache();
|
||||
mHalfDividerSize = mLauncher.getResources().getDimensionPixelSize(
|
||||
R.dimen.multi_window_task_divider_size) / 2;
|
||||
}
|
||||
@@ -74,17 +80,24 @@ public class SplitToWorkspaceController {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Convert original widgetView into bitmap to use for animation
|
||||
// TODO(b/276361926) get the icon for this widget via PackageManager?
|
||||
int width = view.getWidth();
|
||||
int height = view.getHeight();
|
||||
Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
|
||||
Canvas canvas = new Canvas(bitmap);
|
||||
view.draw(canvas);
|
||||
MODEL_EXECUTOR.execute(() -> {
|
||||
PackageItemInfo infoInOut = new PackageItemInfo(pendingIntent.getCreatorPackage(),
|
||||
pendingIntent.getCreatorUserHandle());
|
||||
mIconCache.getTitleAndIconForApp(infoInOut, false);
|
||||
Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
|
||||
|
||||
mController.setSecondTask(pendingIntent);
|
||||
view.post(() -> {
|
||||
mController.setSecondTask(pendingIntent);
|
||||
// Convert original widgetView into bitmap to use for animation
|
||||
Canvas canvas = new Canvas(bitmap);
|
||||
view.draw(canvas);
|
||||
startWorkspaceAnimation(view, bitmap,
|
||||
new BitmapDrawable(mLauncher.getResources(), infoInOut.bitmap.icon));
|
||||
});
|
||||
});
|
||||
|
||||
startWorkspaceAnimation(view, bitmap, null /*icon*/);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user