do not clear mMedia if the intent came from the gallery itself

This commit is contained in:
tibbi 2017-09-30 23:39:04 +02:00
parent b7cb6a5364
commit 6e6af530bf
4 changed files with 14 additions and 4 deletions

View File

@ -21,6 +21,7 @@ import com.simplemobiletools.gallery.extensions.*
import com.simplemobiletools.gallery.fragments.PhotoFragment
import com.simplemobiletools.gallery.fragments.VideoFragment
import com.simplemobiletools.gallery.fragments.ViewPagerFragment
import com.simplemobiletools.gallery.helpers.IS_FROM_GALLERY
import com.simplemobiletools.gallery.helpers.IS_VIEW_INTENT
import com.simplemobiletools.gallery.helpers.MEDIUM
import com.simplemobiletools.gallery.models.Medium
@ -31,6 +32,7 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList
private val STORAGE_PERMISSION = 1
private var mMedium: Medium? = null
private var mIsFullScreen = false
private var mIsFromGallery = false
private var mFragment: ViewPagerFragment? = null
lateinit var mUri: Uri
@ -52,6 +54,7 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList
private fun checkIntent(savedInstanceState: Bundle? = null) {
mUri = intent.data ?: return
mIsFromGallery = intent.getBooleanExtra(IS_FROM_GALLERY, false)
if (mUri.scheme == "file") {
scanPath(mUri.path) {}
@ -126,6 +129,7 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList
private fun sendViewPagerIntent(path: String) {
Intent(this, ViewPagerActivity::class.java).apply {
putExtra(IS_VIEW_INTENT, true)
putExtra(IS_FROM_GALLERY, mIsFromGallery)
putExtra(MEDIUM, path)
startActivity(this)
}

View File

@ -160,8 +160,11 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
}
if (config.isThirdPartyIntent) {
mMedia.clear()
config.isThirdPartyIntent = false
if (intent.extras == null || !intent.getBooleanExtra(IS_FROM_GALLERY, false)) {
mMedia.clear()
}
}
}

View File

@ -24,6 +24,7 @@ import com.simplemobiletools.commons.helpers.*
import com.simplemobiletools.gallery.BuildConfig
import com.simplemobiletools.gallery.R
import com.simplemobiletools.gallery.activities.SimpleActivity
import com.simplemobiletools.gallery.helpers.IS_FROM_GALLERY
import com.simplemobiletools.gallery.helpers.NOMEDIA
import com.simplemobiletools.gallery.helpers.REQUEST_EDIT_IMAGE
import com.simplemobiletools.gallery.helpers.REQUEST_SET_AS
@ -91,14 +92,14 @@ fun Activity.setAs(uri: Uri, file: File, showToast: Boolean = true): Boolean {
addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
val chooser = Intent.createChooser(this, getString(R.string.set_as))
if (resolveActivity(packageManager) != null) {
success = if (resolveActivity(packageManager) != null) {
startActivityForResult(chooser, REQUEST_SET_AS)
success = true
true
} else {
if (showToast) {
toast(R.string.no_capable_app_found)
}
success = false
false
}
}
@ -130,6 +131,7 @@ fun Activity.openWith(file: File, forceChooser: Boolean = true) {
action = Intent.ACTION_VIEW
setDataAndType(uri, file.getMimeType())
addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
putExtra(IS_FROM_GALLERY, true)
if (resolveActivity(packageManager) != null) {
val chooser = Intent.createChooser(this, getString(R.string.open_with))

View File

@ -62,6 +62,7 @@ val GET_ANY_INTENT = "get_any_intent"
val SET_WALLPAPER_INTENT = "set_wallpaper_intent"
val DIRECTORIES = "directories2"
val IS_VIEW_INTENT = "is_view_intent"
val IS_FROM_GALLERY = "is_from_gallery"
val REQUEST_EDIT_IMAGE = 1
val REQUEST_SET_AS = 2