mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-19 11:39:42 +01:00
fix: improve detekt score and threshold
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
This commit is contained in:
parent
69ed8207d0
commit
9d62a6f745
@ -504,12 +504,12 @@ class OfflineFirstChatRepository @Inject constructor(
|
||||
chatBlock.newestMessageId
|
||||
).first()
|
||||
|
||||
if (connectedChatBlocks.size == 1) {
|
||||
return if (connectedChatBlocks.size == 1) {
|
||||
Log.d(TAG, "This chatBlock is not connected to others")
|
||||
val chatBlockFromDb = connectedChatBlocks[0]
|
||||
Log.d(TAG, "chatBlockFromDb.oldestMessageId: " + chatBlockFromDb.oldestMessageId)
|
||||
Log.d(TAG, "chatBlockFromDb.newestMessageId: " + chatBlockFromDb.newestMessageId)
|
||||
return chatBlockFromDb
|
||||
chatBlockFromDb
|
||||
} else if (connectedChatBlocks.size > 1) {
|
||||
Log.d(TAG, "Found " + connectedChatBlocks.size + " chat blocks that are connected")
|
||||
val oldestIdFromDbChatBlocks =
|
||||
@ -536,10 +536,10 @@ class OfflineFirstChatRepository @Inject constructor(
|
||||
Log.d(TAG, "A new chat block was created that covers all the range of the found chatblocks")
|
||||
Log.d(TAG, "new chatBlock - oldest MessageId: $oldestIdFromDbChatBlocks")
|
||||
Log.d(TAG, "new chatBlock - newest MessageId: $newestIdFromDbChatBlocks")
|
||||
return newChatBlock
|
||||
newChatBlock
|
||||
} else {
|
||||
Log.d(TAG, "No chat block found ....")
|
||||
return null
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -77,6 +77,8 @@ object DisplayUtils {
|
||||
private const val TWITTER_HANDLE_PREFIX = "@"
|
||||
private const val HTTP_PROTOCOL = "http://"
|
||||
private const val HTTPS_PROTOCOL = "https://"
|
||||
private const val HTTP_MIN_LENGTH: Int = 7
|
||||
private const val HTTPS_MIN_LENGTH: Int = 7
|
||||
private const val DATE_TIME_PARTS_SIZE = 2
|
||||
fun isDarkModeOn(context: Context): Boolean {
|
||||
val currentNightMode = context.resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK
|
||||
@ -394,10 +396,14 @@ object DisplayUtils {
|
||||
if (TextUtils.isEmpty(url)) {
|
||||
return ""
|
||||
}
|
||||
if (url!!.length >= 7 && HTTP_PROTOCOL.equals(url.substring(0, 7), ignoreCase = true)) {
|
||||
if (url!!.length >= HTTP_MIN_LENGTH &&
|
||||
HTTP_PROTOCOL.equals(url.substring(0, HTTP_MIN_LENGTH), ignoreCase = true)
|
||||
) {
|
||||
return url.substring(HTTP_PROTOCOL.length).trim { it <= ' ' }
|
||||
}
|
||||
return if (url.length >= 8 && HTTPS_PROTOCOL.equals(url.substring(0, 8), ignoreCase = true)) {
|
||||
return if (url.length >= HTTPS_MIN_LENGTH &&
|
||||
HTTPS_PROTOCOL.equals(url.substring(0, HTTPS_MIN_LENGTH), ignoreCase = true)
|
||||
) {
|
||||
url.substring(HTTPS_PROTOCOL.length).trim { it <= ' ' }
|
||||
} else {
|
||||
url.trim { it <= ' ' }
|
||||
|
@ -162,26 +162,26 @@ class PushUtils {
|
||||
var keyGen: KeyPairGenerator? = null
|
||||
try {
|
||||
keyGen = KeyPairGenerator.getInstance("RSA")
|
||||
keyGen.initialize(2048)
|
||||
keyGen.initialize(RSA_KEY_SIZE)
|
||||
val pair = keyGen.generateKeyPair()
|
||||
val statusPrivate = saveKeyToFile(pair.private, privateKeyFile.absolutePath)
|
||||
val statusPublic = saveKeyToFile(pair.public, publicKeyFile.absolutePath)
|
||||
return if (statusPrivate == 0 && statusPublic == 0) {
|
||||
// all went well
|
||||
0
|
||||
RETURN_CODE_KEY_GENERATION_SUCCESSFUL
|
||||
} else {
|
||||
-2
|
||||
RETURN_CODE_KEY_GENERATION_FAILED
|
||||
}
|
||||
} catch (e: NoSuchAlgorithmException) {
|
||||
Log.d(TAG, "RSA algorithm not supported")
|
||||
}
|
||||
} else {
|
||||
// We already have the key
|
||||
return -1
|
||||
return RETURN_CODE_KEY_ALREADY_EXISTS
|
||||
}
|
||||
|
||||
// we failed to generate the key
|
||||
return -2
|
||||
return RETURN_CODE_KEY_GENERATION_FAILED
|
||||
}
|
||||
|
||||
fun pushRegistrationToServer(ncApi: NcApi) {
|
||||
@ -399,6 +399,10 @@ class PushUtils {
|
||||
|
||||
companion object {
|
||||
private const val TAG = "PushUtils"
|
||||
private const val RSA_KEY_SIZE: Int = 2048
|
||||
private const val RETURN_CODE_KEY_GENERATION_SUCCESSFUL: Int = 0
|
||||
private const val RETURN_CODE_KEY_ALREADY_EXISTS: Int = -1
|
||||
private const val RETURN_CODE_KEY_GENERATION_FAILED: Int = -2
|
||||
const val LATEST_PUSH_REGISTRATION_AT_SERVER: String = "LATEST_PUSH_REGISTRATION_AT_SERVER"
|
||||
const val LATEST_PUSH_REGISTRATION_AT_PUSH_PROXY: String = "LATEST_PUSH_REGISTRATION_AT_PUSH_PROXY"
|
||||
}
|
||||
|
@ -503,10 +503,10 @@ class AppPreferencesImpl(val context: Context) : AppPreferences {
|
||||
for (msgStr in queueStr.split("]")) {
|
||||
try {
|
||||
val msgArray = msgStr.replace("[", "").split(",")
|
||||
val message = msgArray[0]
|
||||
val replyTo = msgArray[1].toInt()
|
||||
val displayName = msgArray[2]
|
||||
val silent = msgArray[3].toBoolean()
|
||||
val message = msgArray[MESSAGE_INDEX]
|
||||
val replyTo = msgArray[REPLY_TO_INDEX].toInt()
|
||||
val displayName = msgArray[DISPLY_NAME_INDEX]
|
||||
val silent = msgArray[SILENT_INDEX].toBoolean()
|
||||
|
||||
val qMsg = MessageInputViewModel.QueuedMessage(message, displayName, replyTo, silent)
|
||||
queue.add(qMsg)
|
||||
@ -570,6 +570,10 @@ class AppPreferencesImpl(val context: Context) : AppPreferences {
|
||||
@Suppress("UnusedPrivateProperty")
|
||||
private val TAG = AppPreferencesImpl::class.simpleName
|
||||
private val Context.dataStore: DataStore<Preferences> by preferencesDataStore(name = "settings")
|
||||
private const val MESSAGE_INDEX: Int = 0
|
||||
private const val REPLY_TO_INDEX: Int = 1
|
||||
private const val DISPLY_NAME_INDEX: Int = 2
|
||||
private const val SILENT_INDEX: Int = 3
|
||||
const val PROXY_TYPE = "proxy_type"
|
||||
const val PROXY_SERVER = "proxy_server"
|
||||
const val PROXY_HOST = "proxy_host"
|
||||
|
@ -1,7 +1,7 @@
|
||||
# SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
build:
|
||||
maxIssues: 138
|
||||
maxIssues: 166
|
||||
weights:
|
||||
# complexity: 2
|
||||
# LongParameterList: 1
|
||||
|
Loading…
Reference in New Issue
Block a user