Skip to content

Commit

Permalink
Merge pull request #3224 from nextcloud/issue-1918-chat-message-draft
Browse files Browse the repository at this point in the history
Message drafts are now saved
  • Loading branch information
AndyScherzinger authored Aug 1, 2023
2 parents d0d170f + e5afa96 commit 1f6ced7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
12 changes: 12 additions & 0 deletions app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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")
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -698,5 +698,6 @@ How to translate with transifex:
<string name="nc_settings_socks_value" translatable="false">1080</string>
<string name="this_is_a_test_message">This is a test message</string>
<string name="continuous_voice_message_recording">Lock recording for continuously recording of the voice message</string>
<string name="saved_draft_message">Saved draft message.</string>

</resources>

0 comments on commit 1f6ced7

Please sign in to comment.