From f70eb2b2fc9b00e5dfeae88eba6e6007106619bc Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 4 Dec 2016 11:39:40 +0100 Subject: [PATCH] allow swiping between images if opened from third party app --- .../gallery/activities/PhotoVideoActivity.kt | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/PhotoVideoActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/PhotoVideoActivity.kt index afbc083a7..bcf1a6ec7 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/PhotoVideoActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/PhotoVideoActivity.kt @@ -7,7 +7,6 @@ import android.os.Bundle import android.provider.MediaStore import android.view.Menu import android.view.MenuItem -import com.simplemobiletools.filepicker.extensions.getFilenameFromPath import com.simplemobiletools.gallery.Constants import com.simplemobiletools.gallery.R import com.simplemobiletools.gallery.fragments.PhotoFragment @@ -31,6 +30,15 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentClic 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 file = File(mUri.toString()) val medium = Medium(file.name, mUri.toString(), mIsVideo, 0, file.length()) @@ -43,18 +51,14 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentClic supportFragmentManager.beginTransaction().replace(R.id.fragment_holder, mFragment).commit() } - if (mUri.scheme == "content") { - val proj = arrayOf(MediaStore.Images.Media.TITLE) - val cursor = contentResolver.query(mUri, proj, null, null, null) - if (cursor != null && cursor.count != 0) { - val columnIndex = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.TITLE) - cursor.moveToFirst() - title = cursor.getString(columnIndex) - } - cursor?.close() - } else { - title = mUri.toString().getFilenameFromPath() + val proj = arrayOf(MediaStore.Images.Media.TITLE) + val cursor = contentResolver.query(mUri, proj, null, null, null) + if (cursor != null && cursor.count != 0) { + val columnIndex = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.TITLE) + cursor.moveToFirst() + title = cursor.getString(columnIndex) } + cursor?.close() } override fun onConfigurationChanged(newConfig: Configuration) {