From 3dc5ef54abf002c910e8c9826133fd54efee11e2 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Tue, 22 Oct 2019 12:21:50 +0200 Subject: [PATCH] Fix compilation warnings --- .../matrix/android/api/session/events/model/Event.kt | 2 +- .../crypto/algorithms/megolm/MXMegolmDecryption.kt | 7 ------- .../internal/crypto/algorithms/olm/MXOlmEncryption.kt | 2 +- .../src/main/java/im/vector/riotx/core/utils/FileUtils.kt | 2 +- .../features/settings/VectorSettingsGeneralFragment.kt | 6 ++---- 5 files changed, 5 insertions(+), 14 deletions(-) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/events/model/Event.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/events/model/Event.kt index 7aea73233d..bc6885eddc 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/events/model/Event.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/events/model/Event.kt @@ -134,7 +134,7 @@ data class Event( } fun toContentStringWithIndent(): String { - val contentMap = toContent()?.toMutableMap() ?: HashMap() + val contentMap = toContent().toMutableMap() return JSONObject(contentMap).toString(4) } diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/algorithms/megolm/MXMegolmDecryption.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/algorithms/megolm/MXMegolmDecryption.kt index 6ffaf776b2..0230141e1b 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/algorithms/megolm/MXMegolmDecryption.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/algorithms/megolm/MXMegolmDecryption.kt @@ -244,13 +244,6 @@ internal class MXMegolmDecryption(private val userId: String, keysClaimed = event.getKeysClaimed().toMutableMap() } - if (roomKeyContent.sessionId == null - || roomKeyContent.sessionKey == null - || roomKeyContent.roomId == null) { - Timber.e("## invalid roomKeyContent") - return - } - val added = olmDevice.addInboundGroupSession(roomKeyContent.sessionId, roomKeyContent.sessionKey, roomKeyContent.roomId, diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/algorithms/olm/MXOlmEncryption.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/algorithms/olm/MXOlmEncryption.kt index b6d1b98546..1c275940af 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/algorithms/olm/MXOlmEncryption.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/algorithms/olm/MXOlmEncryption.kt @@ -66,7 +66,7 @@ internal class MXOlmEncryption( ) messageEncrypter.encryptMessage(messageMap, deviceInfos) - return messageMap.toContent()!! + return messageMap.toContent() } /** diff --git a/vector/src/main/java/im/vector/riotx/core/utils/FileUtils.kt b/vector/src/main/java/im/vector/riotx/core/utils/FileUtils.kt index 0009fd46f9..1a19b49872 100644 --- a/vector/src/main/java/im/vector/riotx/core/utils/FileUtils.kt +++ b/vector/src/main/java/im/vector/riotx/core/utils/FileUtils.kt @@ -126,7 +126,7 @@ fun getFileExtension(fileUri: String): String? { * Size * ========================================================================================== */ -fun getSizeOfFiles(context: Context, root: File): Int { +fun getSizeOfFiles(root: File): Int { return root.walkTopDown() .onEnter { Timber.v("Get size of ${it.absolutePath}") diff --git a/vector/src/main/java/im/vector/riotx/features/settings/VectorSettingsGeneralFragment.kt b/vector/src/main/java/im/vector/riotx/features/settings/VectorSettingsGeneralFragment.kt index 7ad7ba5ce1..331b6e935a 100644 --- a/vector/src/main/java/im/vector/riotx/features/settings/VectorSettingsGeneralFragment.kt +++ b/vector/src/main/java/im/vector/riotx/features/settings/VectorSettingsGeneralFragment.kt @@ -185,8 +185,7 @@ class VectorSettingsGeneralFragment : VectorSettingsBaseFragment() { // clear medias cache findPreference(VectorPreferences.SETTINGS_CLEAR_MEDIA_CACHE_PREFERENCE_KEY)!!.let { - val size = getSizeOfFiles(requireContext(), - File(requireContext().cacheDir, DiskCache.Factory.DEFAULT_DISK_CACHE_DIR)) + val size = getSizeOfFiles(File(requireContext().cacheDir, DiskCache.Factory.DEFAULT_DISK_CACHE_DIR)) it.summary = TextUtils.formatFileSize(requireContext(), size.toLong()) @@ -203,8 +202,7 @@ class VectorSettingsGeneralFragment : VectorSettingsBaseFragment() { // On BG thread Glide.get(requireContext()).clearDiskCache() - newSize = getSizeOfFiles(requireContext(), - File(requireContext().cacheDir, DiskCache.Factory.DEFAULT_DISK_CACHE_DIR)) + newSize = getSizeOfFiles(File(requireContext().cacheDir, DiskCache.Factory.DEFAULT_DISK_CACHE_DIR)) } it.summary = TextUtils.formatFileSize(requireContext(), newSize.toLong())