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

@ -329,6 +329,11 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
setResult(Activity.RESULT_OK, this)
}
finish()
} else {
val file = File(path)
val isVideo = file.isVideoFast()
if (isVideo) {
openWith(file, false)
} else {
Intent(this, ViewPagerActivity::class.java).apply {
putExtra(MEDIUM, path)
@ -337,6 +342,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
}
}
}
}
fun gotMedia(media: ArrayList<Medium>) {
mIsGettingMedia = false

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)
}