change the way third party photos are shared

This commit is contained in:
tibbi 2017-01-14 19:58:39 +01:00
parent 5177530b0e
commit 6c7fc3683e
3 changed files with 12 additions and 3 deletions

View File

@ -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)
}

View File

@ -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)

View File

@ -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)