allow setting a default third party video player

This commit is contained in:
tibbi 2017-03-04 22:53:05 +01:00
parent 894a864124
commit a36ffb297a
2 changed files with 12 additions and 6 deletions

View file

@ -330,10 +330,16 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
}
finish()
} else {
Intent(this, ViewPagerActivity::class.java).apply {
putExtra(MEDIUM, path)
putExtra(SHOW_ALL, mShowAll)
startActivity(this)
val file = File(path)
val isVideo = file.isVideoFast()
if (isVideo) {
openWith(file, false)
} else {
Intent(this, ViewPagerActivity::class.java).apply {
putExtra(MEDIUM, path)
putExtra(SHOW_ALL, mShowAll)
startActivity(this)
}
}
}
}

View file

@ -71,14 +71,14 @@ fun Activity.setAsWallpaper(file: File) {
}
}
fun Activity.openWith(file: File) {
fun Activity.openWith(file: File, forceChooser: Boolean = true) {
val intent = Intent(Intent.ACTION_VIEW)
val uri = Uri.fromFile(file)
intent.setDataAndType(uri, file.getMimeType("image/jpeg"))
val chooser = Intent.createChooser(intent, getString(R.string.open_with))
if (intent.resolveActivity(packageManager) != null) {
startActivity(chooser)
startActivity(if (forceChooser) chooser else intent)
} else {
toast(R.string.no_app_found)
}