Skip to content

Commit

Permalink
Merge pull request #527 from maks/521-view-files-without-texteditor
Browse files Browse the repository at this point in the history
fix handling js mimetypes
  • Loading branch information
maks authored Mar 3, 2020
2 parents 0caeb52 + 15c9407 commit 3d708fe
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions app/src/main/java/me/sheimi/android/utils/FsUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,8 @@ public static void openFile(SheimiFragmentActivity activity, File file) {
activity.startActivity(intent);
activity.forwardTransition();
} catch (ActivityNotFoundException e) {
//This can occur if no app for file type or more than one app
// Looks like many editor apps only register for VIEW not EDIT intents :-(
intent.setAction(Intent.ACTION_VIEW);
intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
try {
activity.startActivity(intent);
activity.forwardTransition();
Expand Down Expand Up @@ -201,4 +200,7 @@ public static File joinPath(File dir, String relative_path) {
return new File(dir.getAbsolutePath() + File.separator + relative_path);
}

public static boolean isTextMimeType(String mime) {
return mime.startsWith("text") || mime.equals("application/javascript") || mime.equals("application/json");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public void onItemClick(AdapterView<?> adapterView,
return;
}
String mime = FsUtils.getMimeType(file);
if (mime.startsWith("text")) {
if (FsUtils.isTextMimeType(mime)) {
Intent intent = new Intent(getActivity(),
ViewFileActivity.class);
intent.putExtra(ViewFileActivity.TAG_FILE_NAME,
Expand Down

0 comments on commit 3d708fe

Please sign in to comment.