Insert quotes

pull/209/head
M66B 2 years ago
parent ec8153ace2
commit f7e118f858

@ -214,6 +214,7 @@ public class StyleHelper {
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,7 +251,9 @@ public class StyleHelper {
} else if (groupId == R.id.group_style_strikethrough) {
return setStrikeThrough(item);
} else if (groupId == R.id.group_style_parenthesis) {
return setParenthesis(item);
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) {
@ -492,10 +495,10 @@ public class StyleHelper {
return true;
}
private boolean setParenthesis(MenuItem item) {
private boolean surround(MenuItem item, String before, String after) {
Log.breadcrumb("style", "action", "parenthesis");
edit.insert(end, ")");
edit.insert(start, "(");
edit.insert(end, after);
edit.insert(start, before);
return true;
}

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M4,22H2V2h2V22zM22,2h-2v20h2V2zM13.5,7h-3v10h3V7z"/>
</vector>

@ -168,9 +168,18 @@
android:title="@string/title_style_parenthesis" />
</group>
<group
android:id="@+id/group_style_quotes"
android:orderInCategory="12">
<item
android:id="@+id/menu_style_quotes"
android:icon="@drawable/twotone_horizontal_distribute_24"
android:title="@string/title_style_quotes" />
</group>
<group
android:id="@+id/group_style_code"
android:orderInCategory="11">
android:orderInCategory="13">
<item
android:id="@+id/menu_style_code"
android:icon="@drawable/twotone_code_24"
@ -179,7 +188,7 @@
<group
android:id="@+id/group_style_clear"
android:orderInCategory="12">
android:orderInCategory="14">
<item
android:id="@+id/menu_style_clear"
android:icon="@drawable/twotone_format_clear_24"

@ -1445,6 +1445,7 @@
<string name="title_style_mark">Highlight</string>
<string name="title_style_strikethrough">Strikethrough</string>
<string name="title_style_parenthesis" translatable="false">Parenthesis</string>
<string name="title_style_quotes" translatable="false">Quotes</string>
<string name="title_style_code" translatable="false">Code</string>
<string name="title_style_clear">Clear formatting</string>
<string name="title_style_link">Insert link</string>

Loading…
Cancel
Save