Skip to content

Commit

Permalink
#176: Fixed a bug when opening files via an external application (e.g…
Browse files Browse the repository at this point in the history
…. gallery) on Android <= 10.
  • Loading branch information
Keidan committed Feb 15, 2022
1 parent d782e65 commit 3163e47
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions app/src/main/java/fr/ralala/hexviewer/models/FileData.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,11 @@ public FileData(final Context ctx, final Uri uri, boolean openFromAppIntent, lon
mRealSize = FileHelper.getFileSize(ctx.getContentResolver(), uri);

if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.Q) {
DocumentFile sourceFile = DocumentFile.fromSingleUri(ctx, mUri);
mIsNotFound = (sourceFile == null || !sourceFile.exists());
/* We assume that if the file sizes are not <= 0, the file exists. */
if(mSize <= 0 || mRealSize <= 0) {
DocumentFile sourceFile = DocumentFile.fromSingleUri(ctx, mUri);
mIsNotFound = (sourceFile == null || !sourceFile.exists());
}
}
if (mIsNotFound) {
mIsAccessError = false;
Expand Down

0 comments on commit 3163e47

Please sign in to comment.