introduced expert setting to not scroll down after sending a message

Daniel Gultsch created

Change summary

src/main/java/eu/siacs/conversations/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(-)

Detailed changes

src/main/java/eu/siacs/conversations/ui/ConversationFragment.java 🔗

@@ -1904,10 +1904,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() {

src/main/res/values/defaults.xml 🔗

@@ -41,4 +41,5 @@
     <bool name="return_to_previous">false</bool>
     <bool name="validate_hostname">false</bool>
     <bool name="show_qr_code_scan">true</bool>
+    <bool name="scroll_to_bottom">true</bool>
 </resources>

src/main/res/values/strings.xml 🔗

@@ -709,4 +709,6 @@
 	<string name="mtm_notification">Certificate Verification</string>
 	<string name="once">Once</string>
     <string name="qr_code_scanner_needs_access_to_camera">The QR code scanner needs access to the camera</string>
+    <string name="pref_scroll_to_bottom">Scroll to bottom</string>
+	<string name="pref_scroll_to_bottom_summary">Scroll down after sending a message</string>
 </resources>

src/main/res/xml/preferences.xml 🔗

@@ -257,6 +257,11 @@
                     android:key="display_enter_key"
                     android:summary="@string/pref_display_enter_key_summary"
                     android:title="@string/pref_display_enter_key"/>
+                <CheckBoxPreference
+                    android:defaultValue="@bool/scroll_to_bottom"
+                    android:key="scroll_to_bottom"
+                    android:title="@string/pref_scroll_to_bottom"
+                    android:summary="@string/pref_scroll_to_bottom_summary"/>
             </PreferenceCategory>
             <PreferenceCategory android:title="@string/pref_presence_settings">
                 <CheckBoxPreference