From 30c6ad5ab62c6d7e5f79362b58764a3e58775b4a Mon Sep 17 00:00:00 2001 From: Julius Linus Date: Thu, 4 Jan 2024 11:14:14 -0600 Subject: [PATCH] save cursor position Signed-off-by: Julius Linus --- app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt b/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt index c5d23b62a..3ace986ef 100644 --- a/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt +++ b/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt @@ -525,7 +525,9 @@ class ChatActivity : active = true context.getSharedPreferences(localClassName, MODE_PRIVATE).apply { val text = getString(roomToken, "") + val cursor = getInt(roomToken + CURSOR_KEY, 0) binding.messageInputView.messageInput.setText(text) + binding.messageInputView.messageInput.setSelection(cursor) } this.lifecycle.addObserver(AudioUtils) } @@ -544,10 +546,12 @@ class ChatActivity : stopMediaPlayer(currentlyPlayedVoiceMessage!!) } val text = binding.messageInputView.messageInput.text.toString() + val cursor = binding.messageInputView.messageInput.selectionStart val previous = context.getSharedPreferences(localClassName, MODE_PRIVATE).getString(roomToken, "null") if (text != previous) { context.getSharedPreferences(localClassName, MODE_PRIVATE).edit().apply { putString(roomToken, text) + putInt(roomToken + CURSOR_KEY, cursor) apply() } } @@ -4603,5 +4607,6 @@ class ChatActivity : private const val CALL_STARTED_ID = -2 private const val MILISEC_15: Long = 15 private const val LINEBREAK = "\n" + private const val CURSOR_KEY = "_cursor" } }