Browse Source

fixes

pull/45/head
Thodoris1999 6 years ago
parent
commit
cc755cb969
  1. 42
      app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java
  2. 2
      app/src/main/java/gr/thmmy/mthmmy/utils/EmojiKeyboard.java
  3. 35
      app/src/main/res/layout/activity_topic_edit_row.xml
  4. 2
      app/src/main/res/layout/editor_view.xml

42
app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java

@ -121,9 +121,8 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
} else if (viewType == Post.TYPE_EDIT) { } else if (viewType == Post.TYPE_EDIT) {
View view = LayoutInflater.from(parent.getContext()). View view = LayoutInflater.from(parent.getContext()).
inflate(R.layout.activity_topic_edit_row, parent, false); inflate(R.layout.activity_topic_edit_row, parent, false);
view.findViewById(R.id.edit_message_submit).setEnabled(true);
final EditText editPostEdittext = view.findViewById(R.id.edit_message_text); final EditText editPostEdittext = ((EditorView) view.findViewById(R.id.edit_editorview)).getEditText();
editPostEdittext.setFocusableInTouchMode(true); editPostEdittext.setFocusableInTouchMode(true);
editPostEdittext.setOnFocusChangeListener((v, hasFocus) -> editPostEdittext.post(() -> { editPostEdittext.setOnFocusChangeListener((v, hasFocus) -> editPostEdittext.post(() -> {
InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE); InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
@ -463,6 +462,11 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
InputConnection ic = holder.replyEditor.getInputConnection(); InputConnection ic = holder.replyEditor.getInputConnection();
emojiKeyboardOwner.setEmojiKeyboardInputConnection(ic); emojiKeyboardOwner.setEmojiKeyboardInputConnection(ic);
holder.replyEditor.updateEmojiKeyboardVisibility(); 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 -> {
@ -475,6 +479,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);
viewModel.postReply(context, holder.quickReplySubject.getText().toString(), viewModel.postReply(context, holder.quickReplySubject.getText().toString(),
holder.replyEditor.getText().toString()); holder.replyEditor.getText().toString());
@ -501,23 +506,37 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
.transform(new CircleTransform()) .transform(new CircleTransform())
.into(holder.thumbnail); .into(holder.thumbnail);
holder.username.setText(getSessionManager().getUsername()); holder.username.setText(getSessionManager().getUsername());
holder.editSubject.setText(postsList.get(position).getSubject()); holder.editSubject.setText(postsList.get(position).getSubject());
holder.editMessage.setText(viewModel.getPostBeingEditedText());
holder.submitButton.setOnClickListener(view -> { holder.editEditor.setEmojiKeyboardOwner(emojiKeyboardOwner);
InputConnection ic = holder.editEditor.getInputConnection();
emojiKeyboardOwner.setEmojiKeyboardInputConnection(ic);
holder.editEditor.updateEmojiKeyboardVisibility();
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 -> {
if (holder.editSubject.getText().toString().isEmpty()) return; if (holder.editSubject.getText().toString().isEmpty()) return;
if (holder.editMessage.getText().toString().isEmpty()) return; if (holder.editEditor.getText().toString().isEmpty()) {
holder.editEditor.setError("Required");
return;
}
InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE); InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
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);
viewModel.editPost(position, holder.editSubject.getText().toString(), holder.editMessage.getText().toString()); viewModel.editPost(position, holder.editSubject.getText().toString(), holder.editEditor.getText().toString());
}); });
if (backPressHidden) { if (backPressHidden) {
holder.editMessage.requestFocus(); holder.editEditor.requestFocus();
backPressHidden = false; backPressHidden = false;
} }
} }
@ -601,17 +620,16 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private static class EditMessageViewHolder extends RecyclerView.ViewHolder { private static class EditMessageViewHolder extends RecyclerView.ViewHolder {
final ImageView thumbnail; final ImageView thumbnail;
final TextView username; final TextView username;
final EditText editMessage, editSubject; final EditText editSubject;
final AppCompatImageButton submitButton; final EditorView editEditor;
EditMessageViewHolder(View editView) { EditMessageViewHolder(View editView) {
super(editView); super(editView);
thumbnail = editView.findViewById(R.id.thumbnail); thumbnail = editView.findViewById(R.id.thumbnail);
username = editView.findViewById(R.id.username); username = editView.findViewById(R.id.username);
editMessage = editView.findViewById(R.id.edit_message_text);
editSubject = editView.findViewById(R.id.edit_message_subject); editSubject = editView.findViewById(R.id.edit_message_subject);
submitButton = editView.findViewById(R.id.edit_message_submit); editEditor = editView.findViewById(R.id.edit_editorview);
} }
} }

2
app/src/main/java/gr/thmmy/mthmmy/utils/EmojiKeyboard.java

@ -169,7 +169,7 @@ public class EmojiKeyboard extends LinearLayout {
emojiKeyboardAdapter.setOnEmojiClickListener((view, position) -> { emojiKeyboardAdapter.setOnEmojiClickListener((view, position) -> {
if (inputConnection == null) return; if (inputConnection == null) return;
String bbcode = emojis[position].getBbcode(); String bbcode = emojis[position].getBbcode();
inputConnection.commitText(bbcode, 1); inputConnection.commitText(" " + bbcode, 1);
}); });
emojiRecyclerview.setAdapter(emojiKeyboardAdapter); emojiRecyclerview.setAdapter(emojiKeyboardAdapter);
AppCompatImageButton backspaceButton = findViewById(R.id.backspace_button); AppCompatImageButton backspaceButton = findViewById(R.id.backspace_button);

35
app/src/main/res/layout/activity_topic_edit_row.xml

@ -80,39 +80,12 @@
android:textSize="10sp" android:textSize="10sp"
tools:ignore="SmallSp" /> tools:ignore="SmallSp" />
</RelativeLayout> </RelativeLayout>
<gr.thmmy.mthmmy.utils.EditorView
<LinearLayout android:id="@+id/edit_editorview"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal" android:background="@color/card_background"
android:paddingLeft="16dp" card_view:hint="Post message"/>
android:paddingRight="16dp">
<android.support.design.widget.TextInputLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<EditText
android:id="@+id/edit_message_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/post_message"
android:inputType="textMultiLine" />
</android.support.design.widget.TextInputLayout>
<android.support.v7.widget.AppCompatImageButton
android:id="@+id/edit_message_submit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginBottom="5dp"
android:layout_marginEnd="5dp"
android:background="@color/card_background"
android:contentDescription="@string/submit"
app:srcCompat="@drawable/ic_send_accent_24dp" />
</LinearLayout>
</LinearLayout> </LinearLayout>
</android.support.v7.widget.CardView> </android.support.v7.widget.CardView>
</FrameLayout> </FrameLayout>

2
app/src/main/res/layout/editor_view.xml

@ -128,7 +128,7 @@
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
android:orientation="vertical"> android:orientation="vertical" >
<android.support.design.widget.TextInputEditText <android.support.design.widget.TextInputEditText
android:id="@+id/editor_edittext" android:id="@+id/editor_edittext"

Loading…
Cancel
Save