diff --git a/app/src/main/java/eu/faircode/email/EditTextCompose.java b/app/src/main/java/eu/faircode/email/EditTextCompose.java
index e9bcca2574..1b15cc7b8a 100644
--- a/app/src/main/java/eu/faircode/email/EditTextCompose.java
+++ b/app/src/main/java/eu/faircode/email/EditTextCompose.java
@@ -106,6 +106,58 @@ public class EditTextCompose extends FixedEditText {
boolean undo_manager = prefs.getBoolean("undo_manager", false);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
+ setCustomSelectionActionModeCallback(new ActionMode.Callback() {
+ @Override
+ public boolean onCreateActionMode(ActionMode mode, Menu menu) {
+ try {
+ int order = 1000;
+ menu.add(Menu.CATEGORY_SECONDARY, R.string.title_insert_parenthesis, order++, context.getString(R.string.title_insert_parenthesis));
+ menu.add(Menu.CATEGORY_SECONDARY, R.string.title_insert_quotes, order++, context.getString(R.string.title_insert_quotes));
+ } catch (Throwable ex) {
+ Log.e(ex);
+ }
+ return true;
+ }
+
+ @Override
+ public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
+ int start = getSelectionStart();
+ int end = getSelectionEnd();
+ boolean selection = (BuildConfig.DEBUG && start >= 0 && start < end);
+ menu.findItem(R.string.title_insert_parenthesis).setVisible(selection);
+ menu.findItem(R.string.title_insert_quotes).setVisible(selection);
+ return false;
+ }
+
+ @Override
+ public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
+ if (item.getGroupId() == Menu.CATEGORY_SECONDARY) {
+ int id = item.getItemId();
+ if (id == R.string.title_insert_parenthesis)
+ return surround("(", ")");
+ else if (id == R.string.title_insert_quotes)
+ return surround("\"", "\"");
+ }
+ return false;
+ }
+
+ @Override
+ public void onDestroyActionMode(ActionMode mode) {
+ // Do nothing
+ }
+
+ private boolean surround(String before, String after) {
+ int start = getSelectionStart();
+ int end = getSelectionEnd();
+ boolean selection = (start >= 0 && start < end);
+ if (selection) {
+ getText().insert(end, after);
+ getText().insert(start, before);
+ }
+ return selection;
+ }
+ });
+
setCustomInsertionActionModeCallback(new ActionMode.Callback() {
@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
diff --git a/app/src/main/java/eu/faircode/email/StyleHelper.java b/app/src/main/java/eu/faircode/email/StyleHelper.java
index 78d96644cc..6eb758a8d1 100644
--- a/app/src/main/java/eu/faircode/email/StyleHelper.java
+++ b/app/src/main/java/eu/faircode/email/StyleHelper.java
@@ -213,8 +213,6 @@ public class StyleHelper {
popupMenu.getMenu().findItem(R.id.menu_style_indentation_increase).setEnabled(maxLevel == null);
popupMenu.getMenu().findItem(R.id.menu_style_indentation_decrease).setEnabled(indents.length > 0);
- popupMenu.getMenu().findItem(R.id.menu_style_parenthesis).setEnabled(BuildConfig.DEBUG);
- popupMenu.getMenu().findItem(R.id.menu_style_quotes).setEnabled(BuildConfig.DEBUG);
popupMenu.getMenu().findItem(R.id.menu_style_code).setEnabled(BuildConfig.DEBUG);
popupMenu.insertIcons(context);
@@ -250,10 +248,6 @@ public class StyleHelper {
return setMark(item);
} else if (groupId == R.id.group_style_strikethrough) {
return setStrikeThrough(item);
- } else if (groupId == R.id.group_style_parenthesis) {
- return surround(item, "(", ")");
- } else if (groupId == R.id.group_style_quotes) {
- return surround(item, "\"", "\"");
} else if (groupId == R.id.group_style_code) {
return setCode(item);
} else if (groupId == R.id.group_style_clear) {
@@ -495,13 +489,6 @@ public class StyleHelper {
return true;
}
- private boolean surround(MenuItem item, String before, String after) {
- Log.breadcrumb("style", "action", "parenthesis");
- edit.insert(end, after);
- edit.insert(start, before);
- return true;
- }
-
private boolean setCode(MenuItem item) {
Log.breadcrumb("style", "action", "code");
_setSize(HtmlHelper.FONT_SMALL);
diff --git a/app/src/main/res/drawable/twotone_horizontal_distribute_24.xml b/app/src/main/res/drawable/twotone_horizontal_distribute_24.xml
deleted file mode 100644
index eb2e40aded..0000000000
--- a/app/src/main/res/drawable/twotone_horizontal_distribute_24.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
diff --git a/app/src/main/res/menu/popup_style.xml b/app/src/main/res/menu/popup_style.xml
index f4f697e7be..2973a1e79c 100644
--- a/app/src/main/res/menu/popup_style.xml
+++ b/app/src/main/res/menu/popup_style.xml
@@ -159,27 +159,9 @@
android:title="@string/title_style_strikethrough" />
-
-
-
-
-
-
-
-
+ android:orderInCategory="11">
-
+ android:orderInCategory="12">
- Indentation
Highlight
Strikethrough
- Parenthesis
- Quotes
Code
Clear formatting
Insert link
@@ -1951,6 +1949,8 @@
Redo
Insert line
Select block
+ Parenthesis
+ Quote
Add
Open with
Info