[PM-24411] Add MIME type parameter to file chooser intent (#5661)

This commit is contained in:
Patrick Honkonen
2025-08-07 13:55:50 -04:00
committed by GitHub
parent 85bc76d0a6
commit 93edbb61bf
2 changed files with 7 additions and 3 deletions

View File

@@ -95,8 +95,12 @@ interface IntentManager {
/**
* Creates an intent for choosing a file saved to disk.
*
* @param withCameraIntents Whether to include camera intents in the chooser.
* @param mimeType The MIME type of the files to be selected. Defaults to wildcard to allow all
* types.
*/
fun createFileChooserIntent(withCameraIntents: Boolean): Intent
fun createFileChooserIntent(withCameraIntents: Boolean, mimeType: String = "*/*"): Intent
/**
* Creates an intent to use when selecting to save an item with [fileName] to disk.

View File

@@ -228,11 +228,11 @@ class IntentManagerImpl(
}
}
override fun createFileChooserIntent(withCameraIntents: Boolean): Intent {
override fun createFileChooserIntent(withCameraIntents: Boolean, mimeType: String): Intent {
val chooserIntent = Intent.createChooser(
Intent(Intent.ACTION_OPEN_DOCUMENT)
.addCategory(Intent.CATEGORY_OPENABLE)
.setType("*/*"),
.setType(mimeType),
ContextCompat.getString(context, BitwardenString.file_source),
)