Debug: added text reverse

pull/212/head
M66B 2 years ago
parent 864a090d82
commit 9f10150c34

@ -115,6 +115,7 @@ public class StyleHelper {
R.id.menu_style_spell_check,
R.id.menu_style_password,
R.id.menu_style_code,
R.id.menu_style_reverse,
R.id.menu_style_clear,
R.id.menu_style_settings
};
@ -149,7 +150,7 @@ public class StyleHelper {
v.setVisibility(
!BuildConfig.PLAY_STORE_RELEASE && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O
? View.VISIBLE : View.GONE);
else if (id == R.id.menu_style_code)
else if (id == R.id.menu_style_code || id == R.id.menu_style_reverse)
v.setVisibility(BuildConfig.DEBUG ? View.VISIBLE : View.GONE);
}
@ -465,6 +466,8 @@ public class StyleHelper {
setSize(etBody, start, end, HtmlHelper.FONT_SMALL, keep_selection);
setFont(etBody, start, end, "monospace", keep_selection);
return true;
} else if (itemId == R.id.menu_style_reverse) {
return reverse(etBody, start, end);
} else if (itemId == R.id.menu_link)
return setLink(etBody, start, end, args);
else if (itemId == R.id.menu_style_clear)
@ -1334,6 +1337,17 @@ public class StyleHelper {
return true;
}
static boolean reverse(EditText etBody, int start, int end) {
Log.breadcrumb("style", "action", "reverse");
Editable edit = etBody.getText();
List<String> lines = new ArrayList<>(Arrays.asList(edit.subSequence(start, end).toString().split("\n")));
Collections.reverse(lines);
edit.replace(start, end, TextUtils.join("\n", lines));
return true;
}
static boolean setLink(EditText etBody, int start, int end, Object... args) {
Log.breadcrumb("style", "action", "link");

@ -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,20h16v2H4V20zM4,2h16v2H4V2zM13,9h3l-4,-4L8,9h3v6H8l4,4l4,-4h-3V9z"/>
</vector>

@ -329,6 +329,21 @@
app:srcCompat="@drawable/twotone_code_24"
app:tint="@color/action_foreground" />
<ImageButton
android:id="@+id/menu_style_reverse"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:contentDescription="@string/title_style_reverse"
android:paddingHorizontal="12dp"
android:paddingVertical="6dp"
android:scaleType="fitCenter"
android:tooltipText="@string/title_style_reverse"
app:layout_constraintStart_toEndOf="@id/menu_style_code"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/twotone_expand_24"
app:tint="@color/action_foreground" />
<ImageButton
android:id="@+id/menu_style_clear"
android:layout_width="wrap_content"
@ -339,7 +354,7 @@
android:paddingVertical="6dp"
android:scaleType="fitCenter"
android:tooltipText="@string/title_style_clear"
app:layout_constraintStart_toEndOf="@id/menu_style_code"
app:layout_constraintStart_toEndOf="@id/menu_style_reverse"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/twotone_format_clear_24"
app:tint="@color/action_foreground" />

@ -1570,6 +1570,7 @@
<string name="title_style_superscript">Superscript</string>
<string name="title_style_strikethrough">Strikethrough</string>
<string name="title_style_code" translatable="false">Code</string>
<string name="title_style_reverse" translatable="false">Reverse</string>
<string name="title_style_protect">Password protect</string>
<string name="title_style_protected">Protected content</string>
<string name="title_style_protect_size">Text too long</string>

Loading…
Cancel
Save