mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-28 07:46:55 +00:00
Image actions - fix uri permissions.
Feedback wasn't working, also Share wasn't showing its preview. Bug: 159122067 Test: built and run locally Change-Id: Iccea012a8fc0009a6a980f6233f42c4e7619f4ec
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
package com.android.quickstep;
|
||||
|
||||
import static android.content.Intent.EXTRA_STREAM;
|
||||
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;
|
||||
@@ -67,7 +68,9 @@ public class ImageActionsApi {
|
||||
|
||||
UI_HELPER_EXECUTOR.execute(() -> persistBitmapAndStartActivity(mContext,
|
||||
mBitmapSupplier.get(), crop, intent, (uri, intentForUri) -> {
|
||||
intentForUri.putExtra(EXTRA_STREAM, uri);
|
||||
intentForUri
|
||||
.addFlags(FLAG_GRANT_READ_URI_PERMISSION)
|
||||
.putExtra(EXTRA_STREAM, uri);
|
||||
return new Intent[]{intentForUri};
|
||||
}, TAG));
|
||||
|
||||
|
||||
@@ -88,8 +88,14 @@ public class ImageActionUtils {
|
||||
@WorkerThread
|
||||
public static void persistBitmapAndStartActivity(Context context, Bitmap bitmap, Rect crop,
|
||||
Intent intent, BiFunction<Uri, Intent, Intent[]> uriToIntentMap, String tag) {
|
||||
context.startActivities(
|
||||
uriToIntentMap.apply(getImageUri(bitmap, crop, context, tag), intent));
|
||||
Intent[] intents = uriToIntentMap.apply(getImageUri(bitmap, crop, context, tag), intent);
|
||||
|
||||
// Work around b/159412574
|
||||
if (intents.length == 1) {
|
||||
context.startActivity(intents[0]);
|
||||
} else {
|
||||
context.startActivities(intents);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -158,13 +164,13 @@ public class ImageActionUtils {
|
||||
intent = new Intent();
|
||||
}
|
||||
ClipData clipdata = new ClipData(new ClipDescription("content",
|
||||
new String[]{ClipDescription.MIMETYPE_TEXT_PLAIN}),
|
||||
new String[]{"image/png"}),
|
||||
new ClipData.Item(uri));
|
||||
intent.setAction(Intent.ACTION_SEND)
|
||||
.setComponent(null)
|
||||
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
.addFlags(FLAG_GRANT_READ_URI_PERMISSION)
|
||||
.setType("image/png")
|
||||
.setFlags(FLAG_GRANT_READ_URI_PERMISSION)
|
||||
.putExtra(Intent.EXTRA_STREAM, uri)
|
||||
.setClipData(clipdata);
|
||||
return new Intent[]{Intent.createChooser(intent, null).addFlags(FLAG_ACTIVITY_NEW_TASK)};
|
||||
|
||||
Reference in New Issue
Block a user