MiraFilePicker is an Android Library that lets you choose any kind of file easyly. It handles the storage permission itself.
Api Level 19 or Above
Api Level 30 and Above (Compatible With Scope Storage)
Add the following code snippet in your project level gradle file
repositories {
...
maven { url 'https://jitpack.io' }
}
Add the dependency in your app gradle
dependencies {
...
implementation 'com.github.yehiareda4:MiraFile:$latest_version' //choose latest version
}
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
tools:ignore="ScopedStorage" />
<application
...
android:preserveLegacyExternalStorage="true"
android:requestLegacyExternalStorage="true"/>
@SuppressLint("NotifyDataSetChanged")
private fun setFilesSheet() {
toast =
requireContext().createToast(getString(R.string.upload_file_error), ToastType.WARNING)
val types: MutableList<String> = ArrayList()
types.add(PickerTypesSheet.MIME_TYPE_IMAGE)
types.add(PickerTypesSheet.MIME_TYPE_PDF)
typesSheet = PickerTypesSheet(
requireActivity() as AppCompatActivity,
this,
types,
camera = true,
multiple = true,
multipleCount = maxCount
) { file, max ->
listFiles.add(file)
listFilesPaths.add(file.path)
filesAdapter.notifyDataSetChanged()
if (max) {
toast?.show()
}
}
}
typesSheet.show()
typesSheet.show(sizeList)
typesSheet.show(sizeList: Int = 0, type: Type? = null, cleanImages: Boolean = false)
typesSheet.multiple = BOOLEAN_VALUE
typesSheet.multipleCount = INT_VALUE
Property | Type | Description |
---|---|---|
file | File | Selected file file |
name | String | Selected file name |
size | String | Selected file size |
path | String | Selected file path |
extension | String | Selected file extension |
filePart | MultipartBody.Part? | Selected file filePart |
mediaType | String | Selected file mediaType |
Thumbnail | String | Selected file Thumbnail |
ThumbnailPart | MultipartBody.Part? | Selected file ThumbnailPart |
duration | String | Selected file duration |
- v1.0.0 support Java and Kotlin and migrate to AndroidX