From e5afa96e26b23e119f6aba4e52ce4bf31d88dbd8 Mon Sep 17 00:00:00 2001 From: Julius Linus Date: Mon, 31 Jul 2023 14:55:29 -0500 Subject: [PATCH] In this PR - Drafts are now saved in between rooms. Signed-off-by: Julius Linus --- .../java/com/nextcloud/talk/chat/ChatActivity.kt | 12 ++++++++++++ app/src/main/res/values/strings.xml | 1 + 2 files changed, 13 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 580d1b124..013da8f14 100644 --- a/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt +++ b/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt @@ -480,6 +480,10 @@ class ChatActivity : override fun onStart() { super.onStart() active = true + context.getSharedPreferences(localClassName, MODE_PRIVATE).apply { + val text = getString(roomToken, "") + binding.messageInputView.messageInput.setText(text) + } } override fun onStop() { @@ -495,6 +499,14 @@ class ChatActivity : if (currentlyPlayedVoiceMessage != null) { stopMediaPlayer(currentlyPlayedVoiceMessage!!) } + val text = binding.messageInputView.messageInput.text.toString() + val previous = context.getSharedPreferences(localClassName, MODE_PRIVATE).getString(roomToken, "null") + if (text != previous) { + context.getSharedPreferences(localClassName, MODE_PRIVATE).edit().apply { + putString(roomToken, text) + apply() + } + } } @Suppress("LongMethod") diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 101856103..93324c68f 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -698,5 +698,6 @@ How to translate with transifex: 1080 This is a test message Lock recording for continuously recording of the voice message + Saved draft message.