mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-02-21 02:08:40 +00:00
Use the last part of the URI if the scheme is "file" to avoid returning null as the file's name. Fixes #8561
This commit is contained in:
committed by
Cody Henthorne
parent
da34f9e989
commit
d254d24d77
@@ -233,6 +233,10 @@ class ShareRepository {
|
||||
}
|
||||
|
||||
private static @Nullable String getFileName(@NonNull Context context, @NonNull Uri uri) {
|
||||
if (uri.getScheme().equalsIgnoreCase("file")) {
|
||||
return uri.getLastPathSegment();
|
||||
}
|
||||
|
||||
try (Cursor cursor = context.getContentResolver().query(uri, null, null, null, null)) {
|
||||
if (cursor != null && cursor.moveToFirst() && cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME) >= 0) {
|
||||
return cursor.getString(cursor.getColumnIndexOrThrow(OpenableColumns.DISPLAY_NAME));
|
||||
|
||||
Reference in New Issue
Block a user