|
@ -26,7 +26,6 @@ import android.view.LayoutInflater; |
|
|
import android.view.View; |
|
|
import android.view.View; |
|
|
import android.view.ViewGroup; |
|
|
import android.view.ViewGroup; |
|
|
import android.view.inputmethod.EditorInfo; |
|
|
import android.view.inputmethod.EditorInfo; |
|
|
import android.view.inputmethod.InputConnection; |
|
|
|
|
|
import android.view.inputmethod.InputMethodManager; |
|
|
import android.view.inputmethod.InputMethodManager; |
|
|
import android.webkit.WebResourceRequest; |
|
|
import android.webkit.WebResourceRequest; |
|
|
import android.webkit.WebView; |
|
|
import android.webkit.WebView; |
|
@ -59,7 +58,7 @@ import gr.thmmy.mthmmy.activities.board.BoardActivity; |
|
|
import gr.thmmy.mthmmy.activities.profile.ProfileActivity; |
|
|
import gr.thmmy.mthmmy.activities.profile.ProfileActivity; |
|
|
import gr.thmmy.mthmmy.base.BaseActivity; |
|
|
import gr.thmmy.mthmmy.base.BaseActivity; |
|
|
import gr.thmmy.mthmmy.editorview.EditorView; |
|
|
import gr.thmmy.mthmmy.editorview.EditorView; |
|
|
import gr.thmmy.mthmmy.editorview.EmojiKeyboard; |
|
|
import gr.thmmy.mthmmy.editorview.IEmojiKeyboard; |
|
|
import gr.thmmy.mthmmy.model.Poll; |
|
|
import gr.thmmy.mthmmy.model.Poll; |
|
|
import gr.thmmy.mthmmy.model.Post; |
|
|
import gr.thmmy.mthmmy.model.Post; |
|
|
import gr.thmmy.mthmmy.model.ThmmyFile; |
|
|
import gr.thmmy.mthmmy.model.ThmmyFile; |
|
@ -91,7 +90,7 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { |
|
|
private static int THUMBNAIL_SIZE; |
|
|
private static int THUMBNAIL_SIZE; |
|
|
private final Context context; |
|
|
private final Context context; |
|
|
private final OnPostFocusChangeListener postFocusListener; |
|
|
private final OnPostFocusChangeListener postFocusListener; |
|
|
private final EmojiKeyboard.EmojiKeyboardOwner emojiKeyboardOwner; |
|
|
private final IEmojiKeyboard emojiKeyboard; |
|
|
private final List<TopicItem> topicItems; |
|
|
private final List<TopicItem> topicItems; |
|
|
private TopicViewModel viewModel; |
|
|
private TopicViewModel viewModel; |
|
|
|
|
|
|
|
@ -99,11 +98,11 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { |
|
|
* @param context the context of the {@link RecyclerView} |
|
|
* @param context the context of the {@link RecyclerView} |
|
|
* @param topicItems List of {@link Post} objects to use |
|
|
* @param topicItems List of {@link Post} objects to use |
|
|
*/ |
|
|
*/ |
|
|
TopicAdapter(TopicActivity context, List<TopicItem> topicItems) { |
|
|
TopicAdapter(TopicActivity context, IEmojiKeyboard emojiKeyboard, List<TopicItem> topicItems) { |
|
|
this.context = context; |
|
|
this.context = context; |
|
|
this.topicItems = topicItems; |
|
|
this.topicItems = topicItems; |
|
|
this.postFocusListener = context; |
|
|
this.postFocusListener = context; |
|
|
this.emojiKeyboardOwner = context; |
|
|
this.emojiKeyboard = emojiKeyboard; |
|
|
|
|
|
|
|
|
viewModel = ViewModelProviders.of(context).get(TopicViewModel.class); |
|
|
viewModel = ViewModelProviders.of(context).get(TopicViewModel.class); |
|
|
|
|
|
|
|
@ -590,15 +589,9 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { |
|
|
holder.quickReplySubject.setRawInputType(InputType.TYPE_CLASS_TEXT); |
|
|
holder.quickReplySubject.setRawInputType(InputType.TYPE_CLASS_TEXT); |
|
|
holder.quickReplySubject.setImeOptions(EditorInfo.IME_ACTION_DONE); |
|
|
holder.quickReplySubject.setImeOptions(EditorInfo.IME_ACTION_DONE); |
|
|
|
|
|
|
|
|
holder.replyEditor.setEmojiKeyboardOwner(emojiKeyboardOwner); |
|
|
holder.replyEditor.setEmojiKeyboard(emojiKeyboard); |
|
|
InputConnection ic = holder.replyEditor.getInputConnection(); |
|
|
holder.replyEditor.requestEditTextFocus(); |
|
|
emojiKeyboardOwner.setEmojiKeyboardInputConnection(ic); |
|
|
emojiKeyboard.registerEmojiInputField(holder.replyEditor); |
|
|
holder.replyEditor.updateEmojiKeyboardVisibility(); |
|
|
|
|
|
holder.replyEditor.getEditText().setOnFocusChangeListener((v, hasFocus) -> { |
|
|
|
|
|
InputConnection ic12 = holder.replyEditor.getInputConnection(); |
|
|
|
|
|
emojiKeyboardOwner.setEmojiKeyboardInputConnection(ic12); |
|
|
|
|
|
holder.replyEditor.updateEmojiKeyboardVisibility(); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
holder.replyEditor.setText(viewModel.getBuildedQuotes()); |
|
|
holder.replyEditor.setText(viewModel.getBuildedQuotes()); |
|
|
holder.replyEditor.setOnSubmitListener(view -> { |
|
|
holder.replyEditor.setOnSubmitListener(view -> { |
|
@ -611,7 +604,7 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { |
|
|
imm.hideSoftInputFromWindow(view.getWindowToken(), 0); |
|
|
imm.hideSoftInputFromWindow(view.getWindowToken(), 0); |
|
|
holder.itemView.setAlpha(0.5f); |
|
|
holder.itemView.setAlpha(0.5f); |
|
|
holder.itemView.setEnabled(false); |
|
|
holder.itemView.setEnabled(false); |
|
|
emojiKeyboardOwner.setEmojiKeyboardVisible(false); |
|
|
emojiKeyboard.hide(); |
|
|
|
|
|
|
|
|
viewModel.postReply(context, holder.quickReplySubject.getText().toString(), |
|
|
viewModel.postReply(context, holder.quickReplySubject.getText().toString(), |
|
|
holder.replyEditor.getText().toString()); |
|
|
holder.replyEditor.getText().toString()); |
|
@ -641,18 +634,10 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { |
|
|
holder.editSubject.setRawInputType(InputType.TYPE_CLASS_TEXT); |
|
|
holder.editSubject.setRawInputType(InputType.TYPE_CLASS_TEXT); |
|
|
holder.editSubject.setImeOptions(EditorInfo.IME_ACTION_DONE); |
|
|
holder.editSubject.setImeOptions(EditorInfo.IME_ACTION_DONE); |
|
|
|
|
|
|
|
|
holder.editEditor.setEmojiKeyboardOwner(emojiKeyboardOwner); |
|
|
holder.editEditor.setEmojiKeyboard(emojiKeyboard); |
|
|
InputConnection ic = holder.editEditor.getInputConnection(); |
|
|
holder.editEditor.requestEditTextFocus(); |
|
|
emojiKeyboardOwner.setEmojiKeyboardInputConnection(ic); |
|
|
emojiKeyboard.registerEmojiInputField(holder.editEditor); |
|
|
holder.editEditor.updateEmojiKeyboardVisibility(); |
|
|
|
|
|
holder.editEditor.setText(viewModel.getPostBeingEditedText()); |
|
|
holder.editEditor.setText(viewModel.getPostBeingEditedText()); |
|
|
holder.editEditor.getEditText().setOnFocusChangeListener((v, hasFocus) -> { |
|
|
|
|
|
if (hasFocus) { |
|
|
|
|
|
InputConnection ic1 = holder.editEditor.getInputConnection(); |
|
|
|
|
|
emojiKeyboardOwner.setEmojiKeyboardInputConnection(ic1); |
|
|
|
|
|
holder.editEditor.updateEmojiKeyboardVisibility(); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
holder.editEditor.setOnSubmitListener(view -> { |
|
|
holder.editEditor.setOnSubmitListener(view -> { |
|
|
if (holder.editSubject.getText().toString().isEmpty()) return; |
|
|
if (holder.editSubject.getText().toString().isEmpty()) return; |
|
|
if (holder.editEditor.getText().toString().isEmpty()) { |
|
|
if (holder.editEditor.getText().toString().isEmpty()) { |
|
@ -663,7 +648,7 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { |
|
|
imm.hideSoftInputFromWindow(view.getWindowToken(), 0); |
|
|
imm.hideSoftInputFromWindow(view.getWindowToken(), 0); |
|
|
holder.itemView.setAlpha(0.5f); |
|
|
holder.itemView.setAlpha(0.5f); |
|
|
holder.itemView.setEnabled(false); |
|
|
holder.itemView.setEnabled(false); |
|
|
emojiKeyboardOwner.setEmojiKeyboardVisible(false); |
|
|
emojiKeyboard.hide(); |
|
|
|
|
|
|
|
|
viewModel.editPost(position, holder.editSubject.getText().toString(), holder.editEditor.getText().toString()); |
|
|
viewModel.editPost(position, holder.editSubject.getText().toString(), holder.editEditor.getText().toString()); |
|
|
}); |
|
|
}); |
|
|