From deac2059ff8467e508475409de997f81a3138953 Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Tue, 5 Apr 2022 22:37:57 +0200 Subject: [PATCH] improve lint/detekt Signed-off-by: Andy Scherzinger --- .../com/nextcloud/talk/adapters/ReactionItem.kt | 1 - .../nextcloud/talk/models/json/status/Status.kt | 4 ++-- .../ui/dialog/ConversationsListBottomDialog.kt | 2 +- .../talk/ui/dialog/ShowReactionsDialog.kt | 16 ++++++++++------ .../com/nextcloud/talk/utils/LoggingUtils.kt | 2 +- .../talk/utils/preferences/AppPreferences.java | 2 +- .../talk/webrtc/MagicWebSocketInstance.java | 2 +- detekt.yml | 2 +- 8 files changed, 17 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/adapters/ReactionItem.kt b/app/src/main/java/com/nextcloud/talk/adapters/ReactionItem.kt index e260318d2..37ff543cf 100644 --- a/app/src/main/java/com/nextcloud/talk/adapters/ReactionItem.kt +++ b/app/src/main/java/com/nextcloud/talk/adapters/ReactionItem.kt @@ -22,7 +22,6 @@ package com.nextcloud.talk.adapters import com.nextcloud.talk.models.json.reactions.ReactionVoter -// TODO: replace with proper class with correct data objects data class ReactionItem( val reactionVoter: ReactionVoter, val reaction: String? diff --git a/app/src/main/java/com/nextcloud/talk/models/json/status/Status.kt b/app/src/main/java/com/nextcloud/talk/models/json/status/Status.kt index f66a09724..ae2c082bb 100644 --- a/app/src/main/java/com/nextcloud/talk/models/json/status/Status.kt +++ b/app/src/main/java/com/nextcloud/talk/models/json/status/Status.kt @@ -32,7 +32,7 @@ data class Status( var userId: String?, @JsonField(name = ["message"]) var message: String?, - /* TODO: Change to enum */ + /* TODO Change to enum */ @JsonField(name = ["messageId"]) var messageId: String?, @JsonField(name = ["messageIsPredefined"]) @@ -41,7 +41,7 @@ data class Status( var icon: String?, @JsonField(name = ["clearAt"]) var clearAt: Long = 0, - /* TODO: Change to enum */ + /* TODO Change to enum */ @JsonField(name = ["status"]) var status: String = "offline", @JsonField(name = ["statusIsUserDefined"]) 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 4679dc4e4..a07937228 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 @@ -293,7 +293,7 @@ class ConversationsListBottomDialog( dialogRouter!!.pushController( - // TODO: refresh conversation list after EntryMenuController finished (throw event? / pass controller + // TODO refresh conversation list after EntryMenuController finished (throw event? / pass controller // into EntryMenuController to execute fetch data... ?!) // for example if you set a password, the dialog items should be refreshed for the next time you open it // without to manually have to refresh the conversations list diff --git a/app/src/main/java/com/nextcloud/talk/ui/dialog/ShowReactionsDialog.kt b/app/src/main/java/com/nextcloud/talk/ui/dialog/ShowReactionsDialog.kt index 69b2e1e0c..482251975 100644 --- a/app/src/main/java/com/nextcloud/talk/ui/dialog/ShowReactionsDialog.kt +++ b/app/src/main/java/com/nextcloud/talk/ui/dialog/ShowReactionsDialog.kt @@ -36,7 +36,6 @@ import androidx.annotation.NonNull import androidx.recyclerview.widget.LinearLayoutManager import autodagger.AutoInjector import com.google.android.material.bottomsheet.BottomSheetDialog -import com.nextcloud.talk.R import com.nextcloud.talk.adapters.ReactionItem import com.nextcloud.talk.adapters.ReactionItemClickListener import com.nextcloud.talk.adapters.ReactionsAdapter @@ -85,7 +84,7 @@ class ShowReactionsDialog( var firstEmoji = "" for ((emoji, amount) in chatMessage.reactions) { - if(firstEmoji.isEmpty()){ + if (firstEmoji.isEmpty()) { firstEmoji = emoji } @@ -97,7 +96,12 @@ class ShowReactionsDialog( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT ) - params.setMargins(0, 0, EMOJI_RIGHT_MARGIN, 0) + params.setMargins( + DisplayUtils.convertDpToPixel(EMOJI_MARGIN, context).toInt(), + 0, + DisplayUtils.convertDpToPixel(EMOJI_MARGIN, context).toInt(), + 0 + ) params.gravity = Gravity.CENTER emojiView.layoutParams = params @@ -138,7 +142,6 @@ class ShowReactionsDialog( if (reactionsOverall.ocs?.data != null) { for (reactionVoter in reactionsOverall.ocs?.data!![emoji]!!) { reactionVoters.add(ReactionItem(reactionVoter, emoji)) - } adapter?.list?.addAll(reactionVoters) adapter?.notifyDataSetChanged() @@ -152,13 +155,14 @@ class ShowReactionsDialog( } override fun onComplete() { + // unused atm } }) } override fun onClick(reactionItem: ReactionItem) { Log.d(TAG, "onClick(reactionItem: ReactionItem): " + reactionItem.reaction) - // TODO: implement removal of users reaction, + // TODO implement removal of users reaction, // ownership needs to be checked, so only owned // reactions can be removed upon click dismiss() @@ -166,7 +170,7 @@ class ShowReactionsDialog( companion object { const val TAG = "ShowReactionsDialog" - const val EMOJI_RIGHT_MARGIN: Int = 12 + const val EMOJI_MARGIN: Float = 8F const val EMOJI_SIZE: Float = 30F } } diff --git a/app/src/main/java/com/nextcloud/talk/utils/LoggingUtils.kt b/app/src/main/java/com/nextcloud/talk/utils/LoggingUtils.kt index 391d7be51..18a31a55b 100644 --- a/app/src/main/java/com/nextcloud/talk/utils/LoggingUtils.kt +++ b/app/src/main/java/com/nextcloud/talk/utils/LoggingUtils.kt @@ -22,7 +22,7 @@ package com.nextcloud.talk.utils import android.content.Context -// TODO: improve log handling. https://github.com/nextcloud/talk-android/issues/1376 +// TODO improve log handling. https://github.com/nextcloud/talk-android/issues/1376 // writing logs to a file is temporarily disabled to avoid huge logfiles. object LoggingUtils { diff --git a/app/src/main/java/com/nextcloud/talk/utils/preferences/AppPreferences.java b/app/src/main/java/com/nextcloud/talk/utils/preferences/AppPreferences.java index 30d725f91..6ff15688c 100644 --- a/app/src/main/java/com/nextcloud/talk/utils/preferences/AppPreferences.java +++ b/app/src/main/java/com/nextcloud/talk/utils/preferences/AppPreferences.java @@ -243,7 +243,7 @@ public interface AppPreferences { @KeyByString("phone_book_integration") void setPhoneBookIntegration(boolean value); - // TODO: Remove in 13.0.0 + // TODO Remove in 13.0.0 @KeyByString("link_previews") @RemoveMethod void removeLinkPreviews(); diff --git a/app/src/main/java/com/nextcloud/talk/webrtc/MagicWebSocketInstance.java b/app/src/main/java/com/nextcloud/talk/webrtc/MagicWebSocketInstance.java index 300aee3a6..4cc2667ce 100644 --- a/app/src/main/java/com/nextcloud/talk/webrtc/MagicWebSocketInstance.java +++ b/app/src/main/java/com/nextcloud/talk/webrtc/MagicWebSocketInstance.java @@ -151,7 +151,7 @@ public class MagicWebSocketInstance extends WebSocketListener { public void restartWebSocket() { reconnecting = true; - // TODO: when improving logging, keep in mind this issue: https://github.com/nextcloud/talk-android/issues/1013 + // TODO when improving logging, keep in mind this issue: https://github.com/nextcloud/talk-android/issues/1013 Log.d(TAG, "restartWebSocket: " + connectionUrl); Request request = new Request.Builder().url(connectionUrl).build(); okHttpClient.newWebSocket(request, this); diff --git a/detekt.yml b/detekt.yml index 939ff6ae1..43592c6f4 100644 --- a/detekt.yml +++ b/detekt.yml @@ -1,5 +1,5 @@ build: - maxIssues: 98 + maxIssues: 96 weights: # complexity: 2 # LongParameterList: 1