From 6c7fc3683ea49365233fc3bdcc3058b341a3d834 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sat, 14 Jan 2017 19:58:39 +0100 Subject: [PATCH] change the way third party photos are shared --- .../gallery/activities/PhotoVideoActivity.kt | 2 +- .../simplemobiletools/gallery/extensions/activity.kt | 10 ++++++++++ .../gallery/fragments/PhotoFragment.kt | 3 +-- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/PhotoVideoActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/PhotoVideoActivity.kt index a30fd97e7..66e525a7d 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/PhotoVideoActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/PhotoVideoActivity.kt @@ -104,7 +104,7 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList when (item.itemId) { R.id.menu_set_as_wallpaper -> setAsWallpaper(File(mMedium!!.path)) R.id.menu_open_with -> openWith(File(mMedium!!.path)) - R.id.menu_share -> shareMedium(mMedium!!) + R.id.menu_share -> shareUri(mMedium!!, mUri) R.id.menu_edit -> openEditor(File(mMedium!!.path)) else -> return super.onOptionsItemSelected(item) } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/activity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/activity.kt index 88aff5742..edf3b7c1c 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/activity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/activity.kt @@ -22,6 +22,16 @@ import com.simplemobiletools.gallery.models.Medium import java.io.File import java.util.* +fun Activity.shareUri(medium: Medium, uri: Uri) { + val shareTitle = resources.getString(R.string.share_via) + Intent().apply { + action = Intent.ACTION_SEND + putExtra(Intent.EXTRA_STREAM, uri) + type = medium.getMimeType() + startActivity(Intent.createChooser(this, shareTitle)) + } +} + fun Activity.shareMedium(medium: Medium) { val shareTitle = resources.getString(R.string.share_via) val file = File(medium.path) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt index c495d4965..af9a9ec56 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt @@ -55,8 +55,7 @@ class PhotoFragment : ViewPagerFragment() { exif.setTagValue(ExifInterface.TAG_ORIENTATION, 1) exif.removeCompressedThumbnail() - val uri = Uri.parse(originalPath) - val file = File(context.cacheDir, uri.lastPathSegment) + val file = File(context.externalCacheDir, Uri.parse(originalPath).lastPathSegment) var out: FileOutputStream? = null try { out = FileOutputStream(file)