Adress requested changes and remove an unused return value in NewPipeTextViewHelper
This commit is contained in:
parent
50b85a7734
commit
a744775fe7
|
@ -29,11 +29,8 @@ public final class NewPipeTextViewHelper {
|
||||||
* @param textView the {@link TextView} on which sharing the selected text. It should be a
|
* @param textView the {@link TextView} on which sharing the selected text. It should be a
|
||||||
* {@link NewPipeTextView} or a {@link NewPipeEditText} (even if
|
* {@link NewPipeTextView} or a {@link NewPipeEditText} (even if
|
||||||
* {@link TextView standard TextViews} are supported).
|
* {@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)) {
|
if (!(textView instanceof NewPipeEditText)) {
|
||||||
final CharSequence textViewText;
|
final CharSequence textViewText;
|
||||||
if (textView instanceof NewPipeTextView) {
|
if (textView instanceof NewPipeTextView) {
|
||||||
|
@ -59,8 +56,6 @@ public final class NewPipeTextViewHelper {
|
||||||
shareSelectedTextIfNotNullAndNotEmpty(textView, selectedText);
|
shareSelectedTextIfNotNullAndNotEmpty(textView, selectedText);
|
||||||
Selection.setSelection(text, editText.getSelectionEnd());
|
Selection.setSelection(text, editText.getSelectionEnd());
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
|
|
@ -7,10 +7,9 @@ import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.appcompat.widget.AppCompatEditText;
|
import androidx.appcompat.widget.AppCompatEditText;
|
||||||
|
|
||||||
|
import org.schabi.newpipe.util.NewPipeTextViewHelper;
|
||||||
import org.schabi.newpipe.util.external_communication.ShareUtils;
|
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)}
|
* 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.
|
* when sharing selected text by using the {@code Share} command of the floating actions.
|
||||||
|
@ -38,7 +37,8 @@ public class NewPipeEditText extends AppCompatEditText {
|
||||||
@Override
|
@Override
|
||||||
public boolean onTextContextMenuItem(final int id) {
|
public boolean onTextContextMenuItem(final int id) {
|
||||||
if (id == android.R.id.shareText) {
|
if (id == android.R.id.shareText) {
|
||||||
return shareSelectedTextWithShareUtils(this);
|
NewPipeTextViewHelper.shareSelectedTextWithShareUtils(this);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return super.onTextContextMenuItem(id);
|
return super.onTextContextMenuItem(id);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,10 +7,9 @@ import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.appcompat.widget.AppCompatTextView;
|
import androidx.appcompat.widget.AppCompatTextView;
|
||||||
|
|
||||||
|
import org.schabi.newpipe.util.NewPipeTextViewHelper;
|
||||||
import org.schabi.newpipe.util.external_communication.ShareUtils;
|
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)}
|
* 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.
|
* when sharing selected text by using the {@code Share} command of the floating actions.
|
||||||
|
@ -38,7 +37,8 @@ public class NewPipeTextView extends AppCompatTextView {
|
||||||
@Override
|
@Override
|
||||||
public boolean onTextContextMenuItem(final int id) {
|
public boolean onTextContextMenuItem(final int id) {
|
||||||
if (id == android.R.id.shareText) {
|
if (id == android.R.id.shareText) {
|
||||||
return shareSelectedTextWithShareUtils(this);
|
NewPipeTextViewHelper.shareSelectedTextWithShareUtils(this);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return super.onTextContextMenuItem(id);
|
return super.onTextContextMenuItem(id);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue