allow setting a default third party video player
This commit is contained in:
parent
894a864124
commit
a36ffb297a
2 changed files with 12 additions and 6 deletions
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue