From 050a62ca808a82987e89c911171fc06fd4fe54c2 Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 17 Dec 2018 16:14:51 +0100 Subject: [PATCH] fix #948, add third party intent files in the db at Review intent action --- .../pro/activities/ViewPagerActivity.kt | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt index 8ff340ec4..9c96ec30e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt @@ -80,6 +80,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View var screenHeight = 0 } + @TargetApi(Build.VERSION_CODES.P) override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_medium) @@ -337,6 +338,24 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View } } } + + if (intent.action == "com.android.camera.action.REVIEW") { + Thread { + if (galleryDB.MediumDao().getMediaFromPath(mPath).isEmpty()) { + val type = when { + mPath.isVideoFast() -> TYPE_VIDEOS + mPath.isGif() -> TYPE_GIFS + mPath.isSvg() -> TYPE_SVGS + mPath.isRawFast() -> TYPE_RAWS + else -> TYPE_IMAGES + } + + val duration = if (type == TYPE_VIDEOS) mPath.getVideoDuration() else 0 + val medium = Medium(null, mPath.getFilenameFromPath(), mPath, mPath.getParentPath(), System.currentTimeMillis(), System.currentTimeMillis(), File(mPath).length(), type, duration, false, 0) + galleryDB.MediumDao().insert(medium) + } + }.start() + } } private fun initBottomActions() {