From cf36ea70a3c442ee8c3b42caa7813cf31e48d1f8 Mon Sep 17 00:00:00 2001 From: Christoph Loy Date: Fri, 6 Mar 2020 22:33:16 +0100 Subject: [PATCH] Remove unnecessary blocks from switch-case from ContextBasedRangeFormattingCallback --- .../format/ContextBasedRangeFormattingCallback.java | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/it/niedermann/owncloud/notes/util/format/ContextBasedRangeFormattingCallback.java b/app/src/main/java/it/niedermann/owncloud/notes/util/format/ContextBasedRangeFormattingCallback.java index 74e1c92d..4eeef44c 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/util/format/ContextBasedRangeFormattingCallback.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/util/format/ContextBasedRangeFormattingCallback.java @@ -62,7 +62,7 @@ public class ContextBasedRangeFormattingCallback implements ActionMode.Callback switch (item.getItemId()) { - case R.id.bold: { + case R.id.bold: markdown = "**"; if (hasAlreadyMarkdown(start, end, markdown)) { this.removeMarkdown(ssb, start, end, markdown); @@ -72,8 +72,7 @@ public class ContextBasedRangeFormattingCallback implements ActionMode.Callback editText.setText(ssb); editText.setSelection(end + markdown.length() * 2); return true; - } - case R.id.italic: { + case R.id.italic: markdown = "*"; if (hasAlreadyMarkdown(start, end, markdown)) { this.removeMarkdown(ssb, start, end, markdown); @@ -83,8 +82,7 @@ public class ContextBasedRangeFormattingCallback implements ActionMode.Callback editText.setText(ssb); editText.setSelection(end + markdown.length() * 2); return true; - } - case R.id.link: { + case R.id.link: boolean textToFormatIsLink = TextUtils.indexOf(editText.getText().subSequence(start, end), "http") == 0; if (textToFormatIsLink) { ssb.insert(end, ")"); @@ -108,8 +106,7 @@ public class ContextBasedRangeFormattingCallback implements ActionMode.Callback editText.setSelection(end + 2); // after ]( } 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/477 try { @@ -121,7 +118,6 @@ public class ContextBasedRangeFormattingCallback implements ActionMode.Callback editText.clearFocus(); return true; } - } default: return false; }