Add lens shortcut in overview actions

This commit is contained in:
Suphon Thanakornpakapong committed 2021-10-18 12:07:46 +07:00
1 parent e05cdf2b6c
commit 3c571e77df
8 files changed
+232

No files matched your search

@@ -31,6 +31,7 @@ import android.graphics.Insets;
import android.graphics.Rect;
import android.graphics.RectF;
import android.util.Log;
import android.view.View;
import androidx.annotation.Nullable;
import androidx.annotation.UiThread;
@@ -103,6 +104,11 @@ public class ImageActionsApi {
ImageActionUtils.startShareActivity(mContext, mBitmapSupplier, crop, null, TAG);
}
@UiThread
public void startLensActivity() {
ImageActionUtils.startLensActivity(mContext, mBitmapSupplier, null, null, TAG);
}
/**
* @param screenshot to be saved to the media store.
* @param screenshotBounds the location of where the bitmap was laid out on the screen in
@@ -147,6 +147,19 @@ public class ImageActionUtils {
bitmapSupplier.get(), crop, intent, ImageActionUtils::getShareIntentForImageUri,
tag, sharedElement));
}
@UiThread
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));
}
/**
* Starts activity based on given intent created from image uri.
@@ -272,6 +285,15 @@ public class ImageActionUtils {
.setClipData(clipdata);
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();
}
intent.setPackage("com.google.ar.lens");
return getShareIntentForImageUri(uri, intent);
}
private static void clearOldCacheFiles(Context context) {
THREAD_POOL_EXECUTOR.execute(() -> {