mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-26 22:47:59 +01:00
allow swiping at opening an image for example from Downloads
This commit is contained in:
parent
312e3c8edb
commit
d046cbc1ec
1 changed files with 24 additions and 15 deletions
|
@ -8,10 +8,7 @@ import android.provider.MediaStore
|
||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
import com.simplemobiletools.gallery.R
|
import com.simplemobiletools.gallery.R
|
||||||
import com.simplemobiletools.gallery.extensions.openEditor
|
import com.simplemobiletools.gallery.extensions.*
|
||||||
import com.simplemobiletools.gallery.extensions.openWith
|
|
||||||
import com.simplemobiletools.gallery.extensions.setAsWallpaper
|
|
||||||
import com.simplemobiletools.gallery.extensions.shareMedium
|
|
||||||
import com.simplemobiletools.gallery.fragments.PhotoFragment
|
import com.simplemobiletools.gallery.fragments.PhotoFragment
|
||||||
import com.simplemobiletools.gallery.fragments.VideoFragment
|
import com.simplemobiletools.gallery.fragments.VideoFragment
|
||||||
import com.simplemobiletools.gallery.fragments.ViewPagerFragment
|
import com.simplemobiletools.gallery.fragments.ViewPagerFragment
|
||||||
|
@ -20,10 +17,11 @@ import com.simplemobiletools.gallery.models.Medium
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentClickListener {
|
open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentClickListener {
|
||||||
|
private var mMedium: Medium? = null
|
||||||
private var mIsFullScreen = false
|
private var mIsFullScreen = false
|
||||||
|
|
||||||
lateinit var mUri: Uri
|
lateinit var mUri: Uri
|
||||||
lateinit var mFragment: ViewPagerFragment
|
lateinit var mFragment: ViewPagerFragment
|
||||||
lateinit var mMedium: Medium
|
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
var mIsVideo = false
|
var mIsVideo = false
|
||||||
|
@ -36,12 +34,16 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentClic
|
||||||
mUri = intent.data ?: return
|
mUri = intent.data ?: return
|
||||||
|
|
||||||
if (mUri.scheme == "file") {
|
if (mUri.scheme == "file") {
|
||||||
Intent(this, ViewPagerActivity::class.java).apply {
|
sendViewPagerIntent(mUri.path)
|
||||||
putExtra(MEDIUM, mUri.path)
|
|
||||||
startActivity(this)
|
|
||||||
}
|
|
||||||
finish()
|
finish()
|
||||||
return
|
return
|
||||||
|
} else {
|
||||||
|
val path = applicationContext.getRealPathFromURI(mUri) ?: ""
|
||||||
|
if (path.isNotEmpty()) {
|
||||||
|
sendViewPagerIntent(path)
|
||||||
|
finish()
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val bundle = Bundle()
|
val bundle = Bundle()
|
||||||
|
@ -66,6 +68,13 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentClic
|
||||||
cursor?.close()
|
cursor?.close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun sendViewPagerIntent(path: String) {
|
||||||
|
Intent(this, ViewPagerActivity::class.java).apply {
|
||||||
|
putExtra(MEDIUM, path)
|
||||||
|
startActivity(this)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun onConfigurationChanged(newConfig: Configuration) {
|
override fun onConfigurationChanged(newConfig: Configuration) {
|
||||||
super.onConfigurationChanged(newConfig)
|
super.onConfigurationChanged(newConfig)
|
||||||
mFragment.updateItem()
|
mFragment.updateItem()
|
||||||
|
@ -74,8 +83,8 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentClic
|
||||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||||
menuInflater.inflate(R.menu.photo_video_menu, menu)
|
menuInflater.inflate(R.menu.photo_video_menu, menu)
|
||||||
|
|
||||||
menu.findItem(R.id.menu_set_as_wallpaper).isVisible = mMedium.isImage()
|
menu.findItem(R.id.menu_set_as_wallpaper).isVisible = mMedium?.isImage() == true
|
||||||
menu.findItem(R.id.menu_edit).isVisible = mMedium.isImage()
|
menu.findItem(R.id.menu_edit).isVisible = mMedium?.isImage() == true
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
@ -83,19 +92,19 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentClic
|
||||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||||
return when (item.itemId) {
|
return when (item.itemId) {
|
||||||
R.id.menu_set_as_wallpaper -> {
|
R.id.menu_set_as_wallpaper -> {
|
||||||
setAsWallpaper(File(mMedium.path))
|
setAsWallpaper(File(mMedium!!.path))
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
R.id.menu_open_with -> {
|
R.id.menu_open_with -> {
|
||||||
openWith(File(mMedium.path))
|
openWith(File(mMedium!!.path))
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
R.id.menu_share -> {
|
R.id.menu_share -> {
|
||||||
shareMedium(mMedium)
|
shareMedium(mMedium!!)
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
R.id.menu_edit -> {
|
R.id.menu_edit -> {
|
||||||
openEditor(File(mMedium.path))
|
openEditor(File(mMedium!!.path))
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
else -> super.onOptionsItemSelected(item)
|
else -> super.onOptionsItemSelected(item)
|
||||||
|
|
Loading…
Reference in a new issue