fixing some third party video related intent handling

This commit is contained in:
tibbi 2019-01-02 23:07:53 +01:00
parent 5f9ebf4920
commit 78b68d3dfe
3 changed files with 25 additions and 19 deletions

View file

@ -57,7 +57,7 @@ android {
} }
dependencies { dependencies {
implementation 'com.simplemobiletools:commons:5.6.2' implementation 'com.simplemobiletools:commons:5.6.3'
implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.0' implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.0'
implementation 'androidx.multidex:multidex:2.0.1' implementation 'androidx.multidex:multidex:2.0.1'
implementation 'it.sephiroth.android.exif:library:1.0.1' implementation 'it.sephiroth.android.exif:library:1.0.1'

View file

@ -16,6 +16,7 @@ import com.simplemobiletools.commons.helpers.IS_FROM_GALLERY
import com.simplemobiletools.commons.helpers.PERMISSION_WRITE_STORAGE import com.simplemobiletools.commons.helpers.PERMISSION_WRITE_STORAGE
import com.simplemobiletools.commons.helpers.REAL_FILE_PATH import com.simplemobiletools.commons.helpers.REAL_FILE_PATH
import com.simplemobiletools.commons.helpers.isPiePlus import com.simplemobiletools.commons.helpers.isPiePlus
import com.simplemobiletools.gallery.pro.BuildConfig
import com.simplemobiletools.gallery.pro.R import com.simplemobiletools.gallery.pro.R
import com.simplemobiletools.gallery.pro.extensions.* import com.simplemobiletools.gallery.pro.extensions.*
import com.simplemobiletools.gallery.pro.fragments.PhotoFragment import com.simplemobiletools.gallery.pro.fragments.PhotoFragment
@ -63,6 +64,12 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList
private fun checkIntent(savedInstanceState: Bundle? = null) { private fun checkIntent(savedInstanceState: Bundle? = null) {
mUri = intent.data ?: return mUri = intent.data ?: return
var filename = getFilenameFromUri(mUri!!) var filename = getFilenameFromUri(mUri!!)
mIsFromGallery = intent.getBooleanExtra(IS_FROM_GALLERY, false)
if (mIsFromGallery && filename.isVideoFast()) {
launchVideoPlayer()
return
}
if (intent.extras?.containsKey(REAL_FILE_PATH) == true) { 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 != null) {
@ -76,7 +83,6 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList
} }
} }
mIsFromGallery = intent.getBooleanExtra(IS_FROM_GALLERY, false)
if (mUri!!.scheme == "file") { if (mUri!!.scheme == "file") {
if (filename.contains('.')) { if (filename.contains('.')) {
scanPathRecursively(mUri!!.path) scanPathRecursively(mUri!!.path)
@ -134,6 +140,21 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList
initBottomActions() initBottomActions()
} }
private fun launchVideoPlayer() {
val newUri = getFinalUriFromPath(mUri.toString(), BuildConfig.APPLICATION_ID)
if (newUri == null) {
toast(R.string.unknown_error_occurred)
return
}
val mimeType = getUriMimeType(mUri.toString(), newUri)
Intent(this, VideoPlayerActivity::class.java).apply {
setDataAndType(newUri, mimeType)
startActivity(this)
}
finish()
}
override fun onConfigurationChanged(newConfig: Configuration?) { override fun onConfigurationChanged(newConfig: Configuration?) {
super.onConfigurationChanged(newConfig) super.onConfigurationChanged(newConfig)
initBottomActionsLayout() initBottomActionsLayout()

View file

@ -8,14 +8,9 @@ import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import com.bumptech.glide.Glide import com.bumptech.glide.Glide
import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.gallery.pro.BuildConfig
import com.simplemobiletools.gallery.pro.R import com.simplemobiletools.gallery.pro.R
import com.simplemobiletools.gallery.pro.activities.PanoramaVideoActivity import com.simplemobiletools.gallery.pro.activities.PanoramaVideoActivity
import com.simplemobiletools.gallery.pro.activities.VideoPlayerActivity import com.simplemobiletools.gallery.pro.extensions.*
import com.simplemobiletools.gallery.pro.extensions.config
import com.simplemobiletools.gallery.pro.extensions.navigationBarWidth
import com.simplemobiletools.gallery.pro.extensions.portrait
import com.simplemobiletools.gallery.pro.extensions.realScreenSize
import com.simplemobiletools.gallery.pro.helpers.IsoTypeReader import com.simplemobiletools.gallery.pro.helpers.IsoTypeReader
import com.simplemobiletools.gallery.pro.helpers.MEDIUM import com.simplemobiletools.gallery.pro.helpers.MEDIUM
import com.simplemobiletools.gallery.pro.helpers.PATH import com.simplemobiletools.gallery.pro.helpers.PATH
@ -142,17 +137,7 @@ class VideoFragment : ViewPagerFragment() {
} }
private fun launchVideoPlayer() { private fun launchVideoPlayer() {
val newUri = activity!!.getFinalUriFromPath(medium.path, BuildConfig.APPLICATION_ID) activity!!.openPath(medium.path, false)
if (newUri == null) {
context!!.toast(R.string.unknown_error_occurred)
return
}
val mimeType = activity!!.getUriMimeType(medium.path, newUri)
Intent(activity, VideoPlayerActivity::class.java).apply {
setDataAndType(newUri, mimeType)
context!!.startActivity(this)
}
} }
private fun toggleFullscreen() { private fun toggleFullscreen() {