adding image keyboard support (and some cleanup)
This commit is contained in:
parent
018be25137
commit
2dfd83ef97
|
@ -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 final String REPLYING_STATUS_CONTENT_EXTRA = "replying_status_content";
|
||||||
private static TootDao tootDao = TuskyApplication.getDB().tootDao();
|
private static TootDao tootDao = TuskyApplication.getDB().tootDao();
|
||||||
|
|
||||||
private TextView replyTextView;
|
|
||||||
private TextView replyContentTextView;
|
private TextView replyContentTextView;
|
||||||
private EditTextTyped textEditor;
|
private EditTextTyped textEditor;
|
||||||
private LinearLayout mediaPreviewBar;
|
private LinearLayout mediaPreviewBar;
|
||||||
|
@ -183,7 +182,7 @@ public final class ComposeActivity extends BaseActivity implements ComposeOption
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_compose);
|
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);
|
replyContentTextView = findViewById(R.id.reply_content_tv);
|
||||||
textEditor = findViewById(R.id.compose_edit_field);
|
textEditor = findViewById(R.id.compose_edit_field);
|
||||||
mediaPreviewBar = findViewById(R.id.compose_media_preview_bar);
|
mediaPreviewBar = findViewById(R.id.compose_media_preview_bar);
|
||||||
|
@ -377,7 +376,7 @@ public final class ComposeActivity extends BaseActivity implements ComposeOption
|
||||||
updateVisibleCharactersLeft();
|
updateVisibleCharactersLeft();
|
||||||
|
|
||||||
// Setup the main text field.
|
// 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);
|
final int mentionColour = ThemeUtils.getColor(this, R.attr.compose_mention_color);
|
||||||
SpanUtils.highlightSpans(textEditor.getText(), mentionColour);
|
SpanUtils.highlightSpans(textEditor.getText(), mentionColour);
|
||||||
textEditor.addTextChangedListener(new TextWatcher() {
|
textEditor.addTextChangedListener(new TextWatcher() {
|
||||||
|
@ -861,13 +860,8 @@ public final class ComposeActivity extends BaseActivity implements ComposeOption
|
||||||
.apply();
|
.apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setEditTextMimeTypes(String[] contentMimeTypes) {
|
private void setEditTextMimeTypes() {
|
||||||
final String[] mimeTypes;
|
final String[] mimeTypes = new String[] {"image/*"};
|
||||||
if (contentMimeTypes == null || contentMimeTypes.length == 0) {
|
|
||||||
mimeTypes = new String[0];
|
|
||||||
} else {
|
|
||||||
mimeTypes = Arrays.copyOf(contentMimeTypes, contentMimeTypes.length);
|
|
||||||
}
|
|
||||||
textEditor.setMimeTypes(mimeTypes, new InputConnectionCompat.OnCommitContentListener() {
|
textEditor.setMimeTypes(mimeTypes, new InputConnectionCompat.OnCommitContentListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommitContent(InputContentInfoCompat inputContentInfo,
|
public boolean onCommitContent(InputContentInfoCompat inputContentInfo,
|
||||||
|
@ -950,7 +944,7 @@ public final class ComposeActivity extends BaseActivity implements ComposeOption
|
||||||
|
|
||||||
Callback<Status> callback = new Callback<Status>() {
|
Callback<Status> callback = new Callback<Status>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(Call<Status> call, Response<Status> response) {
|
public void onResponse(@NonNull Call<Status> call, @NonNull Response<Status> response) {
|
||||||
if (response.isSuccessful()) {
|
if (response.isSuccessful()) {
|
||||||
onSendSuccess();
|
onSendSuccess();
|
||||||
} else {
|
} else {
|
||||||
|
@ -959,7 +953,7 @@ public final class ComposeActivity extends BaseActivity implements ComposeOption
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Call<Status> call, Throwable t) {
|
public void onFailure(@NonNull Call<Status> call, @NonNull Throwable t) {
|
||||||
onSendFailure();
|
onSendFailure();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -29,7 +29,6 @@ public class EditTextTyped extends AppCompatMultiAutoCompleteTextView {
|
||||||
|
|
||||||
private InputConnectionCompat.OnCommitContentListener onCommitContentListener;
|
private InputConnectionCompat.OnCommitContentListener onCommitContentListener;
|
||||||
private String[] mimeTypes;
|
private String[] mimeTypes;
|
||||||
private OnPasteListener onPasteListener;
|
|
||||||
|
|
||||||
public EditTextTyped(Context context) {
|
public EditTextTyped(Context context) {
|
||||||
super(context);
|
super(context);
|
||||||
|
@ -39,10 +38,6 @@ public class EditTextTyped extends AppCompatMultiAutoCompleteTextView {
|
||||||
super(context, attributeSet);
|
super(context, attributeSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addOnPasteListener(OnPasteListener mOnPasteListener) {
|
|
||||||
this.onPasteListener = mOnPasteListener;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMimeTypes(String[] types,
|
public void setMimeTypes(String[] types,
|
||||||
InputConnectionCompat.OnCommitContentListener listener) {
|
InputConnectionCompat.OnCommitContentListener listener) {
|
||||||
mimeTypes = types;
|
mimeTypes = types;
|
||||||
|
@ -61,28 +56,4 @@ public class EditTextTyped extends AppCompatMultiAutoCompleteTextView {
|
||||||
return connection;
|
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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue