From 0a70567452a34dd2aebdc968e9179f7a36b34274 Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Thu, 6 Oct 2022 16:54:27 +0200 Subject: [PATCH 1/4] PMD: Use opposite operator instead of the logic complement operator. Signed-off-by: Andy Scherzinger --- .../main/java/com/nextcloud/talk/jobs/NotificationWorker.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/com/nextcloud/talk/jobs/NotificationWorker.java b/app/src/main/java/com/nextcloud/talk/jobs/NotificationWorker.java index efcb75dc7..e946511de 100644 --- a/app/src/main/java/com/nextcloud/talk/jobs/NotificationWorker.java +++ b/app/src/main/java/com/nextcloud/talk/jobs/NotificationWorker.java @@ -183,7 +183,7 @@ public class NotificationWorker extends Worker { } } - muteCall = !(conversation.getNotificationCalls() == 1); + muteCall = conversation.getNotificationCalls() != 1; } @Override From 9bd51ce21b3f58eafa41bc643f982673e4d2f1b6 Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Thu, 6 Oct 2022 16:55:38 +0200 Subject: [PATCH 2/4] PMD: An empty statement (semicolon) not part of a loop Signed-off-by: Andy Scherzinger --- app/src/main/java/com/nextcloud/talk/utils/DisplayUtils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/com/nextcloud/talk/utils/DisplayUtils.java b/app/src/main/java/com/nextcloud/talk/utils/DisplayUtils.java index 3f3d2ed9b..24f8b2e11 100644 --- a/app/src/main/java/com/nextcloud/talk/utils/DisplayUtils.java +++ b/app/src/main/java/com/nextcloud/talk/utils/DisplayUtils.java @@ -283,7 +283,7 @@ public class DisplayUtils { public static Drawable getTintedDrawable(Resources res, @DrawableRes int drawableResId, @ColorRes int colorResId) { Drawable drawable = ResourcesCompat.getDrawable(res, drawableResId, null); - ; + int color = res.getColor(colorResId); if (drawable != null) { drawable.setTint(color); From 89ec37d24df5f71ff3fb87f94f785d214fafc7a0 Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Thu, 6 Oct 2022 18:00:52 +0200 Subject: [PATCH 3/4] simplify condition complexity Signed-off-by: Andy Scherzinger --- .../ConversationsListController.kt | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/controllers/ConversationsListController.kt b/app/src/main/java/com/nextcloud/talk/controllers/ConversationsListController.kt index 84f671a14..3c9098054 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/ConversationsListController.kt +++ b/app/src/main/java/com/nextcloud/talk/controllers/ConversationsListController.kt @@ -784,12 +784,7 @@ class ConversationsListController(bundle: Bundle) : for (flexItem in conversationItems) { val conversation: Conversation = (flexItem as ConversationItem).model val position = adapter!!.getGlobalPositionOf(flexItem) - if (( - conversation.unreadMention || - conversation.unreadMessages > 0 && - conversation.type === Conversation.ConversationType.ROOM_TYPE_ONE_TO_ONE_CALL - ) && position > lastVisibleItem - ) { + if (hasUnreadItems(conversation) && position > lastVisibleItem) { nextUnreadConversationScrollPosition = position if (!binding.newMentionPopupBubble.isShown) { binding.newMentionPopupBubble.show() @@ -809,6 +804,11 @@ class ConversationsListController(bundle: Bundle) : } } + private fun hasUnreadItems(conversation: Conversation) = + conversation.unreadMention || + conversation.unreadMessages > 0 && + conversation.type === Conversation.ConversationType.ROOM_TYPE_ONE_TO_ONE_CALL + private fun showNewConversationsScreen() { val bundle = Bundle() bundle.putBoolean(KEY_NEW_CONVERSATION, true) @@ -1203,8 +1203,7 @@ class ConversationsListController(bundle: Bundle) : conversationMenuBundle = bundle if (activity != null && conversationMenuBundle != null && - currentUser != null && - conversationMenuBundle!!.getLong(KEY_INTERNAL_USER_ID) == currentUser!!.id + isInternalUserEqualsCurrentUser(currentUser, conversationMenuBundle) ) { val conversation = Parcels.unwrap(conversationMenuBundle!!.getParcelable(KEY_ROOM)) if (conversation != null) { @@ -1239,6 +1238,10 @@ class ConversationsListController(bundle: Bundle) : } } + private fun isInternalUserEqualsCurrentUser(currentUser: User?, conversationMenuBundle: Bundle?): Boolean { + return currentUser != null && conversationMenuBundle!!.getLong(KEY_INTERNAL_USER_ID) == currentUser.id + } + private fun showUnauthorizedDialog() { if (activity != null) { val dialogBuilder = MaterialAlertDialogBuilder(binding.floatingActionButton.context) From 47da6226f6247e6fa6671a64d8a6a5fc8f4b3a04 Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Thu, 6 Oct 2022 19:49:52 +0200 Subject: [PATCH 4/4] reduce detekt max issues count Signed-off-by: Andy Scherzinger --- detekt.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/detekt.yml b/detekt.yml index e8e167c4b..dbdbbedcd 100644 --- a/detekt.yml +++ b/detekt.yml @@ -1,5 +1,5 @@ build: - maxIssues: 94 + maxIssues: 80 weights: # complexity: 2 # LongParameterList: 1