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) { when (item.itemId) {
R.id.menu_set_as_wallpaper -> setAsWallpaper(File(mMedium!!.path)) R.id.menu_set_as_wallpaper -> setAsWallpaper(File(mMedium!!.path))
R.id.menu_open_with -> openWith(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)) R.id.menu_edit -> openEditor(File(mMedium!!.path))
else -> return super.onOptionsItemSelected(item) else -> return super.onOptionsItemSelected(item)
} }

View file

@ -22,6 +22,16 @@ import com.simplemobiletools.gallery.models.Medium
import java.io.File import java.io.File
import java.util.* 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) { fun Activity.shareMedium(medium: Medium) {
val shareTitle = resources.getString(R.string.share_via) val shareTitle = resources.getString(R.string.share_via)
val file = File(medium.path) val file = File(medium.path)

View file

@ -55,8 +55,7 @@ class PhotoFragment : ViewPagerFragment() {
exif.setTagValue(ExifInterface.TAG_ORIENTATION, 1) exif.setTagValue(ExifInterface.TAG_ORIENTATION, 1)
exif.removeCompressedThumbnail() exif.removeCompressedThumbnail()
val uri = Uri.parse(originalPath) val file = File(context.externalCacheDir, Uri.parse(originalPath).lastPathSegment)
val file = File(context.cacheDir, uri.lastPathSegment)
var out: FileOutputStream? = null var out: FileOutputStream? = null
try { try {
out = FileOutputStream(file) out = FileOutputStream(file)