From 568bd417f2d373a73976056b2e8e8b296f514425 Mon Sep 17 00:00:00 2001 From: Luca Stefani Date: Mon, 7 Aug 2023 18:48:15 +0200 Subject: [PATCH] Glimpse: Hook up adjust button Change-Id: Id72ec262b0a237b7f07b16f465912eb19cf705e8 --- app/src/main/java/org/lineageos/glimpse/ext/Intent.kt | 7 +++++++ .../org/lineageos/glimpse/fragments/MediaViewerFragment.kt | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/app/src/main/java/org/lineageos/glimpse/ext/Intent.kt b/app/src/main/java/org/lineageos/glimpse/ext/Intent.kt index 08540c2..32c3061 100644 --- a/app/src/main/java/org/lineageos/glimpse/ext/Intent.kt +++ b/app/src/main/java/org/lineageos/glimpse/ext/Intent.kt @@ -7,9 +7,16 @@ package org.lineageos.glimpse.ext import android.content.Intent import android.net.Uri +import org.lineageos.glimpse.models.Media fun Intent.shareIntent(vararg uris: Uri) = apply { action = Intent.ACTION_SEND_MULTIPLE putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris.toCollection(ArrayList())) type = "*/*" } + +fun Intent.editIntent(media: Media) = apply { + action = Intent.ACTION_EDIT + setDataAndType(media.externalContentUri, media.mimeType) + flags = Intent.FLAG_GRANT_READ_URI_PERMISSION +} diff --git a/app/src/main/java/org/lineageos/glimpse/fragments/MediaViewerFragment.kt b/app/src/main/java/org/lineageos/glimpse/fragments/MediaViewerFragment.kt index 044f71d..cd7ea09 100644 --- a/app/src/main/java/org/lineageos/glimpse/fragments/MediaViewerFragment.kt +++ b/app/src/main/java/org/lineageos/glimpse/fragments/MediaViewerFragment.kt @@ -285,6 +285,13 @@ class MediaViewerFragment : Fragment( } } + adjustButton.setOnClickListener { + mediaViewerAdapter.getMediaFromMediaStore(viewPager.currentItem)?.let { + val intent = Intent().editIntent(it) + startActivity(Intent.createChooser(intent, null)) + } + } + if (!permissionsUtils.mainPermissionsGranted()) { mainPermissionsRequestLauncher.launch(PermissionsUtils.mainPermissions) } else {