diff --git a/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java b/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java index 24085a70b..6f991fc72 100644 --- a/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java @@ -144,7 +144,6 @@ public final class ComposeActivity extends BaseActivity implements ComposeOption private static final String REPLYING_STATUS_CONTENT_EXTRA = "replying_status_content"; private static TootDao tootDao = TuskyApplication.getDB().tootDao(); - private TextView replyTextView; private TextView replyContentTextView; private EditTextTyped textEditor; private LinearLayout mediaPreviewBar; @@ -183,7 +182,7 @@ public final class ComposeActivity extends BaseActivity implements ComposeOption super.onCreate(savedInstanceState); setContentView(R.layout.activity_compose); - replyTextView = findViewById(R.id.reply_tv); + TextView replyTextView = findViewById(R.id.reply_tv); replyContentTextView = findViewById(R.id.reply_content_tv); textEditor = findViewById(R.id.compose_edit_field); mediaPreviewBar = findViewById(R.id.compose_media_preview_bar); @@ -377,7 +376,7 @@ public final class ComposeActivity extends BaseActivity implements ComposeOption updateVisibleCharactersLeft(); // Setup the main text field. - setEditTextMimeTypes(null); // new String[] { "image/gif", "image/webp" } + setEditTextMimeTypes(); // new String[] { "image/gif", "image/webp" } final int mentionColour = ThemeUtils.getColor(this, R.attr.compose_mention_color); SpanUtils.highlightSpans(textEditor.getText(), mentionColour); textEditor.addTextChangedListener(new TextWatcher() { @@ -861,13 +860,8 @@ public final class ComposeActivity extends BaseActivity implements ComposeOption .apply(); } - private void setEditTextMimeTypes(String[] contentMimeTypes) { - final String[] mimeTypes; - if (contentMimeTypes == null || contentMimeTypes.length == 0) { - mimeTypes = new String[0]; - } else { - mimeTypes = Arrays.copyOf(contentMimeTypes, contentMimeTypes.length); - } + private void setEditTextMimeTypes() { + final String[] mimeTypes = new String[] {"image/*"}; textEditor.setMimeTypes(mimeTypes, new InputConnectionCompat.OnCommitContentListener() { @Override public boolean onCommitContent(InputContentInfoCompat inputContentInfo, @@ -950,7 +944,7 @@ public final class ComposeActivity extends BaseActivity implements ComposeOption Callback callback = new Callback() { @Override - public void onResponse(Call call, Response response) { + public void onResponse(@NonNull Call call, @NonNull Response response) { if (response.isSuccessful()) { onSendSuccess(); } else { @@ -959,7 +953,7 @@ public final class ComposeActivity extends BaseActivity implements ComposeOption } @Override - public void onFailure(Call call, Throwable t) { + public void onFailure(@NonNull Call call, @NonNull Throwable t) { onSendFailure(); } }; diff --git a/app/src/main/java/com/keylesspalace/tusky/view/EditTextTyped.java b/app/src/main/java/com/keylesspalace/tusky/view/EditTextTyped.java index a6ad6be78..8de38513e 100644 --- a/app/src/main/java/com/keylesspalace/tusky/view/EditTextTyped.java +++ b/app/src/main/java/com/keylesspalace/tusky/view/EditTextTyped.java @@ -29,7 +29,6 @@ public class EditTextTyped extends AppCompatMultiAutoCompleteTextView { private InputConnectionCompat.OnCommitContentListener onCommitContentListener; private String[] mimeTypes; - private OnPasteListener onPasteListener; public EditTextTyped(Context context) { super(context); @@ -39,10 +38,6 @@ public class EditTextTyped extends AppCompatMultiAutoCompleteTextView { super(context, attributeSet); } - public void addOnPasteListener(OnPasteListener mOnPasteListener) { - this.onPasteListener = mOnPasteListener; - } - public void setMimeTypes(String[] types, InputConnectionCompat.OnCommitContentListener listener) { mimeTypes = types; @@ -61,28 +56,4 @@ public class EditTextTyped extends AppCompatMultiAutoCompleteTextView { return connection; } } - - @Override - public boolean onTextContextMenuItem(int id) { - boolean consumed = super.onTextContextMenuItem(id); - switch (id) { - case android.R.id.paste: - onPaste(); - break; - } - return consumed; - } - - /** - * Text was pasted into the EditText. - */ - public void onPaste() { - if (onPasteListener != null) { - onPasteListener.onPaste(); - } - } - - public interface OnPasteListener { - void onPaste(); - } }