Skip to content

Commit

Permalink
feat: Make .htm openable as html file
Browse files Browse the repository at this point in the history
  • Loading branch information
CyberGlitch01 committed Sep 11, 2023
1 parent f9b9e53 commit 1a4c8ce
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public void onClick(View v) {
case "java":
case "xml":
case "html":
case "htm":
case "css":
case "js":
case "md":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -388,12 +388,15 @@ public void run() {
binding.list.addView(treeView);
}
if (preview != null && openedFile != null) {
if (FileUtils.getPathFormat(openedFile.getAbsolutePath()).equals("md")
|| FileUtils.getPathFormat(openedFile.getAbsolutePath()).equals("html")) {
preview.setVisible(true);
} else {
preview.setVisible(false);
boolean showPreview = false;
switch (FileUtils.getPathFormat(openedFile.getAbsolutePath())) {
case "md":
case "html":
case "htm":
showPreview = true;
break;
}
preview.setVisible(showPreview);
}

if (codeEditor != null) {
Expand All @@ -413,12 +416,15 @@ public boolean onPrepareOptionsMenu(Menu arg0) {
menu = arg0;
preview = arg0.findItem(R.id.preview);
if (openedFile != null) {
if (FileUtils.getPathFormat(openedFile.getAbsolutePath()).equals("md")
|| FileUtils.getPathFormat(openedFile.getAbsolutePath()).equals("html")) {
preview.setVisible(true);
} else {
preview.setVisible(false);
boolean showPreview = false;
switch (FileUtils.getPathFormat(openedFile.getAbsolutePath())) {
case "md":
case "html":
case "htm":
showPreview = true;
break;
}
preview.setVisible(showPreview);
} else {
preview.setVisible(false);
}
Expand Down Expand Up @@ -496,12 +502,15 @@ public void onTaskComplete() {
adapter.notifyDataSetChanged();

if (preview != null) {
if (FileUtils.getPathFormat(file.getAbsolutePath()).equals("md")
|| FileUtils.getPathFormat(file.getAbsolutePath()).equals("html")) {
preview.setVisible(true);
} else {
preview.setVisible(false);
boolean showPreview = false;
switch (FileUtils.getPathFormat(file.getAbsolutePath())) {
case "md":
case "html":
case "htm":
showPreview = true;
break;
}
preview.setVisible(showPreview);
}

binding.fileNotOpenedArea.setVisibility(View.GONE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ public void run() {
case "java":
case "xml":
case "html":
case "htm":
case "css":
case "js":
case "md":
Expand Down
1 change: 1 addition & 0 deletions app/src/main/java/android/code/editor/utils/FileIcon.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public static void setUpIcon(Context context, String path, ImageView imageview)
imageview.setImageResource(R.drawable.file_xml_box);
break;
case "html":
case "htm":
imageview.setImageResource(R.drawable.language_html);
break;
case "css":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public static String getLanguageModeForExtension(String ext) {
return Language.Java;
} else if (ext.equals("xml")) {
return Language.XML;
} else if (ext.equals("html")) {
} else if (ext.equals("html") || ext.equals("htm")) {
return Language.HTML;
} else if (ext.equals("css")) {
return Language.CSS;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"java": "source.java",
"md": "text.html.markdown",
"css": "source.css",
"htm": "text.html.basic",
"html": "text.html.basic",
"xml": "text.xml"
}

0 comments on commit 1a4c8ce

Please sign in to comment.