From faeeec0e37a3893a863a58c7bf4f48ab7ae21e84 Mon Sep 17 00:00:00 2001 From: ganfra Date: Wed, 1 Jul 2020 12:10:12 +0200 Subject: [PATCH 01/19] Sync: fix liveState not initialized and add method to get current state without livedata --- .../java/im/vector/matrix/android/api/session/Session.kt | 6 ++++++ .../matrix/android/internal/session/DefaultSession.kt | 6 +++--- .../matrix/android/internal/session/sync/job/SyncService.kt | 2 +- .../matrix/android/internal/session/sync/job/SyncThread.kt | 4 +++- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/Session.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/Session.kt index b4f9afdbd4..5b0f24aed7 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/Session.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/Session.kt @@ -127,6 +127,12 @@ interface Session : */ fun getSyncStateLive(): LiveData + /** + * This method returns the current sync state. + * @return the current [SyncState]. + */ + fun getSyncState(): SyncState + /** * This methods return true if an initial sync has been processed */ diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/DefaultSession.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/DefaultSession.kt index 2172b4a05d..faea73c849 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/DefaultSession.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/DefaultSession.kt @@ -197,9 +197,9 @@ internal class DefaultSession @Inject constructor( eventBus.unregister(this) } - override fun getSyncStateLive(): LiveData { - return getSyncThread().liveState() - } + override fun getSyncStateLive() = getSyncThread().liveState() + + override fun getSyncState() = getSyncThread().currentState() override fun hasAlreadySynced(): Boolean { return syncTokenStore.getLastToken() != null diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/sync/job/SyncService.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/sync/job/SyncService.kt index 3643d65505..49adb1b507 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/sync/job/SyncService.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/sync/job/SyncService.kt @@ -104,7 +104,7 @@ abstract class SyncService : Service() { try { syncTask.execute(params) // Start sync if we were doing an initial sync and the syncThread is not launched yet - if (isInitialSync && session.getSyncStateLive().value == SyncState.Idle) { + if (isInitialSync && session.getSyncState() == SyncState.Idle) { val isForeground = !backgroundDetectionObserver.isInBackground session.startSync(isForeground) } diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/sync/job/SyncThread.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/sync/job/SyncThread.kt index d17294a967..45a478c749 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/sync/job/SyncThread.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/sync/job/SyncThread.kt @@ -51,7 +51,7 @@ internal class SyncThread @Inject constructor(private val syncTask: SyncTask, : Thread(), NetworkConnectivityChecker.Listener, BackgroundDetectionObserver.Listener { private var state: SyncState = SyncState.Idle - private var liveState = MutableLiveData() + private var liveState = MutableLiveData(state) private val lock = Object() private val syncScope = CoroutineScope(SupervisorJob()) private val debouncer = Debouncer(createUIHandler()) @@ -98,6 +98,8 @@ internal class SyncThread @Inject constructor(private val syncTask: SyncTask, lock.notify() } + fun currentState() = state + fun liveState(): LiveData { return liveState } From 693c9804147b63cff659fb5a97d5c5fa86a63357 Mon Sep 17 00:00:00 2001 From: ganfra Date: Wed, 1 Jul 2020 12:11:15 +0200 Subject: [PATCH 02/19] Clean code --- .../im/vector/matrix/android/internal/session/DefaultSession.kt | 2 -- 1 file changed, 2 deletions(-) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/DefaultSession.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/DefaultSession.kt index faea73c849..5c5da997da 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/DefaultSession.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/DefaultSession.kt @@ -17,7 +17,6 @@ package im.vector.matrix.android.internal.session import androidx.annotation.MainThread -import androidx.lifecycle.LiveData import dagger.Lazy import im.vector.matrix.android.api.MatrixCallback import im.vector.matrix.android.api.auth.data.SessionParams @@ -45,7 +44,6 @@ import im.vector.matrix.android.api.session.securestorage.SecureStorageService import im.vector.matrix.android.api.session.securestorage.SharedSecretStorageService import im.vector.matrix.android.api.session.signout.SignOutService import im.vector.matrix.android.api.session.sync.FilterService -import im.vector.matrix.android.api.session.sync.SyncState import im.vector.matrix.android.api.session.terms.TermsService import im.vector.matrix.android.api.session.typing.TypingUsersTracker import im.vector.matrix.android.api.session.user.UserService From f86fa6cb5d9ddb32c3762d7da8de61f3d5922395 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Wed, 1 Jul 2020 09:48:03 +0200 Subject: [PATCH 03/19] Avoid Exception if array is empty. --- .../im/vector/matrix/android/internal/network/ssl/CertUtil.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 2346ff8877..36e40a16c7 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 @@ -239,12 +239,12 @@ internal object CertUtil { fun newConnectionSpecs(hsConfig: HomeServerConnectionConfig): List { val builder = ConnectionSpec.Builder(ConnectionSpec.MODERN_TLS) val tlsVersions = hsConfig.tlsVersions - if (null != tlsVersions) { + if (null != tlsVersions && tlsVersions.isNotEmpty()) { builder.tlsVersions(*tlsVersions.toTypedArray()) } val tlsCipherSuites = hsConfig.tlsCipherSuites - if (null != tlsCipherSuites) { + if (null != tlsCipherSuites && tlsCipherSuites.isNotEmpty()) { builder.cipherSuites(*tlsCipherSuites.toTypedArray()) } From b8b79de91c62d8748a319d1621067a1f930d369a Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Wed, 1 Jul 2020 11:54:03 +0200 Subject: [PATCH 04/19] PinnedTrustManager differ for API 24+ --- .../android/internal/network/ssl/CertUtil.kt | 2 +- .../network/ssl/PinnedTrustManager.kt | 28 ++- .../network/ssl/PinnedTrustManagerApi24.kt | 163 ++++++++++++++++++ .../network/ssl/PinnedTrustManagerProvider.kt | 41 +++++ 4 files changed, 217 insertions(+), 17 deletions(-) create mode 100644 matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/network/ssl/PinnedTrustManagerApi24.kt create mode 100644 matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/network/ssl/PinnedTrustManagerProvider.kt 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 36e40a16c7..4945afa93c 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 @@ -175,7 +175,7 @@ internal object CertUtil { } } - val trustPinned = arrayOf(PinnedTrustManager(hsConfig.allowedFingerprints, defaultTrustManager)) + val trustPinned = arrayOf(PinnedTrustManagerProvider.provide(hsConfig.allowedFingerprints, defaultTrustManager)) val sslSocketFactory: SSLSocketFactory diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/network/ssl/PinnedTrustManager.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/network/ssl/PinnedTrustManager.kt index de41d168fd..73bc3c7d57 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/network/ssl/PinnedTrustManager.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/network/ssl/PinnedTrustManager.kt @@ -27,26 +27,23 @@ import javax.net.ssl.X509TrustManager */ /** - * @param fingerprints An array of SHA256 cert fingerprints + * @param fingerprints Not empty array of SHA256 cert fingerprints * @param defaultTrustManager Optional trust manager to fall back on if cert does not match * any of the fingerprints. Can be null. */ -internal class PinnedTrustManager(private val fingerprints: List?, +internal class PinnedTrustManager(private val fingerprints: List, private val defaultTrustManager: X509TrustManager?) : X509TrustManager { - // Set to false to perform some test - private val USE_DEFAULT_TRUST_MANAGER = true - @Throws(CertificateException::class) override fun checkClientTrusted(chain: Array, s: String) { try { - if (defaultTrustManager != null && USE_DEFAULT_TRUST_MANAGER) { + if (defaultTrustManager != null) { defaultTrustManager.checkClientTrusted(chain, s) return } } catch (e: CertificateException) { // If there is an exception we fall back to checking fingerprints - if (fingerprints.isNullOrEmpty()) { + if (fingerprints.isEmpty()) { throw UnrecognizedCertificateException(chain[0], Fingerprint.newSha256Fingerprint(chain[0]), e.cause) } } @@ -57,13 +54,13 @@ internal class PinnedTrustManager(private val fingerprints: List?, @Throws(CertificateException::class) override fun checkServerTrusted(chain: Array, s: String) { try { - if (defaultTrustManager != null && USE_DEFAULT_TRUST_MANAGER) { + if (defaultTrustManager != null) { defaultTrustManager.checkServerTrusted(chain, s) return } } catch (e: CertificateException) { // If there is an exception we fall back to checking fingerprints - if (fingerprints == null || fingerprints.isEmpty()) { + if (fingerprints.isEmpty()) { throw UnrecognizedCertificateException(chain[0], Fingerprint.newSha256Fingerprint(chain[0]), e.cause /* BMA: Shouldn't be `e` ? */) } } @@ -76,12 +73,11 @@ internal class PinnedTrustManager(private val fingerprints: List?, val cert = chain[0] var found = false - if (fingerprints != null) { - for (allowedFingerprint in fingerprints) { - if (allowedFingerprint.matchesCert(cert)) { - found = true - break - } + + for (allowedFingerprint in fingerprints) { + if (allowedFingerprint.matchesCert(cert)) { + found = true + break } } @@ -91,6 +87,6 @@ internal class PinnedTrustManager(private val fingerprints: List?, } override fun getAcceptedIssuers(): Array { - return emptyArray() + return defaultTrustManager?.acceptedIssuers ?: emptyArray() } } diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/network/ssl/PinnedTrustManagerApi24.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/network/ssl/PinnedTrustManagerApi24.kt new file mode 100644 index 0000000000..4cdae14f25 --- /dev/null +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/network/ssl/PinnedTrustManagerApi24.kt @@ -0,0 +1,163 @@ +/* + * Copyright (c) 2020 New Vector Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package im.vector.matrix.android.internal.network.ssl + +import android.os.Build +import androidx.annotation.RequiresApi +import java.net.Socket +import java.security.cert.CertificateException +import java.security.cert.X509Certificate +import javax.net.ssl.SSLEngine +import javax.net.ssl.X509ExtendedTrustManager + +/** + * Implements a TrustManager that checks Certificates against an explicit list of known + * fingerprints. + */ + +/** + * @param fingerprints An array of SHA256 cert fingerprints + * @param defaultTrustManager Optional trust manager to fall back on if cert does not match + * any of the fingerprints. Can be null. + */ +@RequiresApi(Build.VERSION_CODES.N) +internal class PinnedTrustManagerApi24(private val fingerprints: List, + private val defaultTrustManager: X509ExtendedTrustManager?) : X509ExtendedTrustManager() { + + @Throws(CertificateException::class) + override fun checkClientTrusted(chain: Array, authType: String, engine: SSLEngine?) { + try { + if (defaultTrustManager != null) { + defaultTrustManager.checkClientTrusted(chain, authType, engine) + return + } + } catch (e: CertificateException) { + // If there is an exception we fall back to checking fingerprints + if (fingerprints.isEmpty()) { + throw UnrecognizedCertificateException(chain[0], Fingerprint.newSha256Fingerprint(chain[0]), e.cause) + } + } + + checkTrusted(chain) + } + + @Throws(CertificateException::class) + override fun checkClientTrusted(chain: Array, authType: String, socket: Socket?) { + try { + if (defaultTrustManager != null) { + defaultTrustManager.checkClientTrusted(chain, authType, socket) + return + } + } catch (e: CertificateException) { + // If there is an exception we fall back to checking fingerprints + if (fingerprints.isEmpty()) { + throw UnrecognizedCertificateException(chain[0], Fingerprint.newSha256Fingerprint(chain[0]), e.cause) + } + } + + checkTrusted(chain) + } + + @Throws(CertificateException::class) + override fun checkClientTrusted(chain: Array, authType: String) { + try { + if (defaultTrustManager != null) { + defaultTrustManager.checkClientTrusted(chain, authType) + return + } + } catch (e: CertificateException) { + // If there is an exception we fall back to checking fingerprints + if (fingerprints.isEmpty()) { + throw UnrecognizedCertificateException(chain[0], Fingerprint.newSha256Fingerprint(chain[0]), e.cause) + } + } + + checkTrusted(chain) + } + + @Throws(CertificateException::class) + override fun checkServerTrusted(chain: Array, authType: String, socket: Socket?) { + try { + if (defaultTrustManager != null) { + defaultTrustManager.checkServerTrusted(chain, authType, socket) + return + } + } catch (e: CertificateException) { + // If there is an exception we fall back to checking fingerprints + if (fingerprints.isEmpty()) { + throw UnrecognizedCertificateException(chain[0], Fingerprint.newSha256Fingerprint(chain[0]), e.cause /* BMA: Shouldn't be `e` ? */) + } + } + + checkTrusted(chain) + } + + @Throws(CertificateException::class) + override fun checkServerTrusted(chain: Array, authType: String, engine: SSLEngine?) { + try { + if (defaultTrustManager != null) { + defaultTrustManager.checkServerTrusted(chain, authType, engine) + return + } + } catch (e: CertificateException) { + // If there is an exception we fall back to checking fingerprints + if (fingerprints.isEmpty()) { + throw UnrecognizedCertificateException(chain[0], Fingerprint.newSha256Fingerprint(chain[0]), e.cause /* BMA: Shouldn't be `e` ? */) + } + } + + checkTrusted(chain) + } + + @Throws(CertificateException::class) + override fun checkServerTrusted(chain: Array, s: String) { + try { + if (defaultTrustManager != null) { + defaultTrustManager.checkServerTrusted(chain, s) + return + } + } catch (e: CertificateException) { + // If there is an exception we fall back to checking fingerprints + if (fingerprints.isEmpty()) { + throw UnrecognizedCertificateException(chain[0], Fingerprint.newSha256Fingerprint(chain[0]), e.cause /* BMA: Shouldn't be `e` ? */) + } + } + + checkTrusted(chain) + } + + @Throws(CertificateException::class) + private fun checkTrusted(chain: Array) { + val cert = chain[0] + + var found = false + for (allowedFingerprint in fingerprints) { + if (allowedFingerprint.matchesCert(cert)) { + found = true + break + } + } + + if (!found) { + throw UnrecognizedCertificateException(cert, Fingerprint.newSha256Fingerprint(cert), null) + } + } + + override fun getAcceptedIssuers(): Array { + return defaultTrustManager?.acceptedIssuers ?: emptyArray() + } +} diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/network/ssl/PinnedTrustManagerProvider.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/network/ssl/PinnedTrustManagerProvider.kt new file mode 100644 index 0000000000..d47adbfd07 --- /dev/null +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/network/ssl/PinnedTrustManagerProvider.kt @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2020 New Vector Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package im.vector.matrix.android.internal.network.ssl + +import android.os.Build +import javax.net.ssl.X509ExtendedTrustManager +import javax.net.ssl.X509TrustManager + +internal object PinnedTrustManagerProvider { + // Set to false to perform some tests + private const val USE_DEFAULT_TRUST_MANAGER = true + + fun provide(fingerprints: List?, + defaultTrustManager: X509TrustManager?): X509TrustManager { + return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && defaultTrustManager is X509ExtendedTrustManager) { + PinnedTrustManagerApi24( + fingerprints.orEmpty(), + defaultTrustManager.takeIf { USE_DEFAULT_TRUST_MANAGER } + ) + } else { + PinnedTrustManager( + fingerprints.orEmpty(), + defaultTrustManager.takeIf { USE_DEFAULT_TRUST_MANAGER } + ) + } + } +} From 057f6fdf269fcb32b5f532c947217585ccf02b2c Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Wed, 1 Jul 2020 12:11:45 +0200 Subject: [PATCH 05/19] Kotlin style --- .../internal/network/ssl/PinnedTrustManager.kt | 11 +---------- .../internal/network/ssl/PinnedTrustManagerApi24.kt | 10 +--------- 2 files changed, 2 insertions(+), 19 deletions(-) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/network/ssl/PinnedTrustManager.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/network/ssl/PinnedTrustManager.kt index 73bc3c7d57..615358310f 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/network/ssl/PinnedTrustManager.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/network/ssl/PinnedTrustManager.kt @@ -72,16 +72,7 @@ internal class PinnedTrustManager(private val fingerprints: List, private fun checkTrusted(chain: Array) { val cert = chain[0] - var found = false - - for (allowedFingerprint in fingerprints) { - if (allowedFingerprint.matchesCert(cert)) { - found = true - break - } - } - - if (!found) { + if (!fingerprints.any { it.matchesCert(cert) }) { throw UnrecognizedCertificateException(cert, Fingerprint.newSha256Fingerprint(cert), null) } } diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/network/ssl/PinnedTrustManagerApi24.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/network/ssl/PinnedTrustManagerApi24.kt index 4cdae14f25..98257caefc 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/network/ssl/PinnedTrustManagerApi24.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/network/ssl/PinnedTrustManagerApi24.kt @@ -144,15 +144,7 @@ internal class PinnedTrustManagerApi24(private val fingerprints: List) { val cert = chain[0] - var found = false - for (allowedFingerprint in fingerprints) { - if (allowedFingerprint.matchesCert(cert)) { - found = true - break - } - } - - if (!found) { + if (!fingerprints.any { it.matchesCert(cert) }) { throw UnrecognizedCertificateException(cert, Fingerprint.newSha256Fingerprint(cert), null) } } From 9eab1acf1e6ed3441c89ea476f4f6134e36135fe Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Wed, 1 Jul 2020 13:55:34 +0200 Subject: [PATCH 06/19] Allow clear text communication (to use local synapse) --- .../im/vector/matrix/android/internal/network/ssl/CertUtil.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 4945afa93c..e375c3d364 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 @@ -252,7 +252,8 @@ internal object CertUtil { builder.supportsTlsExtensions(hsConfig.shouldAcceptTlsExtensions) val list = ArrayList() list.add(builder.build()) - if (hsConfig.allowHttpExtension) { + // TODO: we should display a warning if user enter an http url + if (hsConfig.allowHttpExtension || hsConfig.homeServerUri.toString().startsWith("http://")) { list.add(ConnectionSpec.CLEARTEXT) } return list From 53053d8f4a83af1663ef6d0742e4abfc9fec0bc1 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Wed, 1 Jul 2020 14:03:30 +0200 Subject: [PATCH 07/19] Fix layout overlap issue (#1407) --- CHANGES.md | 1 + vector/src/main/res/layout/item_form_switch.xml | 5 ++--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 207d04d6d0..0d59ad563b 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -21,6 +21,7 @@ Bugfix 🐛: - Use vendor prefix for non merged MSC (#1537) - Compress images before sending (#1333) - Searching by displayname is case sensitive (#1468) + - Fix layout overlap issue (#1407) Translations 🗣: - diff --git a/vector/src/main/res/layout/item_form_switch.xml b/vector/src/main/res/layout/item_form_switch.xml index 63004365dc..d4fdaae35c 100644 --- a/vector/src/main/res/layout/item_form_switch.xml +++ b/vector/src/main/res/layout/item_form_switch.xml @@ -30,13 +30,13 @@ @@ -46,7 +46,6 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginEnd="19dp" - android:layout_marginRight="19dp" app:layout_constraintBottom_toTopOf="@+id/formSwitchDivider" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintTop_toTopOf="parent" /> From f8e35da53300b0d57529439b0721cd68cf6b162a Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Wed, 1 Jul 2020 14:52:37 +0200 Subject: [PATCH 08/19] Render room avatar change (#1319) --- CHANGES.md | 1 + .../room/summary/RoomSummaryUpdater.kt | 1 + .../src/main/res/values/strings.xml | 4 ++++ .../action/MessageActionsViewModel.kt | 1 + .../timeline/factory/TimelineItemFactory.kt | 1 + .../timeline/format/NoticeEventFormatter.kt | 20 +++++++++++++++++++ .../helper/TimelineDisplayableEvents.kt | 1 + 7 files changed, 29 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 0d59ad563b..1bf0344f9d 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -13,6 +13,7 @@ Improvements 🙌: - Update user avatar (#1054) - Allow self-signed certificate (#1564) - Improve file download and open in timeline + - Render room avatar change (#1319) Bugfix 🐛: - Fix dark theme issue on login screen (#1097) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/summary/RoomSummaryUpdater.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/summary/RoomSummaryUpdater.kt index fad9938387..ea2948c11f 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/summary/RoomSummaryUpdater.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/summary/RoomSummaryUpdater.kt @@ -65,6 +65,7 @@ internal class RoomSummaryUpdater @Inject constructor( EventType.MESSAGE, EventType.STATE_ROOM_NAME, EventType.STATE_ROOM_TOPIC, + EventType.STATE_ROOM_AVATAR, EventType.STATE_ROOM_MEMBER, EventType.STATE_ROOM_HISTORY_VISIBILITY, EventType.CALL_INVITE, diff --git a/matrix-sdk-android/src/main/res/values/strings.xml b/matrix-sdk-android/src/main/res/values/strings.xml index 4e8e5abc96..9b7fa01eaf 100644 --- a/matrix-sdk-android/src/main/res/values/strings.xml +++ b/matrix-sdk-android/src/main/res/values/strings.xml @@ -37,6 +37,8 @@ You removed your display name (it was %1$s) %1$s changed the topic to: %2$s You changed the topic to: %1$s + %1$s changed the room avatar + You changed the room avatar %1$s changed the room name to: %2$s You changed the room name to: %1$s %s placed a video call. @@ -71,6 +73,8 @@ You removed the room name %1$s removed the room topic You removed the room topic + %1$s removed the room avatar + You removed the room avatar Message removed Message removed by %1$s Message removed [reason: %1$s] diff --git a/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/action/MessageActionsViewModel.kt b/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/action/MessageActionsViewModel.kt index 6c192105d7..a50d748f93 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/action/MessageActionsViewModel.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/action/MessageActionsViewModel.kt @@ -179,6 +179,7 @@ class MessageActionsViewModel @AssistedInject constructor(@Assisted } EventType.STATE_ROOM_NAME, EventType.STATE_ROOM_TOPIC, + EventType.STATE_ROOM_AVATAR, EventType.STATE_ROOM_MEMBER, EventType.STATE_ROOM_ALIASES, EventType.STATE_ROOM_CANONICAL_ALIAS, diff --git a/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/factory/TimelineItemFactory.kt b/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/factory/TimelineItemFactory.kt index 462caf8e97..22fd4eb5ec 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/factory/TimelineItemFactory.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/factory/TimelineItemFactory.kt @@ -48,6 +48,7 @@ class TimelineItemFactory @Inject constructor(private val messageItemFactory: Me EventType.STATE_ROOM_TOMBSTONE, EventType.STATE_ROOM_NAME, EventType.STATE_ROOM_TOPIC, + EventType.STATE_ROOM_AVATAR, EventType.STATE_ROOM_MEMBER, EventType.STATE_ROOM_ALIASES, EventType.STATE_ROOM_CANONICAL_ALIAS, diff --git a/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/format/NoticeEventFormatter.kt b/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/format/NoticeEventFormatter.kt index 89e170e25e..c1f4187e0b 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/format/NoticeEventFormatter.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/format/NoticeEventFormatter.kt @@ -24,6 +24,7 @@ import im.vector.matrix.android.api.session.room.model.GuestAccess import im.vector.matrix.android.api.session.room.model.Membership import im.vector.matrix.android.api.session.room.model.PowerLevelsContent import im.vector.matrix.android.api.session.room.model.RoomAliasesContent +import im.vector.matrix.android.api.session.room.model.RoomAvatarContent import im.vector.matrix.android.api.session.room.model.RoomCanonicalAliasContent import im.vector.matrix.android.api.session.room.model.RoomGuestAccessContent import im.vector.matrix.android.api.session.room.model.RoomHistoryVisibilityContent @@ -57,6 +58,7 @@ class NoticeEventFormatter @Inject constructor(private val sessionHolder: Active EventType.STATE_ROOM_CREATE -> formatRoomCreateEvent(timelineEvent.root) EventType.STATE_ROOM_NAME -> formatRoomNameEvent(timelineEvent.root, timelineEvent.senderInfo.disambiguatedDisplayName) EventType.STATE_ROOM_TOPIC -> formatRoomTopicEvent(timelineEvent.root, timelineEvent.senderInfo.disambiguatedDisplayName) + EventType.STATE_ROOM_AVATAR -> formatRoomAvatarEvent(timelineEvent.root, timelineEvent.senderInfo.disambiguatedDisplayName) EventType.STATE_ROOM_MEMBER -> formatRoomMemberEvent(timelineEvent.root, timelineEvent.senderInfo.disambiguatedDisplayName) EventType.STATE_ROOM_ALIASES -> formatRoomAliasesEvent(timelineEvent.root, timelineEvent.senderInfo.disambiguatedDisplayName) EventType.STATE_ROOM_CANONICAL_ALIAS -> formatRoomCanonicalAliasEvent(timelineEvent.root, timelineEvent.senderInfo.disambiguatedDisplayName) @@ -149,6 +151,7 @@ class NoticeEventFormatter @Inject constructor(private val sessionHolder: Active EventType.STATE_ROOM_JOIN_RULES -> formatJoinRulesEvent(event, senderName) EventType.STATE_ROOM_NAME -> formatRoomNameEvent(event, senderName) EventType.STATE_ROOM_TOPIC -> formatRoomTopicEvent(event, senderName) + EventType.STATE_ROOM_AVATAR -> formatRoomAvatarEvent(event, senderName) EventType.STATE_ROOM_MEMBER -> formatRoomMemberEvent(event, senderName) EventType.STATE_ROOM_HISTORY_VISIBILITY -> formatRoomHistoryVisibilityEvent(event, senderName) EventType.CALL_INVITE, @@ -220,6 +223,23 @@ class NoticeEventFormatter @Inject constructor(private val sessionHolder: Active } } + private fun formatRoomAvatarEvent(event: Event, senderName: String?): CharSequence? { + val content = event.getClearContent().toModel() ?: return null + return if (content.avatarUrl.isNullOrEmpty()) { + if (event.isSentByCurrentUser()) { + sp.getString(R.string.notice_room_avatar_removed_by_you) + } else { + sp.getString(R.string.notice_room_avatar_removed, senderName) + } + } else { + if (event.isSentByCurrentUser()) { + sp.getString(R.string.notice_room_avatar_changed_by_you) + } else { + sp.getString(R.string.notice_room_avatar_changed, senderName) + } + } + } + private fun formatRoomHistoryVisibilityEvent(event: Event, senderName: String?): CharSequence? { val historyVisibility = event.getClearContent().toModel()?.historyVisibility ?: return null diff --git a/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/helper/TimelineDisplayableEvents.kt b/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/helper/TimelineDisplayableEvents.kt index 882d8e8869..62a835ee8e 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/helper/TimelineDisplayableEvents.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/helper/TimelineDisplayableEvents.kt @@ -28,6 +28,7 @@ object TimelineDisplayableEvents { EventType.STATE_ROOM_WIDGET, EventType.STATE_ROOM_NAME, EventType.STATE_ROOM_TOPIC, + EventType.STATE_ROOM_AVATAR, EventType.STATE_ROOM_MEMBER, EventType.STATE_ROOM_ALIASES, EventType.STATE_ROOM_CANONICAL_ALIAS, From fb1c01c37cbe071f725d3f8153bdcc2d717652e7 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Wed, 1 Jul 2020 16:15:06 +0200 Subject: [PATCH 09/19] Catchup tab is removed temporarily (#1565) Invites are displayed in the corresponding DM or Room tab --- CHANGES.md | 1 + .../riotx/features/home/HomeDetailViewModel.kt | 18 +++++++++++------- .../riotx/features/home/HomeDetailViewState.kt | 2 +- .../room/list/RoomListDisplayModeFilter.kt | 4 ++-- .../vector/riotx/features/themes/ThemeUtils.kt | 1 + .../ui/SharedPreferencesUiStateRepository.kt | 2 +- .../main/res/menu/home_bottom_navigation.xml | 3 ++- 7 files changed, 19 insertions(+), 12 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 207d04d6d0..27cab631e7 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -13,6 +13,7 @@ Improvements 🙌: - Update user avatar (#1054) - Allow self-signed certificate (#1564) - Improve file download and open in timeline + - Catchup tab is removed temporarily (#1565) Bugfix 🐛: - Fix dark theme issue on login screen (#1097) diff --git a/vector/src/main/java/im/vector/riotx/features/home/HomeDetailViewModel.kt b/vector/src/main/java/im/vector/riotx/features/home/HomeDetailViewModel.kt index 3824ba7922..98bd3a76ab 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/HomeDetailViewModel.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/HomeDetailViewModel.kt @@ -117,8 +117,12 @@ class HomeDetailViewModel @AssistedInject constructor(@Assisted initialState: Ho .observeOn(Schedulers.computation()) .map { it.asSequence() } .subscribe { summaries -> - val invites = summaries - .filter { it.membership == Membership.INVITE } + val invitesDm = summaries + .filter { it.membership == Membership.INVITE && it.isDirect } + .count() + + val invitesRoom = summaries + .filter { it.membership == Membership.INVITE && it.isDirect.not() } .count() val peopleNotifications = summaries @@ -139,12 +143,12 @@ class HomeDetailViewModel @AssistedInject constructor(@Assisted initialState: Ho setState { copy( - notificationCountCatchup = peopleNotifications + roomsNotifications + invites, + notificationCountCatchup = peopleNotifications + roomsNotifications + invitesDm + invitesRoom, notificationHighlightCatchup = peopleHasHighlight || roomsHasHighlight, - notificationCountPeople = peopleNotifications, - notificationHighlightPeople = peopleHasHighlight, - notificationCountRooms = roomsNotifications, - notificationHighlightRooms = roomsHasHighlight + notificationCountPeople = peopleNotifications + invitesDm, + notificationHighlightPeople = peopleHasHighlight || invitesDm > 0, + notificationCountRooms = roomsNotifications + invitesRoom, + notificationHighlightRooms = roomsHasHighlight || invitesRoom > 0 ) } } diff --git a/vector/src/main/java/im/vector/riotx/features/home/HomeDetailViewState.kt b/vector/src/main/java/im/vector/riotx/features/home/HomeDetailViewState.kt index 1777fa03c1..a9a838195b 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/HomeDetailViewState.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/HomeDetailViewState.kt @@ -27,7 +27,7 @@ import im.vector.matrix.android.api.session.sync.SyncState data class HomeDetailViewState( val groupSummary: Option = Option.empty(), val asyncRooms: Async> = Uninitialized, - val displayMode: RoomListDisplayMode = RoomListDisplayMode.HOME, + val displayMode: RoomListDisplayMode = RoomListDisplayMode.PEOPLE, val notificationCountCatchup: Int = 0, val notificationHighlightCatchup: Boolean = false, val notificationCountPeople: Int = 0, diff --git a/vector/src/main/java/im/vector/riotx/features/home/room/list/RoomListDisplayModeFilter.kt b/vector/src/main/java/im/vector/riotx/features/home/room/list/RoomListDisplayModeFilter.kt index 9b5f74c9e6..3045987d01 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/room/list/RoomListDisplayModeFilter.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/room/list/RoomListDisplayModeFilter.kt @@ -30,8 +30,8 @@ class RoomListDisplayModeFilter(private val displayMode: RoomListDisplayMode) : return when (displayMode) { RoomListDisplayMode.HOME -> roomSummary.notificationCount > 0 || roomSummary.membership == Membership.INVITE || roomSummary.userDrafts.isNotEmpty() - RoomListDisplayMode.PEOPLE -> roomSummary.isDirect && roomSummary.membership == Membership.JOIN - RoomListDisplayMode.ROOMS -> !roomSummary.isDirect && roomSummary.membership == Membership.JOIN + RoomListDisplayMode.PEOPLE -> roomSummary.isDirect && roomSummary.membership.isActive() + RoomListDisplayMode.ROOMS -> !roomSummary.isDirect && roomSummary.membership.isActive() RoomListDisplayMode.FILTERED -> roomSummary.membership == Membership.JOIN } } diff --git a/vector/src/main/java/im/vector/riotx/features/themes/ThemeUtils.kt b/vector/src/main/java/im/vector/riotx/features/themes/ThemeUtils.kt index 4878134375..35f7e37f41 100644 --- a/vector/src/main/java/im/vector/riotx/features/themes/ThemeUtils.kt +++ b/vector/src/main/java/im/vector/riotx/features/themes/ThemeUtils.kt @@ -171,6 +171,7 @@ object ThemeUtils { * @param resourceId the resource id in the light theme * @return the resource Id for the current theme */ + // TODO Now that we are API 21, this is not necessary anymore fun getResourceId(c: Context, resourceId: Int): Int { val theme = getApplicationTheme(c) diff --git a/vector/src/main/java/im/vector/riotx/features/ui/SharedPreferencesUiStateRepository.kt b/vector/src/main/java/im/vector/riotx/features/ui/SharedPreferencesUiStateRepository.kt index 43761ee214..d1a4315cc9 100644 --- a/vector/src/main/java/im/vector/riotx/features/ui/SharedPreferencesUiStateRepository.kt +++ b/vector/src/main/java/im/vector/riotx/features/ui/SharedPreferencesUiStateRepository.kt @@ -36,7 +36,7 @@ class SharedPreferencesUiStateRepository @Inject constructor(private val sharedP return when (sharedPreferences.getInt(KEY_DISPLAY_MODE, VALUE_DISPLAY_MODE_CATCHUP)) { VALUE_DISPLAY_MODE_PEOPLE -> RoomListDisplayMode.PEOPLE VALUE_DISPLAY_MODE_ROOMS -> RoomListDisplayMode.ROOMS - else -> RoomListDisplayMode.HOME + else -> RoomListDisplayMode.PEOPLE // RoomListDisplayMode.HOME } } diff --git a/vector/src/main/res/menu/home_bottom_navigation.xml b/vector/src/main/res/menu/home_bottom_navigation.xml index f93a018436..aaf3203fe9 100644 --- a/vector/src/main/res/menu/home_bottom_navigation.xml +++ b/vector/src/main/res/menu/home_bottom_navigation.xml @@ -5,7 +5,8 @@ android:id="@+id/bottom_action_home" android:enabled="true" android:icon="@drawable/ic_home_bottom_catchup" - android:title="@string/bottom_action_home" /> + android:title="@string/bottom_action_home" + android:visible="false" /> Date: Wed, 1 Jul 2020 16:51:53 +0200 Subject: [PATCH 10/19] Clear dynamic shortcuts when user log out --- .../im/vector/riotx/features/MainActivity.kt | 5 ++++ .../riotx/features/home/ShortcutsHandler.kt | 26 +++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/vector/src/main/java/im/vector/riotx/features/MainActivity.kt b/vector/src/main/java/im/vector/riotx/features/MainActivity.kt index a9a0cee0d6..a5fa8fc4e4 100644 --- a/vector/src/main/java/im/vector/riotx/features/MainActivity.kt +++ b/vector/src/main/java/im/vector/riotx/features/MainActivity.kt @@ -32,6 +32,7 @@ import im.vector.riotx.core.extensions.startSyncing import im.vector.riotx.core.platform.VectorBaseActivity import im.vector.riotx.core.utils.deleteAllFiles import im.vector.riotx.features.home.HomeActivity +import im.vector.riotx.features.home.ShortcutsHandler import im.vector.riotx.features.login.LoginActivity import im.vector.riotx.features.notifications.NotificationDrawerManager import im.vector.riotx.features.settings.VectorPreferences @@ -82,6 +83,7 @@ class MainActivity : VectorBaseActivity() { @Inject lateinit var errorFormatter: ErrorFormatter @Inject lateinit var vectorPreferences: VectorPreferences @Inject lateinit var uiStateRepository: UiStateRepository + @Inject lateinit var shortcutsHandler: ShortcutsHandler override fun injectWith(injector: ScreenComponent) { injector.inject(this) @@ -105,6 +107,9 @@ class MainActivity : VectorBaseActivity() { // Dismiss all notifications notificationDrawerManager.clearAllEvents() notificationDrawerManager.persistInfo() + + // Also clear the dynamic shortcuts + shortcutsHandler.clearShortcuts() } private fun parseArgs(): MainActivityArgs { diff --git a/vector/src/main/java/im/vector/riotx/features/home/ShortcutsHandler.kt b/vector/src/main/java/im/vector/riotx/features/home/ShortcutsHandler.kt index 34f2b7bd76..805014a81e 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/ShortcutsHandler.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/ShortcutsHandler.kt @@ -17,6 +17,7 @@ package im.vector.riotx.features.home import android.content.Context +import android.content.pm.ShortcutManager import android.graphics.Bitmap import android.os.Build import androidx.core.content.pm.ShortcutInfoCompat @@ -26,6 +27,7 @@ import im.vector.matrix.android.api.util.toMatrixItem import im.vector.riotx.core.glide.GlideApp import im.vector.riotx.core.utils.DimensionConverter import im.vector.riotx.features.home.room.detail.RoomDetailActivity +import io.reactivex.Observable import io.reactivex.disposables.Disposable import io.reactivex.schedulers.Schedulers import javax.inject.Inject @@ -51,6 +53,11 @@ class ShortcutsHandler @Inject constructor( } fun observeRoomsAndBuildShortcuts(): Disposable { + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N_MR1) { + // No op + return Observable.empty().subscribe() + } + return homeRoomListStore .observe() .distinct() @@ -78,6 +85,25 @@ class ShortcutsHandler @Inject constructor( } } + fun clearShortcuts() { + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N_MR1) { + // No op + return + } + + ShortcutManagerCompat.removeAllDynamicShortcuts(context) + + // We can only disabled pinned shortcuts with the API, but at least it will prevent the crash + if (ShortcutManagerCompat.isRequestPinShortcutSupported(context)) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) { + context.getSystemService(ShortcutManager::class.java) + ?.let { + it.disableShortcuts(it.pinnedShortcuts.map { pinnedShortcut -> pinnedShortcut.id }) + } + } + } + } + // PRIVATE API ********************************************************************************* private fun Bitmap.toProfileImageIcon(): IconCompat { From 3e97e03cccffd0a78710d14ac0fa2506924e3137 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Wed, 1 Jul 2020 21:51:30 +0200 Subject: [PATCH 11/19] Prepare release Riot.imX v0.91.3 for the beta channel --- CHANGES.md | 14 +++++++------- vector/build.gradle | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 3a4ae5165f..ad3f82af9a 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,12 @@ -Changes in RiotX 0.23.0 (2020-XX-XX) +Changes in Riot.imX 0.91.3 (2020-07-01) =================================================== +Notes: + - This version is the third beta version of RiotX codebase published as Riot-Android on the PlayStore. + - Changelog below includes changes of v0.91.0, v0.91.1, and v0.91.2, because the first beta versions have been tagged and + published from the branch feature/migration_from_legacy. + - This version uses temporary name `Riot.imX`, to distinguish the app with RiotX app. + Features ✨: - Call with WebRTC support (##611) - Add capability to change the display name (#1529) @@ -25,12 +31,6 @@ Bugfix 🐛: - Searching by displayname is case sensitive (#1468) - Fix layout overlap issue (#1407) -Translations 🗣: - - - -SDK API changes ⚠️: - - - Build 🧱: - Enable code optimization (Proguard) - SDK is now API level 21 minimum, and so RiotX (#405) diff --git a/vector/build.gradle b/vector/build.gradle index c80b716008..3c74ccda97 100644 --- a/vector/build.gradle +++ b/vector/build.gradle @@ -17,7 +17,7 @@ androidExtensions { // Note: 2 digits max for each value ext.versionMajor = 0 ext.versionMinor = 91 -ext.versionPatch = 2 +ext.versionPatch = 3 static def getGitTimestamp() { def cmd = 'git show -s --format=%ct' From f4314ebdaef94e2b3dac5f91f8a7f46bcfc1f313 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Wed, 1 Jul 2020 21:58:58 +0200 Subject: [PATCH 12/19] Version++ --- CHANGES.md | 24 ++++++++++++++++++++++++ vector/build.gradle | 2 +- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index ad3f82af9a..4a7d0d70af 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,27 @@ +Changes in Riot.imX 0.91.4 (2020-XX-XX) +=================================================== + +Features ✨: + - + +Improvements 🙌: + - + +Bugfix 🐛: + - + +Translations 🗣: + - + +SDK API changes ⚠️: + - + +Build 🧱: + - + +Other changes: + - + Changes in Riot.imX 0.91.3 (2020-07-01) =================================================== diff --git a/vector/build.gradle b/vector/build.gradle index 3c74ccda97..e497b156ae 100644 --- a/vector/build.gradle +++ b/vector/build.gradle @@ -17,7 +17,7 @@ androidExtensions { // Note: 2 digits max for each value ext.versionMajor = 0 ext.versionMinor = 91 -ext.versionPatch = 3 +ext.versionPatch = 4 static def getGitTimestamp() { def cmd = 'git show -s --format=%ct' From 69eaf2695e8c48eb78fec1c1defe54e6d41dfa24 Mon Sep 17 00:00:00 2001 From: Valere Date: Thu, 2 Jul 2020 14:08:09 +0200 Subject: [PATCH 13/19] FIx / inbound session bad migration --- .../internal/crypto/store/db/RealmCryptoStoreMigration.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/store/db/RealmCryptoStoreMigration.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/store/db/RealmCryptoStoreMigration.kt index eb2fc9ebad..47af558b90 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/store/db/RealmCryptoStoreMigration.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/store/db/RealmCryptoStoreMigration.kt @@ -182,7 +182,8 @@ internal class RealmCryptoStoreMigration @Inject constructor(private val crossSi try { val oldSerializedData = obj.getString("olmInboundGroupSessionData") deserializeFromRealm(oldSerializedData)?.let { mxOlmInboundGroupSession2 -> - val newOlmInboundGroupSessionWrapper2 = OlmInboundGroupSessionWrapper2() + val sessionKey = mxOlmInboundGroupSession2.mSession.sessionIdentifier() + val newOlmInboundGroupSessionWrapper = OlmInboundGroupSessionWrapper(sessionKey, false) .apply { olmInboundGroupSession = mxOlmInboundGroupSession2.mSession roomId = mxOlmInboundGroupSession2.mRoomId @@ -191,7 +192,7 @@ internal class RealmCryptoStoreMigration @Inject constructor(private val crossSi forwardingCurve25519KeyChain = mxOlmInboundGroupSession2.mForwardingCurve25519KeyChain } - obj.setString("olmInboundGroupSessionData", serializeForRealm(newOlmInboundGroupSessionWrapper2)) + obj.setString("olmInboundGroupSessionData", serializeForRealm(newOlmInboundGroupSessionWrapper)) } } catch (e: Exception) { Timber.e(e, "Error") From 2ef82f1b827eeca512c7f05badbc2f13ef3cf3ae Mon Sep 17 00:00:00 2001 From: ganfra Date: Thu, 2 Jul 2020 16:05:05 +0200 Subject: [PATCH 14/19] Use HomeActivity.newIntent to make sure we have args --- .../features/notifications/NotificationUtils.kt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/vector/src/main/java/im/vector/riotx/features/notifications/NotificationUtils.kt b/vector/src/main/java/im/vector/riotx/features/notifications/NotificationUtils.kt index d7dabd0778..36874d5782 100755 --- a/vector/src/main/java/im/vector/riotx/features/notifications/NotificationUtils.kt +++ b/vector/src/main/java/im/vector/riotx/features/notifications/NotificationUtils.kt @@ -205,7 +205,7 @@ class NotificationUtils @Inject constructor(private val context: Context, @SuppressLint("NewApi") fun buildForegroundServiceNotification(@StringRes subTitleResId: Int, withProgress: Boolean = true): Notification { // build the pending intent go to the home screen if this is clicked. - val i = Intent(context, HomeActivity::class.java) + val i = HomeActivity.newIntent(context) i.flags = Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP val pi = PendingIntent.getActivity(context, 0, i, 0) @@ -307,7 +307,7 @@ class NotificationUtils @Inject constructor(private val context: Context, val contentPendingIntent = PendingIntent.getActivity(context, System.currentTimeMillis().toInt(), contentIntent, 0) val answerCallPendingIntent = TaskStackBuilder.create(context) - .addNextIntentWithParentStack(Intent(context, HomeActivity::class.java)) + .addNextIntentWithParentStack(HomeActivity.newIntent(context)) .addNextIntent(VectorCallActivity.newIntent( context = context, callId = callId, @@ -459,7 +459,7 @@ class NotificationUtils @Inject constructor(private val context: Context, ) val contentPendingIntent = TaskStackBuilder.create(context) - .addNextIntentWithParentStack(Intent(context, HomeActivity::class.java)) + .addNextIntentWithParentStack(HomeActivity.newIntent(context)) // TODO other userId .addNextIntent(VectorCallActivity.newIntent(context, callId, roomId, "otherUserId", true, isVideo, null)) .getPendingIntent(System.currentTimeMillis().toInt(), PendingIntent.FLAG_UPDATE_CURRENT) @@ -651,7 +651,7 @@ class NotificationUtils @Inject constructor(private val context: Context, stringProvider.getString(R.string.join), joinIntentPendingIntent) - val contentIntent = Intent(context, HomeActivity::class.java) + val contentIntent = HomeActivity.newIntent(context) contentIntent.flags = Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP // pending intent get reused by system, this will mess up the extra params, so put unique info to avoid that contentIntent.data = Uri.parse("foobar://" + inviteNotifiableEvent.eventId) @@ -689,7 +689,7 @@ class NotificationUtils @Inject constructor(private val context: Context, .setColor(accentColor) .setAutoCancel(true) .apply { - val contentIntent = Intent(context, HomeActivity::class.java) + val contentIntent = HomeActivity.newIntent(context) contentIntent.flags = Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP // pending intent get reused by system, this will mess up the extra params, so put unique info to avoid that contentIntent.data = Uri.parse("foobar://" + simpleNotifiableEvent.eventId) @@ -718,7 +718,7 @@ class NotificationUtils @Inject constructor(private val context: Context, // Recreate the back stack return TaskStackBuilder.create(context) - .addNextIntentWithParentStack(Intent(context, HomeActivity::class.java)) + .addNextIntentWithParentStack(HomeActivity.newIntent(context)) .addNextIntent(roomIntentTap) .getPendingIntent(System.currentTimeMillis().toInt(), PendingIntent.FLAG_UPDATE_CURRENT) } From 5008bfd6a9c7daf42196ec15749fd4b01e99954d Mon Sep 17 00:00:00 2001 From: ganfra Date: Thu, 2 Jul 2020 16:17:00 +0200 Subject: [PATCH 15/19] Update CHANGES --- CHANGES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 4a7d0d70af..519a42db4e 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -8,7 +8,7 @@ Improvements 🙌: - Bugfix 🐛: - - + - Fix crash when coming from a notification (#1601) Translations 🗣: - From 596fcf94bac88f461cb6ef487f893fe710a6d613 Mon Sep 17 00:00:00 2001 From: Valere Date: Thu, 2 Jul 2020 19:26:05 +0200 Subject: [PATCH 16/19] Fix / Serialization issues Fixes keybackup import failing and UTD of incoming messages --- matrix-sdk-android/proguard-rules.pro | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/matrix-sdk-android/proguard-rules.pro b/matrix-sdk-android/proguard-rules.pro index 08a20cbf0a..fa860d8049 100644 --- a/matrix-sdk-android/proguard-rules.pro +++ b/matrix-sdk-android/proguard-rules.pro @@ -64,3 +64,19 @@ ### Webrtc -keep class org.webrtc.** { *; } + +### Serializable persisted classes +# https://www.guardsquare.com/en/products/proguard/manual/examples#serializable +-keepnames class * implements java.io.Serializable + +-keepclassmembers class * implements java.io.Serializable { + static final long serialVersionUID; + private static final java.io.ObjectStreamField[] serialPersistentFields; + !static !transient ; + !private ; + !private ; + private void writeObject(java.io.ObjectOutputStream); + private void readObject(java.io.ObjectInputStream); + java.lang.Object writeReplace(); + java.lang.Object readResolve(); +} \ No newline at end of file From e098b87d0a9908f9cccbb0afab83819433083f2d Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Thu, 2 Jul 2020 21:30:49 +0200 Subject: [PATCH 17/19] Update comment --- .../internal/crypto/store/db/RealmCryptoStoreMigration.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/store/db/RealmCryptoStoreMigration.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/store/db/RealmCryptoStoreMigration.kt index 47af558b90..7bf8e2478f 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/store/db/RealmCryptoStoreMigration.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/store/db/RealmCryptoStoreMigration.kt @@ -176,7 +176,7 @@ internal class RealmCryptoStoreMigration @Inject constructor(private val crossSi } } - // Convert MXOlmInboundGroupSession2 to OlmInboundGroupSessionWrapper2 + // Convert MXOlmInboundGroupSession2 to OlmInboundGroupSessionWrapper realm.schema.get("OlmInboundGroupSessionEntity") ?.transform { obj -> try { From 15223ecfe4ccda4b97b27c8511d668e9b0b5e49c Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Thu, 2 Jul 2020 21:31:39 +0200 Subject: [PATCH 18/19] Update changelog with the recent change --- CHANGES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 4a7d0d70af..61e27a1476 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -8,7 +8,7 @@ Improvements 🙌: - Bugfix 🐛: - - + - Fix Exception when importing keys (#1576) Translations 🗣: - From bfb8b6203cca75448e97efc0f7bafc2ff62a7121 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Thu, 2 Jul 2020 22:02:42 +0200 Subject: [PATCH 19/19] Add proguard command (commented) --- vector/proguard-rules.pro | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/vector/proguard-rules.pro b/vector/proguard-rules.pro index 56d3b95510..bc27767d8a 100644 --- a/vector/proguard-rules.pro +++ b/vector/proguard-rules.pro @@ -20,4 +20,7 @@ # hide the original source file name. #-renamesourcefileattribute SourceFile --keep class im.vector.riotx.features.** { *; } \ No newline at end of file +-keep class im.vector.riotx.features.** { *; } + +## print all the rules in a file +# -printconfiguration ../proguard_files/full-r8-config.txt