From a744775fe771a9aad41668470ebe55193a83e5d7 Mon Sep 17 00:00:00 2001 From: TiA4f8R <74829229+TiA4f8R@users.noreply.github.com> Date: Sat, 2 Oct 2021 19:53:17 +0200 Subject: [PATCH] Adress requested changes and remove an unused return value in NewPipeTextViewHelper --- .../org/schabi/newpipe/util/NewPipeTextViewHelper.java | 7 +------ .../java/org/schabi/newpipe/views/NewPipeEditText.java | 6 +++--- .../java/org/schabi/newpipe/views/NewPipeTextView.java | 6 +++--- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/util/NewPipeTextViewHelper.java b/app/src/main/java/org/schabi/newpipe/util/NewPipeTextViewHelper.java index 5e3a790d0..6db016090 100644 --- a/app/src/main/java/org/schabi/newpipe/util/NewPipeTextViewHelper.java +++ b/app/src/main/java/org/schabi/newpipe/util/NewPipeTextViewHelper.java @@ -29,11 +29,8 @@ public final class NewPipeTextViewHelper { * @param textView the {@link TextView} on which sharing the selected text. It should be a * {@link NewPipeTextView} or a {@link NewPipeEditText} (even if * {@link TextView standard TextViews} are supported). - * - * @return true if no exceptions occurred when getting the selected text, sharing it and - * deselecting it, otherwise an exception */ - public static boolean shareSelectedTextWithShareUtils(@NonNull final TextView textView) { + public static void shareSelectedTextWithShareUtils(@NonNull final TextView textView) { if (!(textView instanceof NewPipeEditText)) { final CharSequence textViewText; if (textView instanceof NewPipeTextView) { @@ -59,8 +56,6 @@ public final class NewPipeTextViewHelper { shareSelectedTextIfNotNullAndNotEmpty(textView, selectedText); Selection.setSelection(text, editText.getSelectionEnd()); } - - return true; } @Nullable diff --git a/app/src/main/java/org/schabi/newpipe/views/NewPipeEditText.java b/app/src/main/java/org/schabi/newpipe/views/NewPipeEditText.java index cdb4f0041..2adc28d0e 100644 --- a/app/src/main/java/org/schabi/newpipe/views/NewPipeEditText.java +++ b/app/src/main/java/org/schabi/newpipe/views/NewPipeEditText.java @@ -7,10 +7,9 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.widget.AppCompatEditText; +import org.schabi.newpipe.util.NewPipeTextViewHelper; import org.schabi.newpipe.util.external_communication.ShareUtils; -import static org.schabi.newpipe.util.NewPipeTextViewHelper.shareSelectedTextWithShareUtils; - /** * An {@link AppCompatEditText} which uses {@link ShareUtils#shareText(Context, String, String)} * when sharing selected text by using the {@code Share} command of the floating actions. @@ -38,7 +37,8 @@ public class NewPipeEditText extends AppCompatEditText { @Override public boolean onTextContextMenuItem(final int id) { if (id == android.R.id.shareText) { - return shareSelectedTextWithShareUtils(this); + NewPipeTextViewHelper.shareSelectedTextWithShareUtils(this); + return true; } return super.onTextContextMenuItem(id); } diff --git a/app/src/main/java/org/schabi/newpipe/views/NewPipeTextView.java b/app/src/main/java/org/schabi/newpipe/views/NewPipeTextView.java index 75fb8f161..8fdac32db 100644 --- a/app/src/main/java/org/schabi/newpipe/views/NewPipeTextView.java +++ b/app/src/main/java/org/schabi/newpipe/views/NewPipeTextView.java @@ -7,10 +7,9 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.widget.AppCompatTextView; +import org.schabi.newpipe.util.NewPipeTextViewHelper; import org.schabi.newpipe.util.external_communication.ShareUtils; -import static org.schabi.newpipe.util.NewPipeTextViewHelper.shareSelectedTextWithShareUtils; - /** * An {@link AppCompatTextView} which uses {@link ShareUtils#shareText(Context, String, String)} * when sharing selected text by using the {@code Share} command of the floating actions. @@ -38,7 +37,8 @@ public class NewPipeTextView extends AppCompatTextView { @Override public boolean onTextContextMenuItem(final int id) { if (id == android.R.id.shareText) { - return shareSelectedTextWithShareUtils(this); + NewPipeTextViewHelper.shareSelectedTextWithShareUtils(this); + return true; } return super.onTextContextMenuItem(id); }