diff --git a/app/src/main/java/eu/faircode/email/ActivitySignature.java b/app/src/main/java/eu/faircode/email/ActivitySignature.java
index d5506381ba..23fd322357 100644
--- a/app/src/main/java/eu/faircode/email/ActivitySignature.java
+++ b/app/src/main/java/eu/faircode/email/ActivitySignature.java
@@ -52,8 +52,12 @@ import androidx.preference.PreferenceManager;
import com.google.android.material.bottomnavigation.BottomNavigationView;
+import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
+import org.jsoup.parser.ParseError;
+import org.jsoup.parser.ParseErrorList;
+import org.jsoup.parser.Parser;
import java.io.FileNotFoundException;
import java.io.InputStream;
@@ -248,6 +252,7 @@ public class ActivitySignature extends ActivityBase {
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
menu.findItem(R.id.menu_edit_html).setChecked(etText.isRaw());
+ menu.findItem(R.id.menu_check_html).setVisible(etText.isRaw());
return super.onPrepareOptionsMenu(menu);
}
@@ -261,6 +266,9 @@ public class ActivitySignature extends ActivityBase {
item.setChecked(!item.isChecked());
html(item.isChecked());
return true;
+ } else if (itemId == R.id.menu_check_html) {
+ onMenuCheckHtml();
+ return true;
} else if (itemId == R.id.menu_import_file) {
onMenuSelectFile();
return true;
@@ -272,6 +280,29 @@ public class ActivitySignature extends ActivityBase {
Helper.viewFAQ(this, 57);
}
+ private void onMenuCheckHtml() {
+ Parser parser = Parser.htmlParser().setTrackErrors(20);
+ Jsoup.parse(etText.getText().toString(), "", parser);
+ ParseErrorList errors = parser.getErrors();
+ SpannableStringBuilderEx ssb = new SpannableStringBuilderEx();
+ ssb.append("Errors: ")
+ .append(Integer.toString(errors.size()))
+ .append("\n\n");
+ for (ParseError error : errors)
+ ssb.append("At ")
+ .append(error.getCursorPos())
+ .append(' ')
+ .append(error.getErrorMessage())
+ .append("\n\n");
+
+ new AlertDialog.Builder(this)
+ .setIcon(R.drawable.twotone_bug_report_24)
+ .setTitle(R.string.title_check_html)
+ .setMessage(ssb)
+ .setPositiveButton(android.R.string.ok, null)
+ .show();
+ }
+
private void onMenuSelectFile() {
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
diff --git a/app/src/main/res/menu/menu_signature.xml b/app/src/main/res/menu/menu_signature.xml
index 33ae0bcc26..b6adf9962b 100644
--- a/app/src/main/res/menu/menu_signature.xml
+++ b/app/src/main/res/menu/menu_signature.xml
@@ -11,6 +11,10 @@
android:checkable="true"
android:title="@string/title_edit_html"
app:showAsAction="never" />
+
- Delete this account permanently?
Delete this identity permanently?
Edit as HTML
+ Check HTML
Import file
Sign key: %1$s
Created: %1$s