Loading quickstep/src/com/android/quickstep/ImageActionsApi.java +11 −0 Original line number Diff line number Diff line Loading @@ -22,11 +22,14 @@ import static android.content.Intent.FLAG_GRANT_READ_URI_PERMISSION; import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR; import static com.android.quickstep.util.ImageActionUtils.persistBitmapAndStartActivity; import android.app.prediction.AppTarget; import android.content.Context; import android.content.Intent; import android.content.pm.ShortcutInfo; import android.graphics.Bitmap; import android.graphics.Insets; import android.graphics.Rect; import android.graphics.RectF; import android.util.Log; import androidx.annotation.Nullable; Loading Loading @@ -96,4 +99,12 @@ public class ImageActionsApi { ImageActionUtils.saveScreenshot(mSystemUiProxy, screenshot, screenshotBounds, visibleInsets, task); } /** * Share the image when user taps on overview share targets. */ @UiThread public void shareImage(RectF rectF, ShortcutInfo shortcutInfo, AppTarget appTarget) { ImageActionUtils.shareImage(mContext, mBitmapSupplier, rectF, shortcutInfo, appTarget, TAG); } } quickstep/src/com/android/quickstep/util/ImageActionUtils.java +32 −0 Original line number Diff line number Diff line Loading @@ -22,15 +22,19 @@ import static android.content.Intent.FLAG_GRANT_READ_URI_PERMISSION; import static com.android.launcher3.util.Executors.THREAD_POOL_EXECUTOR; import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR; import android.app.prediction.AppTarget; import android.content.ClipData; import android.content.ClipDescription; import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.pm.ShortcutInfo; import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Insets; import android.graphics.Picture; import android.graphics.Rect; import android.graphics.RectF; import android.net.Uri; import android.util.Log; Loading Loading @@ -70,6 +74,34 @@ public class ImageActionUtils { screenshotBounds, visibleInsets, task); } /** * Launch the activity to share image for overview sharing. This is to share cropped bitmap * with specific share targets (with shortcutInfo and appTarget) rendered in overview. */ @UiThread public static void shareImage(Context context, Supplier<Bitmap> bitmapSupplier, RectF rectF, ShortcutInfo shortcutInfo, AppTarget appTarget, String tag) { if (bitmapSupplier.get() == null) { return; } Rect crop = new Rect(); rectF.round(crop); Intent intent = new Intent(); Uri uri = getImageUri(bitmapSupplier.get(), crop, context, tag); ClipData clipdata = new ClipData(new ClipDescription("content", new String[]{"image/png"}), new ClipData.Item(uri)); intent.setAction(Intent.ACTION_SEND) .setComponent(new ComponentName(appTarget.getPackageName(), appTarget.getClassName())) .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) .addFlags(FLAG_GRANT_READ_URI_PERMISSION) .setType("image/png") .putExtra(Intent.EXTRA_STREAM, uri) .putExtra(Intent.EXTRA_SHORTCUT_ID, shortcutInfo.getId()) .setClipData(clipdata); context.startActivity(intent); } /** * Launch the activity to share image. */ Loading Loading
quickstep/src/com/android/quickstep/ImageActionsApi.java +11 −0 Original line number Diff line number Diff line Loading @@ -22,11 +22,14 @@ import static android.content.Intent.FLAG_GRANT_READ_URI_PERMISSION; import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR; import static com.android.quickstep.util.ImageActionUtils.persistBitmapAndStartActivity; import android.app.prediction.AppTarget; import android.content.Context; import android.content.Intent; import android.content.pm.ShortcutInfo; import android.graphics.Bitmap; import android.graphics.Insets; import android.graphics.Rect; import android.graphics.RectF; import android.util.Log; import androidx.annotation.Nullable; Loading Loading @@ -96,4 +99,12 @@ public class ImageActionsApi { ImageActionUtils.saveScreenshot(mSystemUiProxy, screenshot, screenshotBounds, visibleInsets, task); } /** * Share the image when user taps on overview share targets. */ @UiThread public void shareImage(RectF rectF, ShortcutInfo shortcutInfo, AppTarget appTarget) { ImageActionUtils.shareImage(mContext, mBitmapSupplier, rectF, shortcutInfo, appTarget, TAG); } }
quickstep/src/com/android/quickstep/util/ImageActionUtils.java +32 −0 Original line number Diff line number Diff line Loading @@ -22,15 +22,19 @@ import static android.content.Intent.FLAG_GRANT_READ_URI_PERMISSION; import static com.android.launcher3.util.Executors.THREAD_POOL_EXECUTOR; import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR; import android.app.prediction.AppTarget; import android.content.ClipData; import android.content.ClipDescription; import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.pm.ShortcutInfo; import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Insets; import android.graphics.Picture; import android.graphics.Rect; import android.graphics.RectF; import android.net.Uri; import android.util.Log; Loading Loading @@ -70,6 +74,34 @@ public class ImageActionUtils { screenshotBounds, visibleInsets, task); } /** * Launch the activity to share image for overview sharing. This is to share cropped bitmap * with specific share targets (with shortcutInfo and appTarget) rendered in overview. */ @UiThread public static void shareImage(Context context, Supplier<Bitmap> bitmapSupplier, RectF rectF, ShortcutInfo shortcutInfo, AppTarget appTarget, String tag) { if (bitmapSupplier.get() == null) { return; } Rect crop = new Rect(); rectF.round(crop); Intent intent = new Intent(); Uri uri = getImageUri(bitmapSupplier.get(), crop, context, tag); ClipData clipdata = new ClipData(new ClipDescription("content", new String[]{"image/png"}), new ClipData.Item(uri)); intent.setAction(Intent.ACTION_SEND) .setComponent(new ComponentName(appTarget.getPackageName(), appTarget.getClassName())) .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) .addFlags(FLAG_GRANT_READ_URI_PERMISSION) .setType("image/png") .putExtra(Intent.EXTRA_STREAM, uri) .putExtra(Intent.EXTRA_SHORTCUT_ID, shortcutInfo.getId()) .setClipData(clipdata); context.startActivity(intent); } /** * Launch the activity to share image. */ Loading