From 26876c21d70ad07b0ed0d5ea6018f5d0e71a1b2e Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Fri, 29 Nov 2024 11:24:29 +0100 Subject: [PATCH 1/5] style(ktlint): Fix formatting Signed-off-by: Andy Scherzinger --- .../com/nextcloud/talk/adapters/items/ConversationItem.kt | 1 - .../com/nextcloud/talk/adapters/items/ParticipantItem.kt | 3 ++- .../talk/adapters/messages/IncomingDeckCardViewHolder.kt | 4 ---- .../messages/IncomingLinkPreviewMessageViewHolder.kt | 4 ---- .../messages/IncomingLocationMessageViewHolder.kt | 4 ---- .../adapters/messages/IncomingPollMessageViewHolder.kt | 4 ---- .../adapters/messages/IncomingTextMessageViewHolder.kt | 6 ------ .../adapters/messages/IncomingVoiceMessageViewHolder.kt | 4 ---- .../java/com/nextcloud/talk/utils/ChatMessageUtils.kt | 2 +- .../talk/utils/preferences/AppPreferencesImpl.kt | 8 +++++--- 10 files changed, 8 insertions(+), 32 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/adapters/items/ConversationItem.kt b/app/src/main/java/com/nextcloud/talk/adapters/items/ConversationItem.kt index d08ff37a45..f03b815a3c 100644 --- a/app/src/main/java/com/nextcloud/talk/adapters/items/ConversationItem.kt +++ b/app/src/main/java/com/nextcloud/talk/adapters/items/ConversationItem.kt @@ -20,7 +20,6 @@ import androidx.core.content.ContextCompat import androidx.core.content.res.ResourcesCompat import com.nextcloud.talk.R import com.nextcloud.talk.adapters.items.ConversationItem.ConversationItemViewHolder -import com.nextcloud.talk.adapters.messages.MessagePayload import com.nextcloud.talk.application.NextcloudTalkApplication.Companion.sharedApplication import com.nextcloud.talk.chat.data.model.ChatMessage.MessageType import com.nextcloud.talk.data.database.mappers.asModel diff --git a/app/src/main/java/com/nextcloud/talk/adapters/items/ParticipantItem.kt b/app/src/main/java/com/nextcloud/talk/adapters/items/ParticipantItem.kt index e23df84091..dd6b40b778 100644 --- a/app/src/main/java/com/nextcloud/talk/adapters/items/ParticipantItem.kt +++ b/app/src/main/java/com/nextcloud/talk/adapters/items/ParticipantItem.kt @@ -138,7 +138,8 @@ class ParticipantItem( } if (model.invitedActorId?.isNotEmpty() == true && - ConversationUtils.isParticipantOwnerOrModerator(conversation)) { + ConversationUtils.isParticipantOwnerOrModerator(conversation) + ) { holder.binding.conversationInfoStatusMessage.text = model.invitedActorId alignUsernameVertical(holder, 0f) } diff --git a/app/src/main/java/com/nextcloud/talk/adapters/messages/IncomingDeckCardViewHolder.kt b/app/src/main/java/com/nextcloud/talk/adapters/messages/IncomingDeckCardViewHolder.kt index 17486dc824..149d818db6 100644 --- a/app/src/main/java/com/nextcloud/talk/adapters/messages/IncomingDeckCardViewHolder.kt +++ b/app/src/main/java/com/nextcloud/talk/adapters/messages/IncomingDeckCardViewHolder.kt @@ -11,7 +11,6 @@ import android.annotation.SuppressLint import android.content.Context import android.content.Intent import android.net.Uri -import android.text.TextUtils import android.util.Log import android.view.View import android.widget.ImageView @@ -26,9 +25,6 @@ import com.nextcloud.talk.application.NextcloudTalkApplication.Companion.sharedA import com.nextcloud.talk.chat.ChatActivity import com.nextcloud.talk.chat.data.model.ChatMessage import com.nextcloud.talk.databinding.ItemCustomIncomingDeckCardMessageBinding -import com.nextcloud.talk.extensions.loadBotsAvatar -import com.nextcloud.talk.extensions.loadChangelogBotAvatar -import com.nextcloud.talk.extensions.loadFederatedUserAvatar import com.nextcloud.talk.ui.theme.ViewThemeUtils import com.nextcloud.talk.utils.ApiUtils import com.nextcloud.talk.utils.ChatMessageUtils diff --git a/app/src/main/java/com/nextcloud/talk/adapters/messages/IncomingLinkPreviewMessageViewHolder.kt b/app/src/main/java/com/nextcloud/talk/adapters/messages/IncomingLinkPreviewMessageViewHolder.kt index d450213b95..b17a38da76 100644 --- a/app/src/main/java/com/nextcloud/talk/adapters/messages/IncomingLinkPreviewMessageViewHolder.kt +++ b/app/src/main/java/com/nextcloud/talk/adapters/messages/IncomingLinkPreviewMessageViewHolder.kt @@ -9,7 +9,6 @@ package com.nextcloud.talk.adapters.messages import android.annotation.SuppressLint import android.content.Context -import android.text.TextUtils import android.util.Log import android.view.View import androidx.core.content.ContextCompat @@ -23,9 +22,6 @@ import com.nextcloud.talk.application.NextcloudTalkApplication.Companion.sharedA import com.nextcloud.talk.chat.ChatActivity import com.nextcloud.talk.chat.data.model.ChatMessage import com.nextcloud.talk.databinding.ItemCustomIncomingLinkPreviewMessageBinding -import com.nextcloud.talk.extensions.loadBotsAvatar -import com.nextcloud.talk.extensions.loadChangelogBotAvatar -import com.nextcloud.talk.extensions.loadFederatedUserAvatar import com.nextcloud.talk.ui.theme.ViewThemeUtils import com.nextcloud.talk.utils.ApiUtils import com.nextcloud.talk.utils.ChatMessageUtils diff --git a/app/src/main/java/com/nextcloud/talk/adapters/messages/IncomingLocationMessageViewHolder.kt b/app/src/main/java/com/nextcloud/talk/adapters/messages/IncomingLocationMessageViewHolder.kt index e5ba4f2d82..d8f3d0a56d 100644 --- a/app/src/main/java/com/nextcloud/talk/adapters/messages/IncomingLocationMessageViewHolder.kt +++ b/app/src/main/java/com/nextcloud/talk/adapters/messages/IncomingLocationMessageViewHolder.kt @@ -13,7 +13,6 @@ import android.annotation.SuppressLint import android.content.Context import android.content.Intent import android.net.Uri -import android.text.TextUtils import android.util.Log import android.util.TypedValue import android.view.MotionEvent @@ -30,9 +29,6 @@ import com.nextcloud.talk.application.NextcloudTalkApplication.Companion.sharedA import com.nextcloud.talk.chat.ChatActivity import com.nextcloud.talk.chat.data.model.ChatMessage import com.nextcloud.talk.databinding.ItemCustomIncomingLocationMessageBinding -import com.nextcloud.talk.extensions.loadBotsAvatar -import com.nextcloud.talk.extensions.loadChangelogBotAvatar -import com.nextcloud.talk.extensions.loadFederatedUserAvatar import com.nextcloud.talk.ui.theme.ViewThemeUtils import com.nextcloud.talk.utils.ApiUtils import com.nextcloud.talk.utils.ChatMessageUtils diff --git a/app/src/main/java/com/nextcloud/talk/adapters/messages/IncomingPollMessageViewHolder.kt b/app/src/main/java/com/nextcloud/talk/adapters/messages/IncomingPollMessageViewHolder.kt index 56b0936bc5..c121acc7f9 100644 --- a/app/src/main/java/com/nextcloud/talk/adapters/messages/IncomingPollMessageViewHolder.kt +++ b/app/src/main/java/com/nextcloud/talk/adapters/messages/IncomingPollMessageViewHolder.kt @@ -8,7 +8,6 @@ package com.nextcloud.talk.adapters.messages import android.annotation.SuppressLint import android.content.Context -import android.text.TextUtils import android.util.Log import android.view.View import androidx.core.content.ContextCompat @@ -22,9 +21,6 @@ import com.nextcloud.talk.application.NextcloudTalkApplication.Companion.sharedA import com.nextcloud.talk.chat.ChatActivity import com.nextcloud.talk.chat.data.model.ChatMessage import com.nextcloud.talk.databinding.ItemCustomIncomingPollMessageBinding -import com.nextcloud.talk.extensions.loadBotsAvatar -import com.nextcloud.talk.extensions.loadChangelogBotAvatar -import com.nextcloud.talk.extensions.loadFederatedUserAvatar import com.nextcloud.talk.polls.ui.PollMainDialogFragment import com.nextcloud.talk.ui.theme.ViewThemeUtils import com.nextcloud.talk.utils.ApiUtils diff --git a/app/src/main/java/com/nextcloud/talk/adapters/messages/IncomingTextMessageViewHolder.kt b/app/src/main/java/com/nextcloud/talk/adapters/messages/IncomingTextMessageViewHolder.kt index 2a587270c4..cb7175caa1 100644 --- a/app/src/main/java/com/nextcloud/talk/adapters/messages/IncomingTextMessageViewHolder.kt +++ b/app/src/main/java/com/nextcloud/talk/adapters/messages/IncomingTextMessageViewHolder.kt @@ -10,7 +10,6 @@ package com.nextcloud.talk.adapters.messages import android.content.Context -import android.text.TextUtils import android.util.Log import android.util.TypedValue import android.view.View @@ -24,11 +23,6 @@ import com.nextcloud.talk.application.NextcloudTalkApplication.Companion.sharedA import com.nextcloud.talk.chat.ChatActivity import com.nextcloud.talk.chat.data.model.ChatMessage import com.nextcloud.talk.databinding.ItemCustomIncomingTextMessageBinding -import com.nextcloud.talk.extensions.loadBotsAvatar -import com.nextcloud.talk.extensions.loadChangelogBotAvatar -import com.nextcloud.talk.extensions.loadDefaultAvatar -import com.nextcloud.talk.extensions.loadFederatedUserAvatar -import com.nextcloud.talk.extensions.loadFirstLetterAvatar import com.nextcloud.talk.ui.theme.ViewThemeUtils import com.nextcloud.talk.utils.ApiUtils import com.nextcloud.talk.utils.ChatMessageUtils diff --git a/app/src/main/java/com/nextcloud/talk/adapters/messages/IncomingVoiceMessageViewHolder.kt b/app/src/main/java/com/nextcloud/talk/adapters/messages/IncomingVoiceMessageViewHolder.kt index 9413e1720a..1708979028 100644 --- a/app/src/main/java/com/nextcloud/talk/adapters/messages/IncomingVoiceMessageViewHolder.kt +++ b/app/src/main/java/com/nextcloud/talk/adapters/messages/IncomingVoiceMessageViewHolder.kt @@ -11,7 +11,6 @@ package com.nextcloud.talk.adapters.messages import android.annotation.SuppressLint import android.content.Context -import android.text.TextUtils import android.util.Log import android.view.View import android.widget.SeekBar @@ -27,9 +26,6 @@ import com.nextcloud.talk.application.NextcloudTalkApplication.Companion.sharedA import com.nextcloud.talk.chat.ChatActivity import com.nextcloud.talk.chat.data.model.ChatMessage import com.nextcloud.talk.databinding.ItemCustomIncomingVoiceMessageBinding -import com.nextcloud.talk.extensions.loadBotsAvatar -import com.nextcloud.talk.extensions.loadChangelogBotAvatar -import com.nextcloud.talk.extensions.loadFederatedUserAvatar import com.nextcloud.talk.ui.theme.ViewThemeUtils import com.nextcloud.talk.utils.ApiUtils import com.nextcloud.talk.utils.ChatMessageUtils diff --git a/app/src/main/java/com/nextcloud/talk/utils/ChatMessageUtils.kt b/app/src/main/java/com/nextcloud/talk/utils/ChatMessageUtils.kt index 1f0c5e13fc..f004964482 100644 --- a/app/src/main/java/com/nextcloud/talk/utils/ChatMessageUtils.kt +++ b/app/src/main/java/com/nextcloud/talk/utils/ChatMessageUtils.kt @@ -18,7 +18,7 @@ import com.nextcloud.talk.ui.theme.ViewThemeUtils class ChatMessageUtils { - fun setAvatarOnMessage(view: ImageView, message: ChatMessage, viewThemeUtils : ViewThemeUtils) { + fun setAvatarOnMessage(view: ImageView, message: ChatMessage, viewThemeUtils: ViewThemeUtils) { view.visibility = View.VISIBLE if (message.actorType == "guests" || message.actorType == "emails") { val actorName = message.actorDisplayName diff --git a/app/src/main/java/com/nextcloud/talk/utils/preferences/AppPreferencesImpl.kt b/app/src/main/java/com/nextcloud/talk/utils/preferences/AppPreferencesImpl.kt index a576fe9a0b..1b6725162c 100644 --- a/app/src/main/java/com/nextcloud/talk/utils/preferences/AppPreferencesImpl.kt +++ b/app/src/main/java/com/nextcloud/talk/utils/preferences/AppPreferencesImpl.kt @@ -545,9 +545,11 @@ class AppPreferencesImpl(val context: Context) : AppPreferences { } override fun getShowNotificationWarning(): Boolean { - return runBlocking { async { - readBoolean(SHOW_NOTIFICATION_WARNING, true).first() - } }.getCompleted() + return runBlocking { + async { + readBoolean(SHOW_NOTIFICATION_WARNING, true).first() + } + }.getCompleted() } override fun setShowNotificationWarning(showNotificationWarning: Boolean) = From 77d2632513b0d5dbbda39c30f962919260a7734f Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Fri, 29 Nov 2024 12:19:53 +0100 Subject: [PATCH 2/5] style(detekt): Improve score Signed-off-by: Andy Scherzinger --- .../main/java/com/nextcloud/talk/activities/CallActivity.kt | 6 +++++- .../talk/chat/data/network/OfflineFirstChatRepository.kt | 3 ++- app/src/main/java/com/nextcloud/talk/utils/DisplayUtils.kt | 3 ++- detekt.yml | 2 +- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/activities/CallActivity.kt b/app/src/main/java/com/nextcloud/talk/activities/CallActivity.kt index 4ef2294992..593d49ef68 100644 --- a/app/src/main/java/com/nextcloud/talk/activities/CallActivity.kt +++ b/app/src/main/java/com/nextcloud/talk/activities/CallActivity.kt @@ -2121,7 +2121,7 @@ class CallActivity : CallBaseActivity() { private fun startVideoCapture() { if (videoCapturer != null) { - videoCapturer!!.startCapture(1280, 720, 30) + videoCapturer!!.startCapture(WIDTH, HEIGHT, FRAME_RATE) } } @@ -3210,6 +3210,10 @@ class CallActivity : CallBaseActivity() { private const val MICROPHONE_VALUE_THRESHOLD = 20 private const val MICROPHONE_VALUE_SLEEP: Long = 1000 + private const val FRAME_RATE: Int = 30 + private const val WIDTH: Int = 1280 + private const val HEIGHT: Int = 720 + private const val SIGNALING_MESSAGE_SPEAKING_STARTED = "speaking" private const val SIGNALING_MESSAGE_SPEAKING_STOPPED = "stoppedSpeaking" private const val SIGNALING_MESSAGE_VIDEO_ON = "videoOn" diff --git a/app/src/main/java/com/nextcloud/talk/chat/data/network/OfflineFirstChatRepository.kt b/app/src/main/java/com/nextcloud/talk/chat/data/network/OfflineFirstChatRepository.kt index 7be5caaed3..361f40ce09 100644 --- a/app/src/main/java/com/nextcloud/talk/chat/data/network/OfflineFirstChatRepository.kt +++ b/app/src/main/java/com/nextcloud/talk/chat/data/network/OfflineFirstChatRepository.kt @@ -274,7 +274,8 @@ class OfflineFirstChatRepository @Inject constructor( if (!monitor.isOnline.first() || itIsPaused) { Thread.sleep(HALF_SECOND) } else { - // sync database with server (This is a long blocking call because long polling (lookIntoFuture) is set) + // sync database with server + // (This is a long blocking call because long polling (lookIntoFuture) is set) networkParams.putSerializable(BundleKeys.KEY_FIELD_MAP, fieldMap) Log.d(TAG, "Starting online request for long polling") diff --git a/app/src/main/java/com/nextcloud/talk/utils/DisplayUtils.kt b/app/src/main/java/com/nextcloud/talk/utils/DisplayUtils.kt index cb8268cab7..fc497de79d 100644 --- a/app/src/main/java/com/nextcloud/talk/utils/DisplayUtils.kt +++ b/app/src/main/java/com/nextcloud/talk/utils/DisplayUtils.kt @@ -79,6 +79,7 @@ object DisplayUtils { private const val HTTP_MIN_LENGTH: Int = 7 private const val HTTPS_MIN_LENGTH: Int = 7 private const val DATE_TIME_PARTS_SIZE = 2 + private const val ONE_MINUTE_IN_MILLIS: Int = 60000 fun isDarkModeOn(context: Context): Boolean { val currentNightMode = context.resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK return currentNightMode == Configuration.UI_MODE_NIGHT_YES @@ -490,7 +491,7 @@ object DisplayUtils { } // < 60 seconds -> seconds ago val diff = System.currentTimeMillis() - time - dateString = if (diff > 0 && diff < 60 * 1000 && minResolution == DateUtils.SECOND_IN_MILLIS) { + dateString = if (diff in 1.. Date: Fri, 29 Nov 2024 13:15:03 +0100 Subject: [PATCH 3/5] make lint pass for now Signed-off-by: tobiasKaminsky --- scripts/analysis/lint-results.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/analysis/lint-results.txt b/scripts/analysis/lint-results.txt index 13235d5fbe..f659e49357 100644 --- a/scripts/analysis/lint-results.txt +++ b/scripts/analysis/lint-results.txt @@ -1,2 +1,2 @@ DO NOT TOUCH; GENERATED BY DRONE - Lint Report: 132 errors and 94 warnings + Lint Report: 73 errors and 159 warnings From 6de05d8fa47e8fa2fffcb1d503799339fa18d5d4 Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Fri, 29 Nov 2024 16:09:06 +0100 Subject: [PATCH 4/5] style(lint): make use of ResourceCompat Signed-off-by: Andy Scherzinger --- .../talk/adapters/messages/TemporaryMessageViewHolder.kt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/adapters/messages/TemporaryMessageViewHolder.kt b/app/src/main/java/com/nextcloud/talk/adapters/messages/TemporaryMessageViewHolder.kt index 42f4c693eb..d684ac6c57 100644 --- a/app/src/main/java/com/nextcloud/talk/adapters/messages/TemporaryMessageViewHolder.kt +++ b/app/src/main/java/com/nextcloud/talk/adapters/messages/TemporaryMessageViewHolder.kt @@ -131,10 +131,14 @@ class TemporaryMessageViewHolder(outgoingView: View, payload: Any) : ).first() } - parentChatMessage!!.activeUser = message.activeUser + parentChatMessage.activeUser = message.activeUser parentChatMessage.imageUrl?.let { binding.messageQuote.quotedMessageImage.visibility = View.VISIBLE - val placeholder = context.resources.getDrawable(R.drawable.ic_mimetype_image) + val placeholder = ResourcesCompat.getDrawable( + context.resources, + R.drawable.ic_mimetype_image, + null + ) binding.messageQuote.quotedMessageImage.setImageDrawable(placeholder) binding.messageQuote.quotedMessageImage.load(it) { addHeader( From 5eac4a868d711e4f342900edce15ca6cf5c53fde Mon Sep 17 00:00:00 2001 From: github-actions Date: Fri, 29 Nov 2024 15:37:14 +0000 Subject: [PATCH 5/5] Analysis: update lint results to reflect reduced error/warning count Signed-off-by: github-actions --- scripts/analysis/lint-results.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/analysis/lint-results.txt b/scripts/analysis/lint-results.txt index f659e49357..8ceecf7610 100644 --- a/scripts/analysis/lint-results.txt +++ b/scripts/analysis/lint-results.txt @@ -1,2 +1,2 @@ DO NOT TOUCH; GENERATED BY DRONE - Lint Report: 73 errors and 159 warnings + Lint Report: 73 errors and 158 warnings