Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e6259ecd authored by Nick Deakin's avatar Nick Deakin
Browse files

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
parent 082e2eeb
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -63,6 +63,11 @@
                <category android:name="android.intent.category.DEFAULT"/>
                <data android:mimeType="image/*"/>
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.SEND" />
                <category android:name="android.intent.category.DEFAULT" />
                <data android:mimeType="image/*" />
            </intent-filter>
        </activity>

    </application>
+18 −9
Original line number Diff line number Diff line
@@ -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<GainmapImage>(R.id.gainmap_image)!!.setImageSource(source)
            }
            Intent.ACTION_SEND -> {
                val uri = (intent.getParcelableExtra<Parcelable>(Intent.EXTRA_STREAM) as? Uri)
                    ?: return finish()
                val source = ImageDecoder.createSource(contentResolver, uri)
                findViewById<GainmapImage>(R.id.gainmap_image)!!.setImageSource(source)
            }
            else -> {
                finish()
            }
        }
    }
}