From dfc57108a3958b8bf94753ee5fa39fdd8c81df90 Mon Sep 17 00:00:00 2001 From: Ezerous Date: Sat, 15 Jul 2017 01:12:17 +0300 Subject: [PATCH] Fix for scroll-to-quickreply --- .../mthmmy/activities/topic/TopicActivity.java | 1 + .../mthmmy/activities/topic/TopicAdapter.java | 18 ++++++++++++++++++ app/src/main/res/drawable/ic_reply.xml | 9 +++++++++ app/src/main/res/layout/activity_topic.xml | 2 +- 4 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 app/src/main/res/drawable/ic_reply.xml diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java index f96f30bc..a10b7daf 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java @@ -187,6 +187,7 @@ public class TopicActivity extends BaseActivity { topicAdapter.prepareForReply(new ReplyTask(), topicTitle, loadedPageUrl); replyFAB.hide(); bottomNavBar.setVisibility(View.GONE); + recyclerView.scrollToPosition(postsList.size() - 1); } } }); diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java index 3c848c72..88c9694b 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java @@ -21,6 +21,7 @@ import android.text.TextWatcher; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.view.inputmethod.InputMethodManager; import android.webkit.WebResourceRequest; import android.webkit.WebView; import android.webkit.WebViewClient; @@ -136,6 +137,23 @@ class TopicAdapter extends RecyclerView.Adapter { View view = LayoutInflater.from(parent.getContext()). inflate(R.layout.activity_topic_quick_reply_row, parent, false); view.findViewById(R.id.quick_reply_submit).setEnabled(true); + + final EditText quickReplyText = (EditText) view.findViewById(R.id.quick_reply_text); + quickReplyText.setFocusableInTouchMode(true); + quickReplyText.setOnFocusChangeListener(new View.OnFocusChangeListener() { + @Override + public void onFocusChange(View v, boolean hasFocus) { + quickReplyText.post(new Runnable() { + @Override + public void run() { + InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE); + imm.showSoftInput(quickReplyText, InputMethodManager.SHOW_IMPLICIT); + } + }); + } + }); + quickReplyText.requestFocus(); + //Default post subject replyDataHolder[replySubject] = "Re: " + topicTitle; //Build quotes diff --git a/app/src/main/res/drawable/ic_reply.xml b/app/src/main/res/drawable/ic_reply.xml new file mode 100644 index 00000000..1fc7f4f1 --- /dev/null +++ b/app/src/main/res/drawable/ic_reply.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/layout/activity_topic.xml b/app/src/main/res/layout/activity_topic.xml index 1e1c5416..1334fe4e 100644 --- a/app/src/main/res/layout/activity_topic.xml +++ b/app/src/main/res/layout/activity_topic.xml @@ -123,7 +123,7 @@ android:layout_marginBottom="50dp" android:layout_marginEnd="@dimen/fab_margins" app:layout_behavior="gr.thmmy.mthmmy.utils.ScrollAwareFABBehavior" - app:srcCompat="@drawable/ic_add_fab"/> + app:srcCompat="@drawable/ic_reply"/>