From 725b1a7406a06584e1b15a1cc273e926ec9e6804 Mon Sep 17 00:00:00 2001 From: Christian Schneppe Date: Sun, 1 Apr 2018 14:22:34 +0200 Subject: introduced setting to not scroll down after sending a message --- .../java/de/pixart/messenger/ui/ConversationFragment.java | 12 ++++++++---- src/main/res/values/defaults.xml | 1 + src/main/res/values/strings.xml | 2 ++ src/main/res/xml/preferences.xml | 5 +++++ 4 files changed, 16 insertions(+), 4 deletions(-) (limited to 'src/main') diff --git a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java index 749d6a408..c0ebb1338 100644 --- a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java +++ b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java @@ -2198,10 +2198,14 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke activity.xmppConnectionService.updateConversation(conversation); } updateChatMsgHint(); - new Handler().post(() -> { - int size = messageList.size(); - this.binding.messagesView.setSelection(size - 1); - }); + SharedPreferences p = PreferenceManager.getDefaultSharedPreferences(activity); + final boolean prefScrollToBottom = p.getBoolean("scroll_to_bottom", activity.getResources().getBoolean(R.bool.scroll_to_bottom)); + if (prefScrollToBottom || scrolledToBottom()) { + new Handler().post(() -> { + int size = messageList.size(); + this.binding.messagesView.setSelection(size - 1); + }); + } } public void setFocusOnInputField() { diff --git a/src/main/res/values/defaults.xml b/src/main/res/values/defaults.xml index 67545e6a9..425e397c9 100644 --- a/src/main/res/values/defaults.xml +++ b/src/main/res/values/defaults.xml @@ -101,5 +101,6 @@ true false true + true diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index 5e7ac836e..d0432d342 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -767,4 +767,6 @@ Once Theme The QR code scanner needs access to the camera + Scroll down after sending a message + Scroll to bottom diff --git a/src/main/res/xml/preferences.xml b/src/main/res/xml/preferences.xml index 830d0607f..27e188c7f 100644 --- a/src/main/res/xml/preferences.xml +++ b/src/main/res/xml/preferences.xml @@ -45,6 +45,11 @@ android:key="use_auto_rotate" android:summary="@string/pref_use_auto_rotate_summary" android:title="@string/pref_use_auto_rotate" /> +