Launcher3: Start lens activity directly instead of sharesheet
We don't need to open the sharesheet as we're targeting a specific application (Google Lens). Change-Id: I042b3a712dcf03eda21504b66cf99394b0bd4d2b
This commit is contained in:
parent
67b6936756
commit
4aa72dfab8
|
@ -111,7 +111,7 @@ public class ImageActionsApi {
|
|||
|
||||
@UiThread
|
||||
public void startLensActivity() {
|
||||
ImageActionUtils.startLensActivity(mContext, mBitmapSupplier, null, null, TAG);
|
||||
ImageActionUtils.startLensActivity(mContext, mBitmapSupplier, null, TAG);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -161,15 +161,28 @@ public class ImageActionUtils {
|
|||
}
|
||||
|
||||
public static void startLensActivity(Context context, Supplier<Bitmap> bitmapSupplier,
|
||||
Rect crop, Intent intent, String tag) {
|
||||
if (bitmapSupplier.get() == null) {
|
||||
Log.e(tag, "No snapshot available, not starting share.");
|
||||
return;
|
||||
}
|
||||
|
||||
UI_HELPER_EXECUTOR.execute(() -> persistBitmapAndStartActivity(context,
|
||||
bitmapSupplier.get(), crop, intent, ImageActionUtils::getLensIntentForImageUri,
|
||||
tag));
|
||||
Rect crop, String tag) {
|
||||
UI_HELPER_EXECUTOR.execute(() -> {
|
||||
Bitmap bitmap = bitmapSupplier.get();
|
||||
if (bitmap == null) {
|
||||
Log.e(tag, "No snapshot available, not starting lens.");
|
||||
return;
|
||||
}
|
||||
Intent intent = new Intent();
|
||||
Uri uri = getImageUri(bitmap, 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(Utilities.GSA_PACKAGE, Utilities.LENS_SHARE_ACTIVITY))
|
||||
.addFlags(FLAG_ACTIVITY_NEW_TASK)
|
||||
.addFlags(FLAG_GRANT_READ_URI_PERMISSION)
|
||||
.setType("image/png")
|
||||
.putExtra(Intent.EXTRA_STREAM, uri)
|
||||
.setClipData(clipdata);
|
||||
context.startActivity(intent);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -312,24 +325,6 @@ public class ImageActionUtils {
|
|||
return new Intent[]{Intent.createChooser(intent, null).addFlags(FLAG_ACTIVITY_NEW_TASK)};
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
private static Intent[] getLensIntentForImageUri(Uri uri, Intent intent) {
|
||||
if (intent == null) {
|
||||
intent = new Intent();
|
||||
}
|
||||
ClipData clipdata = new ClipData(new ClipDescription("content",
|
||||
new String[]{"image/png"}),
|
||||
new ClipData.Item(uri));
|
||||
intent.setAction(Intent.ACTION_SEND)
|
||||
.setComponent(new ComponentName(Utilities.GSA_PACKAGE, Utilities.LENS_SHARE_ACTIVITY))
|
||||
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
.addFlags(FLAG_GRANT_READ_URI_PERMISSION)
|
||||
.setType("image/png")
|
||||
.putExtra(Intent.EXTRA_STREAM, uri)
|
||||
.setClipData(clipdata);
|
||||
return new Intent[]{Intent.createChooser(intent, null).addFlags(FLAG_ACTIVITY_NEW_TASK)};
|
||||
}
|
||||
|
||||
private static void clearOldCacheFiles(Context context) {
|
||||
THREAD_POOL_EXECUTOR.execute(() -> {
|
||||
File parent = new File(context.getCacheDir(), SUB_FOLDER);
|
||||
|
|
Loading…
Reference in New Issue