Эх сурвалжийг харах

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>
Marcel Hibbe 9 сар өмнө
parent
commit
07cd9e1ced

+ 7 - 5
app/src/main/java/com/nextcloud/talk/chat/MessageInputFragment.kt

@@ -247,11 +247,13 @@ class MessageInputFragment : Fragment() {
     }
 
     private fun restoreState() {
-        requireContext().getSharedPreferences(chatActivity.localClassName, AppCompatActivity.MODE_PRIVATE).apply {
-            val text = getString(chatActivity.roomToken, "")
-            val cursor = getInt(chatActivity.roomToken + CURSOR_KEY, 0)
-            binding.fragmentMessageInputView.messageInput.setText(text)
-            binding.fragmentMessageInputView.messageInput.setSelection(cursor)
+        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)
+                binding.fragmentMessageInputView.messageInput.setText(text)
+                binding.fragmentMessageInputView.messageInput.setSelection(cursor)
+            }
         }
     }