mirror of https://github.com/M66B/FairEmail.git
Replace markdown links
This commit is contained in:
parent
37d570a314
commit
714fa73388
|
@ -70,13 +70,22 @@ public class FragmentDialogMarkdown extends FragmentDialogBase {
|
|||
protected Spanned onExecute(Context context, Bundle args) throws Throwable {
|
||||
String name = args.getString("name");
|
||||
|
||||
String markdown;
|
||||
String asset = Helper.getLocalizedAsset(context, name);
|
||||
try (InputStream is = context.getAssets().open(asset)) {
|
||||
byte[] buffer = new byte[is.available()];
|
||||
is.read(buffer);
|
||||
Markwon markwon = Markwon.create(context);
|
||||
return markwon.toMarkdown(new String(buffer));
|
||||
markdown = new String(buffer);
|
||||
}
|
||||
|
||||
String locale = Helper.getFAQLocale();
|
||||
if (locale != null)
|
||||
markdown = markdown.replace(
|
||||
"https://github.com/M66B/FairEmail/blob/master/FAQ.md",
|
||||
"https://github.com/M66B/FairEmail/blob/master/docs/FAQ-" + locale + ".md");
|
||||
|
||||
Markwon markwon = Markwon.create(context);
|
||||
return markwon.toMarkdown(markdown);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -733,6 +733,17 @@ public class Helper {
|
|||
}
|
||||
}
|
||||
|
||||
static String getFAQLocale() {
|
||||
switch (Locale.getDefault().getLanguage()) {
|
||||
case "de":
|
||||
return "de-rDE";
|
||||
case "fr":
|
||||
return "fr-rFR";
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
static void viewFAQ(Context context, int question) {
|
||||
// Redirection is done to prevent text editors from opening the link
|
||||
// https://email.faircode.eu/faq -> https://github.com/M66B/FairEmail/blob/master/FAQ.md
|
||||
|
@ -741,16 +752,12 @@ public class Helper {
|
|||
// https://github.com/M66B/FairEmail/blob/master/docs/FAQ-de-rDE.md#user-content-faq1
|
||||
|
||||
String base;
|
||||
switch (Locale.getDefault().getLanguage()) {
|
||||
case "de":
|
||||
base = "https://email.faircode.eu/docs/FAQ-de-rDE.md";
|
||||
break;
|
||||
case "fr":
|
||||
base = "https://email.faircode.eu/docs/FAQ-fr-rFR.md";
|
||||
break;
|
||||
default:
|
||||
base = "https://email.faircode.eu/faq";
|
||||
}
|
||||
String locale = getFAQLocale();
|
||||
if (locale == null)
|
||||
base = "https://email.faircode.eu/faq";
|
||||
else
|
||||
base = "https://email.faircode.eu/docs/FAQ-" + locale + ".md";
|
||||
|
||||
if (question == 0)
|
||||
view(context, Uri.parse(base + "#top"), false);
|
||||
else
|
||||
|
|
Loading…
Reference in New Issue