diff --git a/CHANGES.md b/CHANGES.md index 422d94ff06..46057a37ec 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -17,7 +17,7 @@ SDK API changes ⚠️: - Build 🧱: - - + - Update a lot of dependencies, with the help of dependabot. Test: - diff --git a/build.gradle b/build.gradle index 18a0564943..5f4650ee23 100644 --- a/build.gradle +++ b/build.gradle @@ -2,8 +2,8 @@ buildscript { // Ref: https://kotlinlang.org/releases.html - ext.kotlin_version = '1.4.21' - ext.kotlin_coroutines_version = "1.4.1" + ext.kotlin_version = '1.4.30' + ext.kotlin_coroutines_version = "1.4.2" repositories { google() jcenter() diff --git a/matrix-sdk-android/build.gradle b/matrix-sdk-android/build.gradle index cd3fe0b83b..3ade9f7214 100644 --- a/matrix-sdk-android/build.gradle +++ b/matrix-sdk-android/build.gradle @@ -145,7 +145,7 @@ dependencies { // Database implementation 'com.github.Zhuinden:realm-monarchy:0.7.1' - kapt 'dk.ilios:realmfieldnameshelper:1.1.1' + kapt 'dk.ilios:realmfieldnameshelper:2.0.0' // Work implementation "androidx.work:work-runtime-ktx:$work_version" diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/ChunkEntityQueries.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/ChunkEntityQueries.kt index 6028697054..f7d2823303 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/ChunkEntityQueries.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/ChunkEntityQueries.kt @@ -18,7 +18,6 @@ package org.matrix.android.sdk.internal.database.query import org.matrix.android.sdk.internal.database.model.ChunkEntity import org.matrix.android.sdk.internal.database.model.ChunkEntityFields -import org.matrix.android.sdk.internal.database.model.RoomEntityFields import io.realm.Realm import io.realm.RealmQuery import io.realm.RealmResults @@ -27,7 +26,7 @@ import io.realm.kotlin.where internal fun ChunkEntity.Companion.where(realm: Realm, roomId: String): RealmQuery { return realm.where() - .equalTo("${ChunkEntityFields.ROOM}.${RoomEntityFields.ROOM_ID}", roomId) + .equalTo(ChunkEntityFields.ROOM.ROOM_ID, roomId) } internal fun ChunkEntity.Companion.find(realm: Realm, roomId: String, prevToken: String? = null, nextToken: String? = null): ChunkEntity? { diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/PushersQueries.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/PushersQueries.kt index d78bda2317..359b256844 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/PushersQueries.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/PushersQueries.kt @@ -48,6 +48,6 @@ internal fun PushRuleEntity.Companion.where(realm: Realm, scope: String, ruleId: String): RealmQuery { return realm.where() - .equalTo("${PushRuleEntityFields.PARENT}.${PushRulesEntityFields.SCOPE}", scope) + .equalTo(PushRuleEntityFields.PARENT.SCOPE, scope) .equalTo(PushRuleEntityFields.RULE_ID, ruleId) } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/UserDraftsEntityQueries.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/UserDraftsEntityQueries.kt index 35f317f192..4af4da0a22 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/UserDraftsEntityQueries.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/UserDraftsEntityQueries.kt @@ -16,7 +16,6 @@ package org.matrix.android.sdk.internal.database.query -import org.matrix.android.sdk.internal.database.model.RoomSummaryEntityFields import org.matrix.android.sdk.internal.database.model.UserDraftsEntity import org.matrix.android.sdk.internal.database.model.UserDraftsEntityFields import io.realm.Realm @@ -26,7 +25,7 @@ import io.realm.kotlin.where internal fun UserDraftsEntity.Companion.where(realm: Realm, roomId: String? = null): RealmQuery { val query = realm.where() if (roomId != null) { - query.equalTo(UserDraftsEntityFields.ROOM_SUMMARY_ENTITY + "." + RoomSummaryEntityFields.ROOM_ID, roomId) + query.equalTo(UserDraftsEntityFields.ROOM_SUMMARY_ENTITY.ROOM_ID, roomId) } return query } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/timeline/DefaultTimeline.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/timeline/DefaultTimeline.kt index ae90282d52..ca272a3520 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/timeline/DefaultTimeline.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/timeline/DefaultTimeline.kt @@ -43,7 +43,6 @@ import org.matrix.android.sdk.api.util.CancelableBag import org.matrix.android.sdk.internal.database.RealmSessionProvider import org.matrix.android.sdk.internal.database.mapper.TimelineEventMapper import org.matrix.android.sdk.internal.database.model.ChunkEntity -import org.matrix.android.sdk.internal.database.model.ChunkEntityFields import org.matrix.android.sdk.internal.database.model.RoomEntity import org.matrix.android.sdk.internal.database.model.TimelineEventEntity import org.matrix.android.sdk.internal.database.model.TimelineEventEntityFields @@ -688,11 +687,11 @@ internal class DefaultTimeline( return if (initialEventId == null) { TimelineEventEntity .whereRoomId(realm, roomId = roomId) - .equalTo("${TimelineEventEntityFields.CHUNK}.${ChunkEntityFields.IS_LAST_FORWARD}", true) + .equalTo(TimelineEventEntityFields.CHUNK.IS_LAST_FORWARD, true) } else { TimelineEventEntity .whereRoomId(realm, roomId = roomId) - .`in`("${TimelineEventEntityFields.CHUNK}.${ChunkEntityFields.TIMELINE_EVENTS.EVENT_ID}", arrayOf(initialEventId)) + .`in`("${TimelineEventEntityFields.CHUNK.TIMELINE_EVENTS}.${TimelineEventEntityFields.EVENT_ID}", arrayOf(initialEventId)) } } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/timeline/TimelineHiddenReadReceipts.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/timeline/TimelineHiddenReadReceipts.kt index fa517bebf2..0ade8ad3b8 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/timeline/TimelineHiddenReadReceipts.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/timeline/TimelineHiddenReadReceipts.kt @@ -24,6 +24,7 @@ import io.realm.RealmResults import org.matrix.android.sdk.api.session.room.model.ReadReceipt import org.matrix.android.sdk.api.session.room.timeline.TimelineSettings import org.matrix.android.sdk.internal.database.mapper.ReadReceiptsSummaryMapper +import org.matrix.android.sdk.internal.database.model.EventEntityFields import org.matrix.android.sdk.internal.database.model.ReadReceiptsSummaryEntity import org.matrix.android.sdk.internal.database.model.ReadReceiptsSummaryEntityFields import org.matrix.android.sdk.internal.database.model.TimelineEventEntity @@ -121,7 +122,7 @@ internal class TimelineHiddenReadReceipts constructor(private val readReceiptsSu // We are looking for read receipts set on hidden events. // We only accept those with a timelineEvent (so coming from pagination/sync). this.hiddenReadReceipts = ReadReceiptsSummaryEntity.whereInRoom(realm, roomId) - .isNotEmpty(ReadReceiptsSummaryEntityFields.TIMELINE_EVENT) + .isNotEmpty(ReadReceiptsSummaryEntityFields.TIMELINE_EVENT.`$`) .isNotEmpty(ReadReceiptsSummaryEntityFields.READ_RECEIPTS.`$`) .filterReceiptsWithSettings() .findAllAsync() @@ -157,12 +158,12 @@ internal class TimelineHiddenReadReceipts constructor(private val readReceiptsSu // Result: D, F, H, I settings.filters.allowedTypes.forEachIndexed { index, filter -> if (filter.stateKey == null) { - notEqualTo("${ReadReceiptsSummaryEntityFields.TIMELINE_EVENT}.${TimelineEventEntityFields.ROOT.TYPE}", filter.eventType) + notEqualTo("${ReadReceiptsSummaryEntityFields.TIMELINE_EVENT.ROOT}.${EventEntityFields.TYPE}", filter.eventType) } else { beginGroup() - notEqualTo("${ReadReceiptsSummaryEntityFields.TIMELINE_EVENT}.${TimelineEventEntityFields.ROOT.TYPE}", filter.eventType) + notEqualTo("${ReadReceiptsSummaryEntityFields.TIMELINE_EVENT.ROOT}.${EventEntityFields.TYPE}", filter.eventType) or() - notEqualTo("${ReadReceiptsSummaryEntityFields.TIMELINE_EVENT}.${TimelineEventEntityFields.ROOT.STATE_KEY}", filter.stateKey) + notEqualTo("${ReadReceiptsSummaryEntityFields.TIMELINE_EVENT.ROOT}.${EventEntityFields.STATE_KEY}", filter.stateKey) endGroup() } if (index != settings.filters.allowedTypes.size - 1) { @@ -174,19 +175,19 @@ internal class TimelineHiddenReadReceipts constructor(private val readReceiptsSu } if (settings.filters.filterUseless) { if (needOr) or() - equalTo("${ReadReceiptsSummaryEntityFields.TIMELINE_EVENT}.${TimelineEventEntityFields.ROOT.IS_USELESS}", true) + equalTo("${ReadReceiptsSummaryEntityFields.TIMELINE_EVENT.ROOT}.${EventEntityFields.IS_USELESS}", true) needOr = true } if (settings.filters.filterEdits) { if (needOr) or() - like("${ReadReceiptsSummaryEntityFields.TIMELINE_EVENT}.${TimelineEventEntityFields.ROOT.CONTENT}", TimelineEventFilter.Content.EDIT) + like("${ReadReceiptsSummaryEntityFields.TIMELINE_EVENT.ROOT}.${EventEntityFields.CONTENT}", TimelineEventFilter.Content.EDIT) or() - like("${ReadReceiptsSummaryEntityFields.TIMELINE_EVENT}.${TimelineEventEntityFields.ROOT.CONTENT}", TimelineEventFilter.Content.RESPONSE) + like("${ReadReceiptsSummaryEntityFields.TIMELINE_EVENT.ROOT}.${EventEntityFields.CONTENT}", TimelineEventFilter.Content.RESPONSE) needOr = true } if (settings.filters.filterRedacted) { if (needOr) or() - like("${ReadReceiptsSummaryEntityFields.TIMELINE_EVENT}.${TimelineEventEntityFields.ROOT.UNSIGNED_DATA}", TimelineEventFilter.Unsigned.REDACTED) + like("${ReadReceiptsSummaryEntityFields.TIMELINE_EVENT.ROOT}.${EventEntityFields.UNSIGNED_DATA}", TimelineEventFilter.Unsigned.REDACTED) } endGroup() return this diff --git a/vector/build.gradle b/vector/build.gradle index 6e279bd959..2c5dc01e37 100644 --- a/vector/build.gradle +++ b/vector/build.gradle @@ -299,6 +299,7 @@ dependencies { def work_version = '2.5.0' def arch_version = '2.1.0' def lifecycle_version = '2.2.0' + def rxbinding_version = '3.1.0' // Tests def kluent_version = '1.65' @@ -345,9 +346,9 @@ dependencies { implementation 'io.reactivex.rxjava2:rxandroid:2.1.1' implementation 'com.jakewharton.rxrelay2:rxrelay:2.1.1' // RXBinding - implementation 'com.jakewharton.rxbinding3:rxbinding:3.1.0' - implementation 'com.jakewharton.rxbinding3:rxbinding-appcompat:3.1.0' - implementation 'com.jakewharton.rxbinding3:rxbinding-material:3.1.0' + implementation "com.jakewharton.rxbinding3:rxbinding:$rxbinding_version" + implementation "com.jakewharton.rxbinding3:rxbinding-appcompat:$rxbinding_version" + implementation "com.jakewharton.rxbinding3:rxbinding-material:$rxbinding_version" implementation("com.airbnb.android:epoxy:$epoxy_version") implementation "com.airbnb.android:epoxy-glide-preloading:$epoxy_version" @@ -381,13 +382,13 @@ dependencies { implementation 'com.github.vector-im:PFLockScreen-Android:1.0.0-beta12' // Custom Tab - implementation 'androidx.browser:browser:1.2.0' + implementation 'androidx.browser:browser:1.3.0' // Passphrase strength helper implementation 'com.nulab-inc:zxcvbn:1.4.0' //Alerter - implementation 'com.tapadoo.android:alerter:5.1.2' + implementation 'com.tapadoo.android:alerter:7.0.1' implementation 'com.otaliastudios:autocomplete:1.1.0' diff --git a/vector/src/main/java/im/vector/app/core/utils/ExternalApplicationsUtil.kt b/vector/src/main/java/im/vector/app/core/utils/ExternalApplicationsUtil.kt index 45db8ea91d..fa1c50f419 100644 --- a/vector/src/main/java/im/vector/app/core/utils/ExternalApplicationsUtil.kt +++ b/vector/src/main/java/im/vector/app/core/utils/ExternalApplicationsUtil.kt @@ -33,14 +33,15 @@ import android.provider.Settings import android.webkit.MimeTypeMap import android.widget.Toast import androidx.activity.result.ActivityResultLauncher +import androidx.browser.customtabs.CustomTabColorSchemeParams import androidx.browser.customtabs.CustomTabsIntent import androidx.browser.customtabs.CustomTabsSession -import androidx.core.content.ContextCompat import androidx.core.content.FileProvider import androidx.core.content.getSystemService import im.vector.app.BuildConfig import im.vector.app.R import im.vector.app.features.notifications.NotificationUtils +import im.vector.app.features.themes.ThemeUtils import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch @@ -92,17 +93,24 @@ fun openUrlInExternalBrowser(context: Context, uri: Uri?) { * If several compatible browsers are installed, the user will be proposed to choose one. * Ref: https://developer.chrome.com/multidevice/android/customtabs */ -fun openUrlInChromeCustomTab(context: Context, session: CustomTabsSession?, url: String) { +fun openUrlInChromeCustomTab(context: Context, + session: CustomTabsSession?, + url: String) { try { CustomTabsIntent.Builder() - .setToolbarColor(ContextCompat.getColor(context, R.color.riotx_background_light)) - .apply { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) { - setNavigationBarColor(ContextCompat.getColor(context, R.color.riotx_header_panel_background_light)) - } - } - .setNavigationBarColor(ContextCompat.getColor(context, R.color.riotx_background_light)) - .setColorScheme(CustomTabsIntent.COLOR_SCHEME_LIGHT) + .setDefaultColorSchemeParams( + CustomTabColorSchemeParams.Builder() + .setToolbarColor(ThemeUtils.getColor(context, R.attr.riotx_background)) + .setNavigationBarColor(ThemeUtils.getColor(context, R.attr.riotx_background)) + .build() + ) + .setColorScheme( + when { + ThemeUtils.isSystemTheme(context) -> CustomTabsIntent.COLOR_SCHEME_SYSTEM + ThemeUtils.isLightTheme(context) -> CustomTabsIntent.COLOR_SCHEME_LIGHT + else -> CustomTabsIntent.COLOR_SCHEME_DARK + } + ) // Note: setting close button icon does not work .setCloseButtonIcon(BitmapFactory.decodeResource(context.resources, R.drawable.ic_back_24dp)) .setStartAnimations(context, R.anim.enter_fade_in, R.anim.exit_fade_out) diff --git a/vector/src/main/java/im/vector/app/features/popup/PopupAlertManager.kt b/vector/src/main/java/im/vector/app/features/popup/PopupAlertManager.kt index 6952d5f653..67ef0514f2 100644 --- a/vector/src/main/java/im/vector/app/features/popup/PopupAlertManager.kt +++ b/vector/src/main/java/im/vector/app/features/popup/PopupAlertManager.kt @@ -99,7 +99,7 @@ class PopupAlertManager @Inject constructor() { // we want to remove existing popup on previous activity and display it on new one if (currentAlerter != null) { weakCurrentActivity?.get()?.let { - Alerter.clearCurrent(it) + Alerter.clearCurrent(it, null) if (currentAlerter?.isLight == false) { setLightStatusBar() } diff --git a/vector/src/main/java/im/vector/app/features/themes/ThemeUtils.kt b/vector/src/main/java/im/vector/app/features/themes/ThemeUtils.kt index 0856ac4b35..3bf58ab709 100644 --- a/vector/src/main/java/im/vector/app/features/themes/ThemeUtils.kt +++ b/vector/src/main/java/im/vector/app/features/themes/ThemeUtils.kt @@ -59,6 +59,14 @@ object ThemeUtils { setApplicationTheme(context, theme) } + /** + * @return true if current theme is System + */ + fun isSystemTheme(context: Context): Boolean { + val theme = getApplicationTheme(context) + return theme == SYSTEM_THEME_VALUE + } + /** * @return true if current theme is Light or current theme is System and system theme is light */