Skip to content

Commit

Permalink
Merge branch 'master' into l10n_master
Browse files Browse the repository at this point in the history
  • Loading branch information
gsantner authored Dec 27, 2023
2 parents 90269d3 + 7541b2f commit 61173a0
Show file tree
Hide file tree
Showing 17 changed files with 1,999 additions and 18 deletions.
2 changes: 2 additions & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,5 @@ Where:
* **[Winston Feng](https://github.com/tifish)**<br/>~° Support spaces in URL
* **[k3b](https://github.com/k3b)**<br/>~° Added CSV-Support
* **[Li Guanglin](https://github.com/guanglinn)**<br/>~° Added line numbers support
* **[bigger124](https://github.com/bigger124)**<br>~° Added OrgMode-Support
* **[Ayowel](https://github.com/ayowel)**<br>~° Mermaid update
17 changes: 16 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@

<action android:name="com.google.android.gm.action.AUTO_SEND" />
<category android:name="com.google.android.voicesearch.SELF_NOTE" />
<action android:name="android.intent.action.PROCESS_TEXT" />

<data android:mimeType="text/plain" />
<data android:mimeType="text/*" />
Expand Down Expand Up @@ -1080,6 +1079,22 @@

</intent-filter>
</activity>

<activity-alias
android:name="AliasDocumentProcessText"
android:label="@string/app_name"
android:exported="true"
android:targetActivity=".activity.DocumentActivity"
android:enabled="false">

<intent-filter>
<category android:name="android.intent.category.DEFAULT" />
<action android:name="android.intent.action.PROCESS_TEXT" />

<data android:mimeType="text/plain" />
<data android:mimeType="text/*" />
</intent-filter>
</activity-alias>
</application>

<queries>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@

import android.content.Context;

import androidx.core.text.TextUtilsCompat;

import net.gsantner.markor.format.TextConverterBase;
import net.gsantner.opoc.util.GsFileUtils;
import net.gsantner.opoc.format.GsTextUtils;

import java.io.File;
import java.util.ArrayList;
Expand All @@ -14,11 +13,16 @@

@SuppressWarnings("WeakerAccess")
public class OrgmodeTextConverter extends TextConverterBase {
private static final String HTML100_BODY_PRE_BEGIN = "<pre style='white-space: pre-wrap;font-family: " + TOKEN_FONT + "' >";
private static final String HTML101_BODY_PRE_END = "</pre>";
private static final List<String> EXT_ORG = Arrays.asList(".org");
private static final List<String> EXT = new ArrayList<>();

/**
* this file is exported by browserify from <a href="https://github.com/mooz/org-js">org-js</a>
*/
public static final String HTML_ORG_JS_INCLUDE = "<script src='file:///android_asset/orgmode/org-bundle.js'></script>\n";
public static final String HTML_ORG_CSS_INCLUDE = "<link href='file:///android_asset/orgmode/org.css' type='text/css' rel='stylesheet'/>\n";


static {
EXT.addAll(EXT_ORG);
}
Expand All @@ -29,16 +33,28 @@ public class OrgmodeTextConverter extends TextConverterBase {

@Override
public String convertMarkup(String markup, Context context, boolean lightMode, boolean lineNum, File file) {
String converted = "", onLoadJs = "", head = "";
final String extWithDot = GsFileUtils.getFilenameExtension(file);

///////////////////////////////////////////
// Convert
///////////////////////////////////////////
converted = HTML100_BODY_PRE_BEGIN
+ TextUtilsCompat.htmlEncode(markup)
+ HTML101_BODY_PRE_END;
return putContentIntoTemplate(context, converted, lightMode, file, onLoadJs, head);

String converted = "<div id=\"orgmode_content\"></div>\n";
String onLoadJs =
"var textBase64 = `" +
//convert a text to base64 to simplify supporting special characters
GsTextUtils.toBase64(markup) +
"`;\n" +
//decode base64 to utf8 string
"const asciiPlainText = atob(textBase64);\n" +
"const length = asciiPlainText.length;\n" +
"const bytes = new Uint8Array(length);\n" +
"for (let i = 0; i < length; i++) {\n" +
" bytes[i] = asciiPlainText.charCodeAt(i);\n" +
"}\n" +
"const decoder = new TextDecoder();\n" +
"var utf8PlainText = decoder.decode(bytes);" +
"var parser = new org.Parser();\n" +
"var orgDocument = parser.parse(utf8PlainText);\n" +
"var orgHTMLDocument = orgDocument.convert(org.ConverterHTML, {});" +
"document.getElementById(\"orgmode_content\").innerHTML = orgHTMLDocument;" +
"";
return putContentIntoTemplate(context, converted, lightMode, file, onLoadJs, HTML_ORG_JS_INCLUDE + HTML_ORG_CSS_INCLUDE);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,10 @@ private String getTemplateByPos(
"3;\"multi\n" +
" line\";2059-12-24\n";
}
case 12: {
// orgmode
return "OrgMode Reference\n" + "* Headline\n" + "** Nested headline\n" + "*** Deeper\n" + "\n" + "* Basic markup\n" + "This is the general building block for org-mode navigation.\n" + "- _underscores let you underline things_\n" + "- *stars add emphasis*\n" + "- /slashes are italics/\n" + "- +pluses are strikethrough+\n" + "- =equal signs are verbatim text=\n" + "- ~tildes can also be used~\n" + "\n" + "* List\n" + "** Unordered List\n" + "- Item 1\n" + "- Item 2\n" + " - Subitem 2.1\n" + " - Subitem 2.2\n" + "** Ordered List\n" + "1. First Item\n" + "2. Second Item\n" + " 1. Subitem 2.1\n" + " 2. Subitem 2.2\n" + "- [X] Completed Task\n" + "- [ ] Uncompleted Task\n" + "** Nested List\n" + " - Item A\n" + " - Subitem A.1\n" + " - Subitem A.2\n" + " - Item B\n" + "\n" + "* Tables\n" + "\n" + "| First Name | Last Name | Years using Emacs |\n" + "|----------------------------+---------------------+-------------------|\n" + "| Lee | Hinman | 5 |\n" + "| Mike | Hunsinger | 2 |\n" + "| Daniel | Glauser | 4 |\n" + "| Really-long-first-name-guy | long-last-name-pers | 1 |\n" + "\n" + "* Org-mode links\n" + "\n" + "#+BEGIN_SRC fundamental\n" + "[[http://google.com/][Google]]\n" + "#+END_SRC\n" + "\n" + "[[./images/pic1.png]]\n" + "\n" + "\n" + "* TODO List\n" + "** TODO This is a task that needs doing\n" + "** TODO Another todo task\n" + "- [ ] sub task one\n" + "- [X] sub task two\n" + "- [ ] sub task three\n" + "** DONE I've already finished this one\n" + "*** CANCELLED learn todos\n" + " CLOSED: [2023-10-16 Mon 08:39]\n" + "\n" + "* Code\n" + "#+BEGIN_LaTeX\n" + "$a + b$\n" + "#+END_LaTeX\n" + "\n" + "#+BEGIN_SRC emacs-lisp\n" + "(defun my/function ()\n" + " \"docstring\"\n" + " (interactive)\n" + " (progn\n" + " (+ 1 1)\n" + " (message \"Hi\")))\n" + "#+END_SRC\n" + "\n";
}
}
return null;
}
Expand Down Expand Up @@ -366,4 +370,4 @@ private Pair<byte[], Integer> getTemplateContent(

return Pair.create(bytes, startingIndex);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public <T extends GsContextUtils> T applySpecialLaunchersVisibility(final Contex
setLauncherActivityEnabled(context, OpenEditorQuickNoteActivity.class, extraLaunchersEnabled);
setLauncherActivityEnabled(context, OpenEditorTodoActivity.class, extraLaunchersEnabled);
setLauncherActivityEnabled(context, OpenShareIntoActivity.class, extraLaunchersEnabled);
setLauncherActivityEnabledFromString(context, "net.gsantner.markor.AliasDocumentProcessText", extraLaunchersEnabled);
return thisp();
}

Expand Down
9 changes: 9 additions & 0 deletions app/src/main/java/net/gsantner/opoc/util/GsContextUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -1150,6 +1150,15 @@ public <T extends GsContextUtils> T setLauncherActivityEnabled(final Context con
return thisp();
}

public <T extends GsContextUtils> T setLauncherActivityEnabledFromString(final Context context, String activityClass, boolean enable) {
try {
ComponentName component = new ComponentName(context, activityClass);
context.getPackageManager().setComponentEnabledSetting(component, enable ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED : PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
} catch (Exception ignored) {
}
return thisp();
}

/**
* Try to create a new desktop shortcut on the launcher. Add permissions:
* <uses-permission android:name="android.permission.INSTALL_SHORTCUT" />
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/drawable-anydpi-v26/ic_launcher.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background"/>
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
<monochrome android:drawable="@drawable/ic_launcher_monochrome"/>
</adaptive-icon>
19 changes: 19 additions & 0 deletions app/src/main/res/drawable/ic_launcher_monochrome.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:targetApi="n"
android:width="108dp"
android:height="108dp"
android:viewportWidth="930"
android:viewportHeight="930">
<path
android:pathData="M384.8,579l140.7,0l0,26l-140.7,0z"
android:fillColor="#000000"/>
<path
android:pathData="m305.7,321.1l0,284.1l73,0l0,-191.7l77.2,69 0.1,0.1 78.7,-69.1l0,191.7L607.8,605.2L607.8,321.1l-73,0l-78,69.8 -78,-69.8z"
android:fillType="evenOdd"
android:fillColor="#000000"/>
<path
android:pathData="m408.9,592.6 l42.7,-83.2 186.2,-175c31.2,-24.4 67.2,24.5 41.3,52.2l-186.7,170.4z"
android:fillType="evenOdd"
android:fillColor="#000000"/>
</vector>
18 changes: 18 additions & 0 deletions app/src/main/res/drawable/ic_org_mode_file.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<vector android:height="24dp"
android:viewportHeight="160"
android:viewportWidth="145"
android:width="24dp"
xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#000"
android:pathData="M14.1,117.64s10.02,36.1 46.55,24.68c36.26,-10.28 56.26,13.81 58.57,15.5 3.4,3.43 -8.79,-29.83 -34.59,-44.79 -15.25,-8.32 -5.68,-22.66 -4.59,-27.72 0,0 12.23,8.56 21.09,-4.52 8,2.06 13.37,-1.46 20.25,1.03 4.18,1.83 21.77,0.73 15.23,-9.1 4.11,-2.68 4.54,-1.82 6.6,-5.9 1.11,-4.95 -1.4,-6.01 -2.17,-7.37 -0.2,-3.15 -2.84,-4.37 -5.99,-2.13 -7.22,-1.3 -14.31,-0.69 -17.8,-0.98 -7.66,-1.07 -14.04,-5.13 -14.04,-5.13 0.93,-1.24 0.49,-3.92 -5.5,-4.1 -3.29,-1.08 -6.75,-3.14 -9.29,-3.16 -2.57,0 -2.91,-2.54 -2.91,-2.54 -1.61,-0.87 -3.92,-4.25 -3.9,-9.44 0,-3.28 -6.1,0.32 -6.1,6.78s-5.82,7.76 -5.82,7.76 -2.55,-2.28 -2.86,-5.96c-0.58,-3.79 -4.93,-9.56 -7.06,-2.43 -3.23,7.65 -3.48,9.43 -4.11,13.15 -1.31,7.71 -0.34,8.01 -0.34,8.01l-32.82,23.43z"
android:strokeColor="#000" android:strokeWidth=".5"/>
<path android:fillColor="#000"
android:pathData="M67.58,82.62c0,-3.52 -1.51,-7.17 -7.04,-14.58 -1.63,-2.19 -2.62,-4.34 -3.21,-6.28 -1.4,-3.3 -3.43,-8.02 -0.61,-17.23 0,0 0.62,-0.38 0,0 -2.62,1.62 -3.56,6.69 -13.07,9.88 -3.21,1.08 -7.4,1.95 -12.96,2.39 -9.57,0.77 -27.89,17.31 -29.11,33.1 -0.28,3.96 0.31,13.74 3.6,22.31l0,0.02c0.01,0.04 0.03,0.08 0.05,0.12 0.05,0.13 0.1,0.27 0.16,0.4 0.28,0.72 0.58,1.4 0.89,2.06 1.88,4.03 4.46,7.59 7.93,9.88 3.08,2.4 5.61,3.31 5.61,3.31 -2.59,-3.58 -3.77,-7.56 -2.26,-12.32 0.65,2.64 1.9,4.16 3.65,4.78 -0.62,-1.88 -0.83,-3.55 0,-4.65 2.57,6.73 5.35,9.03 8.17,10.69 -2.63,-4.91 -4.03,-10.01 -3.77,-15.34 2.57,6.03 6.6,9.94 10.56,13.95 -3.78,-5.97 -6.91,-12.1 -6.98,-19.05 1.69,2.78 3.93,4.93 6.6,6.6 -1.68,-2.71 -2.51,-5.51 -2.26,-8.42 4.42,4.95 9.36,6.61 14.33,8.05 -5.2,-3.63 -9.84,-7.54 -12.32,-12.57 2.97,1.46 5.95,1.69 8.93,1.38 -3.71,-1.87 -5.07,-5.25 -5.78,-9.05 5.18,5.28 10.59,8.83 16.09,11.69 -5.45,-5.26 -9.48,-10.65 -11.56,-16.22 2.1,1.18 4.16,1.74 6.16,1.51 -2.77,-3.12 -3.46,-6.18 -4.21,-9.24 2.64,3.92 4.96,6.02 7.1,7.1 -2.19,-4.48 -2.03,-8.43 -0.5,-12.07 2.52,1.67 4.9,4.3 6.91,9.3 0.73,-2.39 -0.45,-6.36 -1.89,-10.56 2.17,0.62 4.78,3.35 8.17,9.93 -0.33,-3.87 -2.14,-7.78 -4.15,-11.69 3.03,3.51 7.56,12.71 6.79,10.81z"
android:strokeColor="#000" android:strokeWidth=".5"/>
<path android:fillColor="#000"
android:pathData="M83.92,43.57s-0.25,7.47 6.72,2.6c3.61,0.08 2.02,-3.86 2.02,-3.86 2.43,-0.67 2.81,-3.84 1.85,-5.71 3.11,0.08 2.61,-4.72 2.18,-6.38 2.43,-0.92 2.77,-3.83 1.76,-6.13 2.94,-0.67 3.02,-4.11 2.77,-6.55 3.02,-0.17 2.6,-5.46 2.6,-6.55 2.6,-1.68 2.02,-3.95 2.42,-6.57 1.61,-3.25 -0.58,-4.17 -2.12,-0.71 -1.65,3 -3.77,4.31 -3.75,6.53 0.75,1.26 -5.63,3.11 -3.61,7.05 -1.43,1.76 -4.78,4.03 -3.59,6.73 -0.61,1.33 -4.89,4.43 -3.04,7.37 -4.03,2.69 -3.79,3.34 -2.94,5.79 -2.15,1.38 -4.41,4.13 -3.28,6.38z"
android:strokeColor="#000" android:strokeWidth=".5"/>
<path android:fillColor="#000"
android:pathData="M84,43.68c-0.45,-0.45 -0.53,-0.9 -0.37,-1.72 0,0 0.37,-4.11 -16.33,-0.16 -1.07,0.74 2.4,4.72 2.4,4.72s0.42,0.22 1.05,-0.41c0.25,1.12 0.85,4.08 0.23,4.58 1.25,-0.77 1.87,-1.95 1.68,-4.13 2.12,0.46 3.74,1.64 4.69,3.78 0.3,-1.4 0.6,-2.8 -0.38,-4.13 2.18,0.28 3.88,1.5 5.36,3.12 0.22,-0.93 0.35,-1.88 0,-2.93 1.39,0.47 2.59,1.61 3.71,2.99 0,0 0.21,-3.86 -2.03,-5.72z"
android:strokeColor="#000" android:strokeWidth=".5"/>
</vector>
2 changes: 1 addition & 1 deletion app/src/main/res/menu/document__edit__menu.xml
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@
android:title="@string/embed_binary" />
<item
android:id="@string/action_format_orgmode"
android:icon="@drawable/fountain_pen"
android:icon="@drawable/ic_org_mode_file"
android:title="@string/orgmode" />
</group>
</menu>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/arrays.xml
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@
<item translatable="false">@string/file_template__md_zettelkasten</item>
<item translatable="false">@string/file_template__ad_jekyll_post</item>
<item translatable="false">@string/file_template__csv_sample</item>
<item translatable="false">@string/file_template__orgmode_reference</item>
</string-array>

<string-array name="new_file_types__file_extension" translatable="false">
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/string-not_translatable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,7 @@ work. If not, see <https://creativecommons.org/publicdomain/zero/1.0/>.
<string name="file_template__md_hugo_post_front_matter" translatable="false">hugo-post-front-matter.md</string>
<string name="file_template__md_presentation_beamer" translatable="false">presentation-beamer.md</string>
<string name="file_template__csv_sample" translatable="false">sample.csv</string>
<string name="file_template__orgmode_reference" translatable="false">orgmode-reference.org</string>
<string name="asciidoc" translatable="false">AsciiDoc</string>
<string name="key_value" translatable="false">Key - Value</string>
<string name="ohm" translatable="false">Ohm (Ω)</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/xml/preferences_master.xml
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@
</PreferenceScreen>
<!-- OrgMode Screen -->
<PreferenceScreen
android:icon="@drawable/fountain_pen"
android:icon="@drawable/ic_org_mode_file"
android:title="@string/orgmode">

<PreferenceCategory android:title="@string/syntax_highlighting">
Expand Down
Loading

0 comments on commit 61173a0

Please sign in to comment.