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()
|
finish()
|
||||||
} else {
|
} else {
|
||||||
Intent(this, ViewPagerActivity::class.java).apply {
|
val file = File(path)
|
||||||
putExtra(MEDIUM, path)
|
val isVideo = file.isVideoFast()
|
||||||
putExtra(SHOW_ALL, mShowAll)
|
if (isVideo) {
|
||||||
startActivity(this)
|
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 intent = Intent(Intent.ACTION_VIEW)
|
||||||
val uri = Uri.fromFile(file)
|
val uri = Uri.fromFile(file)
|
||||||
intent.setDataAndType(uri, file.getMimeType("image/jpeg"))
|
intent.setDataAndType(uri, file.getMimeType("image/jpeg"))
|
||||||
val chooser = Intent.createChooser(intent, getString(R.string.open_with))
|
val chooser = Intent.createChooser(intent, getString(R.string.open_with))
|
||||||
|
|
||||||
if (intent.resolveActivity(packageManager) != null) {
|
if (intent.resolveActivity(packageManager) != null) {
|
||||||
startActivity(chooser)
|
startActivity(if (forceChooser) chooser else intent)
|
||||||
} else {
|
} else {
|
||||||
toast(R.string.no_app_found)
|
toast(R.string.no_app_found)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue