Skip to content

Commit

Permalink
Android: Fix UI background on scoped storage.
Browse files Browse the repository at this point in the history
  • Loading branch information
unknownbrackets committed Sep 13, 2021
1 parent 2ecaa61 commit dab1a3a
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions android/src/org/ppsspp/ppsspp/NativeActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -1120,13 +1120,20 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == RESULT_LOAD_IMAGE) {
Uri selectedImage = data.getData();
if (selectedImage != null) {
String[] filePathColumn = {MediaStore.Images.Media.DATA};
Cursor cursor = getContentResolver().query(selectedImage, filePathColumn, null, null, null);
cursor.moveToFirst();
int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
String picturePath = cursor.getString(columnIndex);
cursor.close();
NativeApp.sendMessage("bgImage_updated", picturePath);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
NativeApp.sendMessage("bgImage_updated", selectedImage.toString());
} else {
String[] filePathColumn = {MediaStore.Images.Media.DATA};
Cursor cursor = getContentResolver().query(selectedImage, filePathColumn, null, null, null);
if (cursor != null) {
cursor.moveToFirst();
int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
String picturePath = cursor.getString(columnIndex);
cursor.close();

NativeApp.sendMessage("bgImage_updated", picturePath);
}
}
}
} else if (requestCode == RESULT_OPEN_DOCUMENT) {
Uri selectedFile = data.getData();
Expand Down

0 comments on commit dab1a3a

Please sign in to comment.