mirror of
https://github.com/M66B/FairEmail.git
synced 2025-02-23 14:41:08 +00:00
Added check HTML to signature editor
This commit is contained in:
parent
e4d3e8637e
commit
be6993aa17
3 changed files with 36 additions and 0 deletions
|
@ -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);
|
||||
|
|
|
@ -11,6 +11,10 @@
|
|||
android:checkable="true"
|
||||
android:title="@string/title_edit_html"
|
||||
app:showAsAction="never" />
|
||||
<item
|
||||
android:id="@+id/menu_check_html"
|
||||
android:title="@string/title_check_html"
|
||||
app:showAsAction="never" />
|
||||
<item
|
||||
android:id="@+id/menu_import_file"
|
||||
android:title="@string/title_import_file"
|
||||
|
|
|
@ -1110,6 +1110,7 @@
|
|||
<string name="title_account_delete">Delete this account permanently?</string>
|
||||
<string name="title_identity_delete">Delete this identity permanently?</string>
|
||||
<string name="title_edit_html">Edit as HTML</string>
|
||||
<string name="title_check_html">Check HTML</string>
|
||||
<string name="title_import_file">Import file</string>
|
||||
<string name="title_sign_key">Sign key: %1$s</string>
|
||||
<string name="title_created_at">Created: %1$s</string>
|
||||
|
|
Loading…
Reference in a new issue