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