You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Adds error messages and logic to file pickers to handle cases where no file is selected.
- Includes new string resources for "no data" errors in document and media pickers.
- Modifies `DocumentFilePickerActivity` and `MediaFilePickerActivity` to check for `clipData` when `data` is null and set a canceled result with the appropriate error message if no file is found.
Copy file name to clipboardExpand all lines: filepickerlibrary/src/main/java/com/nareshchocha/filepickerlibrary/ui/activitys/DocumentFilePickerActivity.kt
+6Lines changed: 6 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -57,6 +57,12 @@ internal class DocumentFilePickerActivity : ComponentActivity() {
57
57
val data = result.data?.data
58
58
val filePath = data?.let { FileUtils.getRealPath(this, it) }
59
59
setSuccessResult(data, filePath)
60
+
} elseif (result.data?.clipData !=null) {
61
+
val uri = result.data?.getClipDataUris()?.firstOrNull()
62
+
val filePath = uri?.let { FileUtils.getRealPath(this, it) }
Copy file name to clipboardExpand all lines: filepickerlibrary/src/main/java/com/nareshchocha/filepickerlibrary/ui/activitys/MediaFilePickerActivity.kt
+6Lines changed: 6 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -58,6 +58,12 @@ internal class MediaFilePickerActivity : ComponentActivity() {
58
58
val data = result.data?.data
59
59
val filePath = data?.let { FileUtils.getRealPath(this, it) }
60
60
setSuccessResult(data, filePath)
61
+
} elseif (result.data?.clipData !=null) {
62
+
val uri = result.data?.getClipDataUris()?.firstOrNull()
63
+
val filePath = uri?.let { FileUtils.getRealPath(this, it) }
<stringname="document_file_picker_config_null_error">The document picker configuration is missing.</string>
50
50
<stringname="document_file_picker_permission_rationale">This app requires access to your storage in order to pick and manage documents. Please grant the storage permission to proceed.</string>
51
+
<stringname="document_file_picker_no_data_error">No Document files found in the selected directory.</string>
51
52
52
53
<!-- Media file picker configuration error message -->
53
54
<stringname="media_file_picker_config_null_error">The media file picker configuration is missing.</string>
54
55
<stringname="media_file_picker_permission_rationale">This app requires access to your storage to pick media files such as images and videos. Please grant the storage permission to continue.</string>
56
+
<stringname="media_file_picker_no_data_error">No media files found in the selected directory.</string>
0 commit comments