From e6259ecd342eec8c5d4d9ffa7222589f609df230 Mon Sep 17 00:00:00 2001 From: Nick Deakin Date: Wed, 3 May 2023 12:10:41 -0400 Subject: [PATCH] SilkFX: enable sharing to the app. SilkFX previously enabled VIEW intent, so you could "open with" the app on an image file for the Gain Map viewer. This change also adds support for the SEND intent, so you can "share to" the app from other apps. Bug: 280608957 Test: Share to works from Files and Photos, open with still works. Change-Id: If647471fcf10ce6395300a9c38aa7e05379dfe85 --- tests/SilkFX/AndroidManifest.xml | 5 ++++ .../android/test/silkfx/app/HdrImageViewer.kt | 27 ++++++++++++------- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/tests/SilkFX/AndroidManifest.xml b/tests/SilkFX/AndroidManifest.xml index 1b8e08bd009f3..c293589bdbafe 100644 --- a/tests/SilkFX/AndroidManifest.xml +++ b/tests/SilkFX/AndroidManifest.xml @@ -63,6 +63,11 @@ + + + + + diff --git a/tests/SilkFX/src/com/android/test/silkfx/app/HdrImageViewer.kt b/tests/SilkFX/src/com/android/test/silkfx/app/HdrImageViewer.kt index f16f0e474db44..7302169f4d1b6 100644 --- a/tests/SilkFX/src/com/android/test/silkfx/app/HdrImageViewer.kt +++ b/tests/SilkFX/src/com/android/test/silkfx/app/HdrImageViewer.kt @@ -18,7 +18,9 @@ package com.android.test.silkfx.app import android.content.Intent import android.graphics.ImageDecoder +import android.net.Uri import android.os.Bundle +import android.os.Parcelable import com.android.test.silkfx.R import com.android.test.silkfx.hdr.GainmapImage @@ -29,14 +31,21 @@ class HdrImageViewer : BaseDemoActivity() { setContentView(R.layout.hdr_image_viewer) val intent = this.intent ?: return finish() - if (Intent.ACTION_VIEW != intent.action) { - finish() - return + when (intent.action) { + Intent.ACTION_VIEW -> { + val data = intent.data ?: return finish() + val source = ImageDecoder.createSource(contentResolver, data) + findViewById(R.id.gainmap_image)!!.setImageSource(source) + } + Intent.ACTION_SEND -> { + val uri = (intent.getParcelableExtra(Intent.EXTRA_STREAM) as? Uri) + ?: return finish() + val source = ImageDecoder.createSource(contentResolver, uri) + findViewById(R.id.gainmap_image)!!.setImageSource(source) + } + else -> { + finish() + } } - - val data = intent.data ?: return finish() - - val source = ImageDecoder.createSource(contentResolver, data) - findViewById(R.id.gainmap_image)!!.setImageSource(source) } -} \ No newline at end of file +}