Browse Source

fix klint warnings

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
Marcel Hibbe 3 years ago
parent
commit
be29459955

+ 5 - 4
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()

+ 21 - 1
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 <dev@mhibbe.de>
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+
 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
     }
-}
+}

+ 28 - 9
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 <dev@mhibbe.de>
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+
 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
     }
-}
+}