Browse Source

fixed bug where the state of message input fragment wasn't saved because of capabilities

Signed-off-by: rapterjet2004 <juliuslinus1@gmail.com>
rapterjet2004 10 months ago
parent
commit
9d75550482

+ 5 - 1
app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt

@@ -332,6 +332,8 @@ class ChatActivity :
         }
         }
     }
     }
 
 
+    private lateinit var messageInputFragment: MessageInputFragment
+
     val typingParticipants = HashMap<String, TypingParticipant>()
     val typingParticipants = HashMap<String, TypingParticipant>()
 
 
     var callStarted = false
     var callStarted = false
@@ -398,6 +400,8 @@ class ChatActivity :
         setContentView(binding.root)
         setContentView(binding.root)
         setupSystemColors()
         setupSystemColors()
 
 
+        messageInputFragment = MessageInputFragment()
+
         conversationUser = currentUserProvider.currentUser.blockingGet()
         conversationUser = currentUserProvider.currentUser.blockingGet()
 
 
         handleIntent(intent)
         handleIntent(intent)
@@ -579,7 +583,7 @@ class ChatActivity :
 
 
                     supportFragmentManager.commit {
                     supportFragmentManager.commit {
                         setReorderingAllowed(true) // optimizes out redundant replace operations
                         setReorderingAllowed(true) // optimizes out redundant replace operations
-                        replace(R.id.fragment_container_activity_chat, MessageInputFragment())
+                        replace(R.id.fragment_container_activity_chat, messageInputFragment)
                     }
                     }
 
 
                     joinRoomWithPassword()
                     joinRoomWithPassword()

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

@@ -136,9 +136,13 @@ class MessageInputFragment : Fragment() {
         return binding.root
         return binding.root
     }
     }
 
 
+    override fun onPause() {
+        super.onPause()
+        saveState()
+    }
+
     override fun onDestroyView() {
     override fun onDestroyView() {
         super.onDestroyView()
         super.onDestroyView()
-        saveState()
         if (mentionAutocomplete != null && mentionAutocomplete!!.isPopupShowing) {
         if (mentionAutocomplete != null && mentionAutocomplete!!.isPopupShowing) {
             mentionAutocomplete?.dismissPopup()
             mentionAutocomplete?.dismissPopup()
         }
         }