wrote this file. You can do whatever
+ * you want with this stuff. If we meet some day, and you think this stuff is
+ * worth it, you can buy me a coke in return. Provided as is without any kind
+ * of warranty. No attribution required. - Gregor Santner
+ * ----------------------------------------------------------------------------
+ */
+package com.github.dfa.diaspora_android.util;
+
+import java.io.BufferedReader;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+
+/**
+ * Simple Markdown Parser
+ *
+ * Parses most common markdown tags. Only inline tags are supported, multiline/block syntax
+ * is not supported (citation, multiline code, ..). This is intended to stay as easy as possible.
+ *
+ * You can e.g. apply a accent color by replacing #000001 with your accentColor string.
+ *
+ * FILTER_ANDROID_TEXTVIEW output is intended to be used at simple Android TextViews,
+ * were a limited set of html tags is supported. This allow to still display e.g. a simple
+ * CHANGELOG.md file without inlcuding a WebView for showing HTML, or other additional UI-libraries.
+ *
+ * FILTER_HTMLPART is intended to be used at engines understanding most common HTML tags.
+ *
+ * You can use this anywhere you want, no backlink/attribution required, but I would appreciate it.
+ */
+@SuppressWarnings({"WeakerAccess", "CaughtExceptionImmediatelyRethrown"})
+public class SimpleMarkdownParser {
+ public interface SimpleLineFilter {
+ String filterLine(String line);
+ }
+
+ public static final SimpleLineFilter FILTER_ANDROID_TEXTVIEW = new SimpleLineFilter() {
+ @Override
+ public String filterLine(String line) {
+ // TextView supports a limited set of html tags, most notably
+ // a href, b, big, font size&color, i, li, small, u
+ line = line
+ .replace("~°", " ") // double space/half tab
+ .replaceAll("^### ([^<]*)", "
$1 ") // h3
+ .replaceAll("^## ([^<]*)", "
$1
") // h2 (DEP: h3)
+ .replaceAll("^# ([^<]*)", "
$1
") // h1 (DEP: h2,h3)
+ .replaceAll("!\\[(.*?)\\]\\((.*?)\\)", "$1") // img
+ .replaceAll("\\[(.*?)\\]\\((.*?)\\)", "$1") // a href (DEP: img)
+ .replaceAll("<(http|https):\\/\\/(.*)>", "$1://$2") // a href (DEP: img)
+ .replaceAll("^(-|\\*) ([^<]*)", "• $2 ") // unordered list + end line
+ .replaceAll("^ (-|\\*) ([^<]*)", " • $2 ") // unordered list2 + end line
+ .replaceAll("`([^<]*)`", "$1") // code
+ .replace("\\*", "●") // temporary replace escaped star symbol
+ .replaceAll("\\*\\*([^<]*)\\*\\*", "$1") // bold (DEP: temp star)
+ .replaceAll("\\*([^<]*)\\*", "$1") // italic (DEP: temp star code)
+ .replace("●", "*") // restore escaped star symbol (DEP: b,i)
+ .replaceAll(" $", "
") // new line (DEP: ul)
+ ;
+ return line.isEmpty() ? line + "
" : line;
+ }
+ };
+
+ public static final SimpleLineFilter FILTER_HTMLPART = new SimpleLineFilter() {
+ @Override
+ public String filterLine(String line) {
+ line = line
+ .replaceAll("~°", " ") // double space/half tab
+ .replaceAll("^### ([^<]*)", "
$1
") // h3
+ .replaceAll("^## ([^<]*)", "$1
") /// h2 (DEP: h3)
+ .replaceAll("^# ([^<]*)", "$1
") // h1 (DEP: h2,h3)
+ .replaceAll("!\\[(.*?)\\]\\((.*?)\\)", "") // img
+ .replaceAll("<(http|https):\\/\\/(.*)>", "$1://$2") // a href (DEP: img)
+ .replaceAll("\\[(.*?)\\]\\((.*?)\\)", "$1") // a href (DEP: img)
+ .replaceAll("^(-|\\*) ([^<]*)", "• $2 ") // unordered list + end line
+ .replaceAll("^ (-|\\*) ([^<]*)", " • $2 ") // unordered list2 + end line
+ .replaceAll("`([^<]*)`", "$1
") // code
+ .replace("\\*", "●") // temporary replace escaped star symbol
+ .replaceAll("\\*\\*([^<]*)\\*\\*", "$1") // bold (DEP: temp star)
+ .replaceAll("\\*([^<]*)\\*", "$1") // italic (DEP: temp star)
+ .replace("●", "*") // restore escaped star symbol (DEP: b,i)
+ .replaceAll(" $", "
") // new line (DEP: ul)
+ ;
+ return line.isEmpty() ? line + "
" : line;
+ }
+ };
+
+ //########################
+ //##
+ //## Members
+ //##
+ //########################
+ private String html;
+
+ public SimpleMarkdownParser parse(String filepath, SimpleLineFilter simpleLineFilter) throws IOException {
+ return parse(new FileInputStream(filepath), simpleLineFilter, "");
+ }
+
+ public SimpleMarkdownParser parse(InputStream inputStream, SimpleLineFilter simpleLineFilter, String lineMdPrefix) throws IOException {
+ StringBuilder sb = new StringBuilder();
+ BufferedReader br = null;
+ String line;
+
+ try {
+ br = new BufferedReader(new InputStreamReader(inputStream));
+ while ((line = br.readLine()) != null) {
+ sb.append(simpleLineFilter.filterLine(lineMdPrefix + line));
+ sb.append("\n");
+ }
+ } catch (IOException rethrow) {
+ html = "";
+ throw rethrow;
+ } finally {
+ if (br != null) {
+ try {
+ br.close();
+ } catch (IOException ignored) {
+ }
+ }
+ }
+ html = sb.toString().trim();
+ return this;
+ }
+
+ public String getHtml() {
+ return html;
+ }
+
+ public SimpleMarkdownParser setHtml(String html) {
+ this.html = html;
+ return this;
+ }
+
+ public SimpleMarkdownParser removeMultiNewlines() {
+ html = html.replace("\n", "").replaceAll("(
){3,}", "
");
+ return this;
+ }
+
+ public SimpleMarkdownParser replaceBulletCharacter(String replacment) {
+ html = html.replace("•", replacment);
+ return this;
+ }
+
+ public SimpleMarkdownParser replaceColor(String hexColor, int newIntColor) {
+ html = html.replace(hexColor, colorToHexString(newIntColor));
+ return this;
+ }
+
+ public static String colorToHexString(int intColor) {
+ return String.format("#%06X", 0xFFFFFF & intColor);
+ }
+
+ @Override
+ public String toString() {
+ return html != null ? html : "";
+ }
+}
+
+/*
+ // Apply to Android TextView:
+ textView.setText(new SpannableString(Html.fromHtml(htmlFromParser)));
+
+ // As wrapper method, includes applying accent color
+ public static String loadMarkdownFromRawForTextView(Context context, @RawRes int rawMdFile, String prepend) {
+ try {
+ return new SimpleMarkdownParser()
+ .parse(context.getResources().openRawResource(rawMdFile),
+ SimpleMarkdownParser.FILTER_ANDROID_TEXTVIEW, prepend)
+ .replaceColor("#000001", ContextCompat.getColor(context, R.color.accent))
+ .removeMultiNewlines().replaceBulletCharacter("*").getHtml();
+ } catch (IOException e) {
+ e.printStackTrace();
+ return "";
+ }
+ }
+
+ // Show HTML a TextView in a scrollable Dialog
+ public static void showDialogWithHtmlTextView(Context context, String html, @StringRes int resTitleId) {
+ LinearLayout layout = new LinearLayout(context);
+ TextView textView = new TextView(context);
+ textView.setMovementMethod(LinkMovementMethod.getInstance());
+ ScrollView root = new ScrollView(context);
+ int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 20,
+ context.getResources().getDisplayMetrics());
+ LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
+ LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
+ layoutParams.setMargins(margin, 0, margin, 0);
+ layout.setLayoutParams(layoutParams);
+
+ layout.addView(textView);
+ root.addView(layout);
+
+ textView.setText(new SpannableString(Html.fromHtml(html)));
+ AlertDialog.Builder dialog = new AlertDialog.Builder(context)
+ .setPositiveButton(android.R.string.ok, null)
+ .setTitle(resTitleId)
+ .setView(root);
+ dialog.show();
+ }
+ */
diff --git a/app/src/main/res/raw/license_third_party.md b/app/src/main/res/raw/license_third_party.md
new file mode 100644
index 00000000..fce02fc6
--- /dev/null
+++ b/app/src/main/res/raw/license_third_party.md
@@ -0,0 +1,14 @@
+* NetCipher
+
+
+* ButterKnife
+
+
+* ShiftColorPicker
+
+
+* Android Support Library
+
+
+* Android Design Library
+
diff --git a/app/src/main/res/raw/license_third_party.tpl b/app/src/main/res/raw/license_third_party.tpl
deleted file mode 100644
index 6b8a734a..00000000
--- a/app/src/main/res/raw/license_third_party.tpl
+++ /dev/null
@@ -1,14 +0,0 @@
-NEWENTRY NetCipher
-https://github.com/guardianproject/NetCipher
-
-NEWENTRY ButterKnife
-https://jakewharton.github.io/butterknife
-
-NEWENTRY ShiftColorPicker
-https://github.com/DASAR/ShiftColorPicker
-
-NEWENTRY Android Support Library
-https://developer.android.com/topic/libraries/support-library/index.html
-
-NEWENTRY Android Design Library
-https://android-developers.blogspot.de/2015/05/android-design-support-library.html
diff --git a/app/src/main/res/raw/maintainers.md b/app/src/main/res/raw/maintainers.md
new file mode 100644
index 00000000..96fb0a61
--- /dev/null
+++ b/app/src/main/res/raw/maintainers.md
@@ -0,0 +1,5 @@
+* Gregor Santner (gsantner)
+~° https://gsantner.github.io
+
+* Paul Schaub (vanitasvitae)
+~° https://github.com/vanitasvitae
diff --git a/app/src/main/res/raw/maintainers.tpl b/app/src/main/res/raw/maintainers.tpl
deleted file mode 100644
index 77be0317..00000000
--- a/app/src/main/res/raw/maintainers.tpl
+++ /dev/null
@@ -1,5 +0,0 @@
-NEWENTRY Gregor Santner (gsantner)
-SUBTABBY https://gsantner.github.io
-
-NEWENTRY Paul Schaub (vanitasvitae)
-SUBTABBY https://github.com/vanitasvitae
diff --git a/app/src/main/res/values/strings-preferences.xml b/app/src/main/res/values/strings-preferences.xml
index d7a0d066..0c9055fb 100644
--- a/app/src/main/res/values/strings-preferences.xml
+++ b/app/src/main/res/values/strings-preferences.xml
@@ -15,6 +15,8 @@
pref_key__http_proxy_load_tor_preset
pref_key__extended_notifications
pref_key__topbar_stream_shortcut
+ pref_key__app_first_start
+ pref_key__app_first_start_current_version
@string/pref_key__primary_color_shade
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index e3b9b855..64aac017 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -27,6 +27,7 @@
Public
Search
Contacts
+ Changelog
Tor
diff --git a/build.gradle b/build.gradle
index 901b3834..28fe9aeb 100644
--- a/build.gradle
+++ b/build.gradle
@@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
- classpath 'com.android.tools.build:gradle:2.2.2'
+ classpath 'com.android.tools.build:gradle:2.2.3'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
// NOTE: Do not place your application dependencies here; they belong
diff --git a/crowdin.yaml b/crowdin.yaml
index cfacc777..b46fbb79 100644
--- a/crowdin.yaml
+++ b/crowdin.yaml
@@ -1,5 +1,5 @@
files:
- -
+ -
source: '/app/src/main/res/values/strings*.xml'
translation: '/app/src/main/res/values-%android_code%/%original_file_name%'
languages_mapping:
@@ -18,6 +18,7 @@ files:
nl: nl # Dutch
hu: hu # Hungarian
cs: cs # Czech
+ ko: ko # Korean
# hi: hi # Hindi
# el: el # Greel
# "no": 'no' # Norwegian