1. reverting changes from commit 971cc79b76. The scroll to methods are used in other places and a user reported that the search window suddenly opened without to search.
2. remove checkIfMessageIsSaved method. If the message is saved or not does not matter. The only fact for "scroll to" would be that it's loaded in the adapter.
3. As the adapter is always null with the current implementation (when coming back from the first search window), the "scroll to" is replaced with the startContextChatWindowForMessage. This could be changed again when adapter is not null anymore after coming back from the other screen...
startContextChatWindowForMessage
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
Opening it when adapter was null is a bit hacky but it works (better would be to make sure adapter is not null of course)
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
For v21.0.0, the following crash was reported:
Exception java.lang.NullPointerException: null cannot be cast to non-null type com.nextcloud.talk.chat.data.model.ChatMessage
at com.nextcloud.talk.chat.ChatActivity.onLoadMore (ChatActivity.kt:3107)
at com.stfalcon.chatkit.messages.MessagesListAdapter.onLoadMore (MessagesListAdapter.java:148)
at com.stfalcon.chatkit.messages.RecyclerScrollMoreListener.onScrolled (RecyclerScrollMoreListener.java:82)
at androidx.recyclerview.widget.RecyclerView.dispatchOnScrolled (RecyclerView.java:5688)
at androidx.recyclerview.widget.RecyclerView.dispatchLayoutStep3 (RecyclerView.java:4741)
at androidx.recyclerview.widget.RecyclerView.dispatchLayout (RecyclerView.java:4367)
at androidx.recyclerview.widget.RecyclerView.onLayout (RecyclerView.java:4919)
This is now improved:
- lastOrNull prevents exceptions if no matching item is found
- as? is a safe cast that returns null if the cast fails
Whole expression becomes null-safe, and id will be null if anything along the way doesn't match. Only when not null, onLoadMore continues.
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
to be discussed: does it make sense to show a dialog instead? At least when it's created via 1:1 conversation
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
snackbars disaapear with the switch to a different screen. Toasts survive the switch so they are visible during the activities switch
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
- Most code removed from ChatActivity
- Most work in MediaPlayerManager
- Added BackgroundVoiceMessageCard
Signed-off-by: rapterjet2004 <juliuslinus1@gmail.com>
because setData was called too late (after sendTempChatMessages was called from messageInputFragment, internalConversationId was not initialized in repository).
With this change, internalConversationId, credentials and urlForChatting are initialized earlier which should avoid the issue.
However conversationModel is still initialized quite late and should be accessed with caution. This could may be improved by better architecture..
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
onDestroy is not called when navigating to the next activity or bringing the app to background. That's why the adapter was not set to null and all messages were added another time the next time the activity comes to foreground. With this fix, the adapter is set to null in onStop.
All in all, the adapter handling may not be the best, but will be replaced by Compose anyway..
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
when being offline and no messages are set -> hide shimmer
when messages are received -> hide shimmer and "offlineNoMessages"-info
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>