force an app chooser at some openFile intents

This commit is contained in:
tibbi 2017-10-27 14:08:33 +02:00
parent b6a266d436
commit c9f6668fc1
5 changed files with 6 additions and 6 deletions

View file

@ -504,7 +504,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
val file = File(path)
val isVideo = file.isVideoFast()
if (isVideo) {
openFile(Uri.fromFile(file))
openFile(Uri.fromFile(file), false)
} else {
Intent(this, ViewPagerActivity::class.java).apply {
putExtra(MEDIUM, path)

View file

@ -130,7 +130,7 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList
when (item.itemId) {
R.id.menu_set_as -> setAs(mUri)
R.id.menu_open_with -> openFile(mUri)
R.id.menu_open_with -> openFile(mUri, true)
R.id.menu_share -> shareUri(mUri)
R.id.menu_edit -> openEditor(mUri)
R.id.menu_properties -> showProperties()

View file

@ -250,7 +250,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
R.id.slideshow -> initSlideshow()
R.id.menu_copy_to -> copyMoveTo(true)
R.id.menu_move_to -> copyMoveTo(false)
R.id.menu_open_with -> openFile(Uri.fromFile(getCurrentFile()))
R.id.menu_open_with -> openFile(Uri.fromFile(getCurrentFile()), true)
R.id.menu_hide -> toggleFileVisibility(true)
R.id.menu_unhide -> toggleFileVisibility(false)
R.id.menu_share_1 -> shareMedium(getCurrentMedium()!!)

View file

@ -87,7 +87,7 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList<Medium>,
R.id.cab_copy_to -> copyMoveTo(true)
R.id.cab_move_to -> copyMoveTo(false)
R.id.cab_select_all -> selectAll()
R.id.cab_open_with -> activity.openFile(Uri.fromFile(getCurrentFile()))
R.id.cab_open_with -> activity.openFile(Uri.fromFile(getCurrentFile()), true)
R.id.cab_set_as -> activity.setAs(Uri.fromFile(getCurrentFile()))
R.id.cab_delete -> checkDeleteConfirmation()
else -> return false

View file

@ -79,7 +79,7 @@ fun Activity.setAs(uri: Uri) {
}
}
fun Activity.openFile(uri: Uri) {
fun Activity.openFile(uri: Uri, forceChooser: Boolean) {
val newUri = ensurePublicUri(uri)
Intent().apply {
action = Intent.ACTION_VIEW
@ -93,7 +93,7 @@ fun Activity.openFile(uri: Uri) {
if (resolveActivity(packageManager) != null) {
val chooser = Intent.createChooser(this, getString(R.string.open_with))
startActivity(chooser)
startActivity(if (forceChooser) chooser else this)
} else {
toast(R.string.no_app_found)
}