From be29459955233a51f5202b0e6971cc7746b695d0 Mon Sep 17 00:00:00 2001 From: Marcel Hibbe Date: Tue, 10 May 2022 18:21:07 +0200 Subject: [PATCH] fix klint warnings Signed-off-by: Marcel Hibbe --- .../talk/controllers/ChatController.kt | 9 +++-- .../talk/utils/AttendeePermissionsUtil.kt | 22 ++++++++++- .../talk/utils/AttendeePermissionsUtilTest.kt | 37 ++++++++++++++----- 3 files changed, 54 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/controllers/ChatController.kt b/app/src/main/java/com/nextcloud/talk/controllers/ChatController.kt index 2d67c5b12..537de9726 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/ChatController.kt +++ b/app/src/main/java/com/nextcloud/talk/controllers/ChatController.kt @@ -1177,9 +1177,9 @@ class ChatController(args: Bundle) : private fun checkShowMessageInputView() { if (isAlive()) { - if (isReadOnlyConversation() - || shouldShowLobby() - || !hasChatPermission + if (isReadOnlyConversation() || + shouldShowLobby() || + !hasChatPermission ) { binding.messageInputView.visibility = View.GONE } else { @@ -2534,7 +2534,8 @@ class ChatController(args: Bundle) : fun deleteMessage(message: IMessage?) { if (!hasChatPermission) { Log.e( - TAG, "Deletion of message is skipped because of restrictions by permissions. " + + TAG, + "Deletion of message is skipped because of restrictions by permissions. " + "This method should not have been called!" ) Toast.makeText(context, R.string.nc_common_error_sorry, Toast.LENGTH_LONG).show() diff --git a/app/src/main/java/com/nextcloud/talk/utils/AttendeePermissionsUtil.kt b/app/src/main/java/com/nextcloud/talk/utils/AttendeePermissionsUtil.kt index b7b431deb..e1e291b6f 100644 --- a/app/src/main/java/com/nextcloud/talk/utils/AttendeePermissionsUtil.kt +++ b/app/src/main/java/com/nextcloud/talk/utils/AttendeePermissionsUtil.kt @@ -1,3 +1,23 @@ +/* + * Nextcloud Talk application + * + * @author Marcel Hibbe + * Copyright (C) 2022 Marcel Hibbe + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package com.nextcloud.talk.utils import com.nextcloud.talk.models.database.CapabilitiesUtil @@ -49,4 +69,4 @@ class AttendeePermissionsUtil(flag: Int) { const val PUBLISH_SCREEN = 64 const val CHAT = 128 } -} \ No newline at end of file +} diff --git a/app/src/test/java/com/nextcloud/talk/utils/AttendeePermissionsUtilTest.kt b/app/src/test/java/com/nextcloud/talk/utils/AttendeePermissionsUtilTest.kt index bd9d29aa7..6ce41bd3c 100644 --- a/app/src/test/java/com/nextcloud/talk/utils/AttendeePermissionsUtilTest.kt +++ b/app/src/test/java/com/nextcloud/talk/utils/AttendeePermissionsUtilTest.kt @@ -1,3 +1,23 @@ +/* + * Nextcloud Talk application + * + * @author Marcel Hibbe + * Copyright (C) 2022 Marcel Hibbe + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package com.nextcloud.talk.utils import junit.framework.TestCase @@ -7,22 +27,21 @@ class AttendeePermissionsUtilTest : TestCase() { @Test fun test_areFlagsSet() { - val attendeePermissionsUtil = AttendeePermissionsUtil( - AttendeePermissionsUtil.PUBLISH_SCREEN - or AttendeePermissionsUtil.JOIN_CALL - or AttendeePermissionsUtil.DEFAULT) + val attendeePermissionsUtil = + AttendeePermissionsUtil( + AttendeePermissionsUtil.PUBLISH_SCREEN or + AttendeePermissionsUtil.JOIN_CALL or + AttendeePermissionsUtil.DEFAULT + ) assert(attendeePermissionsUtil.canPublishScreen) assert(attendeePermissionsUtil.canJoinCall) - assert(attendeePermissionsUtil.isDefault) // if AttendeePermissionsUtil.DEFAULT is not set with setFlags and - // checked with assertFalse, the logic fails somehow?! + assert(attendeePermissionsUtil.isDefault) assertFalse(attendeePermissionsUtil.isCustom) assertFalse(attendeePermissionsUtil.canStartCall) assertFalse(attendeePermissionsUtil.canIgnoreLobby) assertFalse(attendeePermissionsUtil.canPublishAudio) assertFalse(attendeePermissionsUtil.canPublishVideo) - - // hasChatPermission() is not possible to test because userEntity is necessary } -} \ No newline at end of file +}