From 5399723ea729f8d36cc603f15793d116034a3ad5 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 5 May 2021 17:29:26 +0200 Subject: [PATCH 1/4] Deprecate props and remove already whats not used anymore Signed-off-by: Joas Schilling --- .../json/conversations/Conversation.java | 50 +------------------ 1 file changed, 2 insertions(+), 48 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/models/json/conversations/Conversation.java b/app/src/main/java/com/nextcloud/talk/models/json/conversations/Conversation.java index befa1799a..c034bdaaf 100644 --- a/app/src/main/java/com/nextcloud/talk/models/json/conversations/Conversation.java +++ b/app/src/main/java/com/nextcloud/talk/models/json/conversations/Conversation.java @@ -52,14 +52,9 @@ public class Conversation { public String displayName; @JsonField(name = "type", typeConverter = EnumRoomTypeConverter.class) public ConversationType type; - @JsonField(name = "count") - public long count; @JsonField(name = "lastPing") public long lastPing; - @JsonField(name = "numGuests") - public long numberOfGuests; - @JsonField(name = "guestList") - public HashMap> guestList; + @Deprecated @JsonField(name = "participants") public HashMap> participants; @JsonField(name = "participantType", typeConverter = EnumParticipantTypeConverter.class) @@ -167,22 +162,10 @@ public class Conversation { return this.type; } - public long getCount() { - return this.count; - } - public long getLastPing() { return this.lastPing; } - public long getNumberOfGuests() { - return this.numberOfGuests; - } - - public HashMap> getGuestList() { - return this.guestList; - } - public HashMap> getParticipants() { return this.participants; } @@ -271,22 +254,10 @@ public class Conversation { this.type = type; } - public void setCount(long count) { - this.count = count; - } - public void setLastPing(long lastPing) { this.lastPing = lastPing; } - public void setNumberOfGuests(long numberOfGuests) { - this.numberOfGuests = numberOfGuests; - } - - public void setGuestList(HashMap> guestList) { - this.guestList = guestList; - } - public void setParticipants(HashMap> participants) { this.participants = participants; } @@ -391,20 +362,9 @@ public class Conversation { if (this$type == null ? other$type != null : !this$type.equals(other$type)) { return false; } - if (this.getCount() != other.getCount()) { - return false; - } if (this.getLastPing() != other.getLastPing()) { return false; } - if (this.getNumberOfGuests() != other.getNumberOfGuests()) { - return false; - } - final Object this$guestList = this.getGuestList(); - final Object other$guestList = other.getGuestList(); - if (this$guestList == null ? other$guestList != null : !this$guestList.equals(other$guestList)) { - return false; - } final Object this$participants = this.getParticipants(); final Object other$participants = other.getParticipants(); if (this$participants == null ? other$participants != null : !this$participants.equals(other$participants)) { @@ -494,14 +454,8 @@ public class Conversation { result = result * PRIME + ($displayName == null ? 43 : $displayName.hashCode()); final Object $type = this.getType(); result = result * PRIME + ($type == null ? 43 : $type.hashCode()); - final long $count = this.getCount(); - result = result * PRIME + (int) ($count >>> 32 ^ $count); final long $lastPing = this.getLastPing(); result = result * PRIME + (int) ($lastPing >>> 32 ^ $lastPing); - final long $numberOfGuests = this.getNumberOfGuests(); - result = result * PRIME + (int) ($numberOfGuests >>> 32 ^ $numberOfGuests); - final Object $guestList = this.getGuestList(); - result = result * PRIME + ($guestList == null ? 43 : $guestList.hashCode()); final Object $participants = this.getParticipants(); result = result * PRIME + ($participants == null ? 43 : $participants.hashCode()); final Object $participantType = this.getParticipantType(); @@ -534,7 +488,7 @@ public class Conversation { } public String toString() { - return "Conversation(roomId=" + this.getRoomId() + ", token=" + this.getToken() + ", name=" + this.getName() + ", displayName=" + this.getDisplayName() + ", type=" + this.getType() + ", count=" + this.getCount() + ", lastPing=" + this.getLastPing() + ", numberOfGuests=" + this.getNumberOfGuests() + ", guestList=" + this.getGuestList() + ", participants=" + this.getParticipants() + ", participantType=" + this.getParticipantType() + ", hasPassword=" + this.isHasPassword() + ", sessionId=" + this.getSessionId() + ", password=" + this.getPassword() + ", isFavorite=" + this.isFavorite() + ", lastActivity=" + this.getLastActivity() + ", unreadMessages=" + this.getUnreadMessages() + ", unreadMention=" + this.isUnreadMention() + ", lastMessage=" + this.getLastMessage() + ", objectType=" + this.getObjectType() + ", notificationLevel=" + this.getNotificationLevel() + ", conversationReadOnlyState=" + this.getConversationReadOnlyState() + ", lobbyState=" + this.getLobbyState() + ", lobbyTimer=" + this.getLobbyTimer() + ", lastReadMessage=" + this.getLastReadMessage() + ", callFlag=" + this.getCallFlag() + ")"; + return "Conversation(roomId=" + this.getRoomId() + ", token=" + this.getToken() + ", name=" + this.getName() + ", displayName=" + this.getDisplayName() + ", type=" + this.getType() + ", lastPing=" + this.getLastPing() + ", participants=" + this.getParticipants() + ", participantType=" + this.getParticipantType() + ", hasPassword=" + this.isHasPassword() + ", sessionId=" + this.getSessionId() + ", password=" + this.getPassword() + ", isFavorite=" + this.isFavorite() + ", lastActivity=" + this.getLastActivity() + ", unreadMessages=" + this.getUnreadMessages() + ", unreadMention=" + this.isUnreadMention() + ", lastMessage=" + this.getLastMessage() + ", objectType=" + this.getObjectType() + ", notificationLevel=" + this.getNotificationLevel() + ", conversationReadOnlyState=" + this.getConversationReadOnlyState() + ", lobbyState=" + this.getLobbyState() + ", lobbyTimer=" + this.getLobbyTimer() + ", lastReadMessage=" + this.getLastReadMessage() + ", callFlag=" + this.getCallFlag() + ")"; } public enum NotificationLevel { From f32c0867e5b8662bfd344b3907fcfa43c6128c55 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 6 May 2021 08:24:04 +0200 Subject: [PATCH 2/4] Remove participants usage outside the conversation usage Signed-off-by: Joas Schilling --- .../controllers/ConversationInfoController.kt | 2 +- .../ConversationsListController.java | 2 +- .../json/conversations/Conversation.java | 38 +++++++------------ 3 files changed, 15 insertions(+), 27 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/controllers/ConversationInfoController.kt b/app/src/main/java/com/nextcloud/talk/controllers/ConversationInfoController.kt index bb774eab3..27fba851e 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/ConversationInfoController.kt +++ b/app/src/main/java/com/nextcloud/talk/controllers/ConversationInfoController.kt @@ -362,7 +362,7 @@ class ConversationInfoController(args: Bundle) : BaseController(args), FlexibleA ) .setPositiveButtonColor(context!!.resources.getColor(R.color.nc_darkRed)) .setTitle(R.string.nc_delete_call) - .setMessage(conversation!!.deleteWarningMessage) + .setMessage(R.string.nc_delete_conversation_more) .setPositiveButton(R.string.nc_delete) { deleteConversation() } .setNegativeButton(R.string.nc_cancel, null) .setInstanceStateHandler(ID_DELETE_CONVERSATION_DIALOG, saveStateHandler!!) diff --git a/app/src/main/java/com/nextcloud/talk/controllers/ConversationsListController.java b/app/src/main/java/com/nextcloud/talk/controllers/ConversationsListController.java index 0fff10672..8fc10a198 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/ConversationsListController.java +++ b/app/src/main/java/com/nextcloud/talk/controllers/ConversationsListController.java @@ -802,7 +802,7 @@ public class ConversationsListController extends BaseController implements Searc R.drawable.ic_delete_black_24dp, R.color.bg_default)) .setPositiveButtonColor(context.getResources().getColor(R.color.nc_darkRed)) .setTitle(R.string.nc_delete_call) - .setMessage(conversation.getDeleteWarningMessage()) + .setMessage(R.string.nc_delete_conversation_more) .setPositiveButton(R.string.nc_delete, new View.OnClickListener() { @Override public void onClick(View v) { diff --git a/app/src/main/java/com/nextcloud/talk/models/json/conversations/Conversation.java b/app/src/main/java/com/nextcloud/talk/models/json/conversations/Conversation.java index c034bdaaf..882a298c2 100644 --- a/app/src/main/java/com/nextcloud/talk/models/json/conversations/Conversation.java +++ b/app/src/main/java/com/nextcloud/talk/models/json/conversations/Conversation.java @@ -20,12 +20,8 @@ */ package com.nextcloud.talk.models.json.conversations; -import android.content.res.Resources; - import com.bluelinelabs.logansquare.annotation.JsonField; import com.bluelinelabs.logansquare.annotation.JsonObject; -import com.nextcloud.talk.R; -import com.nextcloud.talk.application.NextcloudTalkApplication; import com.nextcloud.talk.models.database.UserEntity; import com.nextcloud.talk.models.json.chat.ChatMessage; import com.nextcloud.talk.models.json.converters.EnumLobbyStateConverter; @@ -88,6 +84,8 @@ public class Conversation { public int lastReadMessage; @JsonField(name = "callFlag") public int callFlag; + @JsonField(name = "canLeaveConversation") + public Boolean canLeaveConversation; public boolean isPublic() { return (ConversationType.ROOM_PUBLIC_CALL.equals(type)); @@ -126,20 +124,13 @@ public class Conversation { } public boolean canLeave(UserEntity conversationUser) { - return !canModerate(conversationUser) || - (getType() != ConversationType.ROOM_TYPE_ONE_TO_ONE_CALL && getParticipants().size() > 1); - } - - public String getDeleteWarningMessage() { - Resources resources = NextcloudTalkApplication.Companion.getSharedApplication().getResources(); - if (getType() == ConversationType.ROOM_TYPE_ONE_TO_ONE_CALL) { - return String.format(resources.getString(R.string.nc_delete_conversation_one2one), - getDisplayName()); - } else if (getParticipants().size() > 1) { - return resources.getString(R.string.nc_delete_conversation_more); + if (canLeaveConversation != null) { + // Available since APIv2 + return canLeaveConversation; } - - return resources.getString(R.string.nc_delete_conversation_default); + // Fallback for APIv1 + return !canModerate(conversationUser) || + (getType() != ConversationType.ROOM_TYPE_ONE_TO_ONE_CALL && this.participants.size() > 1); } public String getRoomId() { @@ -166,10 +157,6 @@ public class Conversation { return this.lastPing; } - public HashMap> getParticipants() { - return this.participants; - } - public Participant.ParticipantType getParticipantType() { return this.participantType; } @@ -258,6 +245,7 @@ public class Conversation { this.lastPing = lastPing; } + @Deprecated public void setParticipants(HashMap> participants) { this.participants = participants; } @@ -365,8 +353,8 @@ public class Conversation { if (this.getLastPing() != other.getLastPing()) { return false; } - final Object this$participants = this.getParticipants(); - final Object other$participants = other.getParticipants(); + final Object this$participants = this.participants; + final Object other$participants = other.participants; if (this$participants == null ? other$participants != null : !this$participants.equals(other$participants)) { return false; } @@ -456,7 +444,7 @@ public class Conversation { result = result * PRIME + ($type == null ? 43 : $type.hashCode()); final long $lastPing = this.getLastPing(); result = result * PRIME + (int) ($lastPing >>> 32 ^ $lastPing); - final Object $participants = this.getParticipants(); + final Object $participants = this.participants; result = result * PRIME + ($participants == null ? 43 : $participants.hashCode()); final Object $participantType = this.getParticipantType(); result = result * PRIME + ($participantType == null ? 43 : $participantType.hashCode()); @@ -488,7 +476,7 @@ public class Conversation { } public String toString() { - return "Conversation(roomId=" + this.getRoomId() + ", token=" + this.getToken() + ", name=" + this.getName() + ", displayName=" + this.getDisplayName() + ", type=" + this.getType() + ", lastPing=" + this.getLastPing() + ", participants=" + this.getParticipants() + ", participantType=" + this.getParticipantType() + ", hasPassword=" + this.isHasPassword() + ", sessionId=" + this.getSessionId() + ", password=" + this.getPassword() + ", isFavorite=" + this.isFavorite() + ", lastActivity=" + this.getLastActivity() + ", unreadMessages=" + this.getUnreadMessages() + ", unreadMention=" + this.isUnreadMention() + ", lastMessage=" + this.getLastMessage() + ", objectType=" + this.getObjectType() + ", notificationLevel=" + this.getNotificationLevel() + ", conversationReadOnlyState=" + this.getConversationReadOnlyState() + ", lobbyState=" + this.getLobbyState() + ", lobbyTimer=" + this.getLobbyTimer() + ", lastReadMessage=" + this.getLastReadMessage() + ", callFlag=" + this.getCallFlag() + ")"; + return "Conversation(roomId=" + this.getRoomId() + ", token=" + this.getToken() + ", name=" + this.getName() + ", displayName=" + this.getDisplayName() + ", type=" + this.getType() + ", lastPing=" + this.getLastPing() + ", participants=" + this.participants + ", participantType=" + this.getParticipantType() + ", hasPassword=" + this.isHasPassword() + ", sessionId=" + this.getSessionId() + ", password=" + this.getPassword() + ", isFavorite=" + this.isFavorite() + ", lastActivity=" + this.getLastActivity() + ", unreadMessages=" + this.getUnreadMessages() + ", unreadMention=" + this.isUnreadMention() + ", lastMessage=" + this.getLastMessage() + ", objectType=" + this.getObjectType() + ", notificationLevel=" + this.getNotificationLevel() + ", conversationReadOnlyState=" + this.getConversationReadOnlyState() + ", lobbyState=" + this.getLobbyState() + ", lobbyTimer=" + this.getLobbyTimer() + ", lastReadMessage=" + this.getLastReadMessage() + ", callFlag=" + this.getCallFlag() + ")"; } public enum NotificationLevel { From 22b68daaa4d69c75ffde7ee1bb22e82beb66e9d8 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 7 May 2021 16:10:05 +0200 Subject: [PATCH 3/4] Remove unused translation strings Signed-off-by: Joas Schilling --- app/src/main/res/values/strings.xml | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 21eafdfdf..5848fbf86 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -179,8 +179,6 @@ Make conversation private Delete conversation Delete - Please confirm your intent to remove the conversation. - If you delete the conversation, it will also be deleted for %1$s. If you delete the conversation, it will also be deleted for all other participants. New conversation From 4ca07bd264679e8dfd99e121eb6d5d5c6943386b Mon Sep 17 00:00:00 2001 From: drone Date: Fri, 7 May 2021 14:20:15 +0000 Subject: [PATCH 4/4] Drone: update FindBugs results to reflect reduced error/warning count [skip ci] Signed-off-by: drone --- scripts/analysis/findbugs-results.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/analysis/findbugs-results.txt b/scripts/analysis/findbugs-results.txt index 9301519f5..1e27e32d4 100644 --- a/scripts/analysis/findbugs-results.txt +++ b/scripts/analysis/findbugs-results.txt @@ -1 +1 @@ -483 \ No newline at end of file +478 \ No newline at end of file