From 15485fa183772fdadca2131e53fb448a258ffa64 Mon Sep 17 00:00:00 2001 From: tibbi Date: Thu, 21 Feb 2019 23:43:26 +0100 Subject: [PATCH] fix #1274, be more creative at retrieving file path from third party intents --- .../gallery/pro/activities/PhotoVideoActivity.kt | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/PhotoVideoActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/PhotoVideoActivity.kt index ef96f5afa..8c1688a26 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/PhotoVideoActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/PhotoVideoActivity.kt @@ -68,6 +68,16 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList private fun checkIntent(savedInstanceState: Bundle? = null) { mUri = intent.data ?: return + val uri = mUri.toString() + if (uri.startsWith("content:/") && uri.contains("/storage/")) { + val guessedPath = uri.substring(uri.indexOf("/storage/")) + val extras = intent.extras ?: Bundle() + extras.apply { + putString(REAL_FILE_PATH, guessedPath) + intent.putExtras(this) + } + } + var filename = getFilenameFromUri(mUri!!) mIsFromGallery = intent.getBooleanExtra(IS_FROM_GALLERY, false) if (mIsFromGallery && filename.isVideoFast() && config.openVideosOnSeparateScreen) { @@ -76,7 +86,7 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList } if (intent.extras?.containsKey(REAL_FILE_PATH) == true) { - val realPath = intent.extras.getString(REAL_FILE_PATH) + val realPath = intent.extras!!.getString(REAL_FILE_PATH) if (realPath != null) { if (realPath.getFilenameFromPath().contains('.') || filename.contains('.')) { sendViewPagerIntent(realPath)