mirror of
https://github.com/nextcloud/talk-android
synced 2025-07-22 12:15:00 +01:00
Fix updates to items + various improvements
Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
parent
2681e6ef24
commit
9d2a5d4f2c
app/src/main
java/com/nextcloud/talk
adapters/items
newarch
features/conversationsList
local/dao
res/values
@ -50,6 +50,7 @@ import eu.davidea.flexibleadapter.items.IFlexible;
|
|||||||
import eu.davidea.flexibleadapter.utils.FlexibleUtils;
|
import eu.davidea.flexibleadapter.utils.FlexibleUtils;
|
||||||
import eu.davidea.viewholders.FlexibleViewHolder;
|
import eu.davidea.viewholders.FlexibleViewHolder;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
public class ConversationItem
|
public class ConversationItem
|
||||||
@ -71,7 +72,23 @@ public class ConversationItem
|
|||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (o instanceof ConversationItem) {
|
if (o instanceof ConversationItem) {
|
||||||
ConversationItem inItem = (ConversationItem) o;
|
ConversationItem inItem = (ConversationItem) o;
|
||||||
return conversation.getConversationId().equals(inItem.getModel().getConversationId());
|
Conversation comparedConversation = inItem.conversation;
|
||||||
|
return (conversation.getConversationId().equals(comparedConversation.getConversationId())
|
||||||
|
&& Objects.equals(conversation.getToken(), comparedConversation.getToken())
|
||||||
|
&& Objects.equals(conversation.getName(), comparedConversation.getName())
|
||||||
|
&& Objects.equals(conversation.getDisplayName(), comparedConversation.getDisplayName())
|
||||||
|
&& Objects.equals(conversation.getType(), comparedConversation.getType())
|
||||||
|
&& Objects.equals(conversation.getLastMessage(), comparedConversation.getLastMessage())
|
||||||
|
&& Objects.equals(conversation.getFavorite(), comparedConversation.getFavorite())
|
||||||
|
&& Objects.equals(conversation.getHasPassword(), comparedConversation.getHasPassword())
|
||||||
|
&& Objects.equals(conversation.getUnreadMessages(),
|
||||||
|
comparedConversation.getUnreadMessages())
|
||||||
|
&& Objects.equals(conversation.getUnreadMention(),
|
||||||
|
comparedConversation.getUnreadMention())
|
||||||
|
&& Objects.equals(conversation.getObjectType(), comparedConversation.getObjectType())
|
||||||
|
&& Objects.equals(conversation.getChanging(), comparedConversation.getChanging())
|
||||||
|
&& Objects.equals(userEntity.getId(), inItem.userEntity.getId())
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -82,7 +99,8 @@ public class ConversationItem
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return conversation.hashCode();
|
return Objects.hash(conversation.getConversationId(), conversation.getToken(),
|
||||||
|
userEntity.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -86,7 +86,7 @@ class ConversationsListView : BaseView(), OnQueryTextListener,
|
|||||||
lateinit var viewModel: ConversationsListViewModel
|
lateinit var viewModel: ConversationsListViewModel
|
||||||
val factory: ConversationListViewModelFactory by inject()
|
val factory: ConversationListViewModelFactory by inject()
|
||||||
|
|
||||||
private val recyclerViewAdapter = FlexibleAdapter(mutableListOf())
|
private val recyclerViewAdapter = FlexibleAdapter(mutableListOf(), null, true)
|
||||||
|
|
||||||
private var searchItem: MenuItem? = null
|
private var searchItem: MenuItem? = null
|
||||||
private var settingsItem: MenuItem? = null
|
private var settingsItem: MenuItem? = null
|
||||||
@ -246,7 +246,7 @@ class ConversationsListView : BaseView(), OnQueryTextListener,
|
|||||||
})
|
})
|
||||||
|
|
||||||
conversationsLiveData.observe(this@ConversationsListView, Observer {
|
conversationsLiveData.observe(this@ConversationsListView, Observer {
|
||||||
if (it.size == 0) {
|
if (it.isEmpty()) {
|
||||||
viewState.value = LOADED_EMPTY
|
viewState.value = LOADED_EMPTY
|
||||||
} else {
|
} else {
|
||||||
viewState.value = LOADED
|
viewState.value = LOADED
|
||||||
@ -270,7 +270,7 @@ class ConversationsListView : BaseView(), OnQueryTextListener,
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
recyclerViewAdapter.updateDataSet(newConversations as List<IFlexible<ViewHolder>>?)
|
recyclerViewAdapter.updateDataSet(newConversations as List<IFlexible<ViewHolder>>?, false)
|
||||||
})
|
})
|
||||||
|
|
||||||
searchQuery.observe(this@ConversationsListView, Observer {
|
searchQuery.observe(this@ConversationsListView, Observer {
|
||||||
@ -320,16 +320,17 @@ class ConversationsListView : BaseView(), OnQueryTextListener,
|
|||||||
override fun onAttach(view: View) {
|
override fun onAttach(view: View) {
|
||||||
super.onAttach(view)
|
super.onAttach(view)
|
||||||
view.recyclerView.initRecyclerView(
|
view.recyclerView.initRecyclerView(
|
||||||
SmoothScrollLinearLayoutManager(view.context), recyclerViewAdapter
|
SmoothScrollLinearLayoutManager(view.context), recyclerViewAdapter, false
|
||||||
)
|
)
|
||||||
|
|
||||||
view.swipeRefreshLayoutView.setOnRefreshListener { viewModel.loadConversations() }
|
|
||||||
view.swipeRefreshLayoutView.setColorSchemeResources(R.color.colorPrimary)
|
|
||||||
|
|
||||||
recyclerViewAdapter.fastScroller = view.fast_scroller
|
recyclerViewAdapter.fastScroller = view.fast_scroller
|
||||||
recyclerViewAdapter.mItemClickListener = this
|
recyclerViewAdapter.mItemClickListener = this
|
||||||
recyclerViewAdapter.mItemLongClickListener = this
|
recyclerViewAdapter.mItemLongClickListener = this
|
||||||
|
|
||||||
|
view.swipeRefreshLayoutView.setOnRefreshListener { viewModel.loadConversations() }
|
||||||
|
view.swipeRefreshLayoutView.setColorSchemeResources(R.color.colorPrimary)
|
||||||
|
|
||||||
|
|
||||||
view.fast_scroller.setBubbleTextCreator { position ->
|
view.fast_scroller.setBubbleTextCreator { position ->
|
||||||
var displayName =
|
var displayName =
|
||||||
(recyclerViewAdapter.getItem(position) as ConversationItem).model.displayName
|
(recyclerViewAdapter.getItem(position) as ConversationItem).model.displayName
|
||||||
|
@ -103,6 +103,9 @@ class ConversationsListViewModel constructor(
|
|||||||
|
|
||||||
override fun onError(errorModel: ErrorModel?) {
|
override fun onError(errorModel: ErrorModel?) {
|
||||||
messageData = errorModel?.getErrorMessage()
|
messageData = errorModel?.getErrorMessage()
|
||||||
|
if (errorModel?.code == 400) {
|
||||||
|
// couldn't leave because we're last moderator
|
||||||
|
}
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
setConversationUpdateStatus(conversation, false)
|
setConversationUpdateStatus(conversation, false)
|
||||||
}
|
}
|
||||||
|
@ -50,8 +50,7 @@ abstract class ConversationsDao {
|
|||||||
abstract suspend fun saveConversations(vararg conversations: ConversationEntity)
|
abstract suspend fun saveConversations(vararg conversations: ConversationEntity)
|
||||||
|
|
||||||
@Query(
|
@Query(
|
||||||
"UPDATE conversations SET changing = :changing WHERE user = :userId AND " +
|
"UPDATE conversations SET changing = :changing WHERE user = :userId AND conversation_id = :conversationId"
|
||||||
"'conversation_id' = :conversationId"
|
|
||||||
)
|
)
|
||||||
abstract suspend fun updateChangingValueForConversation(
|
abstract suspend fun updateChangingValueForConversation(
|
||||||
userId: Long,
|
userId: Long,
|
||||||
@ -60,7 +59,7 @@ abstract class ConversationsDao {
|
|||||||
)
|
)
|
||||||
|
|
||||||
@Query(
|
@Query(
|
||||||
"UPDATE conversations SET favorite = :favorite, changing = 0 WHERE user = :userId AND 'conversation_id' = :conversationId"
|
"UPDATE conversations SET favorite = :favorite, changing = 0 WHERE user = :userId AND conversation_id = :conversationId"
|
||||||
)
|
)
|
||||||
abstract suspend fun updateFavoriteValueForConversation(
|
abstract suspend fun updateFavoriteValueForConversation(
|
||||||
userId: Long,
|
userId: Long,
|
||||||
@ -68,7 +67,7 @@ abstract class ConversationsDao {
|
|||||||
favorite: Boolean
|
favorite: Boolean
|
||||||
)
|
)
|
||||||
|
|
||||||
@Query("DELETE FROM conversations WHERE user = :userId AND 'conversation_id' = :conversationId")
|
@Query("DELETE FROM conversations WHERE user = :userId AND conversation_id = :conversationId")
|
||||||
abstract suspend fun deleteConversation(
|
abstract suspend fun deleteConversation(
|
||||||
userId: Long,
|
userId: Long,
|
||||||
conversationId: String
|
conversationId: String
|
||||||
@ -77,7 +76,7 @@ abstract class ConversationsDao {
|
|||||||
@Delete
|
@Delete
|
||||||
abstract suspend fun deleteConversations(vararg conversation: ConversationEntity)
|
abstract suspend fun deleteConversations(vararg conversation: ConversationEntity)
|
||||||
|
|
||||||
@Query("DELETE FROM conversations WHERE user = :userId AND 'modified_at' < :timestamp")
|
@Query("DELETE FROM conversations WHERE user = :userId AND modified_at < :timestamp")
|
||||||
abstract suspend fun deleteConversationsForUserWithTimestamp(
|
abstract suspend fun deleteConversationsForUserWithTimestamp(
|
||||||
userId: Long,
|
userId: Long,
|
||||||
timestamp: Long
|
timestamp: Long
|
||||||
|
@ -317,5 +317,7 @@
|
|||||||
|
|
||||||
<string name="nc_general_settings">General</string>
|
<string name="nc_general_settings">General</string>
|
||||||
<string name="nc_allow_guests">Allow guests</string>
|
<string name="nc_allow_guests">Allow guests</string>
|
||||||
|
<string name="nc_last_moderator_title">Could not leave conversation</string>
|
||||||
|
<string name="nc_last_moderator">You need to promote a new moderator before you can leave %1$s.</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
Loading…
Reference in New Issue
Block a user