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