Merge pull request #2473 from nextcloud/chore/noid/housekeepingOne

Code scanner warnings housekeeping - part one
This commit is contained in:
Tim Krüger 2022-10-07 09:25:54 +02:00 committed by GitHub
commit 89607b8776
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 11 deletions

View File

@ -784,12 +784,7 @@ class ConversationsListController(bundle: Bundle) :
for (flexItem in conversationItems) { for (flexItem in conversationItems) {
val conversation: Conversation = (flexItem as ConversationItem).model val conversation: Conversation = (flexItem as ConversationItem).model
val position = adapter!!.getGlobalPositionOf(flexItem) val position = adapter!!.getGlobalPositionOf(flexItem)
if (( if (hasUnreadItems(conversation) && position > lastVisibleItem) {
conversation.unreadMention ||
conversation.unreadMessages > 0 &&
conversation.type === Conversation.ConversationType.ROOM_TYPE_ONE_TO_ONE_CALL
) && position > lastVisibleItem
) {
nextUnreadConversationScrollPosition = position nextUnreadConversationScrollPosition = position
if (!binding.newMentionPopupBubble.isShown) { if (!binding.newMentionPopupBubble.isShown) {
binding.newMentionPopupBubble.show() 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() { private fun showNewConversationsScreen() {
val bundle = Bundle() val bundle = Bundle()
bundle.putBoolean(KEY_NEW_CONVERSATION, true) bundle.putBoolean(KEY_NEW_CONVERSATION, true)
@ -1203,8 +1203,7 @@ class ConversationsListController(bundle: Bundle) :
conversationMenuBundle = bundle conversationMenuBundle = bundle
if (activity != null && if (activity != null &&
conversationMenuBundle != null && conversationMenuBundle != null &&
currentUser != null && isInternalUserEqualsCurrentUser(currentUser, conversationMenuBundle)
conversationMenuBundle!!.getLong(KEY_INTERNAL_USER_ID) == currentUser!!.id
) { ) {
val conversation = Parcels.unwrap<Conversation>(conversationMenuBundle!!.getParcelable(KEY_ROOM)) val conversation = Parcels.unwrap<Conversation>(conversationMenuBundle!!.getParcelable(KEY_ROOM))
if (conversation != null) { 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() { private fun showUnauthorizedDialog() {
if (activity != null) { if (activity != null) {
val dialogBuilder = MaterialAlertDialogBuilder(binding.floatingActionButton.context) val dialogBuilder = MaterialAlertDialogBuilder(binding.floatingActionButton.context)

View File

@ -183,7 +183,7 @@ public class NotificationWorker extends Worker {
} }
} }
muteCall = !(conversation.getNotificationCalls() == 1); muteCall = conversation.getNotificationCalls() != 1;
} }
@Override @Override

View File

@ -283,7 +283,7 @@ public class DisplayUtils {
public static Drawable getTintedDrawable(Resources res, @DrawableRes int drawableResId, @ColorRes int colorResId) { public static Drawable getTintedDrawable(Resources res, @DrawableRes int drawableResId, @ColorRes int colorResId) {
Drawable drawable = ResourcesCompat.getDrawable(res, drawableResId, null); Drawable drawable = ResourcesCompat.getDrawable(res, drawableResId, null);
;
int color = res.getColor(colorResId); int color = res.getColor(colorResId);
if (drawable != null) { if (drawable != null) {
drawable.setTint(color); drawable.setTint(color);

View File

@ -1,5 +1,5 @@
build: build:
maxIssues: 94 maxIssues: 80
weights: weights:
# complexity: 2 # complexity: 2
# LongParameterList: 1 # LongParameterList: 1