Remove unnecessary blocks from switch-case from ContextBasedRangeFormattingCallback

This commit is contained in:
Christoph Loy 2020-03-06 22:33:16 +01:00 committed by Niedermann IT-Dienstleistungen
parent 9b1a090f6a
commit cf36ea70a3

View file

@ -62,7 +62,7 @@ public class ContextBasedRangeFormattingCallback implements ActionMode.Callback
switch (item.getItemId()) { switch (item.getItemId()) {
case R.id.bold: { case R.id.bold:
markdown = "**"; markdown = "**";
if (hasAlreadyMarkdown(start, end, markdown)) { if (hasAlreadyMarkdown(start, end, markdown)) {
this.removeMarkdown(ssb, start, end, markdown); this.removeMarkdown(ssb, start, end, markdown);
@ -72,8 +72,7 @@ public class ContextBasedRangeFormattingCallback implements ActionMode.Callback
editText.setText(ssb); editText.setText(ssb);
editText.setSelection(end + markdown.length() * 2); editText.setSelection(end + markdown.length() * 2);
return true; return true;
} case R.id.italic:
case R.id.italic: {
markdown = "*"; markdown = "*";
if (hasAlreadyMarkdown(start, end, markdown)) { if (hasAlreadyMarkdown(start, end, markdown)) {
this.removeMarkdown(ssb, start, end, markdown); this.removeMarkdown(ssb, start, end, markdown);
@ -83,8 +82,7 @@ public class ContextBasedRangeFormattingCallback implements ActionMode.Callback
editText.setText(ssb); editText.setText(ssb);
editText.setSelection(end + markdown.length() * 2); editText.setSelection(end + markdown.length() * 2);
return true; return true;
} case R.id.link:
case R.id.link: {
boolean textToFormatIsLink = TextUtils.indexOf(editText.getText().subSequence(start, end), "http") == 0; boolean textToFormatIsLink = TextUtils.indexOf(editText.getText().subSequence(start, end), "http") == 0;
if (textToFormatIsLink) { if (textToFormatIsLink) {
ssb.insert(end, ")"); ssb.insert(end, ")");
@ -108,8 +106,7 @@ public class ContextBasedRangeFormattingCallback implements ActionMode.Callback
editText.setSelection(end + 2); // after <end>]( editText.setSelection(end + 2); // after <end>](
} }
return true; return true;
} case android.R.id.cut:
case android.R.id.cut: {
// https://github.com/stefan-niedermann/nextcloud-notes/issues/604 // https://github.com/stefan-niedermann/nextcloud-notes/issues/604
// https://github.com/stefan-niedermann/nextcloud-notes/issues/477 // https://github.com/stefan-niedermann/nextcloud-notes/issues/477
try { try {
@ -121,7 +118,6 @@ public class ContextBasedRangeFormattingCallback implements ActionMode.Callback
editText.clearFocus(); editText.clearFocus();
return true; return true;
} }
}
default: default:
return false; return false;
} }