From 640cc82f63c9a4e74ad84de1a547192ca9dae5be Mon Sep 17 00:00:00 2001 From: sowjanyakch Date: Mon, 18 Nov 2024 18:20:58 +0100 Subject: [PATCH] lint warnings Signed-off-by: sowjanyakch --- .../talk/ui/dialog/ConversationsListBottomDialog.kt | 4 ++-- .../preferencestorage/DatabaseStorageModule.kt | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/ui/dialog/ConversationsListBottomDialog.kt b/app/src/main/java/com/nextcloud/talk/ui/dialog/ConversationsListBottomDialog.kt index 9b4f009ee..6a33abb7f 100644 --- a/app/src/main/java/com/nextcloud/talk/ui/dialog/ConversationsListBottomDialog.kt +++ b/app/src/main/java/com/nextcloud/talk/ui/dialog/ConversationsListBottomDialog.kt @@ -202,7 +202,7 @@ class ConversationsListBottomDialog( } } - @SuppressLint("StringFormatInvalid") + @SuppressLint("StringFormatInvalid", "TooGenericExceptionCaught") private fun addConversationToFavorites() { val apiVersion = ApiUtils.getConversationApiVersion(currentUser, intArrayOf(ApiUtils.API_V4, ApiUtils.API_V1)) val url = ApiUtils.getUrlForRoomFavorite(apiVersion, currentUser.baseUrl!!, conversation.token) @@ -228,7 +228,7 @@ class ConversationsListBottomDialog( } } - @SuppressLint("StringFormatInvalid") + @SuppressLint("StringFormatInvalid", "TooGenericExceptionCaught") private fun removeConversationFromFavorites() { val apiVersion = ApiUtils.getConversationApiVersion(currentUser, intArrayOf(ApiUtils.API_V4, ApiUtils.API_V1)) val url = ApiUtils.getUrlForRoomFavorite(apiVersion, currentUser.baseUrl!!, conversation.token) diff --git a/app/src/main/java/com/nextcloud/talk/utils/preferences/preferencestorage/DatabaseStorageModule.kt b/app/src/main/java/com/nextcloud/talk/utils/preferences/preferencestorage/DatabaseStorageModule.kt index 2a239e869..e6b376f87 100644 --- a/app/src/main/java/com/nextcloud/talk/utils/preferences/preferencestorage/DatabaseStorageModule.kt +++ b/app/src/main/java/com/nextcloud/talk/utils/preferences/preferencestorage/DatabaseStorageModule.kt @@ -8,6 +8,7 @@ */ package com.nextcloud.talk.utils.preferences.preferencestorage +import android.annotation.SuppressLint import android.text.TextUtils import android.util.Log import autodagger.AutoInjector @@ -63,6 +64,7 @@ class DatabaseStorageModule(conversationUser: User, conversationToken: String) { this.conversationToken = conversationToken } + @SuppressLint("TooGenericExceptionCaught") suspend fun saveBoolean(key: String, value: Boolean) { if ("call_notifications_switch" == key) { val apiVersion = getConversationApiVersion(conversationUser, intArrayOf(4)) @@ -73,7 +75,7 @@ class DatabaseStorageModule(conversationUser: User, conversationToken: String) { try { ncApiCoroutines!!.notificationCalls(credentials!!, url, notificationLevel) Log.d(TAG, "Toggled notification calls") - } catch (e: Throwable) { + } catch (e: Exception) { Log.e(TAG, "Error when trying to toggle notification calls", e) } } @@ -90,11 +92,12 @@ class DatabaseStorageModule(conversationUser: User, conversationToken: String) { } } + @SuppressLint("TooGenericExceptionCaught") suspend fun saveString(key: String, value: String) { when (key) { "conversation_settings_dropdown" -> { try { - val apiVersion = getConversationApiVersion(conversationUser, intArrayOf(4)) + val apiVersion = getConversationApiVersion(conversationUser, intArrayOf(API_VERSION_4)) val trimmedValue = value.replace("expire_", "") val valueInt = trimmedValue.toInt() withContext(Dispatchers.IO) { @@ -202,5 +205,6 @@ class DatabaseStorageModule(conversationUser: User, conversationToken: String) { private const val NOTIFICATION_NEVER = 3 private const val NOTIFICATION_MENTION = 2 private const val NOTIFICATION_ALWAYS = 1 + private const val API_VERSION_4 = 4 } }