From 02e342849fa9af94044a60e9df4e6faf826bc705 Mon Sep 17 00:00:00 2001 From: Dominic Fischer Date: Sun, 21 Jul 2019 23:23:56 +0100 Subject: [PATCH] Remove most usages of the java.util package Signed-off-by: Dominic Fischer --- .../android/internal/crypto/CryptoStoreHelper.kt | 4 ++-- .../api/comparators/DatedObjectComparators.kt | 1 - .../android/api/extensions/MatrixSdkExtensions.kt | 2 +- .../api/pushrules/RoomMemberCountCondition.kt | 12 ++++-------- .../android/api/session/pushers/PushersService.kt | 2 +- .../session/room/model/create/CreateRoomParams.kt | 5 ++--- .../matrix/android/api/util/SecretStoringUtils.kt | 2 +- .../matrix/android/internal/crypto/ObjectSigner.kt | 1 - .../crypto/algorithms/olm/MXOlmDecryption.kt | 1 - .../crypto/attachments/MXEncryptedAttachments.kt | 4 +--- .../android/internal/crypto/keysbackup/KeysBackup.kt | 6 ++---- .../internal/crypto/keysbackup/KeysBackupPassword.kt | 2 +- .../crypto/keysbackup/KeysBackupStateManager.kt | 1 - .../android/internal/crypto/model/MXDeviceInfo.kt | 1 - .../matrix/android/internal/crypto/model/MXKey.kt | 1 - .../internal/crypto/model/MXUsersDevicesMap.kt | 1 - .../internal/crypto/tasks/SendToDeviceTask.kt | 4 ++-- .../verification/DefaultSasVerificationService.kt | 2 +- .../android/internal/database/mapper/EventMapper.kt | 1 - .../internal/database/mapper/RoomSummaryMapper.kt | 2 +- .../android/internal/database/model/EventEntity.kt | 1 - .../matrix/android/internal/network/ssl/CertUtil.kt | 1 - .../android/internal/network/ssl/TLSSocketFactory.kt | 1 - .../content/DefaultContentUploadStateTracker.kt | 3 +-- .../internal/session/pushers/DefaultPusherService.kt | 2 +- .../session/room/send/LocalEchoEventFactory.kt | 2 +- .../android/internal/session/sync/RoomTagHandler.kt | 1 - .../matrix/android/internal/util/CancelableWork.kt | 2 +- .../matrix/android/internal/util/CompatUtil.kt | 2 +- .../android/internal/util/JsonCanonicalizer.kt | 2 +- 30 files changed, 25 insertions(+), 47 deletions(-) diff --git a/matrix-sdk-android/src/androidTest/java/im/vector/matrix/android/internal/crypto/CryptoStoreHelper.kt b/matrix-sdk-android/src/androidTest/java/im/vector/matrix/android/internal/crypto/CryptoStoreHelper.kt index cea612dd92..c0fc6c4454 100644 --- a/matrix-sdk-android/src/androidTest/java/im/vector/matrix/android/internal/crypto/CryptoStoreHelper.kt +++ b/matrix-sdk-android/src/androidTest/java/im/vector/matrix/android/internal/crypto/CryptoStoreHelper.kt @@ -21,7 +21,7 @@ import im.vector.matrix.android.internal.crypto.store.IMXCryptoStore import im.vector.matrix.android.internal.crypto.store.db.RealmCryptoStore import im.vector.matrix.android.internal.crypto.store.db.RealmCryptoStoreModule import io.realm.RealmConfiguration -import java.util.* +import kotlin.random.Random internal class CryptoStoreHelper { @@ -35,7 +35,7 @@ internal class CryptoStoreHelper { } fun createCredential() = Credentials( - userId = "userId_" + Random().nextInt(), + userId = "userId_" + Random.nextInt(), homeServer = "http://matrix.org", accessToken = "access_token", refreshToken = null, diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/comparators/DatedObjectComparators.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/comparators/DatedObjectComparators.kt index aad33ab7b9..c9245e7331 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/comparators/DatedObjectComparators.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/comparators/DatedObjectComparators.kt @@ -17,7 +17,6 @@ package im.vector.matrix.android.api.comparators import im.vector.matrix.android.api.interfaces.DatedObject -import java.util.* object DatedObjectComparators { diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/extensions/MatrixSdkExtensions.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/extensions/MatrixSdkExtensions.kt index e2e53904ff..180d80c5c5 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/extensions/MatrixSdkExtensions.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/extensions/MatrixSdkExtensions.kt @@ -19,7 +19,7 @@ package im.vector.matrix.android.api.extensions import im.vector.matrix.android.api.comparators.DatedObjectComparators import im.vector.matrix.android.internal.crypto.model.MXDeviceInfo import im.vector.matrix.android.internal.crypto.model.rest.DeviceInfo -import java.util.* +import java.util.Collections /* ========================================================================================== * MXDeviceInfo diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/pushrules/RoomMemberCountCondition.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/pushrules/RoomMemberCountCondition.kt index b2bed4c230..1c02d63d76 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/pushrules/RoomMemberCountCondition.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/pushrules/RoomMemberCountCondition.kt @@ -18,9 +18,8 @@ package im.vector.matrix.android.api.pushrules import im.vector.matrix.android.api.session.events.model.Event import im.vector.matrix.android.api.session.room.RoomService import timber.log.Timber -import java.util.regex.Pattern -private val regex = Pattern.compile("^(==|<=|>=|<|>)?(\\d*)$") +private val regex = Regex("^(==|<=|>=|<|>)?(\\d*)$") class RoomMemberCountCondition(val `is`: String) : Condition(Kind.room_member_count) { @@ -56,12 +55,9 @@ class RoomMemberCountCondition(val `is`: String) : Condition(Kind.room_member_co */ private fun parseIsField(): Pair? { try { - val match = regex.matcher(`is`) - if (match.find()) { - val prefix = match.group(1) - val count = match.group(2).toInt() - return prefix to count - } + val match = regex.find(`is`) ?: return null + val (prefix, count) = match.destructured + return prefix to count.toInt() } catch (t: Throwable) { Timber.d(t) } diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/pushers/PushersService.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/pushers/PushersService.kt index 1450dbb500..c905490432 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/pushers/PushersService.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/pushers/PushersService.kt @@ -17,7 +17,7 @@ package im.vector.matrix.android.api.session.pushers import androidx.lifecycle.LiveData import im.vector.matrix.android.api.MatrixCallback -import java.util.* +import java.util.UUID interface PushersService { diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/create/CreateRoomParams.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/create/CreateRoomParams.kt index 77c4fcf1e2..7fd4d109f6 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/create/CreateRoomParams.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/create/CreateRoomParams.kt @@ -29,7 +29,6 @@ import im.vector.matrix.android.api.session.room.model.PowerLevels import im.vector.matrix.android.api.session.room.model.RoomDirectoryVisibility import im.vector.matrix.android.api.session.room.model.RoomHistoryVisibility import im.vector.matrix.android.internal.auth.data.ThreePidMedium -import java.util.* /** * Parameter to create a room, with facilities functions to configure it @@ -133,7 +132,7 @@ class CreateRoomParams { ) if (null == initialStates) { - initialStates = Arrays.asList(algoEvent) + initialStates = mutableListOf(algoEvent) } else { initialStates!!.add(algoEvent) } @@ -166,7 +165,7 @@ class CreateRoomParams { content = contentMap.toContent()) if (null == initialStates) { - initialStates = Arrays.asList(historyVisibilityEvent) + initialStates = mutableListOf(historyVisibilityEvent) } else { initialStates!!.add(historyVisibilityEvent) } diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/util/SecretStoringUtils.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/util/SecretStoringUtils.kt index 6dc0d789cc..7b66f7585b 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/util/SecretStoringUtils.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/util/SecretStoringUtils.kt @@ -27,7 +27,7 @@ import java.math.BigInteger import java.security.KeyPairGenerator import java.security.KeyStore import java.security.SecureRandom -import java.util.* +import java.util.Calendar import javax.crypto.* import javax.crypto.spec.GCMParameterSpec import javax.crypto.spec.IvParameterSpec diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/ObjectSigner.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/ObjectSigner.kt index 7b8e01994c..ebed85aedf 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/ObjectSigner.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/ObjectSigner.kt @@ -18,7 +18,6 @@ package im.vector.matrix.android.internal.crypto import im.vector.matrix.android.api.auth.data.Credentials import im.vector.matrix.android.internal.session.SessionScope -import java.util.* import javax.inject.Inject internal class ObjectSigner @Inject constructor(private val credentials: Credentials, diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/algorithms/olm/MXOlmDecryption.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/algorithms/olm/MXOlmDecryption.kt index 7b5a8cd498..0a0a158c56 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/algorithms/olm/MXOlmDecryption.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/algorithms/olm/MXOlmDecryption.kt @@ -32,7 +32,6 @@ import im.vector.matrix.android.internal.crypto.model.event.OlmPayloadContent import im.vector.matrix.android.internal.di.MoshiProvider import im.vector.matrix.android.internal.util.convertFromUTF8 import timber.log.Timber -import java.util.* internal class MXOlmDecryption( // The olm device interface diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/attachments/MXEncryptedAttachments.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/attachments/MXEncryptedAttachments.kt index d8c627097d..86ef488eac 100755 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/attachments/MXEncryptedAttachments.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/attachments/MXEncryptedAttachments.kt @@ -26,7 +26,6 @@ import java.io.ByteArrayOutputStream import java.io.InputStream import java.security.MessageDigest import java.security.SecureRandom -import java.util.* import javax.crypto.Cipher import javax.crypto.spec.IvParameterSpec import javax.crypto.spec.SecretKeySpec @@ -59,8 +58,7 @@ object MXEncryptedAttachments { // Half of the IV is random, the lower order bits are zeroed // such that the counter never wraps. // See https://github.com/matrix-org/matrix-ios-kit/blob/3dc0d8e46b4deb6669ed44f72ad79be56471354c/MatrixKit/Models/Room/MXEncryptedAttachments.m#L75 - val initVectorBytes = ByteArray(16) - Arrays.fill(initVectorBytes, 0.toByte()) + val initVectorBytes = ByteArray(16) { 0.toByte() } val ivRandomPart = ByteArray(8) secureRandom.nextBytes(ivRandomPart) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/keysbackup/KeysBackup.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/keysbackup/KeysBackup.kt index 88d9aec97f..5a4783c492 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/keysbackup/KeysBackup.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/keysbackup/KeysBackup.kt @@ -67,9 +67,9 @@ import org.matrix.olm.OlmPkEncryption import org.matrix.olm.OlmPkMessage import timber.log.Timber import java.security.InvalidParameterException -import java.util.* import javax.inject.Inject import kotlin.collections.HashMap +import kotlin.random.Random /** * A KeysBackup class instance manage incremental backup of e2e keys (megolm keys) @@ -115,8 +115,6 @@ internal class KeysBackup @Inject constructor( // The backup key being used. private var backupOlmPkEncryption: OlmPkEncryption? = null - private val random = Random() - private var backupAllGroupSessionsCallback: MatrixCallback? = null private var keysBackupStateListener: KeysBackupStateListener? = null @@ -842,7 +840,7 @@ internal class KeysBackup @Inject constructor( // Wait between 0 and 10 seconds, to avoid backup requests from // different clients hitting the server all at the same time when a // new key is sent - val delayInMs = random.nextInt(KEY_BACKUP_WAITING_TIME_TO_SEND_KEY_BACKUP_MILLIS).toLong() + val delayInMs = Random.nextInt(KEY_BACKUP_WAITING_TIME_TO_SEND_KEY_BACKUP_MILLIS).toLong() uiHandler.postDelayed({ backupKeys() }, delayInMs) } diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/keysbackup/KeysBackupPassword.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/keysbackup/KeysBackupPassword.kt index 51346c8993..12c618d032 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/keysbackup/KeysBackupPassword.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/keysbackup/KeysBackupPassword.kt @@ -22,7 +22,7 @@ package im.vector.matrix.android.internal.crypto.keysbackup import androidx.annotation.WorkerThread import im.vector.matrix.android.api.listeners.ProgressListener import timber.log.Timber -import java.util.* +import java.util.UUID import javax.crypto.Mac import javax.crypto.spec.SecretKeySpec import kotlin.experimental.xor diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/keysbackup/KeysBackupStateManager.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/keysbackup/KeysBackupStateManager.kt index ff812e75c0..cd74d04a67 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/keysbackup/KeysBackupStateManager.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/keysbackup/KeysBackupStateManager.kt @@ -20,7 +20,6 @@ import android.os.Handler import im.vector.matrix.android.api.session.crypto.keysbackup.KeysBackupState import im.vector.matrix.android.api.session.crypto.keysbackup.KeysBackupStateListener import timber.log.Timber -import java.util.* internal class KeysBackupStateManager(private val uiHandler: Handler) { diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/MXDeviceInfo.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/MXDeviceInfo.kt index a458cdfe03..36d6785e41 100755 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/MXDeviceInfo.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/MXDeviceInfo.kt @@ -23,7 +23,6 @@ import com.squareup.moshi.JsonClass import im.vector.matrix.android.api.util.JsonDict import im.vector.matrix.android.internal.crypto.model.rest.DeviceKeys import java.io.Serializable -import java.util.* @JsonClass(generateAdapter = true) data class MXDeviceInfo( diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/MXKey.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/MXKey.kt index db0f26528b..7fd48f8bb8 100755 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/MXKey.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/MXKey.kt @@ -18,7 +18,6 @@ package im.vector.matrix.android.internal.crypto.model import im.vector.matrix.android.api.util.JsonDict import timber.log.Timber -import java.util.* data class MXKey( /** diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/MXUsersDevicesMap.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/MXUsersDevicesMap.kt index a4b6e247a6..d3c76a1430 100755 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/MXUsersDevicesMap.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/MXUsersDevicesMap.kt @@ -16,7 +16,6 @@ package im.vector.matrix.android.internal.crypto.model -import java.util.* class MXUsersDevicesMap { diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/tasks/SendToDeviceTask.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/tasks/SendToDeviceTask.kt index 27559f7422..36fa3701fe 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/tasks/SendToDeviceTask.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/tasks/SendToDeviceTask.kt @@ -23,8 +23,8 @@ import im.vector.matrix.android.internal.crypto.model.rest.SendToDeviceBody import im.vector.matrix.android.internal.network.executeRequest import im.vector.matrix.android.internal.session.SessionScope import im.vector.matrix.android.internal.task.Task -import java.util.* import javax.inject.Inject +import kotlin.random.Random internal interface SendToDeviceTask : Task { data class Params( @@ -47,7 +47,7 @@ internal class DefaultSendToDeviceTask @Inject constructor(private val cryptoApi return executeRequest { apiCall = cryptoApi.sendToDevice( params.eventType, - params.transactionId ?: Random().nextInt(Integer.MAX_VALUE).toString(), + params.transactionId ?: Random.nextInt(Integer.MAX_VALUE).toString(), sendToDeviceBody ) } diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/DefaultSasVerificationService.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/DefaultSasVerificationService.kt index 54a4e14dc8..ac30f0253b 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/DefaultSasVerificationService.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/DefaultSasVerificationService.kt @@ -43,7 +43,7 @@ import im.vector.matrix.android.internal.util.MatrixCoroutineDispatchers import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch import timber.log.Timber -import java.util.* +import java.util.UUID import javax.inject.Inject import kotlin.collections.HashMap diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/database/mapper/EventMapper.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/database/mapper/EventMapper.kt index 30346f789e..274a14ce0f 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/database/mapper/EventMapper.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/database/mapper/EventMapper.kt @@ -26,7 +26,6 @@ import im.vector.matrix.android.internal.crypto.algorithms.olm.OlmDecryptionResu import im.vector.matrix.android.internal.database.model.EventEntity import im.vector.matrix.android.internal.di.MoshiProvider import timber.log.Timber -import java.util.* internal object EventMapper { diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/database/mapper/RoomSummaryMapper.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/database/mapper/RoomSummaryMapper.kt index 5f946e4291..1411d70c31 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/database/mapper/RoomSummaryMapper.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/database/mapper/RoomSummaryMapper.kt @@ -22,7 +22,7 @@ import im.vector.matrix.android.api.session.room.model.RoomSummary import im.vector.matrix.android.api.session.room.model.tag.RoomTag import im.vector.matrix.android.internal.crypto.algorithms.olm.OlmDecryptionResult import im.vector.matrix.android.internal.database.model.RoomSummaryEntity -import java.util.* +import java.util.UUID import javax.inject.Inject internal class RoomSummaryMapper @Inject constructor( diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/database/model/EventEntity.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/database/model/EventEntity.kt index ab10297fe6..60344f60a4 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/database/model/EventEntity.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/database/model/EventEntity.kt @@ -25,7 +25,6 @@ import io.realm.RealmResults import io.realm.annotations.Index import io.realm.annotations.LinkingObjects import io.realm.annotations.PrimaryKey -import java.util.* internal open class EventEntity(@Index var eventId: String = "", @Index var roomId: String = "", diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/network/ssl/CertUtil.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/network/ssl/CertUtil.kt index 64e941a6ed..976cbde17d 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/network/ssl/CertUtil.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/network/ssl/CertUtil.kt @@ -24,7 +24,6 @@ import java.security.KeyStore import java.security.MessageDigest import java.security.cert.CertificateException import java.security.cert.X509Certificate -import java.util.* import javax.net.ssl.* import kotlin.experimental.and diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/network/ssl/TLSSocketFactory.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/network/ssl/TLSSocketFactory.kt index e249ed74c8..761a18c87a 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/network/ssl/TLSSocketFactory.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/network/ssl/TLSSocketFactory.kt @@ -25,7 +25,6 @@ import java.net.UnknownHostException import java.security.KeyManagementException import java.security.NoSuchAlgorithmException import java.security.SecureRandom -import java.util.* import javax.net.ssl.SSLContext import javax.net.ssl.SSLSocket import javax.net.ssl.SSLSocketFactory diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/content/DefaultContentUploadStateTracker.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/content/DefaultContentUploadStateTracker.kt index 4bb58fe74f..e44c8eb5ee 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/content/DefaultContentUploadStateTracker.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/content/DefaultContentUploadStateTracker.kt @@ -30,9 +30,8 @@ internal class DefaultContentUploadStateTracker @Inject constructor() : ContentU private val listeners = mutableMapOf>() override fun track(key: String, updateListener: ContentUploadStateTracker.UpdateListener) { - val listeners = listeners[key] ?: ArrayList() + val listeners = listeners.getOrPut(key) { ArrayList() } listeners.add(updateListener) - this.listeners[key] = listeners val currentState = states[key] ?: ContentUploadStateTracker.State.Idle mainHandler.post { updateListener.onUpdate(currentState) } } diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/pushers/DefaultPusherService.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/pushers/DefaultPusherService.kt index 5d9af0d34a..d4449fe168 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/pushers/DefaultPusherService.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/pushers/DefaultPusherService.kt @@ -33,7 +33,7 @@ import im.vector.matrix.android.internal.task.toConfigurableTask import im.vector.matrix.android.internal.worker.WorkManagerUtil import im.vector.matrix.android.internal.worker.WorkManagerUtil.matrixOneTimeWorkRequestBuilder import im.vector.matrix.android.internal.worker.WorkerParamsFactory -import java.util.* +import java.util.UUID import java.util.concurrent.TimeUnit import javax.inject.Inject diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/send/LocalEchoEventFactory.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/send/LocalEchoEventFactory.kt index c6b6864704..12d747fe33 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/send/LocalEchoEventFactory.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/send/LocalEchoEventFactory.kt @@ -39,7 +39,7 @@ import im.vector.matrix.android.internal.util.StringProvider import im.vector.matrix.android.internal.util.tryTransactionAsync import org.commonmark.parser.Parser import org.commonmark.renderer.html.HtmlRenderer -import java.util.* +import java.util.UUID import javax.inject.Inject /** diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/sync/RoomTagHandler.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/sync/RoomTagHandler.kt index 49038eed3d..85f4ce7849 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/sync/RoomTagHandler.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/sync/RoomTagHandler.kt @@ -22,7 +22,6 @@ import im.vector.matrix.android.internal.database.model.RoomTagEntity import im.vector.matrix.android.internal.database.query.where import im.vector.matrix.android.internal.session.SessionScope import io.realm.Realm -import java.util.* import javax.inject.Inject internal class RoomTagHandler @Inject constructor() { diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/util/CancelableWork.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/util/CancelableWork.kt index ebd20ec6e1..ddaeb1fd9d 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/util/CancelableWork.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/util/CancelableWork.kt @@ -19,7 +19,7 @@ package im.vector.matrix.android.internal.util import android.content.Context import androidx.work.WorkManager import im.vector.matrix.android.api.util.Cancelable -import java.util.* +import java.util.UUID internal class CancelableWork(private val context: Context, private val workId: UUID) : Cancelable { diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/util/CompatUtil.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/util/CompatUtil.kt index e713c4357e..d0a5f2f82f 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/util/CompatUtil.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/util/CompatUtil.kt @@ -34,7 +34,7 @@ import java.security.* import java.security.cert.CertificateException import java.security.spec.AlgorithmParameterSpec import java.security.spec.RSAKeyGenParameterSpec -import java.util.* +import java.util.Calendar import java.util.zip.GZIPOutputStream import javax.crypto.* import javax.crypto.spec.GCMParameterSpec diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/util/JsonCanonicalizer.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/util/JsonCanonicalizer.kt index 36c1ba1553..d8f059f43b 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/util/JsonCanonicalizer.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/util/JsonCanonicalizer.kt @@ -22,7 +22,7 @@ import org.json.JSONArray import org.json.JSONException import org.json.JSONObject import timber.log.Timber -import java.util.* +import java.util.TreeSet /** * Build canonical Json