diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8d233dcc06..151d83ac45 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,7 @@
### 1.1866 - 2022-04-02
+* Added highlighting (marking) of text
* Small improvements and minor bug fixes
* Updated translations
diff --git a/app/src/main/assets/CHANGELOG.md b/app/src/main/assets/CHANGELOG.md
index 8d233dcc06..151d83ac45 100644
--- a/app/src/main/assets/CHANGELOG.md
+++ b/app/src/main/assets/CHANGELOG.md
@@ -6,6 +6,7 @@
### 1.1866 - 2022-04-02
+* Added highlighting (marking) of text
* Small improvements and minor bug fixes
* Updated translations
diff --git a/app/src/main/java/eu/faircode/email/HtmlEx.java b/app/src/main/java/eu/faircode/email/HtmlEx.java
index f948b029dc..3a0776d08a 100644
--- a/app/src/main/java/eu/faircode/email/HtmlEx.java
+++ b/app/src/main/java/eu/faircode/email/HtmlEx.java
@@ -392,6 +392,9 @@ public class HtmlEx {
if (style[j] instanceof UnderlineSpan) {
out.append("");
}
+ if (style[j] instanceof MarkSpan) {
+ out.append("");
+ }
if (style[j] instanceof StrikethroughSpan) {
out.append("");
}
@@ -429,7 +432,7 @@ public class HtmlEx {
out.append(String.format("",
eu.faircode.email.HtmlHelper.encodeWebColor(color)));
}
- if (style[j] instanceof BackgroundColorSpan) {
+ if (style[j] instanceof BackgroundColorSpan && !(style[j] instanceof MarkSpan)) {
int color = ((BackgroundColorSpan) style[j]).getBackgroundColor();
//out.append(String.format("",
// 0xFFFFFF & color));
@@ -441,7 +444,7 @@ public class HtmlEx {
withinStyle(out, text, i, next);
for (int j = style.length - 1; j >= 0; j--) {
- if (style[j] instanceof BackgroundColorSpan) {
+ if (style[j] instanceof BackgroundColorSpan && !(style[j] instanceof MarkSpan)) {
out.append("");
}
if (style[j] instanceof ForegroundColorSpan) {
@@ -459,6 +462,9 @@ public class HtmlEx {
if (style[j] instanceof StrikethroughSpan) {
out.append("");
}
+ if (style[j] instanceof MarkSpan) {
+ out.append("");
+ }
if (style[j] instanceof UnderlineSpan) {
out.append("");
}
diff --git a/app/src/main/java/eu/faircode/email/HtmlHelper.java b/app/src/main/java/eu/faircode/email/HtmlHelper.java
index 64c7da0d87..03b9611395 100644
--- a/app/src/main/java/eu/faircode/email/HtmlHelper.java
+++ b/app/src/main/java/eu/faircode/email/HtmlHelper.java
@@ -2910,7 +2910,6 @@ public class HtmlHelper {
final int colorPrimary = Helper.resolveColor(context, R.attr.colorPrimary);
final int colorAccent = Helper.resolveColor(context, R.attr.colorAccent);
- final int colorHighlight = Helper.resolveColor(context, R.attr.colorHighlight);
final int colorBlockquote = Helper.resolveColor(context, R.attr.colorBlockquote, colorPrimary);
final int colorSeparator = Helper.resolveColor(context, R.attr.colorSeparator);
int bulletGap = context.getResources().getDimensionPixelSize(R.dimen.bullet_gap_size);
@@ -3375,7 +3374,7 @@ public class HtmlHelper {
break;
case "mark":
- setSpan(ssb, new BackgroundColorSpan(colorHighlight), start, ssb.length());
+ setSpan(ssb, new MarkSpan(), start, ssb.length());
break;
case "pre":
case "tt":
diff --git a/app/src/main/java/eu/faircode/email/MarkSpan.java b/app/src/main/java/eu/faircode/email/MarkSpan.java
new file mode 100644
index 0000000000..d61f06e5a0
--- /dev/null
+++ b/app/src/main/java/eu/faircode/email/MarkSpan.java
@@ -0,0 +1,38 @@
+package eu.faircode.email;
+
+/*
+ This file is part of FairEmail.
+
+ FairEmail is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ FairEmail is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with FairEmail. If not, see .
+
+ Copyright 2018-2022 by Marcel Bokhorst (M66B)
+*/
+
+import android.graphics.Color;
+import android.text.TextPaint;
+import android.text.style.BackgroundColorSpan;
+
+import androidx.annotation.NonNull;
+
+public class MarkSpan extends BackgroundColorSpan {
+ public MarkSpan() {
+ super(Color.YELLOW);
+ }
+
+ @Override
+ public void updateDrawState(@NonNull TextPaint textPaint) {
+ super.updateDrawState(textPaint);
+ textPaint.setColor(Color.BLACK);
+ }
+}
diff --git a/app/src/main/java/eu/faircode/email/StyleHelper.java b/app/src/main/java/eu/faircode/email/StyleHelper.java
index 5a34c31b46..2f7996885e 100644
--- a/app/src/main/java/eu/faircode/email/StyleHelper.java
+++ b/app/src/main/java/eu/faircode/email/StyleHelper.java
@@ -228,6 +228,8 @@ public class StyleHelper {
return setBlockQuote(item);
} else if (groupId == R.id.group_style_indentation) {
return setIndentation(item);
+ } else if (groupId == R.id.group_style_mark) {
+ return setMark(item);
} else if (groupId == R.id.group_style_strikethrough) {
return setStrikeThrough(item);
} else if (groupId == R.id.group_style_code) {
@@ -609,6 +611,32 @@ public class StyleHelper {
return true;
}
+ private boolean setMark(MenuItem item) {
+ Log.breadcrumb("style", "action", "strike");
+
+ Context context = etBody.getContext();
+
+ boolean has = false;
+ MarkSpan[] spans = edit.getSpans(start, end, MarkSpan.class);
+ for (MarkSpan span : spans) {
+ int s = edit.getSpanStart(span);
+ int e = edit.getSpanEnd(span);
+ int f = edit.getSpanFlags(span);
+ edit.removeSpan(span);
+ if (splitSpan(edit, start, end, s, e, f, true,
+ new MarkSpan(), new MarkSpan()))
+ has = true;
+ }
+
+ if (!has)
+ edit.setSpan(new MarkSpan(), start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
+
+ etBody.setText(edit);
+ etBody.setSelection(end);
+
+ return true;
+ }
+
private boolean setStrikeThrough(MenuItem item) {
Log.breadcrumb("style", "action", "strike");
diff --git a/app/src/main/res/drawable/twotone_border_color_24.xml b/app/src/main/res/drawable/twotone_border_color_24.xml
new file mode 100644
index 0000000000..ca82025c28
--- /dev/null
+++ b/app/src/main/res/drawable/twotone_border_color_24.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
diff --git a/app/src/main/res/menu/popup_style.xml b/app/src/main/res/menu/popup_style.xml
index 17940d3804..c2f44766a0 100644
--- a/app/src/main/res/menu/popup_style.xml
+++ b/app/src/main/res/menu/popup_style.xml
@@ -134,8 +134,17 @@
+
+
+
+
-
+ android:orderInCategory="11">
-
+ android:orderInCategory="12">
- Default
Block quote
Indentation
+ Highlight
Strikethrough
Code
Clear formatting
diff --git a/metadata/en-US/changelogs/1866.txt b/metadata/en-US/changelogs/1866.txt
index 8d233dcc06..151d83ac45 100644
--- a/metadata/en-US/changelogs/1866.txt
+++ b/metadata/en-US/changelogs/1866.txt
@@ -6,6 +6,7 @@
### 1.1866 - 2022-04-02
+* Added highlighting (marking) of text
* Small improvements and minor bug fixes
* Updated translations