fix to display text that was sent to app via "share to"

the bug was, that the sent text was overwritten with "" in restoreState.

With this fix the saved state is only applied when the input field is empty (which means there was nothing shared)

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
Marcel Hibbe 2024-09-04 13:41:15 +02:00
parent 9e48c9a40f
commit 07cd9e1ced
No known key found for this signature in database
GPG key ID: C793F8B59F43CE7B

View file

@ -247,6 +247,7 @@ class MessageInputFragment : Fragment() {
}
private fun restoreState() {
if (binding.fragmentMessageInputView.inputEditText.text.isEmpty()) {
requireContext().getSharedPreferences(chatActivity.localClassName, AppCompatActivity.MODE_PRIVATE).apply {
val text = getString(chatActivity.roomToken, "")
val cursor = getInt(chatActivity.roomToken + CURSOR_KEY, 0)
@ -254,6 +255,7 @@ class MessageInputFragment : Fragment() {
binding.fragmentMessageInputView.messageInput.setSelection(cursor)
}
}
}
private fun saveState() {
val text = binding.fragmentMessageInputView.messageInput.text.toString()