mirror of
https://github.com/M66B/FairEmail.git
synced 2025-02-24 15:11:03 +00:00
View code: added pretty print option
This commit is contained in:
parent
16400443f7
commit
fe11ac32c6
3 changed files with 29 additions and 7 deletions
|
@ -72,6 +72,7 @@ public class ActivityCode extends ActivityBase {
|
|||
private boolean sanitize = false;
|
||||
private boolean lines = false;
|
||||
private boolean links = false;
|
||||
private boolean pretty = true;
|
||||
private String searching = null;
|
||||
|
||||
private static final int REQUEST_SAVE = 1;
|
||||
|
@ -85,6 +86,7 @@ public class ActivityCode extends ActivityBase {
|
|||
sanitize = savedInstanceState.getBoolean("fair:sanitize");
|
||||
lines = savedInstanceState.getBoolean("fair:lines");
|
||||
links = savedInstanceState.getBoolean("fair:links");
|
||||
pretty = savedInstanceState.getBoolean("fair:pretty");
|
||||
searching = savedInstanceState.getString("fair:searching");
|
||||
}
|
||||
|
||||
|
@ -159,6 +161,7 @@ public class ActivityCode extends ActivityBase {
|
|||
outState.putBoolean("fair:sanitize", sanitize);
|
||||
outState.putBoolean("fair:lines", lines);
|
||||
outState.putBoolean("fair:links", links);
|
||||
outState.putBoolean("fair:pretty", pretty);
|
||||
outState.putString("fair:searching", searching);
|
||||
super.onSaveInstanceState(outState);
|
||||
}
|
||||
|
@ -227,7 +230,7 @@ public class ActivityCode extends ActivityBase {
|
|||
|
||||
menu.findItem(R.id.menu_lines).setChecked(lines);
|
||||
menu.findItem(R.id.menu_links).setChecked(links);
|
||||
menu.findItem(R.id.menu_check_html).setVisible(BuildConfig.DEBUG || debug);
|
||||
menu.findItem(R.id.menu_pretty).setChecked(pretty);
|
||||
|
||||
return super.onPrepareOptionsMenu(menu);
|
||||
}
|
||||
|
@ -258,6 +261,11 @@ public class ActivityCode extends ActivityBase {
|
|||
item.setChecked(links);
|
||||
load();
|
||||
return true;
|
||||
} else if (itemId == R.id.menu_pretty) {
|
||||
pretty = !pretty;
|
||||
item.setChecked(pretty);
|
||||
load();
|
||||
return true;
|
||||
} else if (itemId == R.id.menu_check_html) {
|
||||
checkHtml();
|
||||
return true;
|
||||
|
@ -303,6 +311,7 @@ public class ActivityCode extends ActivityBase {
|
|||
args.putLong("id", id);
|
||||
args.putCharSequence("selected", selected);
|
||||
args.putBoolean("sanitize", sanitize);
|
||||
args.putBoolean("pretty", pretty);
|
||||
|
||||
new SimpleTask<String>() {
|
||||
@Override
|
||||
|
@ -320,6 +329,7 @@ public class ActivityCode extends ActivityBase {
|
|||
long id = args.getLong("id");
|
||||
CharSequence selected = args.getCharSequence("selected");
|
||||
boolean sanitize = args.getBoolean("sanitize");
|
||||
boolean pretty = args.getBoolean("pretty");
|
||||
|
||||
DB db = DB.getInstance(context);
|
||||
EntityMessage message = db.message().getMessage(id);
|
||||
|
@ -354,8 +364,8 @@ public class ActivityCode extends ActivityBase {
|
|||
}
|
||||
|
||||
d.outputSettings()
|
||||
.prettyPrint(true)
|
||||
.outline(true)
|
||||
.prettyPrint(pretty)
|
||||
.outline(pretty)
|
||||
.indentAmount(1);
|
||||
|
||||
if (selected == null)
|
||||
|
@ -421,6 +431,10 @@ public class ActivityCode extends ActivityBase {
|
|||
|
||||
@Override
|
||||
protected void onExecuted(Bundle args, ParseErrorList errors) {
|
||||
lines = true;
|
||||
pretty = false;
|
||||
load();
|
||||
|
||||
SpannableStringBuilderEx ssb = new SpannableStringBuilderEx();
|
||||
ssb.append("Errors: ")
|
||||
.append(Integer.toString(errors.size()))
|
||||
|
|
|
@ -23,13 +23,19 @@
|
|||
<item
|
||||
android:id="@+id/menu_lines"
|
||||
android:checkable="true"
|
||||
android:title="@string/title_legend_line_numbers"
|
||||
android:title="@string/title_code_line_numbers"
|
||||
app:showAsAction="never" />
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_links"
|
||||
android:checkable="true"
|
||||
android:title="@string/title_legend_enable_links"
|
||||
android:title="@string/title_code_enable_links"
|
||||
app:showAsAction="never" />
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_pretty"
|
||||
android:checkable="true"
|
||||
android:title="@string/title_code_pretty"
|
||||
app:showAsAction="never" />
|
||||
|
||||
<item
|
||||
|
|
|
@ -2031,6 +2031,10 @@
|
|||
<string name="title_rule_alarm_title">Alarm</string>
|
||||
<string name="title_rule_alarm_stop">Stop</string>
|
||||
|
||||
<string name="title_code_line_numbers">Show line numbers</string>
|
||||
<string name="title_code_enable_links">Enable links</string>
|
||||
<string name="title_code_pretty">Pretty print</string>
|
||||
|
||||
<string name="title_legend_section_synchronize">Synchronize</string>
|
||||
<string name="title_legend_section_folders">Folders</string>
|
||||
<string name="title_legend_section_messages">Messages</string>
|
||||
|
@ -2138,8 +2142,6 @@
|
|||
<string name="title_legend_show_amp">Show AMP variant</string>
|
||||
<string name="title_legend_show_full">Show original message</string>
|
||||
<string name="title_legend_show_reformatted">Show reformatted message</string>
|
||||
<string name="title_legend_line_numbers">Show line numbers</string>
|
||||
<string name="title_legend_enable_links">Enable links</string>
|
||||
<string name="title_legend_edit">Edit</string>
|
||||
<string name="title_legend_default_color">Default color</string>
|
||||
<string name="title_legend_close_hint">Close hint</string>
|
||||
|
|
Loading…
Reference in a new issue