mirror of
https://github.com/nextcloud/talk-android.git
synced 2024-11-24 14:05:40 +03:00
Fix a bunch of easy detekt issues
Signed-off-by: Álvaro Brey <alvaro.brey@nextcloud.com>
This commit is contained in:
parent
b9f91429a2
commit
d86622588a
7 changed files with 71 additions and 84 deletions
|
@ -403,11 +403,9 @@ class ChatController(args: Bundle) :
|
|||
}
|
||||
)
|
||||
|
||||
val itemTouchHelper = ItemTouchHelper(messageSwipeController)
|
||||
try {
|
||||
withNullableControllerViewBinding {
|
||||
val itemTouchHelper = ItemTouchHelper(messageSwipeController)
|
||||
itemTouchHelper.attachToRecyclerView(binding.messagesListView)
|
||||
} catch (npe: NullPointerException) {
|
||||
Log.i(TAG, "UI already teared down", npe)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,7 +49,6 @@ import eu.davidea.flexibleadapter.SelectableAdapter
|
|||
import eu.davidea.flexibleadapter.common.SmoothScrollLinearLayoutManager
|
||||
import eu.davidea.flexibleadapter.items.AbstractFlexibleItem
|
||||
import java.io.IOException
|
||||
import java.util.ArrayList
|
||||
|
||||
@AutoInjector(NextcloudTalkApplication::class)
|
||||
class RingtoneSelectionController(args: Bundle) :
|
||||
|
@ -107,11 +106,11 @@ class RingtoneSelectionController(args: Bundle) :
|
|||
private fun findSelectedSound() {
|
||||
var foundDefault = false
|
||||
var preferencesString: String? = null
|
||||
if (callNotificationSounds &&
|
||||
TextUtils.isEmpty(appPreferences!!.callRingtoneUri.also { preferencesString = it }) ||
|
||||
!callNotificationSounds &&
|
||||
TextUtils.isEmpty(appPreferences!!.messageRingtoneUri.also { preferencesString = it })
|
||||
) {
|
||||
val callsEnabledButNoRingtone = callNotificationSounds &&
|
||||
TextUtils.isEmpty(appPreferences.callRingtoneUri.also { preferencesString = it })
|
||||
val noCallsAndNoMessageTone = !callNotificationSounds &&
|
||||
TextUtils.isEmpty(appPreferences.messageRingtoneUri.also { preferencesString = it })
|
||||
if (callsEnabledButNoRingtone || noCallsAndNoMessageTone) {
|
||||
adapter!!.toggleSelection(1)
|
||||
foundDefault = true
|
||||
}
|
||||
|
|
|
@ -84,7 +84,7 @@ class UploadAndShareFilesWorker(val context: Context, workerParameters: WorkerPa
|
|||
)
|
||||
}
|
||||
|
||||
try {
|
||||
return try {
|
||||
val currentUser = userManager.currentUser.blockingGet()
|
||||
val sourcefiles = inputData.getStringArray(DEVICE_SOURCEFILES)
|
||||
val ncTargetpath = inputData.getString(NC_TARGETPATH)
|
||||
|
@ -111,14 +111,14 @@ class UploadAndShareFilesWorker(val context: Context, workerParameters: WorkerPa
|
|||
metaData
|
||||
)
|
||||
}
|
||||
Result.success()
|
||||
} catch (e: IllegalStateException) {
|
||||
Log.e(javaClass.simpleName, "Something went wrong when trying to upload file", e)
|
||||
return Result.failure()
|
||||
Result.failure()
|
||||
} catch (e: IllegalArgumentException) {
|
||||
Log.e(javaClass.simpleName, "Something went wrong when trying to upload file", e)
|
||||
return Result.failure()
|
||||
Result.failure()
|
||||
}
|
||||
return Result.success()
|
||||
}
|
||||
|
||||
@Suppress("Detekt.TooGenericExceptionCaught")
|
||||
|
@ -196,7 +196,6 @@ class UploadAndShareFilesWorker(val context: Context, workerParameters: WorkerPa
|
|||
filename: String?,
|
||||
metaData: String?
|
||||
) {
|
||||
|
||||
val paths: MutableList<String> = ArrayList()
|
||||
paths.add("$ncTargetpath/$filename")
|
||||
|
||||
|
@ -221,9 +220,9 @@ class UploadAndShareFilesWorker(val context: Context, workerParameters: WorkerPa
|
|||
const val META_DATA = "META_DATA"
|
||||
|
||||
fun isStoragePermissionGranted(context: Context): Boolean {
|
||||
when {
|
||||
return when {
|
||||
Build.VERSION.SDK_INT > Build.VERSION_CODES.Q -> {
|
||||
return if (PermissionChecker.checkSelfPermission(
|
||||
if (PermissionChecker.checkSelfPermission(
|
||||
context,
|
||||
Manifest.permission.READ_EXTERNAL_STORAGE
|
||||
) == PermissionChecker.PERMISSION_GRANTED
|
||||
|
@ -236,7 +235,7 @@ class UploadAndShareFilesWorker(val context: Context, workerParameters: WorkerPa
|
|||
}
|
||||
}
|
||||
Build.VERSION.SDK_INT >= Build.VERSION_CODES.M -> {
|
||||
return if (PermissionChecker.checkSelfPermission(
|
||||
if (PermissionChecker.checkSelfPermission(
|
||||
context,
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE
|
||||
) == PermissionChecker.PERMISSION_GRANTED
|
||||
|
@ -250,13 +249,12 @@ class UploadAndShareFilesWorker(val context: Context, workerParameters: WorkerPa
|
|||
}
|
||||
else -> { // permission is automatically granted on sdk<23 upon installation
|
||||
Log.d(TAG, "Permission is granted")
|
||||
return true
|
||||
true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun requestStoragePermission(controller: Controller) {
|
||||
|
||||
when {
|
||||
Build.VERSION.SDK_INT > Build.VERSION_CODES.Q -> {
|
||||
controller.requestPermissions(
|
||||
|
@ -283,6 +281,6 @@ class UploadAndShareFilesWorker(val context: Context, workerParameters: WorkerPa
|
|||
private data class UploadItem(
|
||||
val uri: Uri,
|
||||
val fileName: String,
|
||||
val requestBody: RequestBody?,
|
||||
val requestBody: RequestBody?
|
||||
)
|
||||
}
|
||||
|
|
|
@ -177,60 +177,56 @@ class EnumSystemMessageTypeConverter : StringBasedTypeConverter<ChatMessage.Syst
|
|||
|
||||
@Suppress("Detekt.ComplexMethod")
|
||||
override fun convertToString(`object`: ChatMessage.SystemMessageType?): String {
|
||||
|
||||
if (`object` == null) {
|
||||
return ""
|
||||
}
|
||||
|
||||
when (`object`) {
|
||||
CONVERSATION_CREATED -> return "conversation_created"
|
||||
CONVERSATION_RENAMED -> return "conversation_renamed"
|
||||
DESCRIPTION_REMOVED -> return "description_removed"
|
||||
DESCRIPTION_SET -> return "description_set"
|
||||
CALL_STARTED -> return "call_started"
|
||||
CALL_JOINED -> return "call_joined"
|
||||
CALL_LEFT -> return "call_left"
|
||||
CALL_ENDED -> return "call_ended"
|
||||
CALL_ENDED_EVERYONE -> return "call_ended_everyone"
|
||||
CALL_MISSED -> return "call_missed"
|
||||
CALL_TRIED -> return "call_tried"
|
||||
READ_ONLY_OFF -> return "read_only_off"
|
||||
READ_ONLY -> return "read_only"
|
||||
LISTABLE_NONE -> return "listable_none"
|
||||
LISTABLE_USERS -> return "listable_users"
|
||||
LISTABLE_ALL -> return "listable_all"
|
||||
LOBBY_NONE -> return "lobby_none"
|
||||
LOBBY_NON_MODERATORS -> return "lobby_non_moderators"
|
||||
LOBBY_OPEN_TO_EVERYONE -> return "lobby_timer_reached"
|
||||
GUESTS_ALLOWED -> return "guests_allowed"
|
||||
GUESTS_DISALLOWED -> return "guests_disallowed"
|
||||
PASSWORD_SET -> return "password_set"
|
||||
PASSWORD_REMOVED -> return "password_removed"
|
||||
USER_ADDED -> return "user_added"
|
||||
USER_REMOVED -> return "user_removed"
|
||||
GROUP_ADDED -> return "group_added"
|
||||
GROUP_REMOVED -> return "group_removed"
|
||||
CIRCLE_ADDED -> return "circle_added"
|
||||
CIRCLE_REMOVED -> return "circle_removed"
|
||||
MODERATOR_PROMOTED -> return "moderator_promoted"
|
||||
MODERATOR_DEMOTED -> return "moderator_demoted"
|
||||
GUEST_MODERATOR_PROMOTED -> return "guest_moderator_promoted"
|
||||
GUEST_MODERATOR_DEMOTED -> return "guest_moderator_demoted"
|
||||
MESSAGE_DELETED -> return "message_deleted"
|
||||
FILE_SHARED -> return "file_shared"
|
||||
OBJECT_SHARED -> return "object_shared"
|
||||
MATTERBRIDGE_CONFIG_ADDED -> return "matterbridge_config_added"
|
||||
MATTERBRIDGE_CONFIG_EDITED -> return "matterbridge_config_edited"
|
||||
MATTERBRIDGE_CONFIG_REMOVED -> return "matterbridge_config_removed"
|
||||
MATTERBRIDGE_CONFIG_ENABLED -> return "matterbridge_config_enabled"
|
||||
MATTERBRIDGE_CONFIG_DISABLED -> return "matterbridge_config_disabled"
|
||||
CLEARED_CHAT -> return "clear_history"
|
||||
REACTION -> return "reaction"
|
||||
REACTION_DELETED -> return "reaction_deleted"
|
||||
REACTION_REVOKED -> return "reaction_revoked"
|
||||
POLL_VOTED -> return "poll_voted"
|
||||
POLL_CLOSED -> return "poll_closed"
|
||||
else -> return ""
|
||||
return when (`object`) {
|
||||
null -> ""
|
||||
CONVERSATION_CREATED -> "conversation_created"
|
||||
CONVERSATION_RENAMED -> "conversation_renamed"
|
||||
DESCRIPTION_REMOVED -> "description_removed"
|
||||
DESCRIPTION_SET -> "description_set"
|
||||
CALL_STARTED -> "call_started"
|
||||
CALL_JOINED -> "call_joined"
|
||||
CALL_LEFT -> "call_left"
|
||||
CALL_ENDED -> "call_ended"
|
||||
CALL_ENDED_EVERYONE -> "call_ended_everyone"
|
||||
CALL_MISSED -> "call_missed"
|
||||
CALL_TRIED -> "call_tried"
|
||||
READ_ONLY_OFF -> "read_only_off"
|
||||
READ_ONLY -> "read_only"
|
||||
LISTABLE_NONE -> "listable_none"
|
||||
LISTABLE_USERS -> "listable_users"
|
||||
LISTABLE_ALL -> "listable_all"
|
||||
LOBBY_NONE -> "lobby_none"
|
||||
LOBBY_NON_MODERATORS -> "lobby_non_moderators"
|
||||
LOBBY_OPEN_TO_EVERYONE -> "lobby_timer_reached"
|
||||
GUESTS_ALLOWED -> "guests_allowed"
|
||||
GUESTS_DISALLOWED -> "guests_disallowed"
|
||||
PASSWORD_SET -> "password_set"
|
||||
PASSWORD_REMOVED -> "password_removed"
|
||||
USER_ADDED -> "user_added"
|
||||
USER_REMOVED -> "user_removed"
|
||||
GROUP_ADDED -> "group_added"
|
||||
GROUP_REMOVED -> "group_removed"
|
||||
CIRCLE_ADDED -> "circle_added"
|
||||
CIRCLE_REMOVED -> "circle_removed"
|
||||
MODERATOR_PROMOTED -> "moderator_promoted"
|
||||
MODERATOR_DEMOTED -> "moderator_demoted"
|
||||
GUEST_MODERATOR_PROMOTED -> "guest_moderator_promoted"
|
||||
GUEST_MODERATOR_DEMOTED -> "guest_moderator_demoted"
|
||||
MESSAGE_DELETED -> "message_deleted"
|
||||
FILE_SHARED -> "file_shared"
|
||||
OBJECT_SHARED -> "object_shared"
|
||||
MATTERBRIDGE_CONFIG_ADDED -> "matterbridge_config_added"
|
||||
MATTERBRIDGE_CONFIG_EDITED -> "matterbridge_config_edited"
|
||||
MATTERBRIDGE_CONFIG_REMOVED -> "matterbridge_config_removed"
|
||||
MATTERBRIDGE_CONFIG_ENABLED -> "matterbridge_config_enabled"
|
||||
MATTERBRIDGE_CONFIG_DISABLED -> "matterbridge_config_disabled"
|
||||
CLEARED_CHAT -> "clear_history"
|
||||
REACTION -> "reaction"
|
||||
REACTION_DELETED -> "reaction_deleted"
|
||||
REACTION_REVOKED -> "reaction_revoked"
|
||||
POLL_VOTED -> "poll_voted"
|
||||
POLL_CLOSED -> "poll_closed"
|
||||
else -> ""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -318,7 +318,7 @@ class ShowReactionsDialog(
|
|||
val reactionVote1Active = activeUser == actorId1
|
||||
val reactionVote2Active = activeUser == actorId2
|
||||
|
||||
if (!reactionVote1Active && !reactionVote2Active || reactionVote1Active && reactionVote2Active) {
|
||||
if (reactionVote1Active == reactionVote2Active) {
|
||||
return 0
|
||||
}
|
||||
|
||||
|
|
|
@ -122,16 +122,12 @@ object AccountUtils {
|
|||
PackageManager.GET_SIGNATURES
|
||||
).signatures
|
||||
|
||||
if (Arrays.equals(ownSignatures, filesAppSignatures)) {
|
||||
return if (Arrays.equals(ownSignatures, filesAppSignatures)) {
|
||||
val accMgr = AccountManager.get(context)
|
||||
val accounts = accMgr.getAccountsByType(context.getString(R.string.nc_import_account_type))
|
||||
for (account in accounts) {
|
||||
if (account.name == accountName) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
accounts.any { it.name == accountName }
|
||||
} else {
|
||||
return true
|
||||
true
|
||||
}
|
||||
}
|
||||
} catch (appNotFoundException: PackageManager.NameNotFoundException) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
build:
|
||||
maxIssues: 84
|
||||
maxIssues: 77
|
||||
weights:
|
||||
# complexity: 2
|
||||
# LongParameterList: 1
|
||||
|
|
Loading…
Reference in a new issue