allow swiping between images if opened from third party app

This commit is contained in:
tibbi 2016-12-04 11:39:40 +01:00
parent 2469609399
commit f70eb2b2fc

View file

@ -7,7 +7,6 @@ import android.os.Bundle
import android.provider.MediaStore import android.provider.MediaStore
import android.view.Menu import android.view.Menu
import android.view.MenuItem import android.view.MenuItem
import com.simplemobiletools.filepicker.extensions.getFilenameFromPath
import com.simplemobiletools.gallery.Constants import com.simplemobiletools.gallery.Constants
import com.simplemobiletools.gallery.R import com.simplemobiletools.gallery.R
import com.simplemobiletools.gallery.fragments.PhotoFragment import com.simplemobiletools.gallery.fragments.PhotoFragment
@ -31,6 +30,15 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentClic
mUri = intent.data ?: return mUri = intent.data ?: return
if (mUri.scheme == "file") {
Intent(this, ViewPagerActivity::class.java).apply {
putExtra(Constants.MEDIUM, mUri.path)
startActivity(this)
}
finish()
return
}
val bundle = Bundle() val bundle = Bundle()
val file = File(mUri.toString()) val file = File(mUri.toString())
val medium = Medium(file.name, mUri.toString(), mIsVideo, 0, file.length()) val medium = Medium(file.name, mUri.toString(), mIsVideo, 0, file.length())
@ -43,7 +51,6 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentClic
supportFragmentManager.beginTransaction().replace(R.id.fragment_holder, mFragment).commit() supportFragmentManager.beginTransaction().replace(R.id.fragment_holder, mFragment).commit()
} }
if (mUri.scheme == "content") {
val proj = arrayOf(MediaStore.Images.Media.TITLE) val proj = arrayOf(MediaStore.Images.Media.TITLE)
val cursor = contentResolver.query(mUri, proj, null, null, null) val cursor = contentResolver.query(mUri, proj, null, null, null)
if (cursor != null && cursor.count != 0) { if (cursor != null && cursor.count != 0) {
@ -52,9 +59,6 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentClic
title = cursor.getString(columnIndex) title = cursor.getString(columnIndex)
} }
cursor?.close() cursor?.close()
} else {
title = mUri.toString().getFilenameFromPath()
}
} }
override fun onConfigurationChanged(newConfig: Configuration) { override fun onConfigurationChanged(newConfig: Configuration) {