Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8006,19 +8006,27 @@ private String getImageFilePath(Uri uri) {
//String[] filePaths = file.getPath().split(":");
//String image_id = filePath[filePath.length - 1];
String[] filePathColumn = {MediaStore.Images.Media.DATA};
Cursor cursor = getContext().getContentResolver().query(
android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
new String[]{ MediaStore.Images.Media.DATA},
null,
null,
null
);
cursor.moveToFirst();
int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
String filePath = cursor.getString(columnIndex);
cursor.close();

if (filePath == null || "content".equals(scheme)) {
Cursor cursor = getContext().getContentResolver().query(
android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
new String[]{ MediaStore.Images.Media.DATA},
null,
null,
null
);
// Some gallery providers may return an empty cursor on modern Android builds.
String filePath = null;
if (cursor != null) {
try {
int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
if (columnIndex >= 0 && cursor.moveToFirst()) {
filePath = cursor.getString(columnIndex);
}
} finally {
cursor.close();
}
}

if (filePath == null || "content".equals(scheme)) {
//if the file is not on the filesystem download it and save it
//locally
try {
Expand Down Expand Up @@ -8159,24 +8167,26 @@ else if (requestCode == FILECHOOSER_RESULTCODE) {
Uri selectedImage = intent.getData();
String scheme = intent.getScheme();

String[] filePathColumn = {MediaStore.Images.Media.DATA};
Cursor cursor = getContext().getContentResolver().query(selectedImage, filePathColumn, null, null, null);

// this happens on Android devices, not exactly sure what the use case is
if(cursor == null) {
callback.fireActionEvent(null);
return;
}

cursor.moveToFirst();
int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
String filePath = cursor.getString(columnIndex);
cursor.close();
boolean fileExists = false;
if (filePath != null) {
File file = new File(filePath);
fileExists = file.exists() && file.canRead();
}
String[] filePathColumn = {MediaStore.Images.Media.DATA};
Cursor cursor = getContext().getContentResolver().query(selectedImage, filePathColumn, null, null, null);

// Some gallery providers may return an empty cursor on modern Android builds.
String filePath = null;
if (cursor != null) {
try {
int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
if (columnIndex >= 0 && cursor.moveToFirst()) {
filePath = cursor.getString(columnIndex);
}
} finally {
cursor.close();
}
}
boolean fileExists = false;
if (filePath != null) {
File file = new File(filePath);
fileExists = file.exists() && file.canRead();
}

if (!fileExists && "content".equals(scheme)) {
//if the file is not on the filesystem download it and save it
Expand Down Expand Up @@ -8204,26 +8214,33 @@ else if (requestCode == FILECHOOSER_RESULTCODE) {
}
}

callback.fireActionEvent(new ActionEvent(new String[]{filePath}));
return;
if (filePath == null) {
callback.fireActionEvent(null);
return;
}

callback.fireActionEvent(new ActionEvent(new String[]{filePath}));
return;
} else if (requestCode == OPEN_GALLERY) {

Uri selectedImage = intent.getData();
String scheme = intent.getScheme();

String[] filePathColumn = {MediaStore.Images.Media.DATA};
Cursor cursor = getContext().getContentResolver().query(selectedImage, filePathColumn, null, null, null);

// this happens on Android devices, not exactly sure what the use case is
if(cursor == null) {
callback.fireActionEvent(null);
return;
String[] filePathColumn = {MediaStore.Images.Media.DATA};
Cursor cursor = getContext().getContentResolver().query(selectedImage, filePathColumn, null, null, null);

// Some gallery providers may return an empty cursor on modern Android builds.
String filePath = null;
if (cursor != null) {
try {
int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
if (columnIndex >= 0 && cursor.moveToFirst()) {
filePath = cursor.getString(columnIndex);
}
} finally {
cursor.close();
}
}

cursor.moveToFirst();
int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
String filePath = cursor.getString(columnIndex);
cursor.close();
boolean fileExists = false;
if (filePath != null) {
File file = new File(filePath);
Expand Down Expand Up @@ -8256,6 +8273,11 @@ else if (requestCode == FILECHOOSER_RESULTCODE) {
}
}

if (filePath == null) {
callback.fireActionEvent(null);
return;
}

callback.fireActionEvent(new ActionEvent(filePath));
return;
} else {
Expand Down