1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2024-12-23 08:30:44 +00:00

Adress requested changes and remove an unused return value in NewPipeTextViewHelper

This commit is contained in:
TiA4f8R 2021-10-02 19:53:17 +02:00
parent 50b85a7734
commit a744775fe7
No known key found for this signature in database
GPG Key ID: E6D3E7F5949450DD
3 changed files with 7 additions and 12 deletions

View File

@ -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

View File

@ -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);
}

View File

@ -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);
}