diff --git a/.editorconfig b/.editorconfig
index 0a49eadc0b..1966f91763 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -9,25 +9,6 @@ insert_final_newline=true
# it's automatically set to 100 on `ktlint --android ...` (per Android Kotlin Style Guide)
max_line_length=off
-# Comma-separated list of rules to disable (Since 0.34.0)
-# Note that rules in any ruleset other than the standard ruleset will need to be prefixed
-# by the ruleset identifier.
-disabled_rules=no-multi-spaces,colon-spacing,chain-wrapping,import-ordering,experimental:annotation
-
-# The following (so far identified) rules are kept:
-# no-blank-line-before-rbrace
-# final-newline
-# no-consecutive-blank-lines
-# comment-spacing
-# filename
-# comma-spacing
-# paren-spacing
-# op-spacing
-# string-template
-# no-unused-imports
-# curly-spacing
-# no-semi
-# no-empty-class-body
-# experimental:multiline-if-else
-# experimental:no-empty-first-line-in-method-block
-# no-wildcard-imports
+# From https://github.com/pinterest/ktlint#custom-ktlint-specific-editorconfig-properties
+# default IntelliJ IDEA style, same as alphabetical, but with "java", "javax", "kotlin" and alias imports in the end of the imports list
+ij_kotlin_imports_layout=*,java.**,javax.**,kotlin.**,^
diff --git a/.github/ISSUE_TEMPLATE/bug.yml b/.github/ISSUE_TEMPLATE/bug.yml
index dcb9f0a766..38885e9cc7 100644
--- a/.github/ISSUE_TEMPLATE/bug.yml
+++ b/.github/ISSUE_TEMPLATE/bug.yml
@@ -23,12 +23,12 @@ body:
- type: textarea
id: result
attributes:
- label: What happened?
+ label: Intended result and actual result
placeholder: Tell us what went wrong
value: |
- ### What did you expect?
+ #### What did you expect?
- ### What happened?
+ #### What happened instead?
validations:
required: true
- type: input
diff --git a/.github/ISSUE_TEMPLATE/release.yml b/.github/ISSUE_TEMPLATE/release.yml
index 4fecde2e90..903c05c5d3 100644
--- a/.github/ISSUE_TEMPLATE/release.yml
+++ b/.github/ISSUE_TEMPLATE/release.yml
@@ -1,7 +1,7 @@
name: Release checklist
description: Checklist for each release. This template is only for the core team.
title: "[Release] Element Android v"
-labels: [\U0001F680 Release]
+labels: [🚀 Release]
assignees:
- bmarty
diff --git a/.github/workflows/quality.yml b/.github/workflows/quality.yml
index 0f11915258..5ccd00a02b 100644
--- a/.github/workflows/quality.yml
+++ b/.github/workflows/quality.yml
@@ -14,15 +14,19 @@ jobs:
- name: Run code quality check suite
run: ./tools/check/check_code_quality.sh
- klint:
+ ktlint:
name: Kotlin Linter
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- - name: Run klint
+ - name: Run ktlint
run: |
- curl -sSLO https://github.com/pinterest/ktlint/releases/download/0.36.0/ktlint && chmod a+x ktlint
- ./ktlint --android --experimental -v
+ ./gradlew ktlintCheck --continue
+ - name: Upload reports
+ uses: actions/upload-artifact@v2
+ with:
+ name: ktlinting-report
+ path: vector/build/reports/ktlint/*.*
# Lint for main module and all the other modules
android-lint:
diff --git a/.gitignore b/.gitignore
index 935a3fc329..ff086d7723 100644
--- a/.gitignore
+++ b/.gitignore
@@ -16,4 +16,4 @@
/fastlane/private
/fastlane/report.xml
-ktlint
+/library/build
diff --git a/CHANGES.md b/CHANGES.md
index 8d4899e6fb..4b76ccce84 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -1,3 +1,49 @@
+Changes in Element v1.3.2 (2021-10-08)
+======================================
+
+Features ✨
+----------
+ - Android Auto notification support ([#240](https://github.com/vector-im/element-android/issues/240))
+ - Add a fallback for user displayName when this one is null or empty ([#3732](https://github.com/vector-im/element-android/issues/3732))
+ - Add client base url config to customize permalinks ([#4027](https://github.com/vector-im/element-android/issues/4027))
+ - Check if DM exists before creating a new one ([#4157](https://github.com/vector-im/element-android/issues/4157))
+ - Handle 8 new slash commands: `/ignore`, `/unignore`, `/roomname`, `/myroomnick`, `/roomavatar`, `/myroomavatar`, `/lenny`, `/whois`. ([#4158](https://github.com/vector-im/element-android/issues/4158))
+ - Display identity server policies in the Discovery screen ([#4184](https://github.com/vector-im/element-android/issues/4184))
+
+Bugfixes 🐛
+----------
+ - Ensure initial sync progress dialog is hidden when the initial sync is over ([#983](https://github.com/vector-im/element-android/issues/983))
+ - Avoid resending notifications that are already shown ([#1673](https://github.com/vector-im/element-android/issues/1673))
+ - Room filter no results bad CTA in space mode when a space selected ([#3048](https://github.com/vector-im/element-android/issues/3048))
+ - Fixes notifications not dismissing when reading messages on other devices ([#3347](https://github.com/vector-im/element-android/issues/3347))
+ - Fixes the passphrase screen being incorrectly shown when pressing back on the key verification screen.
+ When the user doesn't have a passphrase set we don't show the passphrase screen. ([#3898](https://github.com/vector-im/element-android/issues/3898))
+ - App doesn't take you to a Space after choosing to Join it ([#3933](https://github.com/vector-im/element-android/issues/3933))
+ - Validate public space addresses and room aliases length ([#3934](https://github.com/vector-im/element-android/issues/3934))
+ - Save button for adding rooms to a space is hidden when scrolling through list of rooms ([#3935](https://github.com/vector-im/element-android/issues/3935))
+ - Align new room encryption default to Web ([#4045](https://github.com/vector-im/element-android/issues/4045))
+ - Fix Reply/Edit mode animation is broken when sending ([#4077](https://github.com/vector-im/element-android/issues/4077))
+ - Added changes that will make SearchView in search bar focused by default on opening reaction picker.
+
+ When tapping close icon of SearchView, the SearchView did not collapse therefore added the on close listener
+ which will collapse the SearchView on close. ([#4092](https://github.com/vector-im/element-android/issues/4092))
+ - Troubleshoot notification: Fix button not clickable ([#4109](https://github.com/vector-im/element-android/issues/4109))
+ - Harmonize wording in the message bottom sheet and move up the View Reactions item ([#4155](https://github.com/vector-im/element-android/issues/4155))
+ - Remove unused SendRelationWorker and related API call (3588) ([#4156](https://github.com/vector-im/element-android/issues/4156))
+ - SIP user to native user mapping is wrong ([#4176](https://github.com/vector-im/element-android/issues/4176))
+
+SDK API changes ⚠️
+------------------
+ - Create extension `String.isMxcUrl()` ([#4158](https://github.com/vector-im/element-android/issues/4158))
+
+Other changes
+-------------
+ - Use ktlint plugin. See [the documentation](https://github.com/vector-im/element-android/blob/develop/CONTRIBUTING.md#ktlint) for more detail. ([#3957](https://github.com/vector-im/element-android/issues/3957))
+ - Minimize the use of exported="true" in android Manifest (link: https://github.com/matrix-org/matrix-dinsic/issues/618) ([#4018](https://github.com/vector-im/element-android/issues/4018))
+ - Fix redundancy in heading in the bug report issue form ([#4076](https://github.com/vector-im/element-android/issues/4076))
+ - Fix release label in the release issue template ([#4113](https://github.com/vector-im/element-android/issues/4113))
+
+
Changes in Element v1.3.1 (2021-09-29)
======================================
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index e1d213e6b7..dbc0ce9b72 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -9,7 +9,7 @@ Android support can be found in this [![Element Android Matrix room #element-and
## Android Studio settings
Please set the "hard wrap" setting of Android Studio to 160 chars, this is the setting we use internally to format the source code (Menu `Settings/Editor/Code Style` then `Hard wrap at`).
-Please ensure that your using the project formatting rules (which are in the project at .idea/codeStyles/), and format the file before committing them.
+Please ensure that you're using the project formatting rules (which are in the project at .idea/codeStyles/), and format the file before committing them.
### Template
@@ -80,14 +80,13 @@ Make sure the following commands execute without any error:
#### ktlint
-curl -sSLO https://github.com/pinterest/ktlint/releases/download/0.34.2/ktlint && chmod a+x ktlint
-./ktlint --android --experimental -v
+./gradlew ktlintCheck --continue
Note that you can run
-./ktlint --android --experimental -v -F
+./gradlew ktlintFormat
For ktlint to fix some detected errors for you (you still have to check and commit the fix of course)
diff --git a/attachment-viewer/src/main/java/im/vector/lib/attachmentviewer/AttachmentViewerActivity.kt b/attachment-viewer/src/main/java/im/vector/lib/attachmentviewer/AttachmentViewerActivity.kt
index f909418d6f..4ca6ced8fe 100644
--- a/attachment-viewer/src/main/java/im/vector/lib/attachmentviewer/AttachmentViewerActivity.kt
+++ b/attachment-viewer/src/main/java/im/vector/lib/attachmentviewer/AttachmentViewerActivity.kt
@@ -39,7 +39,6 @@ import androidx.core.view.updatePadding
import androidx.transition.TransitionManager
import androidx.viewpager2.widget.ViewPager2
import im.vector.lib.attachmentviewer.databinding.ActivityAttachmentViewerBinding
-
import java.lang.ref.WeakReference
import kotlin.math.abs
@@ -291,8 +290,8 @@ abstract class AttachmentViewerActivity : AppCompatActivity(), AttachmentEventLi
private fun calculateTranslationAlpha(translationY: Float, translationLimit: Int): Float =
1.0f - 1.0f / translationLimit.toFloat() / 4f * abs(translationY)
- private fun createSwipeToDismissHandler()
- : SwipeToDismissHandler = SwipeToDismissHandler(
+ private fun createSwipeToDismissHandler(): SwipeToDismissHandler =
+ SwipeToDismissHandler(
swipeView = views.dismissContainer,
shouldAnimateDismiss = { shouldAnimateDismiss() },
onDismiss = { animateClose() },
diff --git a/attachment-viewer/src/main/java/im/vector/lib/attachmentviewer/ImageLoaderTarget.kt b/attachment-viewer/src/main/java/im/vector/lib/attachmentviewer/ImageLoaderTarget.kt
index 531e8171e1..99686eaabb 100644
--- a/attachment-viewer/src/main/java/im/vector/lib/attachmentviewer/ImageLoaderTarget.kt
+++ b/attachment-viewer/src/main/java/im/vector/lib/attachmentviewer/ImageLoaderTarget.kt
@@ -36,8 +36,8 @@ interface ImageLoaderTarget {
fun onResourceReady(uid: String, resource: Drawable)
}
-internal class DefaultImageLoaderTarget(val holder: AnimatedImageViewHolder, private val contextView: ImageView)
- : ImageLoaderTarget {
+internal class DefaultImageLoaderTarget(val holder: AnimatedImageViewHolder, private val contextView: ImageView) :
+ ImageLoaderTarget {
override fun contextView(): ImageView {
return contextView
}
diff --git a/build.gradle b/build.gradle
index 49c3e07ece..93f3e17f34 100644
--- a/build.gradle
+++ b/build.gradle
@@ -27,7 +27,14 @@ buildscript {
}
}
+// ktlint Plugin
+plugins {
+ id "org.jlleitschuh.gradle.ktlint" version "10.2.0"
+}
+
allprojects {
+ apply plugin: "org.jlleitschuh.gradle.ktlint"
+
repositories {
// For olm library. This has to be declared first, to ensure that Olm library is not downloaded from another repo
maven {
@@ -75,6 +82,26 @@ allprojects {
// You can override by passing `-PallWarningsAsErrors=false` in the command line
kotlinOptions.allWarningsAsErrors = project.getProperties().getOrDefault("allWarningsAsErrors", "true").toBoolean()
}
+
+ // Fix "Java heap space" issue
+ tasks.withType(org.jlleitschuh.gradle.ktlint.tasks.BaseKtLintCheckTask).configureEach {
+ it.workerMaxHeapSize.set("2G")
+ }
+
+ // See https://github.com/JLLeitschuh/ktlint-gradle#configuration
+ ktlint {
+ android = true
+ ignoreFailures = false
+ enableExperimentalRules = true
+ // display the corresponding rule
+ verbose = true
+ disabledRules = [
+ "spacing-between-declarations-with-comments",
+ "no-multi-spaces",
+ "experimental:spacing-between-declarations-with-annotations",
+ "experimental:annotation"
+ ]
+ }
}
task clean(type: Delete) {
diff --git a/dependencies.gradle b/dependencies.gradle
index f19c1d3539..92358952db 100644
--- a/dependencies.gradle
+++ b/dependencies.gradle
@@ -9,9 +9,9 @@ ext.versions = [
def gradle = "7.0.2"
// Ref: https://kotlinlang.org/releases.html
-def kotlin = "1.5.30"
-def kotlinCoroutines = "1.5.1"
-def dagger = "2.38.1"
+def kotlin = "1.5.31"
+def kotlinCoroutines = "1.5.2"
+def dagger = "2.39.1"
def retrofit = "2.9.0"
def arrow = "0.8.2"
def markwon = "4.6.2"
@@ -49,7 +49,7 @@ ext.libs = [
'exifinterface' : "androidx.exifinterface:exifinterface:1.3.3",
'fragmentKtx' : "androidx.fragment:fragment-ktx:1.3.6",
'constraintLayout' : "androidx.constraintlayout:constraintlayout:2.1.1",
- 'work' : "androidx.work:work-runtime-ktx:2.5.0",
+ 'work' : "androidx.work:work-runtime-ktx:2.6.0",
'autoFill' : "androidx.autofill:autofill:1.1.0",
'preferenceKtx' : "androidx.preference:preference-ktx:1.1.1",
'junit' : "androidx.test.ext:junit:1.1.3",
diff --git a/fastlane/metadata/android/cs-CZ/changelogs/40103000.txt b/fastlane/metadata/android/cs-CZ/changelogs/40103000.txt
new file mode 100644
index 0000000000..f97ff3ef3a
--- /dev/null
+++ b/fastlane/metadata/android/cs-CZ/changelogs/40103000.txt
@@ -0,0 +1,2 @@
+Hlavní změny v této verzi: Uspořádejte si místnosti pomocí Prostorů!
+Úplný seznam změn: https://github.com/vector-im/element-android/releases/tag/v1.3.0
diff --git a/fastlane/metadata/android/en-US/changelogs/40103020.txt b/fastlane/metadata/android/en-US/changelogs/40103020.txt
new file mode 100644
index 0000000000..7ac48f4890
--- /dev/null
+++ b/fastlane/metadata/android/en-US/changelogs/40103020.txt
@@ -0,0 +1,2 @@
+Main changes in this version: Add support for Android Auto. Lot of bug fixes!
+Full changelog: https://github.com/vector-im/element-android/releases/tag/v1.3.2
\ No newline at end of file
diff --git a/fastlane/metadata/android/et/changelogs/40103000.txt b/fastlane/metadata/android/et/changelogs/40103000.txt
new file mode 100644
index 0000000000..643ae1ce0e
--- /dev/null
+++ b/fastlane/metadata/android/et/changelogs/40103000.txt
@@ -0,0 +1,2 @@
+Põhilised muutused selles versioonis: halda oma jututubasid koondades neid uut tüüpi kogukondadesse!
+Kogu ingliskeelne muudatuste logi: https://github.com/vector-im/element-android/releases/tag/v1.3.0
diff --git a/fastlane/metadata/android/fa/changelogs/40103000.txt b/fastlane/metadata/android/fa/changelogs/40103000.txt
new file mode 100644
index 0000000000..ba43459c0a
--- /dev/null
+++ b/fastlane/metadata/android/fa/changelogs/40103000.txt
@@ -0,0 +1,2 @@
+تغییرات عمده در این نگارش: سازماندهی اتاقهایتان با استفاده از فضاها
+گزارش دگرگونی کامل: https://github.com/vector-im/element-android/releases/tag/v1.3.0
diff --git a/fastlane/metadata/android/fr-FR/changelogs/40102000.txt b/fastlane/metadata/android/fr-FR/changelogs/40102000.txt
index 504c3e24be..0bcf3551f6 100644
--- a/fastlane/metadata/android/fr-FR/changelogs/40102000.txt
+++ b/fastlane/metadata/android/fr-FR/changelogs/40102000.txt
@@ -1,2 +1,2 @@
-Principaux changements pour cette version : messages vocaux activés par défault.
-Intégralité des changements : https://github.com/vector-im/element-android/releases/tag/v1.1.16
+Principaux changements pour cette version : messages vocaux activés par défaut.
+Intégralité des changements : https://github.com/vector-im/element-android/releases/tag/v1.2.0
diff --git a/fastlane/metadata/android/fr-FR/changelogs/40102010.txt b/fastlane/metadata/android/fr-FR/changelogs/40102010.txt
new file mode 100644
index 0000000000..910d4bd9c0
--- /dev/null
+++ b/fastlane/metadata/android/fr-FR/changelogs/40102010.txt
@@ -0,0 +1,2 @@
+Principaux changements pour cette version : Beaucoup d’améliorations sur la VoIP et les Espaces (toujours en bêta).
+Intégralité des changements : https://github.com/vector-im/element-android/releases/tag/v1.2.1
diff --git a/fastlane/metadata/android/fr-FR/changelogs/40103000.txt b/fastlane/metadata/android/fr-FR/changelogs/40103000.txt
new file mode 100644
index 0000000000..66c2c3db86
--- /dev/null
+++ b/fastlane/metadata/android/fr-FR/changelogs/40103000.txt
@@ -0,0 +1,2 @@
+Principaux changements pour cette version : Organisez vous salons à l’aide des Espaces !
+Intégralité des changements : https://github.com/vector-im/element-android/releases/tag/v1.3.0
diff --git a/fastlane/metadata/android/hu-HU/changelogs/40103000.txt b/fastlane/metadata/android/hu-HU/changelogs/40103000.txt
new file mode 100644
index 0000000000..40673b30b1
--- /dev/null
+++ b/fastlane/metadata/android/hu-HU/changelogs/40103000.txt
@@ -0,0 +1,2 @@
+Fő változás ebben a verzióban: Szobák terekbe szervezése
+Teljes változásnapló: https://github.com/vector-im/element-android/releases/tag/v1.3.0
diff --git a/fastlane/metadata/android/id/changelogs/40102000.txt b/fastlane/metadata/android/id/changelogs/40102000.txt
index 2258b114e8..f7d93e2e4f 100644
--- a/fastlane/metadata/android/id/changelogs/40102000.txt
+++ b/fastlane/metadata/android/id/changelogs/40102000.txt
@@ -1,2 +1,2 @@
Perubahan utama dalam versi ini: Pesan Suara diaktifkan secara default
-Changelog lanjutan: https://github.com/vector-im/element-android/releases/tag/v1.1.16
+Changelog lanjutan: https://github.com/vector-im/element-android/releases/tag/v1.2.0
diff --git a/fastlane/metadata/android/id/changelogs/40102010.txt b/fastlane/metadata/android/id/changelogs/40102010.txt
new file mode 100644
index 0000000000..e77f0327b0
--- /dev/null
+++ b/fastlane/metadata/android/id/changelogs/40102010.txt
@@ -0,0 +1,2 @@
+Perubahan utama di versi ini: Banyak perbaikan di VoIP dan Space (masih beta).
+Changelog lanjutan: https://github.com/vector-im/element-android/releases/tag/v1.2.1
diff --git a/fastlane/metadata/android/id/changelogs/40103000.txt b/fastlane/metadata/android/id/changelogs/40103000.txt
new file mode 100644
index 0000000000..bf7b5d8d5d
--- /dev/null
+++ b/fastlane/metadata/android/id/changelogs/40103000.txt
@@ -0,0 +1,2 @@
+Perubahan utama di versi ini: Organisir ruangan Anda menggunakan sebuah Space!
+Changelog lanjutan: https://github.com/vector-im/element-android/releases/tag/v1.3.0
diff --git a/fastlane/metadata/android/id/full_description.txt b/fastlane/metadata/android/id/full_description.txt
index 75249c6a20..bd357bb161 100644
--- a/fastlane/metadata/android/id/full_description.txt
+++ b/fastlane/metadata/android/id/full_description.txt
@@ -11,7 +11,7 @@ Element adalah perpesanan yang aman dan aplikasi kolaborasi tim produktivitas ya
Element benar-benar berbeda dari aplikasi perpesanan dan kolaborasi lainnya. Element beroperasi pada Matrix, jaringan terbuka untuk pengiriman pesan yang aman dan komunikasi terdesentralisasi. Matrix memungkinkan hosting sendiri untuk memberi pengguna kepemilikan maksimum dan kontrol data dan pesan mereka.
Pesan privasi dan terenkripsi
-Element melindungi Anda dari iklan yang tidak diinginkan, data penambangan dan taman berdinding. Element juga mengamankan semua data Anda, komunikasi video dan suara satu-ke-satu melalui enkripsi ujung-ke-ujung dan verifikasi perangkat yang ditanda tangani silang.
+Element melindungi Anda dari iklan yang tidak diinginkan, penambangan data dan taman berdinding. Element juga mengamankan semua data Anda, komunikasi video dan suara satu-ke-satu melalui enkripsi ujung-ke-ujung dan verifikasi perangkat yang ditandatangani secara silang.
Element memberi Anda kendali atas privasi Anda sambil memungkinkan Anda untuk berkomunikasi dengan aman dengan siapa pun di jaringan Matrix, atau alat kolaborasi bisnis lainnya dengan mengintegrasikan dengan aplikasi seperti Slack.
diff --git a/fastlane/metadata/android/it-IT/changelogs/40103000.txt b/fastlane/metadata/android/it-IT/changelogs/40103000.txt
new file mode 100644
index 0000000000..6ad9001bfd
--- /dev/null
+++ b/fastlane/metadata/android/it-IT/changelogs/40103000.txt
@@ -0,0 +1,2 @@
+Modifiche principali in questa versione: organizza le tue stanze usando gli Spazi!
+Cronologia completa: https://github.com/vector-im/element-android/releases/tag/v1.3.0
diff --git a/fastlane/metadata/android/pt-BR/changelogs/40103000.txt b/fastlane/metadata/android/pt-BR/changelogs/40103000.txt
new file mode 100644
index 0000000000..c046c1cbc9
--- /dev/null
+++ b/fastlane/metadata/android/pt-BR/changelogs/40103000.txt
@@ -0,0 +1,2 @@
+Principais mudanças nesta versão: Organize suas salas usando Espaços!
+Changelog completo: https://github.com/vector-im/element-android/releases/tag/v1.3.0
diff --git a/fastlane/metadata/android/sq/changelogs/40103000.txt b/fastlane/metadata/android/sq/changelogs/40103000.txt
new file mode 100644
index 0000000000..ecd5568c02
--- /dev/null
+++ b/fastlane/metadata/android/sq/changelogs/40103000.txt
@@ -0,0 +1,2 @@
+Ndryshime kryesore në këtë version: Sistemoni dhomat tuaja duke përdorur Hapësira!
+Regjistër i plotë ndryshimesh: https://github.com/vector-im/element-android/releases/tag/v1.3.0
diff --git a/fastlane/metadata/android/sv-SE/changelogs/40102010.txt b/fastlane/metadata/android/sv-SE/changelogs/40102010.txt
new file mode 100644
index 0000000000..f29b95de79
--- /dev/null
+++ b/fastlane/metadata/android/sv-SE/changelogs/40102010.txt
@@ -0,0 +1,2 @@
+Huvudsakliga ändringar i den här versionen: Många förbättringar för VoIP och utrymmen (fortfarande i beta).
+Full ändringslogg: https://github.com/vector-im/element-android/releases/tag/v1.2.1
diff --git a/fastlane/metadata/android/sv-SE/changelogs/40103000.txt b/fastlane/metadata/android/sv-SE/changelogs/40103000.txt
new file mode 100644
index 0000000000..d9a2c34f1d
--- /dev/null
+++ b/fastlane/metadata/android/sv-SE/changelogs/40103000.txt
@@ -0,0 +1,2 @@
+Huvudsakliga ändringar i den här versionen: Organisera dina rum med utrymmen!
+Full ändringslogg: https://github.com/vector-im/element-android/releases/tag/v1.3.0
diff --git a/fastlane/metadata/android/uk/changelogs/40103000.txt b/fastlane/metadata/android/uk/changelogs/40103000.txt
new file mode 100644
index 0000000000..64a168cbe9
--- /dev/null
+++ b/fastlane/metadata/android/uk/changelogs/40103000.txt
@@ -0,0 +1,2 @@
+Основні зміни в цій версії: Упорядковуйте свої кімнати за допомогою Просторів!
+Повний журнал змін: https://github.com/vector-im/element-android/releases/tag/v1.3.0
diff --git a/fastlane/metadata/android/zh-CN/changelogs/40103000.txt b/fastlane/metadata/android/zh-CN/changelogs/40103000.txt
new file mode 100644
index 0000000000..96ec8b3322
--- /dev/null
+++ b/fastlane/metadata/android/zh-CN/changelogs/40103000.txt
@@ -0,0 +1,2 @@
+此版本主要更改:使用空间组织你的聊天室!
+完整更新日志:https://github.com/vector-im/element-android/releases/tag/v1.3.0
diff --git a/fastlane/metadata/android/zh-TW/changelogs/40103000.txt b/fastlane/metadata/android/zh-TW/changelogs/40103000.txt
new file mode 100644
index 0000000000..fbae69cd21
--- /dev/null
+++ b/fastlane/metadata/android/zh-TW/changelogs/40103000.txt
@@ -0,0 +1,2 @@
+此版本中的主要變動:使用空間來整理您的聊天室!
+完整的變更紀錄:https://github.com/vector-im/element-android/releases/tag/v1.3.0
diff --git a/matrix-sdk-android-rx/src/main/java/org/matrix/android/sdk/rx/LiveDataObservable.kt b/matrix-sdk-android-rx/src/main/java/org/matrix/android/sdk/rx/LiveDataObservable.kt
index 2174c6f118..56b52facf9 100644
--- a/matrix-sdk-android-rx/src/main/java/org/matrix/android/sdk/rx/LiveDataObservable.kt
+++ b/matrix-sdk-android-rx/src/main/java/org/matrix/android/sdk/rx/LiveDataObservable.kt
@@ -34,8 +34,8 @@ private class LiveDataObservable(
liveData.observeForever(relay)
}
- private inner class RemoveObserverInMainThread(private val observer: io.reactivex.Observer)
- : MainThreadDisposable(), Observer {
+ private inner class RemoveObserverInMainThread(private val observer: io.reactivex.Observer) :
+ MainThreadDisposable(), Observer {
override fun onChanged(t: T?) {
if (!isDisposed) {
diff --git a/matrix-sdk-android-rx/src/main/java/org/matrix/android/sdk/rx/OptionalRx.kt b/matrix-sdk-android-rx/src/main/java/org/matrix/android/sdk/rx/OptionalRx.kt
index ff4b0d755c..936bd824e7 100644
--- a/matrix-sdk-android-rx/src/main/java/org/matrix/android/sdk/rx/OptionalRx.kt
+++ b/matrix-sdk-android-rx/src/main/java/org/matrix/android/sdk/rx/OptionalRx.kt
@@ -16,8 +16,8 @@
package org.matrix.android.sdk.rx
-import org.matrix.android.sdk.api.util.Optional
import io.reactivex.Observable
+import org.matrix.android.sdk.api.util.Optional
fun Observable>.unwrap(): Observable {
return filter { it.hasValue() }.map { it.get() }
diff --git a/matrix-sdk-android/build.gradle b/matrix-sdk-android/build.gradle
index 2be6106d41..e3c8d7c4f1 100644
--- a/matrix-sdk-android/build.gradle
+++ b/matrix-sdk-android/build.gradle
@@ -31,7 +31,7 @@ android {
// that the app's state is completely cleared between tests.
testInstrumentationRunnerArguments clearPackageData: 'true'
- buildConfigField "String", "SDK_VERSION", "\"1.3.1\""
+ buildConfigField "String", "SDK_VERSION", "\"1.3.2\""
buildConfigField "String", "GIT_SDK_REVISION", "\"${gitRevision()}\""
resValue "string", "git_sdk_revision", "\"${gitRevision()}\""
@@ -115,7 +115,7 @@ dependencies {
implementation libs.squareup.retrofit
implementation libs.squareup.retrofitMoshi
- implementation(platform("com.squareup.okhttp3:okhttp-bom:4.9.1"))
+ implementation(platform("com.squareup.okhttp3:okhttp-bom:4.9.2"))
implementation 'com.squareup.okhttp3:okhttp'
implementation 'com.squareup.okhttp3:logging-interceptor'
implementation 'com.squareup.okhttp3:okhttp-urlconnection'
@@ -154,7 +154,7 @@ dependencies {
implementation 'com.otaliastudios:transcoder:0.10.4'
// Phone number https://github.com/google/libphonenumber
- implementation 'com.googlecode.libphonenumber:libphonenumber:8.12.33'
+ implementation 'com.googlecode.libphonenumber:libphonenumber:8.12.34'
testImplementation libs.tests.junit
testImplementation 'org.robolectric:robolectric:4.6.1'
diff --git a/matrix-sdk-android/src/androidTest/AndroidManifest.xml b/matrix-sdk-android/src/androidTest/AndroidManifest.xml
index 274bd8c87b..40360fcd19 100644
--- a/matrix-sdk-android/src/androidTest/AndroidManifest.xml
+++ b/matrix-sdk-android/src/androidTest/AndroidManifest.xml
@@ -8,10 +8,15 @@
This is mandatory to run integration tests
-->
+ tools:node="merge">
+
+
diff --git a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/InstrumentedTest.kt b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/InstrumentedTest.kt
index 583406346e..a763766821 100644
--- a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/InstrumentedTest.kt
+++ b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/InstrumentedTest.kt
@@ -18,8 +18,8 @@ package org.matrix.android.sdk
import android.content.Context
import androidx.test.core.app.ApplicationProvider
-import org.matrix.android.sdk.test.shared.createTimberTestRule
import org.junit.Rule
+import org.matrix.android.sdk.test.shared.createTimberTestRule
interface InstrumentedTest {
diff --git a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/SingleThreadCoroutineDispatcher.kt b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/SingleThreadCoroutineDispatcher.kt
index 9942ea9db3..192f6442b2 100644
--- a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/SingleThreadCoroutineDispatcher.kt
+++ b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/SingleThreadCoroutineDispatcher.kt
@@ -16,9 +16,9 @@
package org.matrix.android.sdk
-import org.matrix.android.sdk.internal.util.MatrixCoroutineDispatchers
import kotlinx.coroutines.Dispatchers.Main
import kotlinx.coroutines.asCoroutineDispatcher
+import org.matrix.android.sdk.internal.util.MatrixCoroutineDispatchers
import java.util.concurrent.Executors
internal val testCoroutineDispatchers = MatrixCoroutineDispatchers(Main, Main, Main, Main,
diff --git a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/account/AccountCreationTest.kt b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/account/AccountCreationTest.kt
index 5dede9dcfd..e0451bea38 100644
--- a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/account/AccountCreationTest.kt
+++ b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/account/AccountCreationTest.kt
@@ -16,16 +16,16 @@
package org.matrix.android.sdk.account
-import org.matrix.android.sdk.InstrumentedTest
-import org.matrix.android.sdk.common.CommonTestHelper
-import org.matrix.android.sdk.common.CryptoTestHelper
-import org.matrix.android.sdk.common.SessionTestParams
-import org.matrix.android.sdk.common.TestConstants
import org.junit.FixMethodOrder
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.JUnit4
import org.junit.runners.MethodSorters
+import org.matrix.android.sdk.InstrumentedTest
+import org.matrix.android.sdk.common.CommonTestHelper
+import org.matrix.android.sdk.common.CryptoTestHelper
+import org.matrix.android.sdk.common.SessionTestParams
+import org.matrix.android.sdk.common.TestConstants
@RunWith(JUnit4::class)
@FixMethodOrder(MethodSorters.JVM)
diff --git a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/account/ChangePasswordTest.kt b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/account/ChangePasswordTest.kt
index 103b638c39..d32bcb3fe5 100644
--- a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/account/ChangePasswordTest.kt
+++ b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/account/ChangePasswordTest.kt
@@ -16,17 +16,17 @@
package org.matrix.android.sdk.account
-import org.matrix.android.sdk.InstrumentedTest
-import org.matrix.android.sdk.api.failure.isInvalidPassword
-import org.matrix.android.sdk.common.CommonTestHelper
-import org.matrix.android.sdk.common.SessionTestParams
-import org.matrix.android.sdk.common.TestConstants
import org.amshove.kluent.shouldBeTrue
import org.junit.FixMethodOrder
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.JUnit4
import org.junit.runners.MethodSorters
+import org.matrix.android.sdk.InstrumentedTest
+import org.matrix.android.sdk.api.failure.isInvalidPassword
+import org.matrix.android.sdk.common.CommonTestHelper
+import org.matrix.android.sdk.common.SessionTestParams
+import org.matrix.android.sdk.common.TestConstants
@RunWith(JUnit4::class)
@FixMethodOrder(MethodSorters.JVM)
diff --git a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/account/DeactivateAccountTest.kt b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/account/DeactivateAccountTest.kt
index 01c4f8ccb3..f8d108fb73 100644
--- a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/account/DeactivateAccountTest.kt
+++ b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/account/DeactivateAccountTest.kt
@@ -67,9 +67,9 @@ class DeactivateAccountTest : InstrumentedTest {
val throwable = commonTestHelper.logAccountWithError(session.myUserId, TestConstants.PASSWORD)
// Test the error
- assertTrue(throwable is Failure.ServerError
- && throwable.error.code == MatrixError.M_USER_DEACTIVATED
- && throwable.error.message == "This account has been deactivated")
+ assertTrue(throwable is Failure.ServerError &&
+ throwable.error.code == MatrixError.M_USER_DEACTIVATED &&
+ throwable.error.message == "This account has been deactivated")
// Try to create an account with the deactivate account user id, it will fail (M_USER_IN_USE)
val hs = commonTestHelper.createHomeServerConfig()
@@ -95,8 +95,8 @@ class DeactivateAccountTest : InstrumentedTest {
// Test the error
accountCreationError.let {
- assertTrue(it is Failure.ServerError
- && it.error.code == MatrixError.M_USER_IN_USE)
+ assertTrue(it is Failure.ServerError &&
+ it.error.code == MatrixError.M_USER_IN_USE)
}
// No need to close the session, it has been deactivated
diff --git a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/common/MockOkHttpInterceptor.kt b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/common/MockOkHttpInterceptor.kt
index e7978a9cb2..b6d833a77c 100644
--- a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/common/MockOkHttpInterceptor.kt
+++ b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/common/MockOkHttpInterceptor.kt
@@ -15,12 +15,12 @@
*/
package org.matrix.android.sdk.common
-import org.matrix.android.sdk.internal.session.TestInterceptor
import okhttp3.Interceptor
import okhttp3.Protocol
import okhttp3.Request
import okhttp3.Response
import okhttp3.ResponseBody.Companion.toResponseBody
+import org.matrix.android.sdk.internal.session.TestInterceptor
import javax.net.ssl.HttpsURLConnection
/**
diff --git a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/common/TestMatrixCallback.kt b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/common/TestMatrixCallback.kt
index c2e1ec0f92..9f6d6eb136 100644
--- a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/common/TestMatrixCallback.kt
+++ b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/common/TestMatrixCallback.kt
@@ -17,8 +17,8 @@
package org.matrix.android.sdk.common
import androidx.annotation.CallSuper
-import org.matrix.android.sdk.api.MatrixCallback
import org.junit.Assert.fail
+import org.matrix.android.sdk.api.MatrixCallback
import timber.log.Timber
import java.util.concurrent.CountDownLatch
diff --git a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/crypto/AttachmentEncryptionTest.kt b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/crypto/AttachmentEncryptionTest.kt
index b6cb7f9e79..aaf779212b 100644
--- a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/crypto/AttachmentEncryptionTest.kt
+++ b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/crypto/AttachmentEncryptionTest.kt
@@ -26,9 +26,9 @@ import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.MethodSorters
import org.matrix.android.sdk.internal.crypto.attachments.MXEncryptedAttachments
+import org.matrix.android.sdk.internal.crypto.attachments.toElementToDecrypt
import org.matrix.android.sdk.internal.crypto.model.rest.EncryptedFileInfo
import org.matrix.android.sdk.internal.crypto.model.rest.EncryptedFileKey
-import org.matrix.android.sdk.internal.crypto.attachments.toElementToDecrypt
import java.io.ByteArrayOutputStream
import java.io.InputStream
diff --git a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/crypto/CryptoStoreHelper.kt b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/crypto/CryptoStoreHelper.kt
index 75ccce0db9..c717c8e33f 100644
--- a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/crypto/CryptoStoreHelper.kt
+++ b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/crypto/CryptoStoreHelper.kt
@@ -16,12 +16,12 @@
package org.matrix.android.sdk.internal.crypto
+import io.realm.RealmConfiguration
import org.matrix.android.sdk.internal.crypto.store.IMXCryptoStore
import org.matrix.android.sdk.internal.crypto.store.db.RealmCryptoStore
import org.matrix.android.sdk.internal.crypto.store.db.RealmCryptoStoreModule
import org.matrix.android.sdk.internal.crypto.store.db.mapper.CrossSigningKeysMapper
import org.matrix.android.sdk.internal.di.MoshiProvider
-import io.realm.RealmConfiguration
import kotlin.random.Random
internal class CryptoStoreHelper {
diff --git a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/crypto/CryptoStoreTest.kt b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/crypto/CryptoStoreTest.kt
index 1d838b5c84..f43c425cc9 100644
--- a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/crypto/CryptoStoreTest.kt
+++ b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/crypto/CryptoStoreTest.kt
@@ -17,9 +17,6 @@
package org.matrix.android.sdk.internal.crypto
import androidx.test.ext.junit.runners.AndroidJUnit4
-import org.matrix.android.sdk.InstrumentedTest
-import org.matrix.android.sdk.internal.crypto.model.OlmSessionWrapper
-import org.matrix.android.sdk.internal.crypto.store.IMXCryptoStore
import io.realm.Realm
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNotEquals
@@ -27,6 +24,9 @@ import org.junit.Assert.assertNull
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
+import org.matrix.android.sdk.InstrumentedTest
+import org.matrix.android.sdk.internal.crypto.model.OlmSessionWrapper
+import org.matrix.android.sdk.internal.crypto.store.IMXCryptoStore
import org.matrix.olm.OlmAccount
import org.matrix.olm.OlmManager
import org.matrix.olm.OlmSession
diff --git a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/crypto/PreShareKeysTest.kt b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/crypto/PreShareKeysTest.kt
index a2566c1414..825fba570a 100644
--- a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/crypto/PreShareKeysTest.kt
+++ b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/crypto/PreShareKeysTest.kt
@@ -50,8 +50,8 @@ class PreShareKeysTest : InstrumentedTest {
aliceSession.cryptoService().discardOutboundSession(e2eRoomID)
val preShareCount = bobSession.cryptoService().getGossipingEvents().count {
- it.senderId == aliceSession.myUserId
- && it.getClearType() == EventType.ROOM_KEY
+ it.senderId == aliceSession.myUserId &&
+ it.getClearType() == EventType.ROOM_KEY
}
assertEquals("Bob should not have receive any key from alice at this point", 0, preShareCount)
@@ -65,16 +65,16 @@ class PreShareKeysTest : InstrumentedTest {
mTestHelper.waitWithLatch { latch ->
mTestHelper.retryPeriodicallyWithLatch(latch) {
val newGossipCount = bobSession.cryptoService().getGossipingEvents().count {
- it.senderId == aliceSession.myUserId
- && it.getClearType() == EventType.ROOM_KEY
+ it.senderId == aliceSession.myUserId &&
+ it.getClearType() == EventType.ROOM_KEY
}
newGossipCount > preShareCount
}
}
val latest = bobSession.cryptoService().getGossipingEvents().lastOrNull {
- it.senderId == aliceSession.myUserId
- && it.getClearType() == EventType.ROOM_KEY
+ it.senderId == aliceSession.myUserId &&
+ it.getClearType() == EventType.ROOM_KEY
}
val content = latest?.getClearContent().toModel()
diff --git a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/crypto/gossiping/WithHeldTests.kt b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/crypto/gossiping/WithHeldTests.kt
index b2516ea2be..c939952dc9 100644
--- a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/crypto/gossiping/WithHeldTests.kt
+++ b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/crypto/gossiping/WithHeldTests.kt
@@ -18,6 +18,11 @@ package org.matrix.android.sdk.internal.crypto.gossiping
import android.util.Log
import androidx.test.ext.junit.runners.AndroidJUnit4
+import org.junit.Assert
+import org.junit.FixMethodOrder
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.junit.runners.MethodSorters
import org.matrix.android.sdk.InstrumentedTest
import org.matrix.android.sdk.api.NoOpMatrixCallback
import org.matrix.android.sdk.api.extensions.tryOrNull
@@ -31,11 +36,6 @@ import org.matrix.android.sdk.common.SessionTestParams
import org.matrix.android.sdk.common.TestConstants
import org.matrix.android.sdk.internal.crypto.model.event.EncryptedEventContent
import org.matrix.android.sdk.internal.crypto.model.event.WithHeldCode
-import org.junit.Assert
-import org.junit.FixMethodOrder
-import org.junit.Test
-import org.junit.runner.RunWith
-import org.junit.runners.MethodSorters
@RunWith(AndroidJUnit4::class)
@FixMethodOrder(MethodSorters.JVM)
diff --git a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/crypto/keysbackup/KeysBackupPasswordTest.kt b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/crypto/keysbackup/KeysBackupPasswordTest.kt
index cc71f88fc0..63e74603d0 100644
--- a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/crypto/keysbackup/KeysBackupPasswordTest.kt
+++ b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/crypto/keysbackup/KeysBackupPasswordTest.kt
@@ -17,9 +17,6 @@
package org.matrix.android.sdk.internal.crypto.keysbackup
import androidx.test.ext.junit.runners.AndroidJUnit4
-import org.matrix.android.sdk.InstrumentedTest
-import org.matrix.android.sdk.api.listeners.ProgressListener
-import org.matrix.android.sdk.common.assertByteArrayNotEqual
import org.junit.Assert.assertArrayEquals
import org.junit.Assert.assertEquals
import org.junit.Assert.assertTrue
@@ -28,6 +25,9 @@ import org.junit.FixMethodOrder
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.MethodSorters
+import org.matrix.android.sdk.InstrumentedTest
+import org.matrix.android.sdk.api.listeners.ProgressListener
+import org.matrix.android.sdk.common.assertByteArrayNotEqual
import org.matrix.olm.OlmManager
import org.matrix.olm.OlmPkDecryption
diff --git a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/crypto/keysbackup/KeysBackupTest.kt b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/crypto/keysbackup/KeysBackupTest.kt
index 89d297c592..0785dba8b9 100644
--- a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/crypto/keysbackup/KeysBackupTest.kt
+++ b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/crypto/keysbackup/KeysBackupTest.kt
@@ -17,6 +17,16 @@
package org.matrix.android.sdk.internal.crypto.keysbackup
import androidx.test.ext.junit.runners.AndroidJUnit4
+import org.junit.Assert.assertEquals
+import org.junit.Assert.assertFalse
+import org.junit.Assert.assertNotNull
+import org.junit.Assert.assertNull
+import org.junit.Assert.assertTrue
+import org.junit.Assert.fail
+import org.junit.FixMethodOrder
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.junit.runners.MethodSorters
import org.matrix.android.sdk.InstrumentedTest
import org.matrix.android.sdk.api.listeners.ProgressListener
import org.matrix.android.sdk.api.listeners.StepProgressListener
@@ -33,16 +43,6 @@ import org.matrix.android.sdk.internal.crypto.keysbackup.model.MegolmBackupCreat
import org.matrix.android.sdk.internal.crypto.keysbackup.model.rest.KeysVersion
import org.matrix.android.sdk.internal.crypto.keysbackup.model.rest.KeysVersionResult
import org.matrix.android.sdk.internal.crypto.model.ImportRoomKeysResult
-import org.junit.Assert.assertEquals
-import org.junit.Assert.assertFalse
-import org.junit.Assert.assertNotNull
-import org.junit.Assert.assertNull
-import org.junit.Assert.assertTrue
-import org.junit.Assert.fail
-import org.junit.FixMethodOrder
-import org.junit.Test
-import org.junit.runner.RunWith
-import org.junit.runners.MethodSorters
import java.util.ArrayList
import java.util.Collections
import java.util.concurrent.CountDownLatch
diff --git a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/crypto/keysbackup/KeysBackupTestHelper.kt b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/crypto/keysbackup/KeysBackupTestHelper.kt
index b6e5ae7364..a625ffc0e9 100644
--- a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/crypto/keysbackup/KeysBackupTestHelper.kt
+++ b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/crypto/keysbackup/KeysBackupTestHelper.kt
@@ -16,6 +16,7 @@
package org.matrix.android.sdk.internal.crypto.keysbackup
+import org.junit.Assert
import org.matrix.android.sdk.api.listeners.ProgressListener
import org.matrix.android.sdk.api.session.Session
import org.matrix.android.sdk.api.session.crypto.keysbackup.KeysBackupService
@@ -28,7 +29,6 @@ import org.matrix.android.sdk.common.assertListEquals
import org.matrix.android.sdk.internal.crypto.MegolmSessionData
import org.matrix.android.sdk.internal.crypto.keysbackup.model.MegolmBackupCreationInfo
import org.matrix.android.sdk.internal.crypto.keysbackup.model.rest.KeysVersion
-import org.junit.Assert
import java.util.concurrent.CountDownLatch
class KeysBackupTestHelper(
diff --git a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/crypto/keysbackup/StateObserver.kt b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/crypto/keysbackup/StateObserver.kt
index ff8ce43b55..80e54d82ec 100644
--- a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/crypto/keysbackup/StateObserver.kt
+++ b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/crypto/keysbackup/StateObserver.kt
@@ -16,11 +16,11 @@
package org.matrix.android.sdk.internal.crypto.keysbackup
+import org.junit.Assert.assertEquals
+import org.junit.Assert.assertNull
import org.matrix.android.sdk.api.session.crypto.keysbackup.KeysBackupService
import org.matrix.android.sdk.api.session.crypto.keysbackup.KeysBackupState
import org.matrix.android.sdk.api.session.crypto.keysbackup.KeysBackupStateListener
-import org.junit.Assert.assertEquals
-import org.junit.Assert.assertNull
import java.util.concurrent.CountDownLatch
/**
@@ -91,8 +91,8 @@ internal class StateObserver(private val keysBackup: KeysBackupService,
stateList.add(newState)
// Check that state transition is valid
- if (stateList.size >= 2
- && !allowedStateTransitions.contains(stateList[stateList.size - 2] to newState)) {
+ if (stateList.size >= 2 &&
+ !allowedStateTransitions.contains(stateList[stateList.size - 2] to newState)) {
// Forbidden transition detected
lastTransitionError = "Forbidden transition detected from " + stateList[stateList.size - 2] + " to " + newState
}
diff --git a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/crypto/ssss/QuadSTests.kt b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/crypto/ssss/QuadSTests.kt
index 74855b8630..b343d7334a 100644
--- a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/crypto/ssss/QuadSTests.kt
+++ b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/crypto/ssss/QuadSTests.kt
@@ -18,8 +18,20 @@ package org.matrix.android.sdk.internal.crypto.ssss
import androidx.lifecycle.Observer
import androidx.test.ext.junit.runners.AndroidJUnit4
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.GlobalScope
+import kotlinx.coroutines.launch
+import kotlinx.coroutines.runBlocking
+import org.junit.Assert.assertEquals
+import org.junit.Assert.assertNotNull
+import org.junit.Assert.assertNull
+import org.junit.FixMethodOrder
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.junit.runners.MethodSorters
import org.matrix.android.sdk.InstrumentedTest
import org.matrix.android.sdk.api.session.Session
+import org.matrix.android.sdk.api.session.accountdata.UserAccountDataEvent
import org.matrix.android.sdk.api.session.securestorage.EncryptedSecretContent
import org.matrix.android.sdk.api.session.securestorage.KeySigner
import org.matrix.android.sdk.api.session.securestorage.RawBytesKeySpec
@@ -33,18 +45,6 @@ import org.matrix.android.sdk.common.TestConstants
import org.matrix.android.sdk.internal.crypto.SSSS_ALGORITHM_AES_HMAC_SHA2
import org.matrix.android.sdk.internal.crypto.crosssigning.toBase64NoPadding
import org.matrix.android.sdk.internal.crypto.secrets.DefaultSharedSecretStorageService
-import org.matrix.android.sdk.api.session.accountdata.UserAccountDataEvent
-import kotlinx.coroutines.Dispatchers
-import kotlinx.coroutines.GlobalScope
-import kotlinx.coroutines.launch
-import kotlinx.coroutines.runBlocking
-import org.junit.Assert.assertEquals
-import org.junit.Assert.assertNotNull
-import org.junit.Assert.assertNull
-import org.junit.FixMethodOrder
-import org.junit.Test
-import org.junit.runner.RunWith
-import org.junit.runners.MethodSorters
import java.util.concurrent.CountDownLatch
@RunWith(AndroidJUnit4::class)
diff --git a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/crypto/verification/SASTest.kt b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/crypto/verification/SASTest.kt
index 4ea8cdc074..e0d49b3f5e 100644
--- a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/crypto/verification/SASTest.kt
+++ b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/crypto/verification/SASTest.kt
@@ -18,6 +18,16 @@ package org.matrix.android.sdk.internal.crypto.verification
import android.util.Log
import androidx.test.ext.junit.runners.AndroidJUnit4
+import org.junit.Assert.assertEquals
+import org.junit.Assert.assertFalse
+import org.junit.Assert.assertNotNull
+import org.junit.Assert.assertNull
+import org.junit.Assert.assertTrue
+import org.junit.Assert.fail
+import org.junit.FixMethodOrder
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.junit.runners.MethodSorters
import org.matrix.android.sdk.InstrumentedTest
import org.matrix.android.sdk.api.session.Session
import org.matrix.android.sdk.api.session.crypto.verification.CancelCode
@@ -38,16 +48,6 @@ import org.matrix.android.sdk.internal.crypto.model.MXUsersDevicesMap
import org.matrix.android.sdk.internal.crypto.model.rest.KeyVerificationCancel
import org.matrix.android.sdk.internal.crypto.model.rest.KeyVerificationStart
import org.matrix.android.sdk.internal.crypto.model.rest.toValue
-import org.junit.Assert.assertEquals
-import org.junit.Assert.assertFalse
-import org.junit.Assert.assertNotNull
-import org.junit.Assert.assertNull
-import org.junit.Assert.assertTrue
-import org.junit.Assert.fail
-import org.junit.FixMethodOrder
-import org.junit.Test
-import org.junit.runner.RunWith
-import org.junit.runners.MethodSorters
import java.util.concurrent.CountDownLatch
@RunWith(AndroidJUnit4::class)
@@ -551,7 +551,7 @@ class SASTest : InstrumentedTest {
cryptoTestData.roomId
)
- var requestID : String? = null
+ var requestID: String? = null
mTestHelper.waitWithLatch {
mTestHelper.retryPeriodicallyWithLatch(it) {
diff --git a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/crypto/verification/qrcode/SharedSecretTest.kt b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/crypto/verification/qrcode/SharedSecretTest.kt
index 97b93dcf5a..9b10f9e9af 100644
--- a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/crypto/verification/qrcode/SharedSecretTest.kt
+++ b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/crypto/verification/qrcode/SharedSecretTest.kt
@@ -17,13 +17,13 @@
package org.matrix.android.sdk.internal.crypto.verification.qrcode
import androidx.test.ext.junit.runners.AndroidJUnit4
-import org.matrix.android.sdk.InstrumentedTest
import org.amshove.kluent.shouldBe
import org.amshove.kluent.shouldNotBeEqualTo
import org.junit.FixMethodOrder
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.MethodSorters
+import org.matrix.android.sdk.InstrumentedTest
@RunWith(AndroidJUnit4::class)
@FixMethodOrder(MethodSorters.JVM)
diff --git a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/session/room/send/MarkdownParserTest.kt b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/session/room/send/MarkdownParserTest.kt
index 94303dda08..1ed2f89977 100644
--- a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/session/room/send/MarkdownParserTest.kt
+++ b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/session/room/send/MarkdownParserTest.kt
@@ -25,6 +25,9 @@ import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.MethodSorters
import org.matrix.android.sdk.InstrumentedTest
+import org.matrix.android.sdk.api.MatrixConfiguration
+import org.matrix.android.sdk.common.TestRoomDisplayNameFallbackProvider
+import org.matrix.android.sdk.internal.session.displayname.DisplayNameResolver
import org.matrix.android.sdk.internal.session.room.send.pills.MentionLinkSpecComparator
import org.matrix.android.sdk.internal.session.room.send.pills.TextPillsUtils
@@ -48,7 +51,14 @@ class MarkdownParserTest : InstrumentedTest {
private val markdownParser = MarkdownParser(
Parser.builder().build(),
HtmlRenderer.builder().softbreak("
").build(),
- TextPillsUtils(MentionLinkSpecComparator())
+ TextPillsUtils(
+ MentionLinkSpecComparator(),
+ DisplayNameResolver(
+ MatrixConfiguration(
+ applicationFlavor = "TestFlavor",
+ roomDisplayNameFallbackProvider = TestRoomDisplayNameFallbackProvider()
+ )
+ ))
)
@Test
diff --git a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/util/JsonCanonicalizerTest.kt b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/util/JsonCanonicalizerTest.kt
index b5ab6589ff..d38afc6b62 100644
--- a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/util/JsonCanonicalizerTest.kt
+++ b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/util/JsonCanonicalizerTest.kt
@@ -17,10 +17,10 @@
package org.matrix.android.sdk.internal.util
import androidx.test.ext.junit.runners.AndroidJUnit4
-import org.matrix.android.sdk.InstrumentedTest
import org.junit.Assert.assertEquals
import org.junit.Test
import org.junit.runner.RunWith
+import org.matrix.android.sdk.InstrumentedTest
@RunWith(AndroidJUnit4::class)
internal class JsonCanonicalizerTest : InstrumentedTest {
diff --git a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/session/room/timeline/TimelineBackToPreviousLastForwardTest.kt b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/session/room/timeline/TimelineBackToPreviousLastForwardTest.kt
index 3774e6f513..7628f287c9 100644
--- a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/session/room/timeline/TimelineBackToPreviousLastForwardTest.kt
+++ b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/session/room/timeline/TimelineBackToPreviousLastForwardTest.kt
@@ -16,6 +16,14 @@
package org.matrix.android.sdk.session.room.timeline
+import org.amshove.kluent.shouldBeFalse
+import org.amshove.kluent.shouldBeTrue
+import org.junit.Assert.assertTrue
+import org.junit.FixMethodOrder
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.junit.runners.JUnit4
+import org.junit.runners.MethodSorters
import org.matrix.android.sdk.InstrumentedTest
import org.matrix.android.sdk.api.extensions.orFalse
import org.matrix.android.sdk.api.session.events.model.EventType
@@ -26,14 +34,6 @@ import org.matrix.android.sdk.api.session.room.timeline.TimelineSettings
import org.matrix.android.sdk.common.CommonTestHelper
import org.matrix.android.sdk.common.CryptoTestHelper
import org.matrix.android.sdk.common.checkSendOrder
-import org.amshove.kluent.shouldBeFalse
-import org.amshove.kluent.shouldBeTrue
-import org.junit.Assert.assertTrue
-import org.junit.FixMethodOrder
-import org.junit.Test
-import org.junit.runner.RunWith
-import org.junit.runners.JUnit4
-import org.junit.runners.MethodSorters
import timber.log.Timber
import java.util.concurrent.CountDownLatch
@@ -111,8 +111,8 @@ class TimelineBackToPreviousLastForwardTest : InstrumentedTest {
}
// Ok, we have the 10 last messages from Alice.
- snapshot.size == 10
- && snapshot.all { it.root.content.toModel()?.body?.startsWith(messageRoot).orFalse() }
+ snapshot.size == 10 &&
+ snapshot.all { it.root.content.toModel()?.body?.startsWith(messageRoot).orFalse() }
}
bobTimeline.addListener(eventsListener)
@@ -160,10 +160,10 @@ class TimelineBackToPreviousLastForwardTest : InstrumentedTest {
}
// Bob can see the first event of the room (so Back pagination has worked)
- snapshot.lastOrNull()?.root?.getClearType() == EventType.STATE_ROOM_CREATE
+ snapshot.lastOrNull()?.root?.getClearType() == EventType.STATE_ROOM_CREATE &&
// 8 for room creation item, and 30 for the forward pagination
- && snapshot.size == 38
- && snapshot.checkSendOrder(messageRoot, 30, 0)
+ snapshot.size == 38 &&
+ snapshot.checkSendOrder(messageRoot, 30, 0)
}
bobTimeline.addListener(eventsListener)
diff --git a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/session/room/timeline/TimelineForwardPaginationTest.kt b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/session/room/timeline/TimelineForwardPaginationTest.kt
index 0fe341cad6..dfa6ec10ae 100644
--- a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/session/room/timeline/TimelineForwardPaginationTest.kt
+++ b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/session/room/timeline/TimelineForwardPaginationTest.kt
@@ -16,6 +16,13 @@
package org.matrix.android.sdk.session.room.timeline
+import org.amshove.kluent.shouldBeFalse
+import org.amshove.kluent.shouldBeTrue
+import org.junit.FixMethodOrder
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.junit.runners.JUnit4
+import org.junit.runners.MethodSorters
import org.matrix.android.sdk.InstrumentedTest
import org.matrix.android.sdk.api.extensions.orFalse
import org.matrix.android.sdk.api.session.events.model.EventType
@@ -26,13 +33,6 @@ import org.matrix.android.sdk.api.session.room.timeline.TimelineSettings
import org.matrix.android.sdk.common.CommonTestHelper
import org.matrix.android.sdk.common.CryptoTestHelper
import org.matrix.android.sdk.common.checkSendOrder
-import org.amshove.kluent.shouldBeFalse
-import org.amshove.kluent.shouldBeTrue
-import org.junit.FixMethodOrder
-import org.junit.Test
-import org.junit.runner.RunWith
-import org.junit.runners.JUnit4
-import org.junit.runners.MethodSorters
import timber.log.Timber
import java.util.concurrent.CountDownLatch
@@ -86,8 +86,8 @@ class TimelineForwardPaginationTest : InstrumentedTest {
}
// Ok, we have the 10 last messages of the initial sync
- snapshot.size == 10
- && snapshot.all { it.root.content.toModel()?.body?.startsWith(message).orFalse() }
+ snapshot.size == 10 &&
+ snapshot.all { it.root.content.toModel()?.body?.startsWith(message).orFalse() }
}
// Open the timeline at last sent message
@@ -110,8 +110,8 @@ class TimelineForwardPaginationTest : InstrumentedTest {
}
// The event is not in db, so it is fetch alone
- snapshot.size == 1
- && snapshot.all { it.root.content.toModel()?.body?.startsWith("Message from Alice").orFalse() }
+ snapshot.size == 1 &&
+ snapshot.all { it.root.content.toModel()?.body?.startsWith("Message from Alice").orFalse() }
}
aliceTimeline.addListener(aliceEventsListener)
@@ -137,9 +137,9 @@ class TimelineForwardPaginationTest : InstrumentedTest {
}
// Alice can see the first event of the room (so Back pagination has worked)
- snapshot.lastOrNull()?.root?.getClearType() == EventType.STATE_ROOM_CREATE
+ snapshot.lastOrNull()?.root?.getClearType() == EventType.STATE_ROOM_CREATE &&
// 6 for room creation item (backward pagination), 1 for the context, and 50 for the forward pagination
- && snapshot.size == 57 // 6 + 1 + 50
+ snapshot.size == 57 // 6 + 1 + 50
}
aliceTimeline.addListener(aliceEventsListener)
@@ -166,8 +166,8 @@ class TimelineForwardPaginationTest : InstrumentedTest {
Timber.w(" event ${it.root.content}")
}
// 6 for room creation item (backward pagination),and numberOfMessagesToSend (all the message of the room)
- snapshot.size == 6 + numberOfMessagesToSend
- && snapshot.checkSendOrder(message, numberOfMessagesToSend, 0)
+ snapshot.size == 6 + numberOfMessagesToSend &&
+ snapshot.checkSendOrder(message, numberOfMessagesToSend, 0)
}
aliceTimeline.addListener(aliceEventsListener)
diff --git a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/session/room/timeline/TimelinePreviousLastForwardTest.kt b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/session/room/timeline/TimelinePreviousLastForwardTest.kt
index 03a4d41988..e865fe17da 100644
--- a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/session/room/timeline/TimelinePreviousLastForwardTest.kt
+++ b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/session/room/timeline/TimelinePreviousLastForwardTest.kt
@@ -16,6 +16,13 @@
package org.matrix.android.sdk.session.room.timeline
+import org.amshove.kluent.shouldBeFalse
+import org.amshove.kluent.shouldBeTrue
+import org.junit.FixMethodOrder
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.junit.runners.JUnit4
+import org.junit.runners.MethodSorters
import org.matrix.android.sdk.InstrumentedTest
import org.matrix.android.sdk.api.extensions.orFalse
import org.matrix.android.sdk.api.session.events.model.EventType
@@ -26,13 +33,6 @@ import org.matrix.android.sdk.api.session.room.timeline.TimelineSettings
import org.matrix.android.sdk.common.CommonTestHelper
import org.matrix.android.sdk.common.CryptoTestHelper
import org.matrix.android.sdk.common.checkSendOrder
-import org.amshove.kluent.shouldBeFalse
-import org.amshove.kluent.shouldBeTrue
-import org.junit.FixMethodOrder
-import org.junit.Test
-import org.junit.runner.RunWith
-import org.junit.runners.JUnit4
-import org.junit.runners.MethodSorters
import timber.log.Timber
import java.util.concurrent.CountDownLatch
@@ -107,8 +107,8 @@ class TimelinePreviousLastForwardTest : InstrumentedTest {
}
// Ok, we have the 10 last messages from Alice. This will be our future previous lastForward chunk
- snapshot.size == 10
- && snapshot.all { it.root.content.toModel()?.body?.startsWith(firstMessage).orFalse() }
+ snapshot.size == 10 &&
+ snapshot.all { it.root.content.toModel()?.body?.startsWith(firstMessage).orFalse() }
}
bobTimeline.addListener(eventsListener)
@@ -141,8 +141,8 @@ class TimelinePreviousLastForwardTest : InstrumentedTest {
}
// Ok, we have the 10 last messages from Alice. This will be our future previous lastForward chunk
- snapshot.size == 10
- && snapshot.all { it.root.content.toModel()?.body?.startsWith(secondMessage).orFalse() }
+ snapshot.size == 10 &&
+ snapshot.all { it.root.content.toModel()?.body?.startsWith(secondMessage).orFalse() }
}
bobTimeline.addListener(eventsListener)
@@ -216,11 +216,11 @@ class TimelinePreviousLastForwardTest : InstrumentedTest {
}
// Bob can see the first event of the room (so Back pagination has worked)
- snapshot.lastOrNull()?.root?.getClearType() == EventType.STATE_ROOM_CREATE
+ snapshot.lastOrNull()?.root?.getClearType() == EventType.STATE_ROOM_CREATE &&
// 8 for room creation item 60 message from Alice
- && snapshot.size == 68 // 8 + 60
- && snapshot.checkSendOrder(secondMessage, 30, 0)
- && snapshot.checkSendOrder(firstMessage, 30, 30)
+ snapshot.size == 68 && // 8 + 60
+ snapshot.checkSendOrder(secondMessage, 30, 0) &&
+ snapshot.checkSendOrder(firstMessage, 30, 30)
}
bobTimeline.addListener(eventsListener)
diff --git a/matrix-sdk-android/src/debug/java/org/matrix/android/sdk/internal/network/interceptors/CurlLoggingInterceptor.kt b/matrix-sdk-android/src/debug/java/org/matrix/android/sdk/internal/network/interceptors/CurlLoggingInterceptor.kt
index 2103dc954d..3add757efa 100644
--- a/matrix-sdk-android/src/debug/java/org/matrix/android/sdk/internal/network/interceptors/CurlLoggingInterceptor.kt
+++ b/matrix-sdk-android/src/debug/java/org/matrix/android/sdk/internal/network/interceptors/CurlLoggingInterceptor.kt
@@ -17,10 +17,10 @@
package org.matrix.android.sdk.internal.network.interceptors
-import org.matrix.android.sdk.internal.di.MatrixScope
import okhttp3.Interceptor
import okhttp3.Response
import okio.Buffer
+import org.matrix.android.sdk.internal.di.MatrixScope
import timber.log.Timber
import java.io.IOException
import java.nio.charset.Charset
@@ -36,8 +36,8 @@ import javax.inject.Inject
* non-production environment.
*/
@MatrixScope
-internal class CurlLoggingInterceptor @Inject constructor()
- : Interceptor {
+internal class CurlLoggingInterceptor @Inject constructor() :
+ Interceptor {
/**
* Set any additional curl command options (see 'curl --help').
@@ -90,8 +90,8 @@ internal class CurlLoggingInterceptor @Inject constructor()
curlCmd += ((if (compressed) " --compressed " else " ") + "'" + request.url.toString()
// Replace localhost for emulator by localhost for shell
- .replace("://10.0.2.2:8080/".toRegex(), "://127.0.0.1:8080/")
- + "'")
+ .replace("://10.0.2.2:8080/".toRegex(), "://127.0.0.1:8080/") +
+ "'")
// Add Json formatting
curlCmd += " | python -m json.tool"
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/MatrixConfiguration.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/MatrixConfiguration.kt
index ed809cdb04..3359e253f6 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/MatrixConfiguration.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/MatrixConfiguration.kt
@@ -32,14 +32,26 @@ data class MatrixConfiguration(
"https://scalar-staging.riot.im/scalar/api"
),
/**
- * Optional proxy to connect to the matrix servers
- * You can create one using for instance Proxy(proxyType, InetSocketAddress.createUnresolved(hostname, port)
+ * Optional base url to create client permalinks (eg. https://www.example.com/#/) instead of Matrix ones (matrix.to links).
+ * Do not forget to add the "#" which is required by the permalink parser.
+ *
+ * Note: this field is only used for permalinks creation, you will also have to edit the string-array `permalink_supported_hosts` in the config file
+ * and add it to your manifest to handle these links in the application.
+ */
+ val clientPermalinkBaseUrl: String? = null,
+ /**
+ * Optional proxy to connect to the matrix servers.
+ * You can create one using for instance Proxy(proxyType, InetSocketAddress.createUnresolved(hostname, port).
*/
val proxy: Proxy? = null,
/**
* True to advertise support for call transfers to other parties on Matrix calls.
*/
val supportsCallTransfer: Boolean = false,
+ /**
+ * MatrixItemDisplayNameFallbackProvider to provide default display name for MatrixItem. By default, the id will be used
+ */
+ val matrixItemDisplayNameFallbackProvider: MatrixItemDisplayNameFallbackProvider? = null,
/**
* RoomDisplayNameFallbackProvider to provide default room display name.
*/
@@ -47,7 +59,7 @@ data class MatrixConfiguration(
) {
/**
- * Can be implemented by your Application class
+ * Can be implemented by your Application class.
*/
interface Provider {
fun providesMatrixConfiguration(): MatrixConfiguration
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/MatrixConstants.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/MatrixConstants.kt
new file mode 100644
index 0000000000..49520f3678
--- /dev/null
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/MatrixConstants.kt
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2021 The Matrix.org Foundation C.I.C.
+ *
+ * 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 org.matrix.android.sdk.api
+
+/**
+ * This object define some global constants regarding the Matrix specification
+ */
+object MatrixConstants {
+ /**
+ * Max length for an alias. Room aliases MUST NOT exceed 255 bytes (including the # sigil and the domain).
+ * See [maxAliasLocalPartLength]
+ * Ref. https://matrix.org/docs/spec/appendices#room-aliases
+ */
+ const val ALIAS_MAX_LENGTH = 255
+
+ fun maxAliasLocalPartLength(domain: String): Int {
+ return (ALIAS_MAX_LENGTH - 1 /* # sigil */ - 1 /* ':' */ - domain.length)
+ .coerceAtLeast(0)
+ }
+}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/MatrixItemDisplayNameFallbackProvider.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/MatrixItemDisplayNameFallbackProvider.kt
new file mode 100644
index 0000000000..82008cda8c
--- /dev/null
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/MatrixItemDisplayNameFallbackProvider.kt
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2021 The Matrix.org Foundation C.I.C.
+ *
+ * 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 org.matrix.android.sdk.api
+
+import org.matrix.android.sdk.api.util.MatrixItem
+
+interface MatrixItemDisplayNameFallbackProvider {
+ fun getDefaultName(matrixItem: MatrixItem): String
+}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/MatrixPatterns.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/MatrixPatterns.kt
index 9a5e40ffeb..2a26b612fb 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/MatrixPatterns.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/MatrixPatterns.kt
@@ -17,6 +17,8 @@
package org.matrix.android.sdk.api
import org.matrix.android.sdk.BuildConfig
+import org.matrix.android.sdk.internal.util.removeInvalidRoomNameChars
+import org.matrix.android.sdk.internal.util.replaceSpaceChars
import timber.log.Timber
/**
@@ -128,10 +130,10 @@ object MatrixPatterns {
* @return true if the string is a valid event id.
*/
fun isEventId(str: String?): Boolean {
- return str != null
- && (str matches PATTERN_CONTAIN_MATRIX_EVENT_IDENTIFIER
- || str matches PATTERN_CONTAIN_MATRIX_EVENT_IDENTIFIER_V3
- || str matches PATTERN_CONTAIN_MATRIX_EVENT_IDENTIFIER_V4)
+ return str != null &&
+ (str matches PATTERN_CONTAIN_MATRIX_EVENT_IDENTIFIER ||
+ str matches PATTERN_CONTAIN_MATRIX_EVENT_IDENTIFIER_V3 ||
+ str matches PATTERN_CONTAIN_MATRIX_EVENT_IDENTIFIER_V4)
}
/**
@@ -162,10 +164,11 @@ object MatrixPatterns {
return order != null && order.length < 50 && order matches ORDER_STRING_REGEX
}
- fun candidateAliasFromRoomName(name: String): String {
- return Regex("\\s").replace(name.lowercase(), "_").let {
- "[^a-z0-9._%#@=+-]".toRegex().replace(it, "")
- }
+ fun candidateAliasFromRoomName(roomName: String, domain: String): String {
+ return roomName.lowercase()
+ .replaceSpaceChars(replacement = "_")
+ .removeInvalidRoomNameChars()
+ .take(MatrixConstants.maxAliasLocalPartLength(domain))
}
/**
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/MatrixUrls.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/MatrixUrls.kt
new file mode 100644
index 0000000000..dc4e0f152d
--- /dev/null
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/MatrixUrls.kt
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2021 The Matrix.org Foundation C.I.C.
+ *
+ * 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 org.matrix.android.sdk.api
+
+/**
+ * This class contains pattern to match Matrix Url, aka mxc urls
+ */
+object MatrixUrls {
+ const val MATRIX_CONTENT_URI_SCHEME = "mxc://"
+
+ fun String.isMxcUrl() = startsWith(MATRIX_CONTENT_URI_SCHEME)
+}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/auth/UIABaseAuth.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/auth/UIABaseAuth.kt
index d5e323e457..3a8e6b1084 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/auth/UIABaseAuth.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/auth/UIABaseAuth.kt
@@ -27,5 +27,5 @@ interface UIABaseAuth {
fun copyWithSession(session: String): UIABaseAuth
- fun asMap() : Map
+ fun asMap(): Map
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/failure/Extensions.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/failure/Extensions.kt
index 3149a0218b..b2035bb2eb 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/failure/Extensions.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/failure/Extensions.kt
@@ -23,20 +23,20 @@ import java.io.IOException
import javax.net.ssl.HttpsURLConnection
fun Throwable.is401() =
- this is Failure.ServerError
- && httpCode == HttpsURLConnection.HTTP_UNAUTHORIZED /* 401 */
- && error.code == MatrixError.M_UNAUTHORIZED
+ this is Failure.ServerError &&
+ httpCode == HttpsURLConnection.HTTP_UNAUTHORIZED && /* 401 */
+ error.code == MatrixError.M_UNAUTHORIZED
fun Throwable.isTokenError() =
- this is Failure.ServerError
- && (error.code == MatrixError.M_UNKNOWN_TOKEN
- || error.code == MatrixError.M_MISSING_TOKEN
- || error.code == MatrixError.ORG_MATRIX_EXPIRED_ACCOUNT)
+ this is Failure.ServerError &&
+ (error.code == MatrixError.M_UNKNOWN_TOKEN ||
+ error.code == MatrixError.M_MISSING_TOKEN ||
+ error.code == MatrixError.ORG_MATRIX_EXPIRED_ACCOUNT)
fun Throwable.shouldBeRetried(): Boolean {
- return this is Failure.NetworkConnection
- || this is IOException
- || (this is Failure.ServerError && error.code == MatrixError.M_LIMIT_EXCEEDED)
+ return this is Failure.NetworkConnection ||
+ this is IOException ||
+ (this is Failure.ServerError && error.code == MatrixError.M_LIMIT_EXCEEDED)
}
/**
@@ -52,31 +52,31 @@ fun Throwable.getRetryDelay(defaultValue: Long): Long {
}
fun Throwable.isInvalidPassword(): Boolean {
- return this is Failure.ServerError
- && error.code == MatrixError.M_FORBIDDEN
- && error.message == "Invalid password"
+ return this is Failure.ServerError &&
+ error.code == MatrixError.M_FORBIDDEN &&
+ error.message == "Invalid password"
}
fun Throwable.isInvalidUIAAuth(): Boolean {
- return this is Failure.ServerError
- && error.code == MatrixError.M_FORBIDDEN
- && error.flows != null
+ return this is Failure.ServerError &&
+ error.code == MatrixError.M_FORBIDDEN &&
+ error.flows != null
}
/**
* Try to convert to a RegistrationFlowResponse. Return null in the cases it's not possible
*/
fun Throwable.toRegistrationFlowResponse(): RegistrationFlowResponse? {
- return if (this is Failure.OtherServerError
- && httpCode == HttpsURLConnection.HTTP_UNAUTHORIZED /* 401 */) {
+ return if (this is Failure.OtherServerError &&
+ httpCode == HttpsURLConnection.HTTP_UNAUTHORIZED /* 401 */) {
tryOrNull {
MoshiProvider.providesMoshi()
.adapter(RegistrationFlowResponse::class.java)
.fromJson(errorBody)
}
- } else if (this is Failure.ServerError
- && httpCode == HttpsURLConnection.HTTP_UNAUTHORIZED /* 401 */
- && error.code == MatrixError.M_FORBIDDEN) {
+ } else if (this is Failure.ServerError &&
+ httpCode == HttpsURLConnection.HTTP_UNAUTHORIZED && /* 401 */
+ error.code == MatrixError.M_FORBIDDEN) {
// This happens when the submission for this stage was bad (like bad password)
if (error.session != null && error.flows != null) {
RegistrationFlowResponse(
@@ -94,9 +94,9 @@ fun Throwable.toRegistrationFlowResponse(): RegistrationFlowResponse? {
}
fun Throwable.isRegistrationAvailabilityError(): Boolean {
- return this is Failure.ServerError
- && httpCode == HttpsURLConnection.HTTP_BAD_REQUEST /* 400 */
- && (error.code == MatrixError.M_USER_IN_USE
- || error.code == MatrixError.M_INVALID_USERNAME
- || error.code == MatrixError.M_EXCLUSIVE)
+ return this is Failure.ServerError &&
+ httpCode == HttpsURLConnection.HTTP_BAD_REQUEST && /* 400 */
+ (error.code == MatrixError.M_USER_IN_USE ||
+ error.code == MatrixError.M_INVALID_USERNAME ||
+ error.code == MatrixError.M_EXCLUSIVE)
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/network/ApiPath.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/network/ApiPath.kt
index db112a30b2..baf33a59c5 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/network/ApiPath.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/network/ApiPath.kt
@@ -154,7 +154,6 @@ enum class ApiPath(val path: String, val method: String) {
SEND_STATE_EVENT(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/state/{state_event_type}", "PUT"),
SEND_STATE_EVENT_WITH_STATE_KEY(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/state/{state_event_type}/{state_key}", "PUT"),
GET_ROOM_STATE(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/state", "GET"),
- SEND_RELATION(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/send_relation/{parent_id}/{relation_type}/{event_type}", "POST"),
GET_RELATIONS(NetworkConstants.URI_API_PREFIX_PATH_UNSTABLE + "rooms/{roomId}/relations/{eventId}/{relationType}/{eventType}", "GET"),
JOIN_ROOM(NetworkConstants.URI_API_PREFIX_PATH_R0 + "join/{roomIdOrAlias}", "POST"),
LEAVE_ROOM(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/leave", "POST"),
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/Session.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/Session.kt
index 1443a8d3b9..bde68da9d7 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/Session.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/Session.kt
@@ -18,6 +18,7 @@ package org.matrix.android.sdk.api.session
import androidx.annotation.MainThread
import androidx.lifecycle.LiveData
+import kotlinx.coroutines.flow.SharedFlow
import okhttp3.OkHttpClient
import org.matrix.android.sdk.api.auth.data.SessionParams
import org.matrix.android.sdk.api.failure.GlobalError
@@ -52,6 +53,7 @@ import org.matrix.android.sdk.api.session.signout.SignOutService
import org.matrix.android.sdk.api.session.space.SpaceService
import org.matrix.android.sdk.api.session.sync.FilterService
import org.matrix.android.sdk.api.session.sync.SyncState
+import org.matrix.android.sdk.api.session.sync.model.SyncResponse
import org.matrix.android.sdk.api.session.terms.TermsService
import org.matrix.android.sdk.api.session.thirdparty.ThirdPartyService
import org.matrix.android.sdk.api.session.typing.TypingUsersTracker
@@ -143,6 +145,11 @@ interface Session :
*/
fun getSyncState(): SyncState
+ /**
+ * This method returns a flow of SyncResponse. New value will be pushed through the sync thread.
+ */
+ fun syncFlow(): SharedFlow
+
/**
* This methods return true if an initial sync has been processed
*/
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/call/CallState.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/call/CallState.kt
index 47a63b4a25..ff1df63300 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/call/CallState.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/call/CallState.kt
@@ -26,7 +26,7 @@ sealed class CallState {
/**
* CreateOffer. Intermediate state between Idle and Dialing.
*/
- object CreateOffer: CallState()
+ object CreateOffer : CallState()
/** Dialing. Outgoing call is signaling the remote peer */
object Dialing : CallState()
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/crypto/crosssigning/MXCrossSigningInfo.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/crypto/crosssigning/MXCrossSigningInfo.kt
index 6327dd92fd..20ee68d228 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/crypto/crosssigning/MXCrossSigningInfo.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/crypto/crosssigning/MXCrossSigningInfo.kt
@@ -24,8 +24,8 @@ data class MXCrossSigningInfo(
val crossSigningKeys: List
) {
- fun isTrusted(): Boolean = masterKey()?.trustLevel?.isVerified() == true
- && selfSigningKey()?.trustLevel?.isVerified() == true
+ fun isTrusted(): Boolean = masterKey()?.trustLevel?.isVerified() == true &&
+ selfSigningKey()?.trustLevel?.isVerified() == true
fun masterKey(): CryptoCrossSigningKey? = crossSigningKeys
.firstOrNull { it.usages?.contains(KeyUsage.MASTER.value) == true }
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/crypto/keyshare/GossipingRequestListener.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/crypto/keyshare/GossipingRequestListener.kt
index 810d28dd83..ba2d4ba3f6 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/crypto/keyshare/GossipingRequestListener.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/crypto/keyshare/GossipingRequestListener.kt
@@ -16,8 +16,8 @@
package org.matrix.android.sdk.api.session.crypto.keyshare
-import org.matrix.android.sdk.internal.crypto.IncomingRoomKeyRequest
import org.matrix.android.sdk.internal.crypto.IncomingRequestCancellation
+import org.matrix.android.sdk.internal.crypto.IncomingRoomKeyRequest
import org.matrix.android.sdk.internal.crypto.IncomingSecretShareRequest
/**
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/crypto/verification/PendingVerificationRequest.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/crypto/verification/PendingVerificationRequest.kt
index 1ee161724a..be450b9d03 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/crypto/verification/PendingVerificationRequest.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/crypto/verification/PendingVerificationRequest.kt
@@ -48,8 +48,8 @@ data class PendingVerificationRequest(
* SAS is supported if I support it and the other party support it
*/
fun isSasSupported(): Boolean {
- return requestInfo?.methods?.contains(VERIFICATION_METHOD_SAS).orFalse()
- && readyInfo?.methods?.contains(VERIFICATION_METHOD_SAS).orFalse()
+ return requestInfo?.methods?.contains(VERIFICATION_METHOD_SAS).orFalse() &&
+ readyInfo?.methods?.contains(VERIFICATION_METHOD_SAS).orFalse()
}
/**
@@ -57,11 +57,11 @@ data class PendingVerificationRequest(
*/
fun otherCanShowQrCode(): Boolean {
return if (isIncoming) {
- requestInfo?.methods?.contains(VERIFICATION_METHOD_QR_CODE_SHOW).orFalse()
- && readyInfo?.methods?.contains(VERIFICATION_METHOD_QR_CODE_SCAN).orFalse()
+ requestInfo?.methods?.contains(VERIFICATION_METHOD_QR_CODE_SHOW).orFalse() &&
+ readyInfo?.methods?.contains(VERIFICATION_METHOD_QR_CODE_SCAN).orFalse()
} else {
- requestInfo?.methods?.contains(VERIFICATION_METHOD_QR_CODE_SCAN).orFalse()
- && readyInfo?.methods?.contains(VERIFICATION_METHOD_QR_CODE_SHOW).orFalse()
+ requestInfo?.methods?.contains(VERIFICATION_METHOD_QR_CODE_SCAN).orFalse() &&
+ readyInfo?.methods?.contains(VERIFICATION_METHOD_QR_CODE_SHOW).orFalse()
}
}
@@ -70,11 +70,11 @@ data class PendingVerificationRequest(
*/
fun otherCanScanQrCode(): Boolean {
return if (isIncoming) {
- requestInfo?.methods?.contains(VERIFICATION_METHOD_QR_CODE_SCAN).orFalse()
- && readyInfo?.methods?.contains(VERIFICATION_METHOD_QR_CODE_SHOW).orFalse()
+ requestInfo?.methods?.contains(VERIFICATION_METHOD_QR_CODE_SCAN).orFalse() &&
+ readyInfo?.methods?.contains(VERIFICATION_METHOD_QR_CODE_SHOW).orFalse()
} else {
- requestInfo?.methods?.contains(VERIFICATION_METHOD_QR_CODE_SHOW).orFalse()
- && readyInfo?.methods?.contains(VERIFICATION_METHOD_QR_CODE_SCAN).orFalse()
+ requestInfo?.methods?.contains(VERIFICATION_METHOD_QR_CODE_SHOW).orFalse() &&
+ readyInfo?.methods?.contains(VERIFICATION_METHOD_QR_CODE_SCAN).orFalse()
}
}
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/events/model/Event.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/events/model/Event.kt
index 1f8471c111..96b44ce8c9 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/events/model/Event.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/events/model/Event.kt
@@ -18,6 +18,9 @@ package org.matrix.android.sdk.api.session.events.model
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
+import org.json.JSONObject
+import org.matrix.android.sdk.api.extensions.tryOrNull
+import org.matrix.android.sdk.api.failure.MatrixError
import org.matrix.android.sdk.api.session.crypto.MXCryptoError
import org.matrix.android.sdk.api.session.room.model.message.MessageContent
import org.matrix.android.sdk.api.session.room.model.message.MessageType
@@ -27,9 +30,6 @@ import org.matrix.android.sdk.api.util.JsonDict
import org.matrix.android.sdk.internal.crypto.algorithms.olm.OlmDecryptionResult
import org.matrix.android.sdk.internal.crypto.model.event.EncryptedEventContent
import org.matrix.android.sdk.internal.di.MoshiProvider
-import org.json.JSONObject
-import org.matrix.android.sdk.api.extensions.tryOrNull
-import org.matrix.android.sdk.api.failure.MatrixError
import timber.log.Timber
typealias Content = JsonDict
@@ -238,8 +238,8 @@ data class Event(
}
fun Event.isTextMessage(): Boolean {
- return getClearType() == EventType.MESSAGE
- && when (getClearContent()?.get(MessageContent.MSG_TYPE_JSON_KEY)) {
+ return getClearType() == EventType.MESSAGE &&
+ when (getClearContent()?.get(MessageContent.MSG_TYPE_JSON_KEY)) {
MessageType.MSGTYPE_TEXT,
MessageType.MSGTYPE_EMOTE,
MessageType.MSGTYPE_NOTICE -> true
@@ -248,40 +248,40 @@ fun Event.isTextMessage(): Boolean {
}
fun Event.isImageMessage(): Boolean {
- return getClearType() == EventType.MESSAGE
- && when (getClearContent()?.get(MessageContent.MSG_TYPE_JSON_KEY)) {
+ return getClearType() == EventType.MESSAGE &&
+ when (getClearContent()?.get(MessageContent.MSG_TYPE_JSON_KEY)) {
MessageType.MSGTYPE_IMAGE -> true
else -> false
}
}
fun Event.isVideoMessage(): Boolean {
- return getClearType() == EventType.MESSAGE
- && when (getClearContent()?.get(MessageContent.MSG_TYPE_JSON_KEY)) {
+ return getClearType() == EventType.MESSAGE &&
+ when (getClearContent()?.get(MessageContent.MSG_TYPE_JSON_KEY)) {
MessageType.MSGTYPE_VIDEO -> true
else -> false
}
}
fun Event.isAudioMessage(): Boolean {
- return getClearType() == EventType.MESSAGE
- && when (getClearContent()?.get(MessageContent.MSG_TYPE_JSON_KEY)) {
+ return getClearType() == EventType.MESSAGE &&
+ when (getClearContent()?.get(MessageContent.MSG_TYPE_JSON_KEY)) {
MessageType.MSGTYPE_AUDIO -> true
else -> false
}
}
fun Event.isFileMessage(): Boolean {
- return getClearType() == EventType.MESSAGE
- && when (getClearContent()?.get(MessageContent.MSG_TYPE_JSON_KEY)) {
+ return getClearType() == EventType.MESSAGE &&
+ when (getClearContent()?.get(MessageContent.MSG_TYPE_JSON_KEY)) {
MessageType.MSGTYPE_FILE -> true
else -> false
}
}
fun Event.isAttachmentMessage(): Boolean {
- return getClearType() == EventType.MESSAGE
- && when (getClearContent()?.get(MessageContent.MSG_TYPE_JSON_KEY)) {
+ return getClearType() == EventType.MESSAGE &&
+ when (getClearContent()?.get(MessageContent.MSG_TYPE_JSON_KEY)) {
MessageType.MSGTYPE_IMAGE,
MessageType.MSGTYPE_AUDIO,
MessageType.MSGTYPE_VIDEO,
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/events/model/EventType.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/events/model/EventType.kt
index 9c3fdd57da..d0ce55070e 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/events/model/EventType.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/events/model/EventType.kt
@@ -106,13 +106,13 @@ object EventType {
internal const val DUMMY = "m.dummy"
fun isCallEvent(type: String): Boolean {
- return type == CALL_INVITE
- || type == CALL_CANDIDATES
- || type == CALL_ANSWER
- || type == CALL_HANGUP
- || type == CALL_SELECT_ANSWER
- || type == CALL_NEGOTIATE
- || type == CALL_REJECT
- || type == CALL_REPLACES
+ return type == CALL_INVITE ||
+ type == CALL_CANDIDATES ||
+ type == CALL_ANSWER ||
+ type == CALL_HANGUP ||
+ type == CALL_SELECT_ANSWER ||
+ type == CALL_NEGOTIATE ||
+ type == CALL_REJECT ||
+ type == CALL_REPLACES
}
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/homeserver/HomeServerCapabilities.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/homeserver/HomeServerCapabilities.kt
index b49236c338..3ed6a7ebb2 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/homeserver/HomeServerCapabilities.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/homeserver/HomeServerCapabilities.kt
@@ -89,7 +89,7 @@ data class HomeServerCapabilities(
* You can also use #isFeatureSupported prior to this call to check if the
* feature is supported and report some feedback to user.
*/
- fun versionOverrideForFeature(feature: String) : String? {
+ fun versionOverrideForFeature(feature: String): String? {
val cap = roomVersions?.capabilities?.get(feature)
return cap?.preferred ?: cap?.support?.lastOrNull()
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/identity/IdentityService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/identity/IdentityService.kt
index 1485ec478b..a22cd572fa 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/identity/IdentityService.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/identity/IdentityService.kt
@@ -132,7 +132,7 @@ interface IdentityService {
* the identity server offers some crypto functionality to help in accepting invitations.
* This is less secure than the client doing it itself, but may be useful where this isn't possible.
*/
- suspend fun sign3pidInvitation(identiyServer: String, token: String, secret: String) : SignInvitationResult
+ suspend fun sign3pidInvitation(identiyServer: String, token: String, secret: String): SignInvitationResult
fun addListener(listener: IdentityServiceListener)
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/initsync/SyncStatusService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/initsync/SyncStatusService.kt
index 38d47ae1a9..daab6d9761 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/initsync/SyncStatusService.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/initsync/SyncStatusService.kt
@@ -25,7 +25,7 @@ interface SyncStatusService {
/**
* For initial sync
*/
- abstract class InitialSyncStatus: Status()
+ abstract class InitialSyncStatus : Status()
object Idle : InitialSyncStatus()
data class Progressing(
@@ -36,7 +36,7 @@ interface SyncStatusService {
/**
* For incremental sync
*/
- abstract class IncrementalSyncStatus: Status()
+ abstract class IncrementalSyncStatus : Status()
object IncrementalSyncIdle : IncrementalSyncStatus()
data class IncrementalSyncParsing(
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/permalinks/MatrixLinkify.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/permalinks/MatrixLinkify.kt
index 5e9f3e1eb9..3e27da0c41 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/permalinks/MatrixLinkify.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/permalinks/MatrixLinkify.kt
@@ -50,11 +50,11 @@ object MatrixLinkify {
if (startPos == 0 || text[startPos - 1] != '/') {
val endPos = match.range.last + 1
var url = text.substring(match.range)
- if (MatrixPatterns.isUserId(url)
- || MatrixPatterns.isRoomAlias(url)
- || MatrixPatterns.isRoomId(url)
- || MatrixPatterns.isGroupId(url)
- || MatrixPatterns.isEventId(url)) {
+ if (MatrixPatterns.isUserId(url) ||
+ MatrixPatterns.isRoomAlias(url) ||
+ MatrixPatterns.isRoomId(url) ||
+ MatrixPatterns.isGroupId(url) ||
+ MatrixPatterns.isEventId(url)) {
url = PermalinkService.MATRIX_TO_URL_BASE + url
}
val span = MatrixPermalinkSpan(url, callback)
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/permalinks/MatrixToConverter.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/permalinks/MatrixToConverter.kt
new file mode 100644
index 0000000000..a904e89681
--- /dev/null
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/permalinks/MatrixToConverter.kt
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2020 The Matrix.org Foundation C.I.C.
+ *
+ * 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 org.matrix.android.sdk.api.session.permalinks
+
+import android.net.Uri
+
+/**
+ * Mapping of an input URI to a matrix.to compliant URI.
+ */
+object MatrixToConverter {
+
+ /**
+ * Try to convert a URL from an element web instance or from a client permalink to a matrix.to url.
+ * To be successfully converted, URL path should contain one of the [SUPPORTED_PATHS].
+ * Examples:
+ * - https://riot.im/develop/#/room/#element-android:matrix.org -> https://matrix.to/#/#element-android:matrix.org
+ * - https://app.element.io/#/room/#element-android:matrix.org -> https://matrix.to/#/#element-android:matrix.org
+ * - https://www.example.org/#/room/#element-android:matrix.org -> https://matrix.to/#/#element-android:matrix.org
+ */
+ fun convert(uri: Uri): Uri? {
+ val uriString = uri.toString()
+
+ return when {
+ // URL is already a matrix.to
+ uriString.startsWith(PermalinkService.MATRIX_TO_URL_BASE) -> uri
+ // Web or client url
+ SUPPORTED_PATHS.any { it in uriString } -> {
+ val path = SUPPORTED_PATHS.first { it in uriString }
+ Uri.parse(PermalinkService.MATRIX_TO_URL_BASE + uriString.substringAfter(path))
+ }
+ // URL is not supported
+ else -> null
+ }
+ }
+
+ private val SUPPORTED_PATHS = listOf(
+ "/#/room/",
+ "/#/user/",
+ "/#/group/"
+ )
+}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/permalinks/PermalinkParser.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/permalinks/PermalinkParser.kt
index 005a2edae7..edb748c76e 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/permalinks/PermalinkParser.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/permalinks/PermalinkParser.kt
@@ -26,6 +26,7 @@ import java.net.URLDecoder
* This class turns a uri to a [PermalinkData]
* element-based domains (e.g. https://app.element.io/#/user/@chagai95:matrix.org) permalinks
* or matrix.to permalinks (e.g. https://matrix.to/#/@chagai95:matrix.org)
+ * or client permalinks (e.g. user/@chagai95:matrix.org)
*/
object PermalinkParser {
@@ -42,13 +43,15 @@ object PermalinkParser {
* https://github.com/matrix-org/matrix-doc/blob/master/proposals/1704-matrix.to-permalinks.md
*/
fun parse(uri: Uri): PermalinkData {
- if (!uri.toString().startsWith(PermalinkService.MATRIX_TO_URL_BASE)) {
- return PermalinkData.FallbackLink(uri)
- }
+ // the client or element-based domain permalinks (e.g. https://app.element.io/#/user/@chagai95:matrix.org) don't have the
+ // mxid in the first param (like matrix.to does - https://matrix.to/#/@chagai95:matrix.org) but rather in the second after /user/ so /user/mxid
+ // so convert URI to matrix.to to simplify parsing process
+ val matrixToUri = MatrixToConverter.convert(uri) ?: return PermalinkData.FallbackLink(uri)
+
// We can't use uri.fragment as it is decoding to early and it will break the parsing
// of parameters that represents url (like signurl)
- val fragment = uri.toString().substringAfter("#") // uri.fragment
- if (fragment.isNullOrEmpty()) {
+ val fragment = matrixToUri.toString().substringAfter("#") // uri.fragment
+ if (fragment.isEmpty()) {
return PermalinkData.FallbackLink(uri)
}
val safeFragment = fragment.substringBefore('?')
@@ -61,20 +64,14 @@ object PermalinkParser {
.map { URLDecoder.decode(it, "UTF-8") }
.take(2)
- // the element-based domain permalinks (e.g. https://app.element.io/#/user/@chagai95:matrix.org) don't have the
- // mxid in the first param (like matrix.to does - https://matrix.to/#/@chagai95:matrix.org) but rather in the second after /user/ so /user/mxid
- var identifier = params.getOrNull(0)
- if (identifier.equals("user")) {
- identifier = params.getOrNull(1)
- }
-
+ val identifier = params.getOrNull(0)
val extraParameter = params.getOrNull(1)
return when {
identifier.isNullOrEmpty() -> PermalinkData.FallbackLink(uri)
MatrixPatterns.isUserId(identifier) -> PermalinkData.UserLink(userId = identifier)
MatrixPatterns.isGroupId(identifier) -> PermalinkData.GroupLink(groupId = identifier)
MatrixPatterns.isRoomId(identifier) -> {
- handleRoomIdCase(fragment, identifier, uri, extraParameter, viaQueryParameters)
+ handleRoomIdCase(fragment, identifier, matrixToUri, extraParameter, viaQueryParameters)
}
MatrixPatterns.isRoomAlias(identifier) -> {
PermalinkData.RoomLink(
@@ -125,12 +122,13 @@ object PermalinkParser {
}
}
- private fun safeExtractParams(fragment: String) = fragment.substringAfter("?").split('&').mapNotNull {
- val splitNameValue = it.split("=")
- if (splitNameValue.size == 2) {
- Pair(splitNameValue[0], URLDecoder.decode(splitNameValue[1], "UTF-8"))
- } else null
- }
+ private fun safeExtractParams(fragment: String) =
+ fragment.substringAfter("?").split('&').mapNotNull {
+ val splitNameValue = it.split("=")
+ if (splitNameValue.size == 2) {
+ Pair(splitNameValue[0], URLDecoder.decode(splitNameValue[1], "UTF-8"))
+ } else null
+ }
private fun String.getViaParameters(): List {
return UrlQuerySanitizer(this)
@@ -138,9 +136,7 @@ object PermalinkParser {
.filter {
it.mParameter == "via"
}.map {
- it.mValue.let {
- URLDecoder.decode(it, "UTF-8")
- }
+ URLDecoder.decode(it.mValue, "UTF-8")
}
}
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/permalinks/PermalinkService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/permalinks/PermalinkService.kt
index a6d4583c76..920dc85c7a 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/permalinks/PermalinkService.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/permalinks/PermalinkService.kt
@@ -19,7 +19,8 @@ package org.matrix.android.sdk.api.session.permalinks
import org.matrix.android.sdk.api.session.events.model.Event
/**
- * Useful methods to create Matrix permalink (matrix.to links).
+ * Useful methods to create permalink (like matrix.to links or client permalinks).
+ * See [org.matrix.android.sdk.api.MatrixConfiguration.clientPermalinkBaseUrl] to setup a custom permalink base url.
*/
interface PermalinkService {
@@ -32,10 +33,11 @@ interface PermalinkService {
* Ex: "https://matrix.to/#/!nbzmcXAqpxBXjAdgoX:matrix.org/$1531497316352799BevdV:matrix.org"
*
* @param event the event
+ * @param forceMatrixTo whether we should force using matrix.to base URL
*
* @return the permalink, or null in case of error
*/
- fun createPermalink(event: Event): String?
+ fun createPermalink(event: Event, forceMatrixTo: Boolean = false): String?
/**
* Creates a permalink for an id (can be a user Id, etc.).
@@ -43,18 +45,21 @@ interface PermalinkService {
* Ex: "https://matrix.to/#/@benoit:matrix.org"
*
* @param id the id
+ * @param forceMatrixTo whether we should force using matrix.to base URL
+ *
* @return the permalink, or null in case of error
*/
- fun createPermalink(id: String): String?
+ fun createPermalink(id: String, forceMatrixTo: Boolean = false): String?
/**
* Creates a permalink for a roomId, including the via parameters
*
* @param roomId the room id
+ * @param forceMatrixTo whether we should force using matrix.to base URL
*
* @return the permalink, or null in case of error
*/
- fun createRoomPermalink(roomId: String, viaServers: List? = null): String?
+ fun createRoomPermalink(roomId: String, viaServers: List? = null, forceMatrixTo: Boolean = false): String?
/**
* Creates a permalink for an event. If you have an event you can use [createPermalink]
@@ -62,10 +67,11 @@ interface PermalinkService {
*
* @param roomId the id of the room
* @param eventId the id of the event
+ * @param forceMatrixTo whether we should force using matrix.to base URL
*
* @return the permalink
*/
- fun createPermalink(roomId: String, eventId: String): String
+ fun createPermalink(roomId: String, eventId: String, forceMatrixTo: Boolean = false): String
/**
* Extract the linked id from the universal link
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/AliasAvailabilityResult.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/AliasAvailabilityResult.kt
index 6f607569c0..fff6adecbf 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/AliasAvailabilityResult.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/AliasAvailabilityResult.kt
@@ -19,6 +19,6 @@ package org.matrix.android.sdk.api.session.room
import org.matrix.android.sdk.api.session.room.alias.RoomAliasError
sealed class AliasAvailabilityResult {
- object Available: AliasAvailabilityResult()
+ object Available : AliasAvailabilityResult()
data class NotAvailable(val roomAliasError: RoomAliasError) : AliasAvailabilityResult()
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/RoomDirectoryService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/RoomDirectoryService.kt
index f3e3913bc1..9446f0fdff 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/RoomDirectoryService.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/RoomDirectoryService.kt
@@ -41,5 +41,5 @@ interface RoomDirectoryService {
*/
suspend fun setRoomDirectoryVisibility(roomId: String, roomDirectoryVisibility: RoomDirectoryVisibility)
- suspend fun checkAliasAvailability(aliasLocalPart: String?) : AliasAvailabilityResult
+ suspend fun checkAliasAvailability(aliasLocalPart: String?): AliasAvailabilityResult
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/RoomService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/RoomService.kt
index 5d26b21349..d80faa729c 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/RoomService.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/RoomService.kt
@@ -220,7 +220,7 @@ interface RoomService {
.setPrefetchDistance(10)
.build()
- fun getFlattenRoomSummaryChildrenOf(spaceId: String?, memberships: List = Membership.activeMemberships()) : List
+ fun getFlattenRoomSummaryChildrenOf(spaceId: String?, memberships: List = Membership.activeMemberships()): List
/**
* Returns all the children of this space, as LiveData
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/call/CallAnswerContent.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/call/CallAnswerContent.kt
index 180b32db05..6b4d782832 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/call/CallAnswerContent.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/call/CallAnswerContent.kt
@@ -44,7 +44,7 @@ data class CallAnswerContent(
* Capability advertisement.
*/
@Json(name = "capabilities") val capabilities: CallCapabilities? = null
-): CallSignalingContent {
+) : CallSignalingContent {
@JsonClass(generateAdapter = true)
data class Answer(
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/call/CallCandidatesContent.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/call/CallCandidatesContent.kt
index dc0a1e3b2e..deec80f4ff 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/call/CallCandidatesContent.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/call/CallCandidatesContent.kt
@@ -41,4 +41,4 @@ data class CallCandidatesContent(
* Required. The version of the VoIP specification this messages adheres to.
*/
@Json(name = "version") override val version: String?
-): CallSignalingContent
+) : CallSignalingContent
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/call/CallInviteContent.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/call/CallInviteContent.kt
index e4332f0ea7..d70e63d122 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/call/CallInviteContent.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/call/CallInviteContent.kt
@@ -55,7 +55,7 @@ data class CallInviteContent(
*/
@Json(name = "capabilities") val capabilities: CallCapabilities? = null
-): CallSignalingContent {
+) : CallSignalingContent {
@JsonClass(generateAdapter = true)
data class Offer(
/**
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/call/CallNegotiateContent.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/call/CallNegotiateContent.kt
index 68dd5ef043..bbbfbe68ab 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/call/CallNegotiateContent.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/call/CallNegotiateContent.kt
@@ -47,7 +47,7 @@ data class CallNegotiateContent(
*/
@Json(name = "version") override val version: String?
- ): CallSignalingContent {
+ ) : CallSignalingContent {
@JsonClass(generateAdapter = true)
data class Description(
/**
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/call/CallReplacesContent.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/call/CallReplacesContent.kt
index 4559c5db6d..7947b7d0bd 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/call/CallReplacesContent.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/call/CallReplacesContent.kt
@@ -61,7 +61,7 @@ data class CallReplacesContent(
* Required. The version of the VoIP specification this messages adheres to.
*/
@Json(name = "version") override val version: String?
-): CallSignalingContent {
+) : CallSignalingContent {
@JsonClass(generateAdapter = true)
data class TargetUser(
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/call/CallSelectAnswerContent.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/call/CallSelectAnswerContent.kt
index 795f332711..634bee1d83 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/call/CallSelectAnswerContent.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/call/CallSelectAnswerContent.kt
@@ -41,4 +41,4 @@ data class CallSelectAnswerContent(
* Required. The version of the VoIP specification this message adheres to.
*/
@Json(name = "version") override val version: String?
-): CallSignalingContent
+) : CallSignalingContent
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/version/RoomVersionService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/version/RoomVersionService.kt
index ea67b55174..d806e6007e 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/version/RoomVersionService.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/version/RoomVersionService.kt
@@ -31,7 +31,7 @@ interface RoomVersionService {
/**
* Get the recommended room version for the current homeserver
*/
- fun getRecommendedVersion() : String
+ fun getRecommendedVersion(): String
/**
* Ask if the user has enough power level to upgrade the room
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/securestorage/SharedSecretStorageError.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/securestorage/SharedSecretStorageError.kt
index 59325f9903..a91b97b86c 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/securestorage/SharedSecretStorageError.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/securestorage/SharedSecretStorageError.kt
@@ -22,8 +22,8 @@ sealed class SharedSecretStorageError(message: String?) : Throwable(message) {
data class UnknownAlgorithm(val keyId: String) : SharedSecretStorageError("Unknown algorithm $keyId")
data class UnsupportedAlgorithm(val algorithm: String) : SharedSecretStorageError("Unknown algorithm $algorithm")
data class SecretNotEncrypted(val secretName: String) : SharedSecretStorageError("Missing content for secret $secretName")
- data class SecretNotEncryptedWithKey(val secretName: String, val keyId: String)
- : SharedSecretStorageError("Missing content for secret $secretName with key $keyId")
+ data class SecretNotEncryptedWithKey(val secretName: String, val keyId: String) :
+ SharedSecretStorageError("Missing content for secret $secretName with key $keyId")
object BadKeyFormat : SharedSecretStorageError("Bad Key Format")
object ParsingError : SharedSecretStorageError("parsing Error")
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/model/DeviceListResponse.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/sync/model/DeviceListResponse.kt
similarity index 90%
rename from matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/model/DeviceListResponse.kt
rename to matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/sync/model/DeviceListResponse.kt
index bfa8c342b6..c05e1e5187 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/model/DeviceListResponse.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/sync/model/DeviceListResponse.kt
@@ -13,7 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.matrix.android.sdk.internal.session.sync.model
+
+package org.matrix.android.sdk.api.session.sync.model
import com.squareup.moshi.JsonClass
@@ -21,7 +22,7 @@ import com.squareup.moshi.JsonClass
* This class describes the device list response from a sync request
*/
@JsonClass(generateAdapter = true)
-internal data class DeviceListResponse(
+data class DeviceListResponse(
// user ids list which have new crypto devices
val changed: List = emptyList(),
// List of user ids who are no more tracked.
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/model/DeviceOneTimeKeysCountSyncResponse.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/sync/model/DeviceOneTimeKeysCountSyncResponse.kt
similarity index 87%
rename from matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/model/DeviceOneTimeKeysCountSyncResponse.kt
rename to matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/sync/model/DeviceOneTimeKeysCountSyncResponse.kt
index d5b435ac27..930cfb153f 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/model/DeviceOneTimeKeysCountSyncResponse.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/sync/model/DeviceOneTimeKeysCountSyncResponse.kt
@@ -14,12 +14,12 @@
* limitations under the License.
*/
-package org.matrix.android.sdk.internal.session.sync.model
+package org.matrix.android.sdk.api.session.sync.model
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
@JsonClass(generateAdapter = true)
-internal data class DeviceOneTimeKeysCountSyncResponse(
+data class DeviceOneTimeKeysCountSyncResponse(
@Json(name = "signed_curve25519") val signedCurve25519: Int? = null
)
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/model/GroupSyncProfile.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/sync/model/GroupSyncProfile.kt
similarity index 91%
rename from matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/model/GroupSyncProfile.kt
rename to matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/sync/model/GroupSyncProfile.kt
index ee6aabb0a9..581e6824ee 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/model/GroupSyncProfile.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/sync/model/GroupSyncProfile.kt
@@ -14,13 +14,13 @@
* limitations under the License.
*/
-package org.matrix.android.sdk.internal.session.sync.model
+package org.matrix.android.sdk.api.session.sync.model
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
@JsonClass(generateAdapter = true)
-internal data class GroupSyncProfile(
+data class GroupSyncProfile(
/**
* The name of the group, if any. May be nil.
*/
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/model/GroupsSyncResponse.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/sync/model/GroupsSyncResponse.kt
similarity index 92%
rename from matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/model/GroupsSyncResponse.kt
rename to matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/sync/model/GroupsSyncResponse.kt
index 4c2dce3ba8..fd8710bbda 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/model/GroupsSyncResponse.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/sync/model/GroupsSyncResponse.kt
@@ -14,13 +14,13 @@
* limitations under the License.
*/
-package org.matrix.android.sdk.internal.session.sync.model
+package org.matrix.android.sdk.api.session.sync.model
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
@JsonClass(generateAdapter = true)
-internal data class GroupsSyncResponse(
+data class GroupsSyncResponse(
/**
* Joined groups: An array of groups ids.
*/
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/model/InvitedGroupSync.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/sync/model/InvitedGroupSync.kt
similarity index 90%
rename from matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/model/InvitedGroupSync.kt
rename to matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/sync/model/InvitedGroupSync.kt
index 148c2aeab9..d41df9f0f6 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/model/InvitedGroupSync.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/sync/model/InvitedGroupSync.kt
@@ -14,13 +14,13 @@
* limitations under the License.
*/
-package org.matrix.android.sdk.internal.session.sync.model
+package org.matrix.android.sdk.api.session.sync.model
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
@JsonClass(generateAdapter = true)
-internal data class InvitedGroupSync(
+data class InvitedGroupSync(
/**
* The identifier of the inviter.
*/
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/model/InvitedRoomSync.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/sync/model/InvitedRoomSync.kt
similarity index 93%
rename from matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/model/InvitedRoomSync.kt
rename to matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/sync/model/InvitedRoomSync.kt
index c21a73abc2..dc63c5ba07 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/model/InvitedRoomSync.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/sync/model/InvitedRoomSync.kt
@@ -13,14 +13,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.matrix.android.sdk.internal.session.sync.model
+
+package org.matrix.android.sdk.api.session.sync.model
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
// InvitedRoomSync represents a room invitation during server sync v2.
@JsonClass(generateAdapter = true)
-internal data class InvitedRoomSync(
+data class InvitedRoomSync(
/**
* The state of a room that the user has been invited to. These state events may only have the 'sender', 'type', 'state_key'
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/model/LazyRoomSyncEphemeral.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/sync/model/LazyRoomSyncEphemeral.kt
similarity index 77%
rename from matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/model/LazyRoomSyncEphemeral.kt
rename to matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/sync/model/LazyRoomSyncEphemeral.kt
index 83006c646b..087a5f52dc 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/model/LazyRoomSyncEphemeral.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/sync/model/LazyRoomSyncEphemeral.kt
@@ -1,11 +1,11 @@
/*
- * Copyright (c) 2021 The Matrix.org Foundation C.I.C.
+ * Copyright 2020 The Matrix.org Foundation C.I.C.
*
* 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
+ * 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,
@@ -14,12 +14,12 @@
* limitations under the License.
*/
-package org.matrix.android.sdk.internal.session.sync.model
+package org.matrix.android.sdk.api.session.sync.model
import com.squareup.moshi.JsonClass
@JsonClass(generateAdapter = false)
-internal sealed class LazyRoomSyncEphemeral {
+sealed class LazyRoomSyncEphemeral {
data class Parsed(val _roomSyncEphemeral: RoomSyncEphemeral) : LazyRoomSyncEphemeral()
object Stored : LazyRoomSyncEphemeral()
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/model/PresenceSyncResponse.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/sync/model/PresenceSyncResponse.kt
similarity index 90%
rename from matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/model/PresenceSyncResponse.kt
rename to matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/sync/model/PresenceSyncResponse.kt
index 92d09aa4f5..d632552888 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/model/PresenceSyncResponse.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/sync/model/PresenceSyncResponse.kt
@@ -14,14 +14,14 @@
* limitations under the License.
*/
-package org.matrix.android.sdk.internal.session.sync.model
+package org.matrix.android.sdk.api.session.sync.model
import com.squareup.moshi.JsonClass
import org.matrix.android.sdk.api.session.events.model.Event
// PresenceSyncResponse represents the updates to the presence status of other users during server sync v2.
@JsonClass(generateAdapter = true)
-internal data class PresenceSyncResponse(
+data class PresenceSyncResponse(
/**
* List of presence events (array of Event with type m.presence).
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/model/RoomInviteState.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/sync/model/RoomInviteState.kt
similarity index 91%
rename from matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/model/RoomInviteState.kt
rename to matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/sync/model/RoomInviteState.kt
index ded9e2a350..59b4b4fc32 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/model/RoomInviteState.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/sync/model/RoomInviteState.kt
@@ -13,7 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.matrix.android.sdk.internal.session.sync.model
+
+package org.matrix.android.sdk.api.session.sync.model
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
@@ -21,7 +22,7 @@ import org.matrix.android.sdk.api.session.events.model.Event
// RoomInviteState represents the state of a room that the user has been invited to.
@JsonClass(generateAdapter = true)
-internal data class RoomInviteState(
+data class RoomInviteState(
/**
* List of state events (array of MXEvent).
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/model/RoomSync.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/sync/model/RoomSync.kt
similarity index 95%
rename from matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/model/RoomSync.kt
rename to matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/sync/model/RoomSync.kt
index 9aed0d37d6..e3d07602c7 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/model/RoomSync.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/sync/model/RoomSync.kt
@@ -13,14 +13,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.matrix.android.sdk.internal.session.sync.model
+
+package org.matrix.android.sdk.api.session.sync.model
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
// RoomSync represents the response for a room during server sync v2.
@JsonClass(generateAdapter = true)
-internal data class RoomSync(
+data class RoomSync(
/**
* The state updates for the room.
*/
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/model/RoomSyncAccountData.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/sync/model/RoomSyncAccountData.kt
similarity index 90%
rename from matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/model/RoomSyncAccountData.kt
rename to matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/sync/model/RoomSyncAccountData.kt
index a2375507d8..f2c4ed551c 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/model/RoomSyncAccountData.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/sync/model/RoomSyncAccountData.kt
@@ -14,14 +14,14 @@
* limitations under the License.
*/
-package org.matrix.android.sdk.internal.session.sync.model
+package org.matrix.android.sdk.api.session.sync.model
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
import org.matrix.android.sdk.api.session.events.model.Event
@JsonClass(generateAdapter = true)
-internal data class RoomSyncAccountData(
+data class RoomSyncAccountData(
/**
* List of account data events (array of Event).
*/
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/model/RoomSyncEphemeral.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/sync/model/RoomSyncEphemeral.kt
similarity index 91%
rename from matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/model/RoomSyncEphemeral.kt
rename to matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/sync/model/RoomSyncEphemeral.kt
index f2135db6b7..f4d831c16f 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/model/RoomSyncEphemeral.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/sync/model/RoomSyncEphemeral.kt
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.matrix.android.sdk.internal.session.sync.model
+package org.matrix.android.sdk.api.session.sync.model
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
@@ -22,7 +22,7 @@ import org.matrix.android.sdk.api.session.events.model.Event
// RoomSyncEphemeral represents the ephemeral events in the room that aren't recorded in the timeline or state of the room (e.g. typing).
@JsonClass(generateAdapter = true)
-internal data class RoomSyncEphemeral(
+data class RoomSyncEphemeral(
/**
* List of ephemeral events (array of Event).
*/
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/model/RoomSyncState.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/sync/model/RoomSyncState.kt
similarity index 91%
rename from matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/model/RoomSyncState.kt
rename to matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/sync/model/RoomSyncState.kt
index f86f05d000..7822467564 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/model/RoomSyncState.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/sync/model/RoomSyncState.kt
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.matrix.android.sdk.internal.session.sync.model
+package org.matrix.android.sdk.api.session.sync.model
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
@@ -22,7 +22,7 @@ import org.matrix.android.sdk.api.session.events.model.Event
// RoomSyncState represents the state updates for a room during server sync v2.
@JsonClass(generateAdapter = true)
-internal data class RoomSyncState(
+data class RoomSyncState(
/**
* List of state events (array of Event). The resulting state corresponds to the *start* of the timeline.
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/model/RoomSyncSummary.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/sync/model/RoomSyncSummary.kt
similarity index 95%
rename from matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/model/RoomSyncSummary.kt
rename to matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/sync/model/RoomSyncSummary.kt
index 228a71ec28..7216a0c992 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/model/RoomSyncSummary.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/sync/model/RoomSyncSummary.kt
@@ -14,13 +14,13 @@
* limitations under the License.
*/
-package org.matrix.android.sdk.internal.session.sync.model
+package org.matrix.android.sdk.api.session.sync.model
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
@JsonClass(generateAdapter = true)
-internal data class RoomSyncSummary(
+data class RoomSyncSummary(
/**
* Present only if the room has no m.room.name or m.room.canonical_alias.
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/model/RoomSyncTimeline.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/sync/model/RoomSyncTimeline.kt
similarity index 93%
rename from matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/model/RoomSyncTimeline.kt
rename to matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/sync/model/RoomSyncTimeline.kt
index 27bbc4343f..82d29a52e2 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/model/RoomSyncTimeline.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/sync/model/RoomSyncTimeline.kt
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.matrix.android.sdk.internal.session.sync.model
+package org.matrix.android.sdk.api.session.sync.model
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
@@ -22,7 +22,7 @@ import org.matrix.android.sdk.api.session.events.model.Event
// RoomSyncTimeline represents the timeline of messages and state changes for a room during server sync v2.
@JsonClass(generateAdapter = true)
-internal data class RoomSyncTimeline(
+data class RoomSyncTimeline(
/**
* List of events (array of Event).
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/model/RoomSyncUnreadNotifications.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/sync/model/RoomSyncUnreadNotifications.kt
similarity index 92%
rename from matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/model/RoomSyncUnreadNotifications.kt
rename to matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/sync/model/RoomSyncUnreadNotifications.kt
index f01534b884..6618bceacd 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/model/RoomSyncUnreadNotifications.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/sync/model/RoomSyncUnreadNotifications.kt
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.matrix.android.sdk.internal.session.sync.model
+package org.matrix.android.sdk.api.session.sync.model
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
@@ -24,7 +24,7 @@ import org.matrix.android.sdk.api.session.events.model.Event
* `MXRoomSyncUnreadNotifications` represents the unread counts for a room.
*/
@JsonClass(generateAdapter = true)
-internal data class RoomSyncUnreadNotifications(
+data class RoomSyncUnreadNotifications(
/**
* List of account data events (array of Event).
*/
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/model/RoomsSyncResponse.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/sync/model/RoomsSyncResponse.kt
similarity index 93%
rename from matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/model/RoomsSyncResponse.kt
rename to matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/sync/model/RoomsSyncResponse.kt
index dd2f96c988..ff3ed54264 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/model/RoomsSyncResponse.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/sync/model/RoomsSyncResponse.kt
@@ -13,14 +13,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.matrix.android.sdk.internal.session.sync.model
+
+package org.matrix.android.sdk.api.session.sync.model
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
// RoomsSyncResponse represents the rooms list in server sync v2 response.
@JsonClass(generateAdapter = true)
-internal data class RoomsSyncResponse(
+data class RoomsSyncResponse(
/**
* Joined rooms: keys are rooms ids.
*/
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/model/SyncResponse.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/sync/model/SyncResponse.kt
similarity index 91%
rename from matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/model/SyncResponse.kt
rename to matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/sync/model/SyncResponse.kt
index f2b2fb7e8f..876e99da63 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/model/SyncResponse.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/sync/model/SyncResponse.kt
@@ -14,15 +14,14 @@
* limitations under the License.
*/
-package org.matrix.android.sdk.internal.session.sync.model
+package org.matrix.android.sdk.api.session.sync.model
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
-import org.matrix.android.sdk.internal.session.sync.model.accountdata.UserAccountDataSync
// SyncResponse represents the request response for server sync v2.
@JsonClass(generateAdapter = true)
-internal data class SyncResponse(
+data class SyncResponse(
/**
* The user private data.
*/
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/model/ToDeviceSyncResponse.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/sync/model/ToDeviceSyncResponse.kt
similarity index 90%
rename from matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/model/ToDeviceSyncResponse.kt
rename to matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/sync/model/ToDeviceSyncResponse.kt
index 8f3af56cde..082460cc2d 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/model/ToDeviceSyncResponse.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/sync/model/ToDeviceSyncResponse.kt
@@ -14,14 +14,14 @@
* limitations under the License.
*/
-package org.matrix.android.sdk.internal.session.sync.model
+package org.matrix.android.sdk.api.session.sync.model
import com.squareup.moshi.JsonClass
import org.matrix.android.sdk.api.session.events.model.Event
// ToDeviceSyncResponse represents the data directly sent to one of user's devices.
@JsonClass(generateAdapter = true)
-internal data class ToDeviceSyncResponse(
+data class ToDeviceSyncResponse(
/**
* List of direct-to-device events.
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/model/accountdata/UserAccountDataSync.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/sync/model/UserAccountDataSync.kt
similarity index 88%
rename from matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/model/accountdata/UserAccountDataSync.kt
rename to matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/sync/model/UserAccountDataSync.kt
index 05b50ab2c5..9e1b791919 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/model/accountdata/UserAccountDataSync.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/sync/model/UserAccountDataSync.kt
@@ -14,13 +14,13 @@
* limitations under the License.
*/
-package org.matrix.android.sdk.internal.session.sync.model.accountdata
+package org.matrix.android.sdk.api.session.sync.model
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
import org.matrix.android.sdk.api.session.accountdata.UserAccountDataEvent
@JsonClass(generateAdapter = true)
-internal data class UserAccountDataSync(
+data class UserAccountDataSync(
@Json(name = "events") val list: List = emptyList()
)
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/user/model/User.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/user/model/User.kt
index 7cd939a5c2..54ae9e54f6 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/user/model/User.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/user/model/User.kt
@@ -23,13 +23,8 @@ package org.matrix.android.sdk.api.session.user.model
data class User(
val userId: String,
/**
- * For usage in UI, consider using [getBestName]
+ * For usage in UI, consider converting to MatrixItem and call getBestName()
*/
val displayName: String? = null,
val avatarUrl: String? = null
-) {
- /**
- * Return the display name or the user id
- */
- fun getBestName() = displayName?.takeIf { it.isNotEmpty() } ?: userId
-}
+)
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/util/MatrixItem.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/util/MatrixItem.kt
index 3d2773fb4b..3396c4a6c9 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/util/MatrixItem.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/util/MatrixItem.kt
@@ -34,8 +34,8 @@ sealed class MatrixItem(
) {
data class UserItem(override val id: String,
override val displayName: String? = null,
- override val avatarUrl: String? = null)
- : MatrixItem(id, displayName?.removeSuffix(ircPattern), avatarUrl) {
+ override val avatarUrl: String? = null) :
+ MatrixItem(id, displayName?.removeSuffix(ircPattern), avatarUrl) {
init {
if (BuildConfig.DEBUG) checkId()
}
@@ -45,8 +45,8 @@ sealed class MatrixItem(
data class EventItem(override val id: String,
override val displayName: String? = null,
- override val avatarUrl: String? = null)
- : MatrixItem(id, displayName, avatarUrl) {
+ override val avatarUrl: String? = null) :
+ MatrixItem(id, displayName, avatarUrl) {
init {
if (BuildConfig.DEBUG) checkId()
}
@@ -56,8 +56,8 @@ sealed class MatrixItem(
data class RoomItem(override val id: String,
override val displayName: String? = null,
- override val avatarUrl: String? = null)
- : MatrixItem(id, displayName, avatarUrl) {
+ override val avatarUrl: String? = null) :
+ MatrixItem(id, displayName, avatarUrl) {
init {
if (BuildConfig.DEBUG) checkId()
}
@@ -67,8 +67,8 @@ sealed class MatrixItem(
data class SpaceItem(override val id: String,
override val displayName: String? = null,
- override val avatarUrl: String? = null)
- : MatrixItem(id, displayName, avatarUrl) {
+ override val avatarUrl: String? = null) :
+ MatrixItem(id, displayName, avatarUrl) {
init {
if (BuildConfig.DEBUG) checkId()
}
@@ -78,36 +78,26 @@ sealed class MatrixItem(
data class RoomAliasItem(override val id: String,
override val displayName: String? = null,
- override val avatarUrl: String? = null)
- : MatrixItem(id, displayName, avatarUrl) {
+ override val avatarUrl: String? = null) :
+ MatrixItem(id, displayName, avatarUrl) {
init {
if (BuildConfig.DEBUG) checkId()
}
- // Best name is the id, and we keep the displayName of the room for the case we need the first letter
- override fun getBestName() = id
-
override fun updateAvatar(newAvatar: String?) = copy(avatarUrl = newAvatar)
}
data class GroupItem(override val id: String,
override val displayName: String? = null,
- override val avatarUrl: String? = null)
- : MatrixItem(id, displayName, avatarUrl) {
+ override val avatarUrl: String? = null) :
+ MatrixItem(id, displayName, avatarUrl) {
init {
if (BuildConfig.DEBUG) checkId()
}
- // Best name is the id, and we keep the displayName of the room for the case we need the first letter
- override fun getBestName() = id
-
override fun updateAvatar(newAvatar: String?) = copy(avatarUrl = newAvatar)
}
- open fun getBestName(): String {
- return displayName?.takeIf { it.isNotBlank() } ?: id
- }
-
protected fun checkId() {
if (!id.startsWith(getIdPrefix())) {
error("Wrong usage of MatrixItem: check the id $id should start with ${getIdPrefix()}")
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/DefaultAuthenticationService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/DefaultAuthenticationService.kt
index e76dc28734..641a8f1bb6 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/DefaultAuthenticationService.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/DefaultAuthenticationService.kt
@@ -172,8 +172,8 @@ internal class DefaultAuthenticationService @Inject constructor(
return try {
getWellknownLoginFlowInternal(homeServerConnectionConfig)
} catch (failure: Throwable) {
- if (failure is Failure.OtherServerError
- && failure.httpCode == HttpsURLConnection.HTTP_NOT_FOUND /* 404 */) {
+ if (failure is Failure.OtherServerError &&
+ failure.httpCode == HttpsURLConnection.HTTP_NOT_FOUND /* 404 */) {
// 404, no well-known data, try direct access to the API
// First check the homeserver version
return runCatching {
@@ -190,8 +190,8 @@ internal class DefaultAuthenticationService @Inject constructor(
it
},
{
- if (it is Failure.OtherServerError
- && it.httpCode == HttpsURLConnection.HTTP_NOT_FOUND /* 404 */) {
+ if (it is Failure.OtherServerError &&
+ it.httpCode == HttpsURLConnection.HTTP_NOT_FOUND /* 404 */) {
// It's maybe a Web client url?
getWebClientDomainLoginFlowInternal(homeServerConnectionConfig)
} else {
@@ -225,8 +225,8 @@ internal class DefaultAuthenticationService @Inject constructor(
it
},
{
- if (it is Failure.OtherServerError
- && it.httpCode == HttpsURLConnection.HTTP_NOT_FOUND /* 404 */) {
+ if (it is Failure.OtherServerError &&
+ it.httpCode == HttpsURLConnection.HTTP_NOT_FOUND /* 404 */) {
// Try with config.json
getWebClientLoginFlowInternal(homeServerConnectionConfig)
} else {
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/IsValidClientServerApiTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/IsValidClientServerApiTask.kt
index bc3d887000..94b301649f 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/IsValidClientServerApiTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/IsValidClientServerApiTask.kt
@@ -54,8 +54,8 @@ internal class DefaultIsValidClientServerApiTask @Inject constructor(
// We get a response, so the API is valid
true
} catch (failure: Throwable) {
- if (failure is Failure.OtherServerError
- && failure.httpCode == HttpsURLConnection.HTTP_NOT_FOUND /* 404 */) {
+ if (failure is Failure.OtherServerError &&
+ failure.httpCode == HttpsURLConnection.HTTP_NOT_FOUND /* 404 */) {
// Probably not valid
false
} else {
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/db/RealmPendingSessionStore.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/db/RealmPendingSessionStore.kt
index 968ae22eda..13f26e321d 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/db/RealmPendingSessionStore.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/db/RealmPendingSessionStore.kt
@@ -16,11 +16,11 @@
package org.matrix.android.sdk.internal.auth.db
+import io.realm.Realm
+import io.realm.RealmConfiguration
import org.matrix.android.sdk.internal.auth.PendingSessionStore
import org.matrix.android.sdk.internal.database.awaitTransaction
import org.matrix.android.sdk.internal.di.AuthDatabase
-import io.realm.Realm
-import io.realm.RealmConfiguration
import javax.inject.Inject
internal class RealmPendingSessionStore @Inject constructor(private val mapper: PendingSessionMapper,
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/db/RealmSessionParamsStore.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/db/RealmSessionParamsStore.kt
index edd3e2bed5..235ef6b709 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/db/RealmSessionParamsStore.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/db/RealmSessionParamsStore.kt
@@ -16,15 +16,15 @@
package org.matrix.android.sdk.internal.auth.db
+import io.realm.Realm
+import io.realm.RealmConfiguration
+import io.realm.exceptions.RealmPrimaryKeyConstraintException
import org.matrix.android.sdk.api.auth.data.Credentials
import org.matrix.android.sdk.api.auth.data.SessionParams
import org.matrix.android.sdk.api.auth.data.sessionId
import org.matrix.android.sdk.internal.auth.SessionParamsStore
import org.matrix.android.sdk.internal.database.awaitTransaction
import org.matrix.android.sdk.internal.di.AuthDatabase
-import io.realm.Realm
-import io.realm.RealmConfiguration
-import io.realm.exceptions.RealmPrimaryKeyConstraintException
import timber.log.Timber
import javax.inject.Inject
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/login/DirectLoginTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/login/DirectLoginTask.kt
index 3888633723..8f61afe374 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/login/DirectLoginTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/login/DirectLoginTask.kt
@@ -17,6 +17,7 @@
package org.matrix.android.sdk.internal.auth.login
import dagger.Lazy
+import okhttp3.OkHttpClient
import org.matrix.android.sdk.api.auth.data.HomeServerConnectionConfig
import org.matrix.android.sdk.api.failure.Failure
import org.matrix.android.sdk.api.session.Session
@@ -29,7 +30,6 @@ import org.matrix.android.sdk.internal.network.executeRequest
import org.matrix.android.sdk.internal.network.httpclient.addSocketFactory
import org.matrix.android.sdk.internal.network.ssl.UnrecognizedCertificateException
import org.matrix.android.sdk.internal.task.Task
-import okhttp3.OkHttpClient
import javax.inject.Inject
internal interface DirectLoginTask : Task {
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/version/Versions.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/version/Versions.kt
index 4e599516ed..74cb3de2ac 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/version/Versions.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/version/Versions.kt
@@ -63,9 +63,9 @@ internal fun Versions.isSupportedBySdk(): Boolean {
* Return true if the SDK supports this homeserver version for login and registration
*/
internal fun Versions.isLoginAndRegistrationSupportedBySdk(): Boolean {
- return !doesServerRequireIdentityServerParam()
- && doesServerAcceptIdentityAccessToken()
- && doesServerSeparatesAddAndBind()
+ return !doesServerRequireIdentityServerParam() &&
+ doesServerAcceptIdentityAccessToken() &&
+ doesServerSeparatesAddAndBind()
}
/**
@@ -74,8 +74,8 @@ internal fun Versions.isLoginAndRegistrationSupportedBySdk(): Boolean {
* @return true if the server support the lazy loading of room members
*/
private fun Versions.supportLazyLoadMembers(): Boolean {
- return getMaxVersion() >= HomeServerVersion.r0_5_0
- || unstableFeatures?.get(FEATURE_LAZY_LOAD_MEMBERS) == true
+ return getMaxVersion() >= HomeServerVersion.r0_5_0 ||
+ unstableFeatures?.get(FEATURE_LAZY_LOAD_MEMBERS) == true
}
/**
@@ -92,13 +92,13 @@ private fun Versions.doesServerRequireIdentityServerParam(): Boolean {
* Some homeservers may trigger errors if they are not prepared for the new parameter.
*/
private fun Versions.doesServerAcceptIdentityAccessToken(): Boolean {
- return getMaxVersion() >= HomeServerVersion.r0_6_0
- || unstableFeatures?.get(FEATURE_ID_ACCESS_TOKEN) ?: false
+ return getMaxVersion() >= HomeServerVersion.r0_6_0 ||
+ unstableFeatures?.get(FEATURE_ID_ACCESS_TOKEN) ?: false
}
private fun Versions.doesServerSeparatesAddAndBind(): Boolean {
- return getMaxVersion() >= HomeServerVersion.r0_6_0
- || unstableFeatures?.get(FEATURE_SEPARATE_ADD_AND_BIND) ?: false
+ return getMaxVersion() >= HomeServerVersion.r0_6_0 ||
+ unstableFeatures?.get(FEATURE_SEPARATE_ADD_AND_BIND) ?: false
}
private fun Versions.getMaxVersion(): HomeServerVersion {
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/CancelGossipRequestWorker.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/CancelGossipRequestWorker.kt
index 0ec020bc46..c11d00278b 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/CancelGossipRequestWorker.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/CancelGossipRequestWorker.kt
@@ -35,8 +35,8 @@ import org.matrix.android.sdk.internal.worker.SessionWorkerParams
import javax.inject.Inject
internal class CancelGossipRequestWorker(context: Context,
- params: WorkerParameters)
- : SessionSafeCoroutineWorker(context, params, Params::class.java) {
+ params: WorkerParameters) :
+ SessionSafeCoroutineWorker(context, params, Params::class.java) {
@JsonClass(generateAdapter = true)
internal data class Params(
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/CryptoModule.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/CryptoModule.kt
index 84d4fef5af..fe388b44e2 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/CryptoModule.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/CryptoModule.kt
@@ -19,6 +19,9 @@ package org.matrix.android.sdk.internal.crypto
import dagger.Binds
import dagger.Module
import dagger.Provides
+import io.realm.RealmConfiguration
+import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.SupervisorJob
import org.matrix.android.sdk.api.session.crypto.CryptoService
import org.matrix.android.sdk.api.session.crypto.crosssigning.CrossSigningService
import org.matrix.android.sdk.internal.crypto.api.CryptoApi
@@ -93,9 +96,6 @@ import org.matrix.android.sdk.internal.di.UserMd5
import org.matrix.android.sdk.internal.session.SessionScope
import org.matrix.android.sdk.internal.session.cache.ClearCacheTask
import org.matrix.android.sdk.internal.session.cache.RealmClearCacheTask
-import io.realm.RealmConfiguration
-import kotlinx.coroutines.CoroutineScope
-import kotlinx.coroutines.SupervisorJob
import retrofit2.Retrofit
import java.io.File
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/DefaultCryptoService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/DefaultCryptoService.kt
index 563c890950..7115ff5db2 100755
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/DefaultCryptoService.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/DefaultCryptoService.kt
@@ -50,6 +50,7 @@ import org.matrix.android.sdk.api.session.room.model.Membership
import org.matrix.android.sdk.api.session.room.model.RoomHistoryVisibility
import org.matrix.android.sdk.api.session.room.model.RoomHistoryVisibilityContent
import org.matrix.android.sdk.api.session.room.model.RoomMemberContent
+import org.matrix.android.sdk.api.session.sync.model.SyncResponse
import org.matrix.android.sdk.internal.crypto.actions.MegolmSessionDataImporter
import org.matrix.android.sdk.internal.crypto.actions.SetDeviceVerificationAction
import org.matrix.android.sdk.internal.crypto.algorithms.IMXEncrypting
@@ -87,7 +88,6 @@ import org.matrix.android.sdk.internal.di.UserId
import org.matrix.android.sdk.internal.extensions.foldToCallback
import org.matrix.android.sdk.internal.session.SessionScope
import org.matrix.android.sdk.internal.session.room.membership.LoadRoomMembersTask
-import org.matrix.android.sdk.internal.session.sync.model.SyncResponse
import org.matrix.android.sdk.internal.task.TaskExecutor
import org.matrix.android.sdk.internal.task.TaskThread
import org.matrix.android.sdk.internal.task.configureWith
@@ -868,8 +868,8 @@ internal class DefaultCryptoService @Inject constructor(
}
private fun getRoomUserIds(roomId: String): List {
- val encryptForInvitedMembers = isEncryptionEnabledForInvitedUser()
- && shouldEncryptForInvitedMembers(roomId)
+ val encryptForInvitedMembers = isEncryptionEnabledForInvitedUser() &&
+ shouldEncryptForInvitedMembers(roomId)
return cryptoSessionInfoProvider.getRoomUserIds(roomId, encryptForInvitedMembers)
}
@@ -887,9 +887,9 @@ internal class DefaultCryptoService @Inject constructor(
if (membership == Membership.JOIN) {
// make sure we are tracking the deviceList for this user.
deviceListManager.startTrackingDeviceList(listOf(userId))
- } else if (membership == Membership.INVITE
- && shouldEncryptForInvitedMembers(roomId)
- && isEncryptionEnabledForInvitedUser()) {
+ } else if (membership == Membership.INVITE &&
+ shouldEncryptForInvitedMembers(roomId) &&
+ isEncryptionEnabledForInvitedUser()) {
// track the deviceList for this invited user.
// Caution: there's a big edge case here in that federated servers do not
// know what other servers are in the room at the time they've been invited.
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/DeviceListManager.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/DeviceListManager.kt
index 79910c6de2..8a91376b60 100755
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/DeviceListManager.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/DeviceListManager.kt
@@ -475,8 +475,8 @@ internal class DeviceListManager @Inject constructor(private val cryptoStore: IM
}
if (!isVerified) {
- Timber.e("## CRYPTO | validateDeviceKeys() : Unable to verify signature on device " + userId + ":"
- + deviceKeys.deviceId + " with error " + errorMessage)
+ Timber.e("## CRYPTO | validateDeviceKeys() : Unable to verify signature on device " + userId + ":" +
+ deviceKeys.deviceId + " with error " + errorMessage)
return false
}
@@ -486,9 +486,9 @@ internal class DeviceListManager @Inject constructor(private val cryptoStore: IM
// best off sticking with the original keys.
//
// Should we warn the user about it somehow?
- Timber.e("## CRYPTO | validateDeviceKeys() : WARNING:Ed25519 key for device " + userId + ":"
- + deviceKeys.deviceId + " has changed : "
- + previouslyStoredDeviceKeys.fingerprint() + " -> " + signKey)
+ Timber.e("## CRYPTO | validateDeviceKeys() : WARNING:Ed25519 key for device " + userId + ":" +
+ deviceKeys.deviceId + " has changed : " +
+ previouslyStoredDeviceKeys.fingerprint() + " -> " + signKey)
Timber.e("## CRYPTO | validateDeviceKeys() : $previouslyStoredDeviceKeys -> $deviceKeys")
Timber.e("## CRYPTO | validateDeviceKeys() : ${previouslyStoredDeviceKeys.keys} -> ${deviceKeys.keys}")
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/EventDecryptor.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/EventDecryptor.kt
index 8d86380e39..fe17dd08e4 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/EventDecryptor.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/EventDecryptor.kt
@@ -107,8 +107,8 @@ internal class EventDecryptor @Inject constructor(
} catch (mxCryptoError: MXCryptoError) {
Timber.v("## CRYPTO | internalDecryptEvent : Failed to decrypt ${event.eventId} reason: $mxCryptoError")
if (algorithm == MXCRYPTO_ALGORITHM_OLM) {
- if (mxCryptoError is MXCryptoError.Base
- && mxCryptoError.errorType == MXCryptoError.ErrorType.BAD_ENCRYPTED_MESSAGE) {
+ if (mxCryptoError is MXCryptoError.Base &&
+ mxCryptoError.errorType == MXCryptoError.ErrorType.BAD_ENCRYPTED_MESSAGE) {
// need to find sending device
cryptoCoroutineScope.launch(coroutineDispatchers.crypto) {
val olmContent = event.content.toModel()
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/OutgoingGossipingRequestManager.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/OutgoingGossipingRequestManager.kt
index ccdb5ab137..6fc7103668 100755
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/OutgoingGossipingRequestManager.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/OutgoingGossipingRequestManager.kt
@@ -16,17 +16,17 @@
package org.matrix.android.sdk.internal.crypto
+import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.delay
+import kotlinx.coroutines.launch
import org.matrix.android.sdk.internal.crypto.model.rest.RoomKeyRequestBody
import org.matrix.android.sdk.internal.crypto.store.IMXCryptoStore
+import org.matrix.android.sdk.internal.crypto.tasks.createUniqueTxnId
+import org.matrix.android.sdk.internal.crypto.util.RequestIdHelper
import org.matrix.android.sdk.internal.di.SessionId
import org.matrix.android.sdk.internal.session.SessionScope
import org.matrix.android.sdk.internal.util.MatrixCoroutineDispatchers
import org.matrix.android.sdk.internal.worker.WorkerParamsFactory
-import kotlinx.coroutines.CoroutineScope
-import kotlinx.coroutines.delay
-import kotlinx.coroutines.launch
-import org.matrix.android.sdk.internal.crypto.tasks.createUniqueTxnId
-import org.matrix.android.sdk.internal.crypto.util.RequestIdHelper
import timber.log.Timber
import javax.inject.Inject
@@ -112,9 +112,8 @@ internal class OutgoingGossipingRequestManager @Inject constructor(
* @param andResend true to resend the key request
*/
private fun cancelRoomKeyRequest(requestBody: RoomKeyRequestBody, andResend: Boolean) {
- val req = cryptoStore.getOutgoingRoomKeyRequest(requestBody)
- ?: // no request was made for this key
- return Unit.also {
+ val req = cryptoStore.getOutgoingRoomKeyRequest(requestBody) // no request was made for this key
+ ?: return Unit.also {
Timber.v("## CRYPTO - GOSSIP cancelRoomKeyRequest() Unknown request $requestBody")
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/SendGossipRequestWorker.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/SendGossipRequestWorker.kt
index 2e26720abb..b2ba189b65 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/SendGossipRequestWorker.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/SendGossipRequestWorker.kt
@@ -38,8 +38,8 @@ import timber.log.Timber
import javax.inject.Inject
internal class SendGossipRequestWorker(context: Context,
- params: WorkerParameters)
- : SessionSafeCoroutineWorker(context, params, Params::class.java) {
+ params: WorkerParameters) :
+ SessionSafeCoroutineWorker(context, params, Params::class.java) {
@JsonClass(generateAdapter = true)
internal data class Params(
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/SendGossipWorker.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/SendGossipWorker.kt
index c5c6d26f79..b96943e4ae 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/SendGossipWorker.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/SendGossipWorker.kt
@@ -38,8 +38,8 @@ import timber.log.Timber
import javax.inject.Inject
internal class SendGossipWorker(context: Context,
- params: WorkerParameters)
- : SessionSafeCoroutineWorker(context, params, Params::class.java) {
+ params: WorkerParameters) :
+ SessionSafeCoroutineWorker(context, params, Params::class.java) {
@JsonClass(generateAdapter = true)
internal data class Params(
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/actions/EnsureOlmSessionsForDevicesAction.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/actions/EnsureOlmSessionsForDevicesAction.kt
index 95b99c54e8..52876b0fff 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/actions/EnsureOlmSessionsForDevicesAction.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/actions/EnsureOlmSessionsForDevicesAction.kt
@@ -90,8 +90,8 @@ internal class EnsureOlmSessionsForDevicesAction @Inject constructor(
oneTimeKey = key
}
if (oneTimeKey == null) {
- Timber.w("## CRYPTO | ensureOlmSessionsForDevices() : No one-time keys " + oneTimeKeyAlgorithm
- + " for device " + userId + " : " + deviceId)
+ Timber.w("## CRYPTO | ensureOlmSessionsForDevices() : No one-time keys " + oneTimeKeyAlgorithm +
+ " for device " + userId + " : " + deviceId)
continue
}
// Update the result for this device in results
@@ -126,15 +126,15 @@ internal class EnsureOlmSessionsForDevicesAction @Inject constructor(
sessionId = olmDevice.createOutboundSession(deviceInfo.identityKey()!!, oneTimeKey.value)
if (!sessionId.isNullOrEmpty()) {
- Timber.v("## CRYPTO | verifyKeyAndStartSession() : Started new sessionid " + sessionId
- + " for device " + deviceInfo + "(theirOneTimeKey: " + oneTimeKey.value + ")")
+ Timber.v("## CRYPTO | verifyKeyAndStartSession() : Started new sessionid " + sessionId +
+ " for device " + deviceInfo + "(theirOneTimeKey: " + oneTimeKey.value + ")")
} else {
// Possibly a bad key
Timber.e("## CRYPTO | verifyKeyAndStartSession() : Error starting session with device $userId:$deviceId")
}
} else {
- Timber.e("## CRYPTO | verifyKeyAndStartSession() : Unable to verify signature on one-time key for device " + userId
- + ":" + deviceId + " Error " + errorMessage)
+ Timber.e("## CRYPTO | verifyKeyAndStartSession() : Unable to verify signature on one-time key for device " + userId +
+ ":" + deviceId + " Error " + errorMessage)
}
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/actions/EnsureOlmSessionsForUsersAction.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/actions/EnsureOlmSessionsForUsersAction.kt
index a276394eaf..a3cfbd91f0 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/actions/EnsureOlmSessionsForUsersAction.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/actions/EnsureOlmSessionsForUsersAction.kt
@@ -38,9 +38,9 @@ internal class EnsureOlmSessionsForUsersAction @Inject constructor(private val o
devices.filter {
// Don't bother setting up session to ourself
- it.identityKey() != olmDevice.deviceCurve25519Key
+ it.identityKey() != olmDevice.deviceCurve25519Key &&
// Don't bother setting up sessions with blocked users
- && !(it.trustLevel?.isVerified() ?: false)
+ !(it.trustLevel?.isVerified() ?: false)
}
}
return ensureOlmSessionsForDevicesAction.handle(devicesByUser)
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/algorithms/megolm/MXMegolmDecryption.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/algorithms/megolm/MXMegolmDecryption.kt
index 70d2022299..d2f6bd0382 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/algorithms/megolm/MXMegolmDecryption.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/algorithms/megolm/MXMegolmDecryption.kt
@@ -16,6 +16,8 @@
package org.matrix.android.sdk.internal.crypto.algorithms.megolm
+import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.launch
import org.matrix.android.sdk.api.session.crypto.MXCryptoError
import org.matrix.android.sdk.api.session.events.model.Event
import org.matrix.android.sdk.api.session.events.model.EventType
@@ -40,8 +42,6 @@ import org.matrix.android.sdk.internal.crypto.model.rest.RoomKeyRequestBody
import org.matrix.android.sdk.internal.crypto.store.IMXCryptoStore
import org.matrix.android.sdk.internal.crypto.tasks.SendToDeviceTask
import org.matrix.android.sdk.internal.util.MatrixCoroutineDispatchers
-import kotlinx.coroutines.CoroutineScope
-import kotlinx.coroutines.launch
import timber.log.Timber
internal class MXMegolmDecryption(private val userId: String,
@@ -82,9 +82,9 @@ internal class MXMegolmDecryption(private val userId: String,
val encryptedEventContent = event.content.toModel()
?: throw MXCryptoError.Base(MXCryptoError.ErrorType.MISSING_FIELDS, MXCryptoError.MISSING_FIELDS_REASON)
- if (encryptedEventContent.senderKey.isNullOrBlank()
- || encryptedEventContent.sessionId.isNullOrBlank()
- || encryptedEventContent.ciphertext.isNullOrBlank()) {
+ if (encryptedEventContent.senderKey.isNullOrBlank() ||
+ encryptedEventContent.sessionId.isNullOrBlank() ||
+ encryptedEventContent.ciphertext.isNullOrBlank()) {
throw MXCryptoError.Base(MXCryptoError.ErrorType.MISSING_FIELDS, MXCryptoError.MISSING_FIELDS_REASON)
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/algorithms/megolm/MXMegolmDecryptionFactory.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/algorithms/megolm/MXMegolmDecryptionFactory.kt
index 95a4342dbf..91640523fc 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/algorithms/megolm/MXMegolmDecryptionFactory.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/algorithms/megolm/MXMegolmDecryptionFactory.kt
@@ -16,6 +16,7 @@
package org.matrix.android.sdk.internal.crypto.algorithms.megolm
+import kotlinx.coroutines.CoroutineScope
import org.matrix.android.sdk.internal.crypto.DeviceListManager
import org.matrix.android.sdk.internal.crypto.MXOlmDevice
import org.matrix.android.sdk.internal.crypto.OutgoingGossipingRequestManager
@@ -25,7 +26,6 @@ import org.matrix.android.sdk.internal.crypto.store.IMXCryptoStore
import org.matrix.android.sdk.internal.crypto.tasks.SendToDeviceTask
import org.matrix.android.sdk.internal.di.UserId
import org.matrix.android.sdk.internal.util.MatrixCoroutineDispatchers
-import kotlinx.coroutines.CoroutineScope
import javax.inject.Inject
internal class MXMegolmDecryptionFactory @Inject constructor(
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/algorithms/megolm/MXMegolmEncryption.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/algorithms/megolm/MXMegolmEncryption.kt
index 540280d8a2..63fe678229 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/algorithms/megolm/MXMegolmEncryption.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/algorithms/megolm/MXMegolmEncryption.kt
@@ -155,11 +155,11 @@ internal class MXMegolmEncryption(
private suspend fun ensureOutboundSession(devicesInRoom: MXUsersDevicesMap): MXOutboundSessionInfo {
Timber.v("## CRYPTO | ensureOutboundSession start")
var session = outboundSession
- if (session == null
+ if (session == null ||
// Need to make a brand new session?
- || session.needsRotation(sessionRotationPeriodMsgs, sessionRotationPeriodMs)
+ session.needsRotation(sessionRotationPeriodMsgs, sessionRotationPeriodMs) ||
// Determine if we have shared with anyone we shouldn't have
- || session.sharedWithTooManyDevices(devicesInRoom)) {
+ session.sharedWithTooManyDevices(devicesInRoom)) {
session = prepareNewSessionInRoom()
outboundSession = session
}
@@ -380,8 +380,8 @@ internal class MXMegolmEncryption(
// with them, which means that they will have announced any new devices via
// an m.new_device.
val keys = deviceListManager.downloadKeys(userIds, false)
- val encryptToVerifiedDevicesOnly = cryptoStore.getGlobalBlacklistUnverifiedDevices()
- || cryptoStore.getRoomsListBlacklistUnverifiedDevices().contains(roomId)
+ val encryptToVerifiedDevicesOnly = cryptoStore.getGlobalBlacklistUnverifiedDevices() ||
+ cryptoStore.getRoomsListBlacklistUnverifiedDevices().contains(roomId)
val devicesInRoom = DeviceInRoomInfo()
val unknownDevices = MXUsersDevicesMap()
@@ -446,10 +446,9 @@ internal class MXMegolmEncryption(
val devicesByUser = mapOf(userId to listOf(deviceInfo))
val usersDeviceMap = ensureOlmSessionsForDevicesAction.handle(devicesByUser)
val olmSessionResult = usersDeviceMap.getObject(userId, deviceId)
- olmSessionResult?.sessionId
- ?: // no session with this device, probably because there were no one-time keys.
+ olmSessionResult?.sessionId // no session with this device, probably because there were no one-time keys.
// ensureOlmSessionsForDevicesAction has already done the logging, so just skip it.
- return false.also {
+ ?: return false.also {
Timber.w("## Crypto reshareKey: no session with this device, probably because there were no one-time keys")
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/algorithms/olm/MXOlmDecryption.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/algorithms/olm/MXOlmDecryption.kt
index 082b86c9da..f1bca4fbc6 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/algorithms/olm/MXOlmDecryption.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/algorithms/olm/MXOlmDecryption.kt
@@ -34,8 +34,8 @@ internal class MXOlmDecryption(
// The olm device interface
private val olmDevice: MXOlmDevice,
// the matrix userId
- private val userId: String)
- : IMXDecrypting {
+ private val userId: String) :
+ IMXDecrypting {
@Throws(MXCryptoError::class)
override fun decryptEvent(event: Event, timeline: String): MXEventDecryptionResult {
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/algorithms/olm/MXOlmEncryption.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/algorithms/olm/MXOlmEncryption.kt
index 65f78e11f0..63f2533ac3 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/algorithms/olm/MXOlmEncryption.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/algorithms/olm/MXOlmEncryption.kt
@@ -32,8 +32,8 @@ internal class MXOlmEncryption(
private val cryptoStore: IMXCryptoStore,
private val messageEncrypter: MessageEncrypter,
private val deviceListManager: DeviceListManager,
- private val ensureOlmSessionsForUsersAction: EnsureOlmSessionsForUsersAction)
- : IMXEncrypting {
+ private val ensureOlmSessionsForUsersAction: EnsureOlmSessionsForUsersAction) :
+ IMXEncrypting {
override suspend fun encryptEventContent(eventContent: Content, eventType: String, userIds: List): Content {
// pick the list of recipients based on the membership list.
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/attachments/ElementToDecrypt.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/attachments/ElementToDecrypt.kt
index c071384df4..3d00e178a0 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/attachments/ElementToDecrypt.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/attachments/ElementToDecrypt.kt
@@ -17,8 +17,8 @@
package org.matrix.android.sdk.internal.crypto.attachments
import android.os.Parcelable
-import org.matrix.android.sdk.internal.crypto.model.rest.EncryptedFileInfo
import kotlinx.parcelize.Parcelize
+import org.matrix.android.sdk.internal.crypto.model.rest.EncryptedFileInfo
fun EncryptedFileInfo.toElementToDecrypt(): ElementToDecrypt? {
// Check the validity of some fields
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/crosssigning/ComputeTrustTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/crosssigning/ComputeTrustTask.kt
index ee5aab977b..113255bb7e 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/crosssigning/ComputeTrustTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/crosssigning/ComputeTrustTask.kt
@@ -15,6 +15,7 @@
*/
package org.matrix.android.sdk.internal.crypto.crosssigning
+import kotlinx.coroutines.withContext
import org.matrix.android.sdk.api.crypto.RoomEncryptionTrustLevel
import org.matrix.android.sdk.api.extensions.orFalse
import org.matrix.android.sdk.api.session.crypto.crosssigning.MXCrossSigningInfo
@@ -22,7 +23,6 @@ import org.matrix.android.sdk.internal.crypto.store.IMXCryptoStore
import org.matrix.android.sdk.internal.di.UserId
import org.matrix.android.sdk.internal.task.Task
import org.matrix.android.sdk.internal.util.MatrixCoroutineDispatchers
-import kotlinx.coroutines.withContext
import javax.inject.Inject
internal interface ComputeTrustTask : Task {
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/crosssigning/DefaultCrossSigningService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/crosssigning/DefaultCrossSigningService.kt
index 0289fadbd8..8a851b1267 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/crosssigning/DefaultCrossSigningService.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/crosssigning/DefaultCrossSigningService.kt
@@ -529,13 +529,13 @@ internal class DefaultCrossSigningService @Inject constructor(
}
override fun canCrossSign(): Boolean {
- return checkSelfTrust().isVerified() && cryptoStore.getCrossSigningPrivateKeys()?.selfSigned != null
- && cryptoStore.getCrossSigningPrivateKeys()?.user != null
+ return checkSelfTrust().isVerified() && cryptoStore.getCrossSigningPrivateKeys()?.selfSigned != null &&
+ cryptoStore.getCrossSigningPrivateKeys()?.user != null
}
override fun allPrivateKeysKnown(): Boolean {
- return checkSelfTrust().isVerified()
- && cryptoStore.getCrossSigningPrivateKeys()?.allKnown().orFalse()
+ return checkSelfTrust().isVerified() &&
+ cryptoStore.getCrossSigningPrivateKeys()?.allKnown().orFalse()
}
override fun trustUser(otherUserId: String, callback: MatrixCallback) {
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/crosssigning/UpdateTrustWorker.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/crosssigning/UpdateTrustWorker.kt
index 76b63b7798..3326d3707a 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/crosssigning/UpdateTrustWorker.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/crosssigning/UpdateTrustWorker.kt
@@ -51,8 +51,8 @@ import timber.log.Timber
import javax.inject.Inject
internal class UpdateTrustWorker(context: Context,
- params: WorkerParameters)
- : SessionSafeCoroutineWorker(context, params, Params::class.java) {
+ params: WorkerParameters) :
+ SessionSafeCoroutineWorker(context, params, Params::class.java) {
@JsonClass(generateAdapter = true)
internal data class Params(
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/DefaultKeysBackupService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/DefaultKeysBackupService.kt
index fbcf5cfdeb..c6e2c1217f 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/DefaultKeysBackupService.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/DefaultKeysBackupService.kt
@@ -21,6 +21,10 @@ import android.os.Looper
import androidx.annotation.UiThread
import androidx.annotation.VisibleForTesting
import androidx.annotation.WorkerThread
+import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.delay
+import kotlinx.coroutines.launch
+import kotlinx.coroutines.withContext
import org.matrix.android.sdk.api.MatrixCallback
import org.matrix.android.sdk.api.auth.data.Credentials
import org.matrix.android.sdk.api.failure.Failure
@@ -40,6 +44,7 @@ import org.matrix.android.sdk.internal.crypto.keysbackup.model.KeysBackupVersion
import org.matrix.android.sdk.internal.crypto.keysbackup.model.KeysBackupVersionTrustSignature
import org.matrix.android.sdk.internal.crypto.keysbackup.model.MegolmBackupAuthData
import org.matrix.android.sdk.internal.crypto.keysbackup.model.MegolmBackupCreationInfo
+import org.matrix.android.sdk.internal.crypto.keysbackup.model.SignalableMegolmBackupAuthData
import org.matrix.android.sdk.internal.crypto.keysbackup.model.rest.BackupKeysResult
import org.matrix.android.sdk.internal.crypto.keysbackup.model.rest.CreateKeysBackupVersionBody
import org.matrix.android.sdk.internal.crypto.keysbackup.model.rest.KeyBackupData
@@ -80,11 +85,6 @@ import org.matrix.android.sdk.internal.task.configureWith
import org.matrix.android.sdk.internal.util.JsonCanonicalizer
import org.matrix.android.sdk.internal.util.MatrixCoroutineDispatchers
import org.matrix.android.sdk.internal.util.awaitCallback
-import kotlinx.coroutines.CoroutineScope
-import kotlinx.coroutines.delay
-import kotlinx.coroutines.launch
-import kotlinx.coroutines.withContext
-import org.matrix.android.sdk.internal.crypto.keysbackup.model.SignalableMegolmBackupAuthData
import org.matrix.olm.OlmException
import org.matrix.olm.OlmPkDecryption
import org.matrix.olm.OlmPkEncryption
@@ -860,8 +860,8 @@ internal class DefaultKeysBackupService @Inject constructor(
}
override fun onFailure(failure: Throwable) {
- if (failure is Failure.ServerError
- && failure.error.code == MatrixError.M_NOT_FOUND) {
+ if (failure is Failure.ServerError &&
+ failure.error.code == MatrixError.M_NOT_FOUND) {
// Workaround because the homeserver currently returns M_NOT_FOUND when there is no key backup
callback.onSuccess(null)
} else {
@@ -883,8 +883,8 @@ internal class DefaultKeysBackupService @Inject constructor(
}
override fun onFailure(failure: Throwable) {
- if (failure is Failure.ServerError
- && failure.error.code == MatrixError.M_NOT_FOUND) {
+ if (failure is Failure.ServerError &&
+ failure.error.code == MatrixError.M_NOT_FOUND) {
// Workaround because the homeserver currently returns M_NOT_FOUND when there is no key backup
callback.onSuccess(null)
} else {
@@ -1042,8 +1042,8 @@ internal class DefaultKeysBackupService @Inject constructor(
return null
}
- if (authData.privateKeySalt.isNullOrBlank()
- || authData.privateKeyIterations == null) {
+ if (authData.privateKeySalt.isNullOrBlank() ||
+ authData.privateKeyIterations == null) {
Timber.w("recoveryKeyFromPassword: Salt and/or iterations not found in key backup auth data")
return null
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/KeysBackupStateManager.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/KeysBackupStateManager.kt
index 7c0c741a2c..78ef958bbf 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/KeysBackupStateManager.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/KeysBackupStateManager.kt
@@ -44,16 +44,16 @@ internal class KeysBackupStateManager(private val uiHandler: Handler) {
}
val isEnabled: Boolean
- get() = state == KeysBackupState.ReadyToBackUp
- || state == KeysBackupState.WillBackUp
- || state == KeysBackupState.BackingUp
+ get() = state == KeysBackupState.ReadyToBackUp ||
+ state == KeysBackupState.WillBackUp ||
+ state == KeysBackupState.BackingUp
// True if unknown or bad state
val isStucked: Boolean
- get() = state == KeysBackupState.Unknown
- || state == KeysBackupState.Disabled
- || state == KeysBackupState.WrongBackUpVersion
- || state == KeysBackupState.NotTrusted
+ get() = state == KeysBackupState.Unknown ||
+ state == KeysBackupState.Disabled ||
+ state == KeysBackupState.WrongBackUpVersion ||
+ state == KeysBackupState.NotTrusted
fun addListener(listener: KeysBackupStateListener) {
synchronized(listeners) {
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/secrets/DefaultSharedSecretStorageService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/secrets/DefaultSharedSecretStorageService.kt
index fb10cf4482..ad3bc012df 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/secrets/DefaultSharedSecretStorageService.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/secrets/DefaultSharedSecretStorageService.kt
@@ -16,6 +16,8 @@
package org.matrix.android.sdk.internal.crypto.secrets
+import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.withContext
import org.matrix.android.sdk.api.extensions.orFalse
import org.matrix.android.sdk.api.listeners.ProgressListener
import org.matrix.android.sdk.api.session.accountdata.SessionAccountDataService
@@ -43,8 +45,6 @@ import org.matrix.android.sdk.internal.crypto.tools.HkdfSha256
import org.matrix.android.sdk.internal.crypto.tools.withOlmDecryption
import org.matrix.android.sdk.internal.di.UserId
import org.matrix.android.sdk.internal.util.MatrixCoroutineDispatchers
-import kotlinx.coroutines.CoroutineScope
-import kotlinx.coroutines.withContext
import org.matrix.olm.OlmPkMessage
import java.security.SecureRandom
import javax.crypto.Cipher
@@ -359,8 +359,8 @@ internal class DefaultSharedSecretStorageService @Inject constructor(
val keyInfo = (keyInfoResult as? KeyInfoResult.Success)?.keyInfo
?: return IntegrityResult.Error(SharedSecretStorageError.UnknownKey(keyId ?: ""))
- if (keyInfo.content.algorithm != SSSS_ALGORITHM_AES_HMAC_SHA2
- && keyInfo.content.algorithm != SSSS_ALGORITHM_CURVE25519_AES_SHA2) {
+ if (keyInfo.content.algorithm != SSSS_ALGORITHM_AES_HMAC_SHA2 &&
+ keyInfo.content.algorithm != SSSS_ALGORITHM_CURVE25519_AES_SHA2) {
// Unsupported algorithm
return IntegrityResult.Error(
SharedSecretStorageError.UnsupportedAlgorithm(keyInfo.content.algorithm ?: "")
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/db/RealmCryptoStore.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/db/RealmCryptoStore.kt
index 860bba7404..3c8f74d419 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/db/RealmCryptoStore.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/db/RealmCryptoStore.kt
@@ -152,8 +152,8 @@ internal class RealmCryptoStore @Inject constructor(
// Check credentials
// The device id may not have been provided in credentials.
// Check it only if provided, else trust the stored one.
- if (currentMetadata.userId != userId
- || (deviceId != null && deviceId != currentMetadata.deviceId)) {
+ if (currentMetadata.userId != userId ||
+ (deviceId != null && deviceId != currentMetadata.deviceId)) {
Timber.w("## open() : Credentials do not match, close this store and delete data")
deleteAll = true
currentMetadata = null
@@ -178,9 +178,9 @@ internal class RealmCryptoStore @Inject constructor(
override fun hasData(): Boolean {
return doWithRealm(realmConfiguration) {
- !it.isEmpty
+ !it.isEmpty &&
// Check if there is a MetaData object
- && it.where().count() > 0
+ it.where().count() > 0
}
}
@@ -1025,10 +1025,10 @@ internal class RealmCryptoStore @Inject constructor(
}.mapNotNull {
it.toOutgoingGossipingRequest() as? OutgoingRoomKeyRequest
}.firstOrNull {
- it.requestBody?.algorithm == requestBody.algorithm
- && it.requestBody?.roomId == requestBody.roomId
- && it.requestBody?.senderKey == requestBody.senderKey
- && it.requestBody?.sessionId == requestBody.sessionId
+ it.requestBody?.algorithm == requestBody.algorithm &&
+ it.requestBody?.roomId == requestBody.roomId &&
+ it.requestBody?.senderKey == requestBody.senderKey &&
+ it.requestBody?.sessionId == requestBody.sessionId
}
}
@@ -1113,10 +1113,10 @@ internal class RealmCryptoStore @Inject constructor(
.mapNotNull {
it.toOutgoingGossipingRequest() as? OutgoingRoomKeyRequest
}.firstOrNull {
- it.requestBody?.algorithm == requestBody.algorithm
- && it.requestBody?.sessionId == requestBody.sessionId
- && it.requestBody?.senderKey == requestBody.senderKey
- && it.requestBody?.roomId == requestBody.roomId
+ it.requestBody?.algorithm == requestBody.algorithm &&
+ it.requestBody?.sessionId == requestBody.sessionId &&
+ it.requestBody?.senderKey == requestBody.senderKey &&
+ it.requestBody?.roomId == requestBody.roomId
}
if (existing == null) {
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/db/RealmCryptoStoreModule.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/db/RealmCryptoStoreModule.kt
index 6aae68c83e..a2f2f8e97a 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/db/RealmCryptoStoreModule.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/db/RealmCryptoStoreModule.kt
@@ -16,6 +16,7 @@
package org.matrix.android.sdk.internal.crypto.store.db
+import io.realm.annotations.RealmModule
import org.matrix.android.sdk.internal.crypto.store.db.model.CrossSigningInfoEntity
import org.matrix.android.sdk.internal.crypto.store.db.model.CryptoMetadataEntity
import org.matrix.android.sdk.internal.crypto.store.db.model.CryptoRoomEntity
@@ -27,13 +28,12 @@ import org.matrix.android.sdk.internal.crypto.store.db.model.KeysBackupDataEntit
import org.matrix.android.sdk.internal.crypto.store.db.model.MyDeviceLastSeenInfoEntity
import org.matrix.android.sdk.internal.crypto.store.db.model.OlmInboundGroupSessionEntity
import org.matrix.android.sdk.internal.crypto.store.db.model.OlmSessionEntity
+import org.matrix.android.sdk.internal.crypto.store.db.model.OutboundGroupSessionInfoEntity
import org.matrix.android.sdk.internal.crypto.store.db.model.OutgoingGossipingRequestEntity
import org.matrix.android.sdk.internal.crypto.store.db.model.SharedSessionEntity
import org.matrix.android.sdk.internal.crypto.store.db.model.TrustLevelEntity
import org.matrix.android.sdk.internal.crypto.store.db.model.UserEntity
import org.matrix.android.sdk.internal.crypto.store.db.model.WithHeldSessionEntity
-import io.realm.annotations.RealmModule
-import org.matrix.android.sdk.internal.crypto.store.db.model.OutboundGroupSessionInfoEntity
/**
* Realm module for Crypto store classes
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/db/mapper/CrossSigningKeysMapper.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/db/mapper/CrossSigningKeysMapper.kt
index 9e73985592..c15414a8dd 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/db/mapper/CrossSigningKeysMapper.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/db/mapper/CrossSigningKeysMapper.kt
@@ -18,10 +18,10 @@ package org.matrix.android.sdk.internal.crypto.store.db.mapper
import com.squareup.moshi.Moshi
import com.squareup.moshi.Types
+import io.realm.RealmList
import org.matrix.android.sdk.internal.crypto.crosssigning.DeviceTrustLevel
import org.matrix.android.sdk.internal.crypto.model.CryptoCrossSigningKey
import org.matrix.android.sdk.internal.crypto.store.db.model.KeyInfoEntity
-import io.realm.RealmList
import timber.log.Timber
import javax.inject.Inject
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/db/model/CryptoMetadataEntity.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/db/model/CryptoMetadataEntity.kt
index 5166f6c31f..35ae86db8b 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/db/model/CryptoMetadataEntity.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/db/model/CryptoMetadataEntity.kt
@@ -16,10 +16,10 @@
package org.matrix.android.sdk.internal.crypto.store.db.model
-import org.matrix.android.sdk.internal.crypto.store.db.deserializeFromRealm
-import org.matrix.android.sdk.internal.crypto.store.db.serializeForRealm
import io.realm.RealmObject
import io.realm.annotations.PrimaryKey
+import org.matrix.android.sdk.internal.crypto.store.db.deserializeFromRealm
+import org.matrix.android.sdk.internal.crypto.store.db.serializeForRealm
import org.matrix.olm.OlmAccount
internal open class CryptoMetadataEntity(
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/db/model/CryptoRoomEntity.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/db/model/CryptoRoomEntity.kt
index e226f3eaa8..711b698464 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/db/model/CryptoRoomEntity.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/db/model/CryptoRoomEntity.kt
@@ -28,8 +28,8 @@ internal open class CryptoRoomEntity(
// to avoid re-create and re-share at each startup (if rotation not needed..)
// This is specific to megolm but not sure how to model it better
var outboundSessionInfo: OutboundGroupSessionInfoEntity? = null
- )
- : RealmObject() {
+ ) :
+ RealmObject() {
companion object
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/db/model/GossipingEventEntity.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/db/model/GossipingEventEntity.kt
index b8675d0823..75094f01db 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/db/model/GossipingEventEntity.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/db/model/GossipingEventEntity.kt
@@ -17,6 +17,8 @@
package org.matrix.android.sdk.internal.crypto.store.db.model
import com.squareup.moshi.JsonDataException
+import io.realm.RealmObject
+import io.realm.annotations.Index
import org.matrix.android.sdk.api.session.crypto.MXCryptoError
import org.matrix.android.sdk.api.session.events.model.Event
import org.matrix.android.sdk.api.session.room.send.SendState
@@ -24,8 +26,6 @@ import org.matrix.android.sdk.internal.crypto.MXEventDecryptionResult
import org.matrix.android.sdk.internal.crypto.algorithms.olm.OlmDecryptionResult
import org.matrix.android.sdk.internal.database.mapper.ContentMapper
import org.matrix.android.sdk.internal.di.MoshiProvider
-import io.realm.RealmObject
-import io.realm.annotations.Index
import timber.log.Timber
/**
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/db/model/IncomingGossipingRequestEntity.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/db/model/IncomingGossipingRequestEntity.kt
index df45568d18..4457a44cb2 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/db/model/IncomingGossipingRequestEntity.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/db/model/IncomingGossipingRequestEntity.kt
@@ -16,6 +16,8 @@
package org.matrix.android.sdk.internal.crypto.store.db.model
+import io.realm.RealmObject
+import io.realm.annotations.Index
import org.matrix.android.sdk.api.extensions.tryOrNull
import org.matrix.android.sdk.internal.crypto.GossipRequestType
import org.matrix.android.sdk.internal.crypto.GossipingRequestState
@@ -23,8 +25,6 @@ import org.matrix.android.sdk.internal.crypto.IncomingRoomKeyRequest
import org.matrix.android.sdk.internal.crypto.IncomingSecretShareRequest
import org.matrix.android.sdk.internal.crypto.IncomingShareRequestCommon
import org.matrix.android.sdk.internal.crypto.model.rest.RoomKeyRequestBody
-import io.realm.RealmObject
-import io.realm.annotations.Index
internal open class IncomingGossipingRequestEntity(@Index var requestId: String? = "",
@Index var typeStr: String? = null,
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/db/model/OlmInboundGroupSessionEntity.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/db/model/OlmInboundGroupSessionEntity.kt
index d0e16bbe11..f330e8822a 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/db/model/OlmInboundGroupSessionEntity.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/db/model/OlmInboundGroupSessionEntity.kt
@@ -16,11 +16,11 @@
package org.matrix.android.sdk.internal.crypto.store.db.model
+import io.realm.RealmObject
+import io.realm.annotations.PrimaryKey
import org.matrix.android.sdk.internal.crypto.model.OlmInboundGroupSessionWrapper2
import org.matrix.android.sdk.internal.crypto.store.db.deserializeFromRealm
import org.matrix.android.sdk.internal.crypto.store.db.serializeForRealm
-import io.realm.RealmObject
-import io.realm.annotations.PrimaryKey
import timber.log.Timber
internal fun OlmInboundGroupSessionEntity.Companion.createPrimaryKey(sessionId: String?, senderKey: String?) = "$sessionId|$senderKey"
@@ -33,8 +33,8 @@ internal open class OlmInboundGroupSessionEntity(
// olmInboundGroupSessionData contains Json
var olmInboundGroupSessionData: String? = null,
// Indicate if the key has been backed up to the homeserver
- var backedUp: Boolean = false)
- : RealmObject() {
+ var backedUp: Boolean = false) :
+ RealmObject() {
fun getInboundGroupSession(): OlmInboundGroupSessionWrapper2? {
return try {
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/db/model/OlmSessionEntity.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/db/model/OlmSessionEntity.kt
index 8f41057807..0b69311c57 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/db/model/OlmSessionEntity.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/db/model/OlmSessionEntity.kt
@@ -16,10 +16,10 @@
package org.matrix.android.sdk.internal.crypto.store.db.model
-import org.matrix.android.sdk.internal.crypto.store.db.deserializeFromRealm
-import org.matrix.android.sdk.internal.crypto.store.db.serializeForRealm
import io.realm.RealmObject
import io.realm.annotations.PrimaryKey
+import org.matrix.android.sdk.internal.crypto.store.db.deserializeFromRealm
+import org.matrix.android.sdk.internal.crypto.store.db.serializeForRealm
import org.matrix.olm.OlmSession
internal fun OlmSessionEntity.Companion.createPrimaryKey(sessionId: String, deviceKey: String) = "$sessionId|$deviceKey"
@@ -29,8 +29,8 @@ internal open class OlmSessionEntity(@PrimaryKey var primaryKey: String = "",
var sessionId: String? = null,
var deviceKey: String? = null,
var olmSessionData: String? = null,
- var lastReceivedMessageTs: Long = 0)
- : RealmObject() {
+ var lastReceivedMessageTs: Long = 0) :
+ RealmObject() {
fun getOlmSession(): OlmSession? {
return deserializeFromRealm(olmSessionData)
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/db/model/OutgoingGossipingRequestEntity.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/db/model/OutgoingGossipingRequestEntity.kt
index 442dda1d71..a19547fddc 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/db/model/OutgoingGossipingRequestEntity.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/db/model/OutgoingGossipingRequestEntity.kt
@@ -18,6 +18,8 @@ package org.matrix.android.sdk.internal.crypto.store.db.model
import com.squareup.moshi.JsonAdapter
import com.squareup.moshi.Types
+import io.realm.RealmObject
+import io.realm.annotations.Index
import org.matrix.android.sdk.api.extensions.tryOrNull
import org.matrix.android.sdk.internal.crypto.GossipRequestType
import org.matrix.android.sdk.internal.crypto.OutgoingGossipingRequest
@@ -26,8 +28,6 @@ import org.matrix.android.sdk.internal.crypto.OutgoingRoomKeyRequest
import org.matrix.android.sdk.internal.crypto.OutgoingSecretRequest
import org.matrix.android.sdk.internal.crypto.model.rest.RoomKeyRequestBody
import org.matrix.android.sdk.internal.di.MoshiProvider
-import io.realm.RealmObject
-import io.realm.annotations.Index
internal open class OutgoingGossipingRequestEntity(
@Index var requestId: String? = null,
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/db/model/WithHeldSessionEntity.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/db/model/WithHeldSessionEntity.kt
index 2864ab768d..6d7889053b 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/db/model/WithHeldSessionEntity.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/db/model/WithHeldSessionEntity.kt
@@ -16,9 +16,9 @@
package org.matrix.android.sdk.internal.crypto.store.db.model
-import org.matrix.android.sdk.internal.crypto.model.event.WithHeldCode
import io.realm.RealmObject
import io.realm.annotations.Index
+import org.matrix.android.sdk.internal.crypto.model.event.WithHeldCode
/**
* When an encrypted message is sent in a room, the megolm key might not be sent to all devices present in the room.
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/db/query/CrossSigningInfoEntityQueries.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/db/query/CrossSigningInfoEntityQueries.kt
index eea2f6f31b..05eed9256e 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/db/query/CrossSigningInfoEntityQueries.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/db/query/CrossSigningInfoEntityQueries.kt
@@ -16,11 +16,11 @@
package org.matrix.android.sdk.internal.crypto.store.db.query
-import org.matrix.android.sdk.internal.crypto.store.db.model.CrossSigningInfoEntity
-import org.matrix.android.sdk.internal.crypto.store.db.model.UserEntityFields
import io.realm.Realm
import io.realm.kotlin.createObject
import io.realm.kotlin.where
+import org.matrix.android.sdk.internal.crypto.store.db.model.CrossSigningInfoEntity
+import org.matrix.android.sdk.internal.crypto.store.db.model.UserEntityFields
internal fun CrossSigningInfoEntity.Companion.getOrCreate(realm: Realm, userId: String): CrossSigningInfoEntity {
return realm.where()
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/db/query/CryptoRoomEntityQueries.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/db/query/CryptoRoomEntityQueries.kt
index 5ebf8b1ed5..5750cc1f67 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/db/query/CryptoRoomEntityQueries.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/db/query/CryptoRoomEntityQueries.kt
@@ -16,11 +16,11 @@
package org.matrix.android.sdk.internal.crypto.store.db.query
-import org.matrix.android.sdk.internal.crypto.store.db.model.CryptoRoomEntity
-import org.matrix.android.sdk.internal.crypto.store.db.model.CryptoRoomEntityFields
import io.realm.Realm
import io.realm.kotlin.createObject
import io.realm.kotlin.where
+import org.matrix.android.sdk.internal.crypto.store.db.model.CryptoRoomEntity
+import org.matrix.android.sdk.internal.crypto.store.db.model.CryptoRoomEntityFields
/**
* Get or create a room
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/db/query/DeviceInfoEntityQueries.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/db/query/DeviceInfoEntityQueries.kt
index 1d5ca2d3cc..c9523d63ce 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/db/query/DeviceInfoEntityQueries.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/db/query/DeviceInfoEntityQueries.kt
@@ -16,12 +16,12 @@
package org.matrix.android.sdk.internal.crypto.store.db.query
-import org.matrix.android.sdk.internal.crypto.store.db.model.DeviceInfoEntity
-import org.matrix.android.sdk.internal.crypto.store.db.model.DeviceInfoEntityFields
-import org.matrix.android.sdk.internal.crypto.store.db.model.createPrimaryKey
import io.realm.Realm
import io.realm.kotlin.createObject
import io.realm.kotlin.where
+import org.matrix.android.sdk.internal.crypto.store.db.model.DeviceInfoEntity
+import org.matrix.android.sdk.internal.crypto.store.db.model.DeviceInfoEntityFields
+import org.matrix.android.sdk.internal.crypto.store.db.model.createPrimaryKey
/**
* Get or create a device info
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/db/query/SharedSessionQueries.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/db/query/SharedSessionQueries.kt
index 39117512bb..2784e58425 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/db/query/SharedSessionQueries.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/db/query/SharedSessionQueries.kt
@@ -29,8 +29,7 @@ internal fun SharedSessionEntity.Companion.get(realm: Realm,
sessionId: String,
userId: String,
deviceId: String,
- deviceIdentityKey: String?)
- : SharedSessionEntity? {
+ deviceIdentityKey: String?): SharedSessionEntity? {
return realm.where()
.equalTo(SharedSessionEntityFields.ROOM_ID, roomId)
.equalTo(SharedSessionEntityFields.SESSION_ID, sessionId)
@@ -41,8 +40,7 @@ internal fun SharedSessionEntity.Companion.get(realm: Realm,
.findFirst()
}
-internal fun SharedSessionEntity.Companion.get(realm: Realm, roomId: String?, sessionId: String)
- : RealmResults {
+internal fun SharedSessionEntity.Companion.get(realm: Realm, roomId: String?, sessionId: String): RealmResults {
return realm.where()
.equalTo(SharedSessionEntityFields.ROOM_ID, roomId)
.equalTo(SharedSessionEntityFields.SESSION_ID, sessionId)
@@ -55,8 +53,7 @@ internal fun SharedSessionEntity.Companion.create(realm: Realm, roomId: String?,
userId: String,
deviceId: String,
deviceIdentityKey: String,
- chainIndex: Int)
- : SharedSessionEntity {
+ chainIndex: Int): SharedSessionEntity {
return realm.createObject().apply {
this.roomId = roomId
this.algorithm = MXCRYPTO_ALGORITHM_MEGOLM
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/db/query/WithHeldSessionQueries.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/db/query/WithHeldSessionQueries.kt
index 3c6c594a70..b8a3e36137 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/db/query/WithHeldSessionQueries.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/db/query/WithHeldSessionQueries.kt
@@ -16,12 +16,12 @@
package org.matrix.android.sdk.internal.crypto.store.db.query
-import org.matrix.android.sdk.internal.crypto.MXCRYPTO_ALGORITHM_MEGOLM
-import org.matrix.android.sdk.internal.crypto.store.db.model.WithHeldSessionEntity
-import org.matrix.android.sdk.internal.crypto.store.db.model.WithHeldSessionEntityFields
import io.realm.Realm
import io.realm.kotlin.createObject
import io.realm.kotlin.where
+import org.matrix.android.sdk.internal.crypto.MXCRYPTO_ALGORITHM_MEGOLM
+import org.matrix.android.sdk.internal.crypto.store.db.model.WithHeldSessionEntity
+import org.matrix.android.sdk.internal.crypto.store.db.model.WithHeldSessionEntityFields
internal fun WithHeldSessionEntity.Companion.get(realm: Realm, roomId: String, sessionId: String): WithHeldSessionEntity? {
return realm.where()
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/DeleteDeviceTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/DeleteDeviceTask.kt
index bdb8e8d137..ca04bac5d5 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/DeleteDeviceTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/DeleteDeviceTask.kt
@@ -16,11 +16,11 @@
package org.matrix.android.sdk.internal.crypto.tasks
+import org.matrix.android.sdk.api.auth.UIABaseAuth
import org.matrix.android.sdk.api.auth.UserInteractiveAuthInterceptor
import org.matrix.android.sdk.internal.auth.registration.handleUIA
import org.matrix.android.sdk.internal.crypto.api.CryptoApi
import org.matrix.android.sdk.internal.crypto.model.rest.DeleteDeviceParams
-import org.matrix.android.sdk.api.auth.UIABaseAuth
import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
import org.matrix.android.sdk.internal.network.executeRequest
import org.matrix.android.sdk.internal.task.Task
@@ -46,8 +46,8 @@ internal class DefaultDeleteDeviceTask @Inject constructor(
cryptoApi.deleteDevice(params.deviceId, DeleteDeviceParams(params.userAuthParam?.asMap()))
}
} catch (throwable: Throwable) {
- if (params.userInteractiveAuthInterceptor == null
- || !handleUIA(
+ if (params.userInteractiveAuthInterceptor == null ||
+ !handleUIA(
failure = throwable,
interceptor = params.userInteractiveAuthInterceptor,
retryBlock = { authUpdate ->
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/InitializeCrossSigningTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/InitializeCrossSigningTask.kt
index 1d40e5defd..e2fd54f0d8 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/InitializeCrossSigningTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/InitializeCrossSigningTask.kt
@@ -125,8 +125,8 @@ internal class DefaultInitializeCrossSigningTask @Inject constructor(
try {
uploadSigningKeysTask.execute(uploadSigningKeysParams)
} catch (failure: Throwable) {
- if (params.interactiveAuthInterceptor == null
- || !handleUIA(
+ if (params.interactiveAuthInterceptor == null ||
+ !handleUIA(
failure = failure,
interceptor = params.interactiveAuthInterceptor,
retryBlock = { authUpdate ->
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/UploadSigningKeysTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/UploadSigningKeysTask.kt
index 08c767ba34..6cb14ded63 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/UploadSigningKeysTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/UploadSigningKeysTask.kt
@@ -16,10 +16,10 @@
package org.matrix.android.sdk.internal.crypto.tasks
+import org.matrix.android.sdk.api.auth.UIABaseAuth
import org.matrix.android.sdk.api.failure.Failure
import org.matrix.android.sdk.internal.crypto.api.CryptoApi
import org.matrix.android.sdk.internal.crypto.model.CryptoCrossSigningKey
-import org.matrix.android.sdk.api.auth.UIABaseAuth
import org.matrix.android.sdk.internal.crypto.model.rest.UploadSigningKeysBody
import org.matrix.android.sdk.internal.crypto.model.toRest
import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/verification/DefaultIncomingSASDefaultVerificationTransaction.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/verification/DefaultIncomingSASDefaultVerificationTransaction.kt
index fde9f70e7b..68f1cf62d5 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/verification/DefaultIncomingSASDefaultVerificationTransaction.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/verification/DefaultIncomingSASDefaultVerificationTransaction.kt
@@ -114,8 +114,8 @@ internal class DefaultIncomingSASDefaultVerificationTransaction(
// No common key sharing/hashing/hmac/SAS methods.
// If a device is unable to complete the verification because the devices are unable to find a common key sharing,
// hashing, hmac, or SAS method, then it should send a m.key.verification.cancel message
- if (listOf(agreedProtocol, agreedHash, agreedMac).any { it.isNullOrBlank() }
- || agreedShortCode.isNullOrEmpty()) {
+ if (listOf(agreedProtocol, agreedHash, agreedMac).any { it.isNullOrBlank() } ||
+ agreedShortCode.isNullOrEmpty()) {
// Failed to find agreement
Timber.e("## SAS Failed to find agreement ")
cancel(CancelCode.UnknownMethod)
@@ -241,12 +241,12 @@ internal class DefaultIncomingSASDefaultVerificationTransaction(
override fun onKeyVerificationMac(vMac: ValidVerificationInfoMac) {
Timber.v("## SAS I: received mac for request id:$transactionId")
// Check for state?
- if (state != VerificationTxState.SendingKey
- && state != VerificationTxState.KeySent
- && state != VerificationTxState.ShortCodeReady
- && state != VerificationTxState.ShortCodeAccepted
- && state != VerificationTxState.SendingMac
- && state != VerificationTxState.MacSent) {
+ if (state != VerificationTxState.SendingKey &&
+ state != VerificationTxState.KeySent &&
+ state != VerificationTxState.ShortCodeReady &&
+ state != VerificationTxState.ShortCodeAccepted &&
+ state != VerificationTxState.SendingMac &&
+ state != VerificationTxState.MacSent) {
Timber.e("## SAS I: received key from invalid state $state")
cancel(CancelCode.UnexpectedMessage)
return
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/verification/DefaultOutgoingSASDefaultVerificationTransaction.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/verification/DefaultOutgoingSASDefaultVerificationTransaction.kt
index 1a41f89006..e203f03b06 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/verification/DefaultOutgoingSASDefaultVerificationTransaction.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/verification/DefaultOutgoingSASDefaultVerificationTransaction.kt
@@ -144,10 +144,10 @@ internal class DefaultOutgoingSASDefaultVerificationTransaction(
return
}
// Check that the agreement is correct
- if (!KNOWN_AGREEMENT_PROTOCOLS.contains(accept.keyAgreementProtocol)
- || !KNOWN_HASHES.contains(accept.hash)
- || !KNOWN_MACS.contains(accept.messageAuthenticationCode)
- || accept.shortAuthenticationStrings.intersect(KNOWN_SHORT_CODES).isEmpty()) {
+ if (!KNOWN_AGREEMENT_PROTOCOLS.contains(accept.keyAgreementProtocol) ||
+ !KNOWN_HASHES.contains(accept.hash) ||
+ !KNOWN_MACS.contains(accept.messageAuthenticationCode) ||
+ accept.shortAuthenticationStrings.intersect(KNOWN_SHORT_CODES).isEmpty()) {
Timber.e("## SAS O: received invalid accept")
cancel(CancelCode.UnknownMethod)
return
@@ -233,12 +233,12 @@ internal class DefaultOutgoingSASDefaultVerificationTransaction(
override fun onKeyVerificationMac(vMac: ValidVerificationInfoMac) {
Timber.v("## SAS O: onKeyVerificationMac id:$transactionId")
// There is starting to be a huge amount of state / race here :/
- if (state != VerificationTxState.OnKeyReceived
- && state != VerificationTxState.ShortCodeReady
- && state != VerificationTxState.ShortCodeAccepted
- && state != VerificationTxState.KeySent
- && state != VerificationTxState.SendingMac
- && state != VerificationTxState.MacSent) {
+ if (state != VerificationTxState.OnKeyReceived &&
+ state != VerificationTxState.ShortCodeReady &&
+ state != VerificationTxState.ShortCodeAccepted &&
+ state != VerificationTxState.KeySent &&
+ state != VerificationTxState.SendingMac &&
+ state != VerificationTxState.MacSent) {
Timber.e("## SAS O: received mac from invalid state $state")
cancel(CancelCode.UnexpectedMessage)
return
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/verification/DefaultVerificationService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/verification/DefaultVerificationService.kt
index d9da88770c..768109979d 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/verification/DefaultVerificationService.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/verification/DefaultVerificationService.kt
@@ -19,6 +19,8 @@ package org.matrix.android.sdk.internal.crypto.verification
import android.os.Handler
import android.os.Looper
import dagger.Lazy
+import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.launch
import org.matrix.android.sdk.api.session.crypto.crosssigning.CrossSigningService
import org.matrix.android.sdk.api.session.crypto.crosssigning.KEYBACKUP_SECRET_SSSS_NAME
import org.matrix.android.sdk.api.session.crypto.crosssigning.MASTER_KEY_SSSS_NAME
@@ -82,8 +84,6 @@ import org.matrix.android.sdk.internal.di.UserId
import org.matrix.android.sdk.internal.session.SessionScope
import org.matrix.android.sdk.internal.task.TaskExecutor
import org.matrix.android.sdk.internal.util.MatrixCoroutineDispatchers
-import kotlinx.coroutines.CoroutineScope
-import kotlinx.coroutines.launch
import timber.log.Timber
import java.util.UUID
import javax.inject.Inject
@@ -537,8 +537,8 @@ internal class DefaultVerificationService @Inject constructor(
// as we are the one requesting in first place (or we accepted the request)
// I need to check if the pending request was related to this device also
val autoAccept = getExistingVerificationRequests(otherUserId).any {
- it.transactionId == startReq.transactionId
- && (it.requestInfo?.fromDevice == this.deviceId || it.readyInfo?.fromDevice == this.deviceId)
+ it.transactionId == startReq.transactionId &&
+ (it.requestInfo?.fromDevice == this.deviceId || it.readyInfo?.fromDevice == this.deviceId)
}
val tx = DefaultIncomingSASDefaultVerificationTransaction(
// this,
@@ -1126,8 +1126,10 @@ internal class DefaultVerificationService @Inject constructor(
}
}
- override fun requestKeyVerificationInDMs(methods: List, otherUserId: String, roomId: String, localId: String?)
- : PendingVerificationRequest {
+ override fun requestKeyVerificationInDMs(methods: List,
+ otherUserId: String,
+ roomId: String,
+ localId: String?): PendingVerificationRequest {
Timber.i("## SAS Requesting verification to user: $otherUserId in room $roomId")
val requestsForUser = pendingRequests.getOrPut(otherUserId) { mutableListOf() }
@@ -1278,8 +1280,8 @@ internal class DefaultVerificationService @Inject constructor(
private fun updatePendingRequest(updated: PendingVerificationRequest) {
val requestsForUser = pendingRequests.getOrPut(updated.otherUserId) { mutableListOf() }
val index = requestsForUser.indexOfFirst {
- it.transactionId == updated.transactionId
- || it.transactionId == null && it.localId == updated.localId
+ it.transactionId == updated.transactionId ||
+ it.transactionId == null && it.localId == updated.localId
}
if (index != -1) {
requestsForUser.removeAt(index)
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/verification/SendVerificationMessageWorker.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/verification/SendVerificationMessageWorker.kt
index 538d7b56e9..481ce85f70 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/verification/SendVerificationMessageWorker.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/verification/SendVerificationMessageWorker.kt
@@ -34,8 +34,8 @@ import javax.inject.Inject
* Possible next worker : None
*/
internal class SendVerificationMessageWorker(context: Context,
- params: WorkerParameters)
- : SessionSafeCoroutineWorker(context, params, Params::class.java) {
+ params: WorkerParameters) :
+ SessionSafeCoroutineWorker(context, params, Params::class.java) {
@JsonClass(generateAdapter = true)
internal data class Params(
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/verification/VerificationInfoStart.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/verification/VerificationInfoStart.kt
index 21a6ba41b1..f727aff39d 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/verification/VerificationInfoStart.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/verification/VerificationInfoStart.kt
@@ -73,8 +73,8 @@ internal interface VerificationInfoStart : VerificationInfo)
- : VerificationInfoAccept = MessageVerificationAcceptContent.create(
+ shortAuthenticationStrings: List): VerificationInfoAccept =
+ MessageVerificationAcceptContent.create(
tid,
keyAgreementProtocol,
hash,
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/DatabaseCleaner.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/DatabaseCleaner.kt
index ee58880eb8..7341d4656a 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/DatabaseCleaner.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/DatabaseCleaner.kt
@@ -21,6 +21,7 @@ import io.realm.RealmConfiguration
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import org.matrix.android.sdk.api.session.Session
+import org.matrix.android.sdk.api.session.SessionLifecycleObserver
import org.matrix.android.sdk.internal.database.helper.nextDisplayIndex
import org.matrix.android.sdk.internal.database.model.ChunkEntity
import org.matrix.android.sdk.internal.database.model.ChunkEntityFields
@@ -30,7 +31,6 @@ import org.matrix.android.sdk.internal.database.model.TimelineEventEntity
import org.matrix.android.sdk.internal.database.model.TimelineEventEntityFields
import org.matrix.android.sdk.internal.database.model.deleteOnCascade
import org.matrix.android.sdk.internal.di.SessionDatabase
-import org.matrix.android.sdk.api.session.SessionLifecycleObserver
import org.matrix.android.sdk.internal.session.room.timeline.PaginationDirection
import org.matrix.android.sdk.internal.task.TaskExecutor
import timber.log.Timber
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/EventInsertLiveObserver.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/EventInsertLiveObserver.kt
index 758c7aa5b9..115025cc7d 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/EventInsertLiveObserver.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/EventInsertLiveObserver.kt
@@ -31,8 +31,8 @@ import timber.log.Timber
import javax.inject.Inject
internal class EventInsertLiveObserver @Inject constructor(@SessionDatabase realmConfiguration: RealmConfiguration,
- private val processors: Set<@JvmSuppressWildcards EventInsertLiveProcessor>)
- : RealmLiveEntityObserver(realmConfiguration) {
+ private val processors: Set<@JvmSuppressWildcards EventInsertLiveProcessor>) :
+ RealmLiveEntityObserver(realmConfiguration) {
override val query = Monarchy.Query {
it.where(EventInsertEntity::class.java).equalTo(EventInsertEntityFields.CAN_BE_PROCESSED, true)
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/RealmKeysUtils.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/RealmKeysUtils.kt
index d5ff7a0f84..7c622146d3 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/RealmKeysUtils.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/RealmKeysUtils.kt
@@ -19,9 +19,9 @@ import android.content.Context
import android.util.Base64
import androidx.core.content.edit
import io.realm.Realm
+import io.realm.RealmConfiguration
import org.matrix.android.sdk.BuildConfig
import org.matrix.android.sdk.internal.session.securestorage.SecretStoringUtils
-import io.realm.RealmConfiguration
import timber.log.Timber
import java.security.SecureRandom
import javax.inject.Inject
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/RealmLiveEntityObserver.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/RealmLiveEntityObserver.kt
index c602ed7075..50eb086f9a 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/RealmLiveEntityObserver.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/RealmLiveEntityObserver.kt
@@ -17,8 +17,6 @@
package org.matrix.android.sdk.internal.database
import com.zhuinden.monarchy.Monarchy
-import org.matrix.android.sdk.api.session.SessionLifecycleObserver
-import org.matrix.android.sdk.internal.util.createBackgroundHandler
import io.realm.Realm
import io.realm.RealmChangeListener
import io.realm.RealmConfiguration
@@ -29,13 +27,15 @@ import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.android.asCoroutineDispatcher
import kotlinx.coroutines.cancelChildren
import org.matrix.android.sdk.api.session.Session
+import org.matrix.android.sdk.api.session.SessionLifecycleObserver
+import org.matrix.android.sdk.internal.util.createBackgroundHandler
import java.util.concurrent.atomic.AtomicBoolean
import java.util.concurrent.atomic.AtomicReference
internal interface LiveEntityObserver : SessionLifecycleObserver
-internal abstract class RealmLiveEntityObserver(protected val realmConfiguration: RealmConfiguration)
- : LiveEntityObserver, RealmChangeListener> {
+internal abstract class RealmLiveEntityObserver(protected val realmConfiguration: RealmConfiguration) :
+ LiveEntityObserver, RealmChangeListener> {
private companion object {
val BACKGROUND_HANDLER = createBackgroundHandler("LIVE_ENTITY_BACKGROUND")
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/RealmSessionProvider.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/RealmSessionProvider.kt
index 52fbabb49f..8c62c345d0 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/RealmSessionProvider.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/RealmSessionProvider.kt
@@ -21,8 +21,8 @@ import androidx.annotation.MainThread
import com.zhuinden.monarchy.Monarchy
import io.realm.Realm
import org.matrix.android.sdk.api.session.Session
-import org.matrix.android.sdk.internal.di.SessionDatabase
import org.matrix.android.sdk.api.session.SessionLifecycleObserver
+import org.matrix.android.sdk.internal.di.SessionDatabase
import org.matrix.android.sdk.internal.session.SessionScope
import javax.inject.Inject
import kotlin.concurrent.getOrSet
@@ -32,8 +32,8 @@ import kotlin.concurrent.getOrSet
* instance. This does check each time if you are on the main thread or not and returns the appropriate realm instance.
*/
@SessionScope
-internal class RealmSessionProvider @Inject constructor(@SessionDatabase private val monarchy: Monarchy)
- : SessionLifecycleObserver {
+internal class RealmSessionProvider @Inject constructor(@SessionDatabase private val monarchy: Monarchy) :
+ SessionLifecycleObserver {
private val realmThreadLocal = ThreadLocal()
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/helper/ChunkEntityHelper.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/helper/ChunkEntityHelper.kt
index e262b40419..f74e4b0f4c 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/helper/ChunkEntityHelper.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/helper/ChunkEntityHelper.kt
@@ -16,6 +16,9 @@
package org.matrix.android.sdk.internal.database.helper
+import io.realm.Realm
+import io.realm.Sort
+import io.realm.kotlin.createObject
import org.matrix.android.sdk.api.session.room.model.RoomMemberContent
import org.matrix.android.sdk.internal.database.model.ChunkEntity
import org.matrix.android.sdk.internal.database.model.CurrentStateEventEntityFields
@@ -33,9 +36,6 @@ import org.matrix.android.sdk.internal.database.query.getOrCreate
import org.matrix.android.sdk.internal.database.query.where
import org.matrix.android.sdk.internal.extensions.assertIsManaged
import org.matrix.android.sdk.internal.session.room.timeline.PaginationDirection
-import io.realm.Realm
-import io.realm.Sort
-import io.realm.kotlin.createObject
import timber.log.Timber
internal fun ChunkEntity.merge(roomId: String, chunkToMerge: ChunkEntity, direction: PaginationDirection) {
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/helper/TimelineEventEntityHelper.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/helper/TimelineEventEntityHelper.kt
index 90e867749e..3993e8e799 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/helper/TimelineEventEntityHelper.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/helper/TimelineEventEntityHelper.kt
@@ -16,9 +16,9 @@
package org.matrix.android.sdk.internal.database.helper
+import io.realm.Realm
import org.matrix.android.sdk.internal.database.model.TimelineEventEntity
import org.matrix.android.sdk.internal.database.model.TimelineEventEntityFields
-import io.realm.Realm
internal fun TimelineEventEntity.Companion.nextId(realm: Realm): Long {
val currentIdNum = realm.where(TimelineEventEntity::class.java).max(TimelineEventEntityFields.LOCAL_ID)
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/mapper/IsUselessResolver.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/mapper/IsUselessResolver.kt
index 5d7afc50d6..d704ecac8e 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/mapper/IsUselessResolver.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/mapper/IsUselessResolver.kt
@@ -29,8 +29,8 @@ internal object IsUselessResolver {
return when (event.type) {
EventType.STATE_ROOM_MEMBER -> {
// Call toContent(), to filter out null value
- event.content != null
- && event.content.toContent() == event.resolvedPrevContent()?.toContent()
+ event.content != null &&
+ event.content.toContent() == event.resolvedPrevContent()?.toContent()
}
else -> false
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/mapper/PollResponseAggregatedSummaryEntityMapper.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/mapper/PollResponseAggregatedSummaryEntityMapper.kt
index b26e7e88e3..00998af9bb 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/mapper/PollResponseAggregatedSummaryEntityMapper.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/mapper/PollResponseAggregatedSummaryEntityMapper.kt
@@ -16,11 +16,11 @@
package org.matrix.android.sdk.internal.database.mapper
+import io.realm.RealmList
import org.matrix.android.sdk.api.session.events.model.toContent
import org.matrix.android.sdk.api.session.events.model.toModel
import org.matrix.android.sdk.api.session.room.model.PollResponseAggregatedSummary
import org.matrix.android.sdk.internal.database.model.PollResponseAggregatedSummaryEntity
-import io.realm.RealmList
internal object PollResponseAggregatedSummaryEntityMapper {
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/model/EventEntity.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/model/EventEntity.kt
index 4dc8712afb..bcd30cb54b 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/model/EventEntity.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/model/EventEntity.kt
@@ -16,12 +16,12 @@
package org.matrix.android.sdk.internal.database.model
+import io.realm.RealmObject
+import io.realm.annotations.Index
import org.matrix.android.sdk.api.session.room.send.SendState
import org.matrix.android.sdk.internal.crypto.MXEventDecryptionResult
import org.matrix.android.sdk.internal.crypto.algorithms.olm.OlmDecryptionResult
import org.matrix.android.sdk.internal.di.MoshiProvider
-import io.realm.RealmObject
-import io.realm.annotations.Index
import org.matrix.android.sdk.internal.extensions.assertIsManaged
internal open class EventEntity(@Index var eventId: String = "",
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/model/GroupEntity.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/model/GroupEntity.kt
index 25a041e3d0..527f782359 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/model/GroupEntity.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/model/GroupEntity.kt
@@ -16,16 +16,16 @@
package org.matrix.android.sdk.internal.database.model
-import org.matrix.android.sdk.api.session.room.model.Membership
import io.realm.RealmObject
import io.realm.annotations.PrimaryKey
+import org.matrix.android.sdk.api.session.room.model.Membership
/**
* This class is used to store group info (groupId and membership) from the sync response.
* Then GetGroupDataTask is called regularly to fetch group information from the homeserver.
*/
-internal open class GroupEntity(@PrimaryKey var groupId: String = "")
- : RealmObject() {
+internal open class GroupEntity(@PrimaryKey var groupId: String = "") :
+ RealmObject() {
private var membershipStr: String = Membership.NONE.name
var membership: Membership
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/model/GroupSummaryEntity.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/model/GroupSummaryEntity.kt
index 8982436ccc..4ba45dcda2 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/model/GroupSummaryEntity.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/model/GroupSummaryEntity.kt
@@ -16,10 +16,10 @@
package org.matrix.android.sdk.internal.database.model
-import org.matrix.android.sdk.api.session.room.model.Membership
import io.realm.RealmList
import io.realm.RealmObject
import io.realm.annotations.PrimaryKey
+import org.matrix.android.sdk.api.session.room.model.Membership
internal open class GroupSummaryEntity(@PrimaryKey var groupId: String = "",
var displayName: String = "",
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/model/PushRulesEntity.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/model/PushRulesEntity.kt
index 571bc71c27..4125d90891 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/model/PushRulesEntity.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/model/PushRulesEntity.kt
@@ -15,9 +15,9 @@
*/
package org.matrix.android.sdk.internal.database.model
-import org.matrix.android.sdk.api.pushrules.RuleKind
import io.realm.RealmList
import io.realm.RealmObject
+import org.matrix.android.sdk.api.pushrules.RuleKind
import org.matrix.android.sdk.internal.extensions.clearWith
internal open class PushRulesEntity(
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/model/RoomEntity.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/model/RoomEntity.kt
index 65483e05bf..2997d5d7d8 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/model/RoomEntity.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/model/RoomEntity.kt
@@ -16,10 +16,10 @@
package org.matrix.android.sdk.internal.database.model
-import org.matrix.android.sdk.api.session.room.model.Membership
import io.realm.RealmList
import io.realm.RealmObject
import io.realm.annotations.PrimaryKey
+import org.matrix.android.sdk.api.session.room.model.Membership
internal open class RoomEntity(@PrimaryKey var roomId: String = "",
var chunks: RealmList = RealmList(),
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/model/RoomMemberSummaryEntity.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/model/RoomMemberSummaryEntity.kt
index e970fab397..75771ff12c 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/model/RoomMemberSummaryEntity.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/model/RoomMemberSummaryEntity.kt
@@ -16,10 +16,11 @@
package org.matrix.android.sdk.internal.database.model
-import org.matrix.android.sdk.api.session.room.model.Membership
import io.realm.RealmObject
import io.realm.annotations.Index
import io.realm.annotations.PrimaryKey
+import org.matrix.android.sdk.api.session.room.model.Membership
+import org.matrix.android.sdk.api.util.MatrixItem
internal open class RoomMemberSummaryEntity(@PrimaryKey var primaryKey: String = "",
@Index var userId: String = "",
@@ -39,7 +40,7 @@ internal open class RoomMemberSummaryEntity(@PrimaryKey var primaryKey: String =
membershipStr = value.name
}
- fun getBestName() = displayName?.takeIf { it.isNotBlank() } ?: userId
+ fun toMatrixItem() = MatrixItem.UserItem(userId, displayName, avatarUrl)
companion object
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/BreadcrumbsEntityQuery.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/BreadcrumbsEntityQuery.kt
index 0463d52fff..3b24ff5f9d 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/BreadcrumbsEntityQuery.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/BreadcrumbsEntityQuery.kt
@@ -16,10 +16,10 @@
package org.matrix.android.sdk.internal.database.query
-import org.matrix.android.sdk.internal.database.model.BreadcrumbsEntity
import io.realm.Realm
import io.realm.kotlin.createObject
import io.realm.kotlin.where
+import org.matrix.android.sdk.internal.database.model.BreadcrumbsEntity
internal fun BreadcrumbsEntity.Companion.get(realm: Realm): BreadcrumbsEntity? {
return realm.where().findFirst()
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 f7d2823303..156a8dd767 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
@@ -16,13 +16,13 @@
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 io.realm.Realm
import io.realm.RealmQuery
import io.realm.RealmResults
import io.realm.kotlin.createObject
import io.realm.kotlin.where
+import org.matrix.android.sdk.internal.database.model.ChunkEntity
+import org.matrix.android.sdk.internal.database.model.ChunkEntityFields
internal fun ChunkEntity.Companion.where(realm: Realm, roomId: String): RealmQuery {
return realm.where()
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/CurrentStateEventEntityQueries.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/CurrentStateEventEntityQueries.kt
index 9a3622e2dc..716783f2ba 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/CurrentStateEventEntityQueries.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/CurrentStateEventEntityQueries.kt
@@ -17,33 +17,46 @@
package org.matrix.android.sdk.internal.database.query
-import org.matrix.android.sdk.internal.database.model.CurrentStateEventEntity
-import org.matrix.android.sdk.internal.database.model.CurrentStateEventEntityFields
import io.realm.Realm
import io.realm.RealmQuery
import io.realm.kotlin.createObject
+import org.matrix.android.sdk.internal.database.model.CurrentStateEventEntity
+import org.matrix.android.sdk.internal.database.model.CurrentStateEventEntityFields
-internal fun CurrentStateEventEntity.Companion.whereType(realm: Realm, roomId: String, type: String): RealmQuery {
+internal fun CurrentStateEventEntity.Companion.whereType(realm: Realm,
+ roomId: String,
+ type: String): RealmQuery {
return realm.where(CurrentStateEventEntity::class.java)
.equalTo(CurrentStateEventEntityFields.ROOM_ID, roomId)
.equalTo(CurrentStateEventEntityFields.TYPE, type)
}
-internal fun CurrentStateEventEntity.Companion.whereStateKey(realm: Realm, roomId: String, type: String, stateKey: String)
- : RealmQuery {
+internal fun CurrentStateEventEntity.Companion.whereStateKey(realm: Realm,
+ roomId: String,
+ type: String,
+ stateKey: String): RealmQuery {
return whereType(realm = realm, roomId = roomId, type = type)
.equalTo(CurrentStateEventEntityFields.STATE_KEY, stateKey)
}
-internal fun CurrentStateEventEntity.Companion.getOrNull(realm: Realm, roomId: String, stateKey: String, type: String): CurrentStateEventEntity? {
+internal fun CurrentStateEventEntity.Companion.getOrNull(realm: Realm,
+ roomId: String,
+ stateKey: String,
+ type: String): CurrentStateEventEntity? {
return whereStateKey(realm = realm, roomId = roomId, type = type, stateKey = stateKey).findFirst()
}
-internal fun CurrentStateEventEntity.Companion.getOrCreate(realm: Realm, roomId: String, stateKey: String, type: String): CurrentStateEventEntity {
+internal fun CurrentStateEventEntity.Companion.getOrCreate(realm: Realm,
+ roomId: String,
+ stateKey: String,
+ type: String): CurrentStateEventEntity {
return getOrNull(realm = realm, roomId = roomId, stateKey = stateKey, type = type) ?: create(realm, roomId, stateKey, type)
}
-private fun create(realm: Realm, roomId: String, stateKey: String, type: String): CurrentStateEventEntity {
+private fun create(realm: Realm,
+ roomId: String,
+ stateKey: String,
+ type: String): CurrentStateEventEntity {
return realm.createObject().apply {
this.type = type
this.roomId = roomId
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/EventAnnotationsSummaryEntityQuery.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/EventAnnotationsSummaryEntityQuery.kt
index c3cae3d268..14cb7e22da 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/EventAnnotationsSummaryEntityQuery.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/EventAnnotationsSummaryEntityQuery.kt
@@ -16,12 +16,12 @@
package org.matrix.android.sdk.internal.database.query
-import org.matrix.android.sdk.internal.database.model.EventAnnotationsSummaryEntity
-import org.matrix.android.sdk.internal.database.model.EventAnnotationsSummaryEntityFields
-import org.matrix.android.sdk.internal.database.model.TimelineEventEntity
import io.realm.Realm
import io.realm.RealmQuery
import io.realm.kotlin.where
+import org.matrix.android.sdk.internal.database.model.EventAnnotationsSummaryEntity
+import org.matrix.android.sdk.internal.database.model.EventAnnotationsSummaryEntityFields
+import org.matrix.android.sdk.internal.database.model.TimelineEventEntity
internal fun EventAnnotationsSummaryEntity.Companion.where(realm: Realm, roomId: String, eventId: String): RealmQuery {
return realm.where()
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/EventEntityQueries.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/EventEntityQueries.kt
index 57e24cf88f..240b2a0691 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/EventEntityQueries.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/EventEntityQueries.kt
@@ -16,15 +16,15 @@
package org.matrix.android.sdk.internal.database.query
-import org.matrix.android.sdk.internal.database.model.EventEntity
-import org.matrix.android.sdk.internal.database.model.EventEntityFields
-import org.matrix.android.sdk.internal.database.model.EventInsertEntity
-import org.matrix.android.sdk.internal.database.model.EventInsertType
import io.realm.Realm
import io.realm.RealmList
import io.realm.RealmQuery
import io.realm.kotlin.where
import org.matrix.android.sdk.api.session.events.model.EventType
+import org.matrix.android.sdk.internal.database.model.EventEntity
+import org.matrix.android.sdk.internal.database.model.EventEntityFields
+import org.matrix.android.sdk.internal.database.model.EventInsertEntity
+import org.matrix.android.sdk.internal.database.model.EventInsertType
internal fun EventEntity.copyToRealmOrIgnore(realm: Realm, insertType: EventInsertType): EventEntity {
val eventEntity = realm.where()
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/FilterEntityQueries.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/FilterEntityQueries.kt
index c76e606805..3968169e08 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/FilterEntityQueries.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/FilterEntityQueries.kt
@@ -16,11 +16,11 @@
package org.matrix.android.sdk.internal.database.query
-import org.matrix.android.sdk.internal.database.model.FilterEntity
-import org.matrix.android.sdk.internal.session.filter.FilterFactory
import io.realm.Realm
import io.realm.kotlin.createObject
import io.realm.kotlin.where
+import org.matrix.android.sdk.internal.database.model.FilterEntity
+import org.matrix.android.sdk.internal.session.filter.FilterFactory
/**
* Get the current filter
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/GroupEntityQueries.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/GroupEntityQueries.kt
index 9a1f2b3782..020592d1dd 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/GroupEntityQueries.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/GroupEntityQueries.kt
@@ -16,13 +16,13 @@
package org.matrix.android.sdk.internal.database.query
+import io.realm.Realm
+import io.realm.RealmQuery
+import io.realm.kotlin.where
import org.matrix.android.sdk.api.session.room.model.Membership
import org.matrix.android.sdk.internal.database.model.GroupEntity
import org.matrix.android.sdk.internal.database.model.GroupEntityFields
import org.matrix.android.sdk.internal.query.process
-import io.realm.Realm
-import io.realm.RealmQuery
-import io.realm.kotlin.where
internal fun GroupEntity.Companion.where(realm: Realm, groupId: String): RealmQuery {
return realm.where()
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/GroupSummaryEntityQueries.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/GroupSummaryEntityQueries.kt
index fbfd8bd19e..8131598d95 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/GroupSummaryEntityQueries.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/GroupSummaryEntityQueries.kt
@@ -16,12 +16,12 @@
package org.matrix.android.sdk.internal.database.query
-import org.matrix.android.sdk.internal.database.model.GroupSummaryEntity
-import org.matrix.android.sdk.internal.database.model.GroupSummaryEntityFields
import io.realm.Realm
import io.realm.RealmQuery
import io.realm.kotlin.createObject
import io.realm.kotlin.where
+import org.matrix.android.sdk.internal.database.model.GroupSummaryEntity
+import org.matrix.android.sdk.internal.database.model.GroupSummaryEntityFields
internal fun GroupSummaryEntity.Companion.where(realm: Realm, groupId: String? = null): RealmQuery {
val query = realm.where()
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/HomeServerCapabilitiesQueries.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/HomeServerCapabilitiesQueries.kt
index b0b4f5a83d..4f8ac20e94 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/HomeServerCapabilitiesQueries.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/HomeServerCapabilitiesQueries.kt
@@ -16,10 +16,10 @@
package org.matrix.android.sdk.internal.database.query
-import org.matrix.android.sdk.internal.database.model.HomeServerCapabilitiesEntity
import io.realm.Realm
import io.realm.kotlin.createObject
import io.realm.kotlin.where
+import org.matrix.android.sdk.internal.database.model.HomeServerCapabilitiesEntity
/**
* Get the current HomeServerCapabilitiesEntity, return null if it does not exist
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 359b256844..1f6b210252 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
@@ -15,6 +15,9 @@
*/
package org.matrix.android.sdk.internal.database.query
+import io.realm.Realm
+import io.realm.RealmQuery
+import io.realm.kotlin.where
import org.matrix.android.sdk.api.pushrules.RuleKind
import org.matrix.android.sdk.internal.database.model.PushRuleEntity
import org.matrix.android.sdk.internal.database.model.PushRuleEntityFields
@@ -22,9 +25,6 @@ import org.matrix.android.sdk.internal.database.model.PushRulesEntity
import org.matrix.android.sdk.internal.database.model.PushRulesEntityFields
import org.matrix.android.sdk.internal.database.model.PusherEntity
import org.matrix.android.sdk.internal.database.model.PusherEntityFields
-import io.realm.Realm
-import io.realm.RealmQuery
-import io.realm.kotlin.where
internal fun PusherEntity.Companion.where(realm: Realm,
pushKey: String? = null): RealmQuery {
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/ReadMarkerEntityQueries.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/ReadMarkerEntityQueries.kt
index 35fb2b068b..d80fe86aae 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/ReadMarkerEntityQueries.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/ReadMarkerEntityQueries.kt
@@ -16,12 +16,12 @@
package org.matrix.android.sdk.internal.database.query
-import org.matrix.android.sdk.internal.database.model.ReadMarkerEntity
-import org.matrix.android.sdk.internal.database.model.ReadMarkerEntityFields
import io.realm.Realm
import io.realm.RealmQuery
import io.realm.kotlin.createObject
import io.realm.kotlin.where
+import org.matrix.android.sdk.internal.database.model.ReadMarkerEntity
+import org.matrix.android.sdk.internal.database.model.ReadMarkerEntityFields
internal fun ReadMarkerEntity.Companion.where(realm: Realm, roomId: String): RealmQuery {
return realm.where()
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/ReadQueries.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/ReadQueries.kt
index 5423025823..60096777d9 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/ReadQueries.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/ReadQueries.kt
@@ -15,13 +15,13 @@
*/
package org.matrix.android.sdk.internal.database.query
+import io.realm.Realm
+import io.realm.RealmConfiguration
import org.matrix.android.sdk.api.session.events.model.LocalEcho
import org.matrix.android.sdk.internal.database.model.ChunkEntity
import org.matrix.android.sdk.internal.database.model.ReadMarkerEntity
import org.matrix.android.sdk.internal.database.model.ReadReceiptEntity
import org.matrix.android.sdk.internal.database.model.TimelineEventEntity
-import io.realm.Realm
-import io.realm.RealmConfiguration
internal fun isEventRead(realmConfiguration: RealmConfiguration,
userId: String?,
@@ -39,19 +39,18 @@ internal fun isEventRead(realmConfiguration: RealmConfiguration,
val liveChunk = ChunkEntity.findLastForwardChunkOfRoom(realm, roomId) ?: return@use
val eventToCheck = liveChunk.timelineEvents.find(eventId)
isEventRead = when {
- eventToCheck == null -> {
- // This can happen in case of fast lane Event
- false
- }
+ eventToCheck == null -> hasReadMissingEvent(
+ realm = realm,
+ latestChunkEntity = liveChunk,
+ roomId = roomId,
+ userId = userId,
+ eventId = eventId
+ )
eventToCheck.root?.sender == userId -> true
else -> {
- val readReceipt = ReadReceiptEntity.where(realm, roomId, userId).findFirst()
- ?: return@use
- val readReceiptIndex = liveChunk.timelineEvents.find(readReceipt.eventId)?.displayIndex
- ?: Int.MIN_VALUE
- val eventToCheckIndex = eventToCheck.displayIndex
-
- eventToCheckIndex <= readReceiptIndex
+ val readReceipt = ReadReceiptEntity.where(realm, roomId, userId).findFirst() ?: return@use
+ val readReceiptIndex = liveChunk.timelineEvents.find(readReceipt.eventId)?.displayIndex ?: Int.MIN_VALUE
+ eventToCheck.displayIndex <= readReceiptIndex
}
}
}
@@ -59,6 +58,24 @@ internal fun isEventRead(realmConfiguration: RealmConfiguration,
return isEventRead
}
+/**
+ * Missing events can be caused by the latest timeline chunk no longer contain an older event or
+ * by fast lane eagerly displaying events before the database has finished updating
+ */
+private fun hasReadMissingEvent(realm: Realm, latestChunkEntity: ChunkEntity, roomId: String, userId: String, eventId: String): Boolean {
+ return realm.doesEventExistInChunkHistory(eventId) && realm.hasReadReceiptInLatestChunk(latestChunkEntity, roomId, userId)
+}
+
+private fun Realm.doesEventExistInChunkHistory(eventId: String): Boolean {
+ return ChunkEntity.findIncludingEvent(this, eventId) != null
+}
+
+private fun Realm.hasReadReceiptInLatestChunk(latestChunkEntity: ChunkEntity, roomId: String, userId: String): Boolean {
+ return ReadReceiptEntity.where(this, roomId = roomId, userId = userId).findFirst()?.let {
+ latestChunkEntity.timelineEvents.find(it.eventId)
+ } != null
+}
+
internal fun isReadMarkerMoreRecent(realmConfiguration: RealmConfiguration,
roomId: String?,
eventId: String?): Boolean {
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/ReadReceiptEntityQueries.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/ReadReceiptEntityQueries.kt
index 1a5e8fcf89..b180c06e2c 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/ReadReceiptEntityQueries.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/ReadReceiptEntityQueries.kt
@@ -16,12 +16,12 @@
package org.matrix.android.sdk.internal.database.query
-import org.matrix.android.sdk.internal.database.model.ReadReceiptEntity
-import org.matrix.android.sdk.internal.database.model.ReadReceiptEntityFields
import io.realm.Realm
import io.realm.RealmQuery
import io.realm.kotlin.createObject
import io.realm.kotlin.where
+import org.matrix.android.sdk.internal.database.model.ReadReceiptEntity
+import org.matrix.android.sdk.internal.database.model.ReadReceiptEntityFields
internal fun ReadReceiptEntity.Companion.where(realm: Realm, roomId: String, userId: String): RealmQuery {
return realm.where()
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/ReadReceiptsSummaryEntityQueries.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/ReadReceiptsSummaryEntityQueries.kt
index 97f8418403..a35df57b7b 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/ReadReceiptsSummaryEntityQueries.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/ReadReceiptsSummaryEntityQueries.kt
@@ -16,11 +16,11 @@
package org.matrix.android.sdk.internal.database.query
-import org.matrix.android.sdk.internal.database.model.ReadReceiptsSummaryEntity
-import org.matrix.android.sdk.internal.database.model.ReadReceiptsSummaryEntityFields
import io.realm.Realm
import io.realm.RealmQuery
import io.realm.kotlin.where
+import org.matrix.android.sdk.internal.database.model.ReadReceiptsSummaryEntity
+import org.matrix.android.sdk.internal.database.model.ReadReceiptsSummaryEntityFields
internal fun ReadReceiptsSummaryEntity.Companion.where(realm: Realm, eventId: String): RealmQuery {
return realm.where()
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/ReferencesAggregatedSummaryEntityQueries.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/ReferencesAggregatedSummaryEntityQueries.kt
index 8b3929cd60..14beb2d853 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/ReferencesAggregatedSummaryEntityQueries.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/ReferencesAggregatedSummaryEntityQueries.kt
@@ -16,11 +16,11 @@
package org.matrix.android.sdk.internal.database.query
-import org.matrix.android.sdk.internal.database.model.ReferencesAggregatedSummaryEntity
-import org.matrix.android.sdk.internal.database.model.ReferencesAggregatedSummaryEntityFields
import io.realm.Realm
import io.realm.RealmQuery
import io.realm.kotlin.where
+import org.matrix.android.sdk.internal.database.model.ReferencesAggregatedSummaryEntity
+import org.matrix.android.sdk.internal.database.model.ReferencesAggregatedSummaryEntityFields
internal fun ReferencesAggregatedSummaryEntity.Companion.where(realm: Realm, eventId: String): RealmQuery {
val query = realm.where()
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/RoomEntityQueries.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/RoomEntityQueries.kt
index a551f97379..08bb9e7ff3 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/RoomEntityQueries.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/RoomEntityQueries.kt
@@ -16,13 +16,13 @@
package org.matrix.android.sdk.internal.database.query
+import io.realm.Realm
+import io.realm.RealmQuery
+import io.realm.kotlin.where
import org.matrix.android.sdk.api.session.room.model.Membership
import org.matrix.android.sdk.internal.database.model.EventEntity
import org.matrix.android.sdk.internal.database.model.RoomEntity
import org.matrix.android.sdk.internal.database.model.RoomEntityFields
-import io.realm.Realm
-import io.realm.RealmQuery
-import io.realm.kotlin.where
internal fun RoomEntity.Companion.where(realm: Realm, roomId: String): RealmQuery {
return realm.where()
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/RoomMemberEntityQueries.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/RoomMemberEntityQueries.kt
index 0747b12665..a19a9cf725 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/RoomMemberEntityQueries.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/RoomMemberEntityQueries.kt
@@ -16,11 +16,11 @@
package org.matrix.android.sdk.internal.database.query
-import org.matrix.android.sdk.internal.database.model.RoomMemberSummaryEntity
-import org.matrix.android.sdk.internal.database.model.RoomMemberSummaryEntityFields
import io.realm.Realm
import io.realm.RealmQuery
import io.realm.kotlin.where
+import org.matrix.android.sdk.internal.database.model.RoomMemberSummaryEntity
+import org.matrix.android.sdk.internal.database.model.RoomMemberSummaryEntityFields
internal fun RoomMemberSummaryEntity.Companion.where(realm: Realm, roomId: String, userId: String? = null): RealmQuery {
val query = realm
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/RoomSummaryEntityQueries.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/RoomSummaryEntityQueries.kt
index 2af5dcf0ae..5294f849af 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/RoomSummaryEntityQueries.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/RoomSummaryEntityQueries.kt
@@ -16,13 +16,13 @@
package org.matrix.android.sdk.internal.database.query
-import org.matrix.android.sdk.internal.database.model.RoomSummaryEntity
-import org.matrix.android.sdk.internal.database.model.RoomSummaryEntityFields
import io.realm.Realm
import io.realm.RealmQuery
import io.realm.RealmResults
import io.realm.kotlin.createObject
import io.realm.kotlin.where
+import org.matrix.android.sdk.internal.database.model.RoomSummaryEntity
+import org.matrix.android.sdk.internal.database.model.RoomSummaryEntityFields
internal fun RoomSummaryEntity.Companion.where(realm: Realm, roomId: String? = null): RealmQuery {
val query = realm.where()
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/ScalarTokenQuery.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/ScalarTokenQuery.kt
index 53fd525092..a7d85d676c 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/ScalarTokenQuery.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/ScalarTokenQuery.kt
@@ -16,11 +16,11 @@
package org.matrix.android.sdk.internal.database.query
-import org.matrix.android.sdk.internal.database.model.ScalarTokenEntity
-import org.matrix.android.sdk.internal.database.model.ScalarTokenEntityFields
import io.realm.Realm
import io.realm.RealmQuery
import io.realm.kotlin.where
+import org.matrix.android.sdk.internal.database.model.ScalarTokenEntity
+import org.matrix.android.sdk.internal.database.model.ScalarTokenEntityFields
internal fun ScalarTokenEntity.Companion.where(realm: Realm, serverUrl: String): RealmQuery {
return realm
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/TimelineEventEntityQueries.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/TimelineEventEntityQueries.kt
index 148232cf94..aa1ce41bb7 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/TimelineEventEntityQueries.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/TimelineEventEntityQueries.kt
@@ -119,8 +119,7 @@ internal fun RealmList.find(eventId: String): TimelineEvent
internal fun TimelineEventEntity.Companion.findAllInRoomWithSendStates(realm: Realm,
roomId: String,
- sendStates: List)
- : RealmResults {
+ sendStates: List): RealmResults {
return whereRoomId(realm, roomId)
.filterSendStates(sendStates)
.findAll()
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 4af4da0a22..aa9d409a2a 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,11 +16,11 @@
package org.matrix.android.sdk.internal.database.query
-import org.matrix.android.sdk.internal.database.model.UserDraftsEntity
-import org.matrix.android.sdk.internal.database.model.UserDraftsEntityFields
import io.realm.Realm
import io.realm.RealmQuery
import io.realm.kotlin.where
+import org.matrix.android.sdk.internal.database.model.UserDraftsEntity
+import org.matrix.android.sdk.internal.database.model.UserDraftsEntityFields
internal fun UserDraftsEntity.Companion.where(realm: Realm, roomId: String? = null): RealmQuery {
val query = realm.where()
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/UserEntityQueries.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/UserEntityQueries.kt
index 6a5528e3db..3159f89311 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/UserEntityQueries.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/UserEntityQueries.kt
@@ -16,11 +16,11 @@
package org.matrix.android.sdk.internal.database.query
-import org.matrix.android.sdk.internal.database.model.UserEntity
-import org.matrix.android.sdk.internal.database.model.UserEntityFields
import io.realm.Realm
import io.realm.RealmQuery
import io.realm.kotlin.where
+import org.matrix.android.sdk.internal.database.model.UserEntity
+import org.matrix.android.sdk.internal.database.model.UserEntityFields
internal fun UserEntity.Companion.where(realm: Realm, userId: String): RealmQuery {
return realm
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/di/MatrixModule.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/di/MatrixModule.kt
index b58fb3e683..4cd960f426 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/di/MatrixModule.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/di/MatrixModule.kt
@@ -20,11 +20,11 @@ import android.content.Context
import android.content.res.Resources
import dagger.Module
import dagger.Provides
-import org.matrix.android.sdk.internal.util.MatrixCoroutineDispatchers
-import org.matrix.android.sdk.internal.util.createBackgroundHandler
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.android.asCoroutineDispatcher
import kotlinx.coroutines.asCoroutineDispatcher
+import org.matrix.android.sdk.internal.util.MatrixCoroutineDispatchers
+import org.matrix.android.sdk.internal.util.createBackgroundHandler
import org.matrix.olm.OlmManager
import java.io.File
import java.util.concurrent.Executors
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/di/NetworkModule.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/di/NetworkModule.kt
index 0d0892b608..fa59b94c17 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/di/NetworkModule.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/di/NetworkModule.kt
@@ -20,15 +20,15 @@ import com.facebook.stetho.okhttp3.StethoInterceptor
import com.squareup.moshi.Moshi
import dagger.Module
import dagger.Provides
+import okhttp3.OkHttpClient
+import okhttp3.logging.HttpLoggingInterceptor
import org.matrix.android.sdk.BuildConfig
import org.matrix.android.sdk.api.MatrixConfiguration
+import org.matrix.android.sdk.internal.network.ApiInterceptor
import org.matrix.android.sdk.internal.network.TimeOutInterceptor
import org.matrix.android.sdk.internal.network.UserAgentInterceptor
import org.matrix.android.sdk.internal.network.interceptors.CurlLoggingInterceptor
import org.matrix.android.sdk.internal.network.interceptors.FormattedJsonHttpLogger
-import okhttp3.OkHttpClient
-import okhttp3.logging.HttpLoggingInterceptor
-import org.matrix.android.sdk.internal.network.ApiInterceptor
import java.util.concurrent.TimeUnit
@Module
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/legacy/DefaultLegacySessionImporter.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/legacy/DefaultLegacySessionImporter.kt
index ad2aff4c9d..445b6be8e8 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/legacy/DefaultLegacySessionImporter.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/legacy/DefaultLegacySessionImporter.kt
@@ -17,6 +17,9 @@
package org.matrix.android.sdk.internal.legacy
import android.content.Context
+import io.realm.Realm
+import io.realm.RealmConfiguration
+import kotlinx.coroutines.runBlocking
import org.matrix.android.sdk.api.auth.data.Credentials
import org.matrix.android.sdk.api.auth.data.DiscoveryInformation
import org.matrix.android.sdk.api.auth.data.HomeServerConnectionConfig
@@ -30,9 +33,6 @@ import org.matrix.android.sdk.internal.database.RealmKeysUtils
import org.matrix.android.sdk.internal.legacy.riot.LoginStorage
import org.matrix.android.sdk.internal.network.ssl.Fingerprint
import org.matrix.android.sdk.internal.util.md5
-import io.realm.Realm
-import io.realm.RealmConfiguration
-import kotlinx.coroutines.runBlocking
import timber.log.Timber
import java.io.File
import javax.inject.Inject
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/legacy/riot/WellKnown.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/legacy/riot/WellKnown.kt
index 56d372faa5..17fd0925f8 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/legacy/riot/WellKnown.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/legacy/riot/WellKnown.kt
@@ -75,9 +75,9 @@ class WellKnown {
(config as? Map<*, *>)?.let { map ->
val apiUrl = map["api_url"] as? String
val uiUrl = map["ui_url"] as? String ?: apiUrl
- if (apiUrl != null
- && apiUrl.startsWith("https://")
- && uiUrl!!.startsWith("https://")) {
+ if (apiUrl != null &&
+ apiUrl.startsWith("https://") &&
+ uiUrl!!.startsWith("https://")) {
managers.add(WellKnownManagerConfig(
apiUrl = apiUrl,
uiUrl = uiUrl
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/network/AccessTokenInterceptor.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/network/AccessTokenInterceptor.kt
index b11fb6a5ee..a34606a6bb 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/network/AccessTokenInterceptor.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/network/AccessTokenInterceptor.kt
@@ -16,9 +16,9 @@
package org.matrix.android.sdk.internal.network
-import org.matrix.android.sdk.internal.network.token.AccessTokenProvider
import okhttp3.Interceptor
import okhttp3.Response
+import org.matrix.android.sdk.internal.network.token.AccessTokenProvider
internal class AccessTokenInterceptor(private val accessTokenProvider: AccessTokenProvider) : Interceptor {
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/network/NetworkConnectivityChecker.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/network/NetworkConnectivityChecker.kt
index c149ed2591..e32f6be6fc 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/network/NetworkConnectivityChecker.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/network/NetworkConnectivityChecker.kt
@@ -17,10 +17,10 @@
package org.matrix.android.sdk.internal.network
import androidx.annotation.WorkerThread
+import kotlinx.coroutines.runBlocking
import org.matrix.android.sdk.internal.session.SessionScope
import org.matrix.android.sdk.internal.session.homeserver.HomeServerPinger
import org.matrix.android.sdk.internal.util.BackgroundDetectionObserver
-import kotlinx.coroutines.runBlocking
import java.util.Collections
import java.util.concurrent.atomic.AtomicBoolean
import javax.inject.Inject
@@ -43,8 +43,8 @@ interface NetworkConnectivityChecker {
@SessionScope
internal class DefaultNetworkConnectivityChecker @Inject constructor(private val homeServerPinger: HomeServerPinger,
private val backgroundDetectionObserver: BackgroundDetectionObserver,
- private val networkCallbackStrategy: NetworkCallbackStrategy)
- : NetworkConnectivityChecker {
+ private val networkCallbackStrategy: NetworkCallbackStrategy) :
+ NetworkConnectivityChecker {
private val hasInternetAccess = AtomicBoolean(true)
private val listeners = Collections.synchronizedSet(LinkedHashSet())
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/network/Request.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/network/Request.kt
index e045cebd3e..927d9f7dd2 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/network/Request.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/network/Request.kt
@@ -74,10 +74,10 @@ internal suspend inline fun executeRequest(globalErrorReceiver: GlobalErr
currentRetryCount++
- if (exception is Failure.ServerError
- && exception.httpCode == 429
- && exception.error.code == MatrixError.M_LIMIT_EXCEEDED
- && currentRetryCount < maxRetriesCount) {
+ if (exception is Failure.ServerError &&
+ exception.httpCode == 429 &&
+ exception.error.code == MatrixError.M_LIMIT_EXCEEDED &&
+ currentRetryCount < maxRetriesCount) {
// 429, we can retry
delay(exception.getRetryDelay(1_000))
} else if (canRetry && currentRetryCount < maxRetriesCount && exception.shouldBeRetried()) {
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/network/RetrofitExtensions.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/network/RetrofitExtensions.kt
index 8a03102527..60055be9ec 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/network/RetrofitExtensions.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/network/RetrofitExtensions.kt
@@ -91,8 +91,8 @@ private fun toFailure(errorBody: ResponseBody?, httpCode: Int, globalErrorReceiv
matrixError.code == MatrixError.M_CONSENT_NOT_GIVEN && !matrixError.consentUri.isNullOrBlank() -> {
globalErrorReceiver?.handleGlobalError(GlobalError.ConsentNotGivenError(matrixError.consentUri))
}
- httpCode == HttpURLConnection.HTTP_UNAUTHORIZED /* 401 */
- && matrixError.code == MatrixError.M_UNKNOWN_TOKEN -> {
+ httpCode == HttpURLConnection.HTTP_UNAUTHORIZED && /* 401 */
+ matrixError.code == MatrixError.M_UNKNOWN_TOKEN -> {
globalErrorReceiver?.handleGlobalError(GlobalError.InvalidToken(matrixError.isSoftLogout.orFalse()))
}
matrixError.code == MatrixError.ORG_MATRIX_EXPIRED_ACCOUNT -> {
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/network/UserAgentHolder.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/network/UserAgentHolder.kt
index 57eab6a8dd..00e15c283e 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/network/UserAgentHolder.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/network/UserAgentHolder.kt
@@ -73,8 +73,8 @@ internal class UserAgentHolder @Inject constructor(private val context: Context,
// if there is no user agent or cannot parse it
if (null == systemUserAgent || systemUserAgent.lastIndexOf(")") == -1 || !systemUserAgent.contains("(")) {
- userAgent = (appName + "/" + appVersion + " ( Flavour " + flavorDescription
- + "; MatrixAndroidSdk2 " + BuildConfig.SDK_VERSION + ")")
+ userAgent = (appName + "/" + appVersion + " ( Flavour " + flavorDescription +
+ "; MatrixAndroidSdk2 " + BuildConfig.SDK_VERSION + ")")
} else {
// update
userAgent = appName + "/" + appVersion + " " +
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/network/httpclient/OkHttpClientUtil.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/network/httpclient/OkHttpClientUtil.kt
index b4a2d191e2..3920c3b527 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/network/httpclient/OkHttpClientUtil.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/network/httpclient/OkHttpClientUtil.kt
@@ -16,12 +16,12 @@
package org.matrix.android.sdk.internal.network.httpclient
+import okhttp3.OkHttpClient
import org.matrix.android.sdk.api.auth.data.HomeServerConnectionConfig
import org.matrix.android.sdk.internal.network.AccessTokenInterceptor
import org.matrix.android.sdk.internal.network.interceptors.CurlLoggingInterceptor
import org.matrix.android.sdk.internal.network.ssl.CertUtil
import org.matrix.android.sdk.internal.network.token.AccessTokenProvider
-import okhttp3.OkHttpClient
import timber.log.Timber
internal fun OkHttpClient.Builder.addAccessTokenInterceptor(accessTokenProvider: AccessTokenProvider): OkHttpClient.Builder {
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/network/parsing/CheckNumberType.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/network/parsing/CheckNumberType.kt
index 14d275e021..27684bbf1a 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/network/parsing/CheckNumberType.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/network/parsing/CheckNumberType.kt
@@ -20,7 +20,6 @@ import androidx.annotation.Nullable
import com.squareup.moshi.JsonAdapter
import com.squareup.moshi.JsonReader
import com.squareup.moshi.JsonWriter
-
import com.squareup.moshi.Moshi
import java.io.IOException
import java.lang.reflect.Type
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/network/ssl/CertUtil.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/network/ssl/CertUtil.kt
index 976751446b..92c7f3f236 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/network/ssl/CertUtil.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/network/ssl/CertUtil.kt
@@ -16,9 +16,9 @@
package org.matrix.android.sdk.internal.network.ssl
-import org.matrix.android.sdk.api.auth.data.HomeServerConnectionConfig
import okhttp3.ConnectionSpec
import okhttp3.internal.tls.OkHostnameVerifier
+import org.matrix.android.sdk.api.auth.data.HomeServerConnectionConfig
import timber.log.Timber
import java.security.KeyStore
import java.security.MessageDigest
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/network/ssl/PinnedTrustManager.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/network/ssl/PinnedTrustManager.kt
index b1001bd39c..6f245aa6d8 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/network/ssl/PinnedTrustManager.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/network/ssl/PinnedTrustManager.kt
@@ -18,7 +18,6 @@ package org.matrix.android.sdk.internal.network.ssl
import java.security.cert.CertificateException
import java.security.cert.X509Certificate
-
import javax.net.ssl.X509TrustManager
/**
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/DefaultSession.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/DefaultSession.kt
index 22167bc77a..d41bf8a702 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/DefaultSession.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/DefaultSession.kt
@@ -223,6 +223,8 @@ internal class DefaultSession @Inject constructor(
override fun getSyncStateLive() = getSyncThread().liveState()
+ override fun syncFlow() = getSyncThread().syncFlow()
+
override fun getSyncState() = getSyncThread().currentState()
override fun hasAlreadySynced(): Boolean {
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/EventInsertLiveProcessor.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/EventInsertLiveProcessor.kt
index 7a687b774b..a650fa2d64 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/EventInsertLiveProcessor.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/EventInsertLiveProcessor.kt
@@ -16,9 +16,9 @@
package org.matrix.android.sdk.internal.session
+import io.realm.Realm
import org.matrix.android.sdk.api.session.events.model.Event
import org.matrix.android.sdk.internal.database.model.EventInsertType
-import io.realm.Realm
internal interface EventInsertLiveProcessor {
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/SessionComponent.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/SessionComponent.kt
index 2003a66c94..71031a4614 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/SessionComponent.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/SessionComponent.kt
@@ -46,7 +46,6 @@ import org.matrix.android.sdk.internal.session.profile.ProfileModule
import org.matrix.android.sdk.internal.session.pushers.AddPusherWorker
import org.matrix.android.sdk.internal.session.pushers.PushersModule
import org.matrix.android.sdk.internal.session.room.RoomModule
-import org.matrix.android.sdk.internal.session.room.relation.SendRelationWorker
import org.matrix.android.sdk.internal.session.room.send.MultipleEventSendingDispatcherWorker
import org.matrix.android.sdk.internal.session.room.send.RedactEventWorker
import org.matrix.android.sdk.internal.session.room.send.SendEventWorker
@@ -115,8 +114,6 @@ internal interface SessionComponent {
fun inject(worker: SendEventWorker)
- fun inject(worker: SendRelationWorker)
-
fun inject(worker: MultipleEventSendingDispatcherWorker)
fun inject(worker: RedactEventWorker)
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/SessionCoroutineScopeHolder.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/SessionCoroutineScopeHolder.kt
index 82a8f79fd5..2a741ddb9b 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/SessionCoroutineScopeHolder.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/SessionCoroutineScopeHolder.kt
@@ -20,12 +20,12 @@ import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.cancelChildren
-import javax.inject.Inject
import org.matrix.android.sdk.api.session.Session
import org.matrix.android.sdk.api.session.SessionLifecycleObserver
+import javax.inject.Inject
@SessionScope
-internal class SessionCoroutineScopeHolder @Inject constructor(): SessionLifecycleObserver {
+internal class SessionCoroutineScopeHolder @Inject constructor() : SessionLifecycleObserver {
val scope: CoroutineScope = CoroutineScope(SupervisorJob())
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/account/ChangePasswordTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/account/ChangePasswordTask.kt
index 02c3735998..7b21ba2e63 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/account/ChangePasswordTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/account/ChangePasswordTask.kt
@@ -45,9 +45,9 @@ internal class DefaultChangePasswordTask @Inject constructor(
} catch (throwable: Throwable) {
val registrationFlowResponse = throwable.toRegistrationFlowResponse()
- if (registrationFlowResponse != null
+ if (registrationFlowResponse != null &&
/* Avoid infinite loop */
- && changePasswordParams.auth?.session == null) {
+ changePasswordParams.auth?.session == null) {
// Retry with authentication
executeRequest(globalErrorReceiver) {
accountAPI.changePassword(
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/cache/CacheModule.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/cache/CacheModule.kt
index 83c7d2b0b5..60adb21242 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/cache/CacheModule.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/cache/CacheModule.kt
@@ -19,9 +19,9 @@ package org.matrix.android.sdk.internal.session.cache
import dagger.Binds
import dagger.Module
import dagger.Provides
+import io.realm.RealmConfiguration
import org.matrix.android.sdk.api.session.cache.CacheService
import org.matrix.android.sdk.internal.di.SessionDatabase
-import io.realm.RealmConfiguration
@Module
internal abstract class CacheModule {
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/cache/ClearCacheTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/cache/ClearCacheTask.kt
index 894c3a4723..7f6b545c97 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/cache/ClearCacheTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/cache/ClearCacheTask.kt
@@ -16,9 +16,9 @@
package org.matrix.android.sdk.internal.session.cache
+import io.realm.RealmConfiguration
import org.matrix.android.sdk.internal.database.awaitTransaction
import org.matrix.android.sdk.internal.task.Task
-import io.realm.RealmConfiguration
import javax.inject.Inject
internal interface ClearCacheTask : Task
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/call/CallEventProcessor.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/call/CallEventProcessor.kt
index bdc254fc99..3f199c5cce 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/call/CallEventProcessor.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/call/CallEventProcessor.kt
@@ -17,10 +17,10 @@
package org.matrix.android.sdk.internal.session.call
import io.realm.Realm
+import org.matrix.android.sdk.api.logger.LoggerTag
import org.matrix.android.sdk.api.session.events.model.Event
import org.matrix.android.sdk.api.session.events.model.EventType
import org.matrix.android.sdk.internal.database.model.EventInsertType
-import org.matrix.android.sdk.api.logger.LoggerTag
import org.matrix.android.sdk.internal.session.EventInsertLiveProcessor
import org.matrix.android.sdk.internal.session.SessionScope
import timber.log.Timber
@@ -29,8 +29,8 @@ import javax.inject.Inject
private val loggerTag = LoggerTag("CallEventProcessor", LoggerTag.VOIP)
@SessionScope
-internal class CallEventProcessor @Inject constructor(private val callSignalingHandler: CallSignalingHandler)
- : EventInsertLiveProcessor {
+internal class CallEventProcessor @Inject constructor(private val callSignalingHandler: CallSignalingHandler) :
+ EventInsertLiveProcessor {
private val allowedTypes = listOf(
EventType.CALL_ANSWER,
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/cleanup/CleanupSession.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/cleanup/CleanupSession.kt
index 8870d92a35..d4374e0702 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/cleanup/CleanupSession.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/cleanup/CleanupSession.kt
@@ -16,22 +16,22 @@
package org.matrix.android.sdk.internal.session.cleanup
+import io.realm.Realm
+import io.realm.RealmConfiguration
import org.matrix.android.sdk.BuildConfig
import org.matrix.android.sdk.internal.SessionManager
import org.matrix.android.sdk.internal.auth.SessionParamsStore
import org.matrix.android.sdk.internal.crypto.CryptoModule
import org.matrix.android.sdk.internal.database.RealmKeysUtils
import org.matrix.android.sdk.internal.di.CryptoDatabase
-import org.matrix.android.sdk.internal.di.SessionDownloadsDirectory
import org.matrix.android.sdk.internal.di.SessionDatabase
+import org.matrix.android.sdk.internal.di.SessionDownloadsDirectory
import org.matrix.android.sdk.internal.di.SessionFilesDirectory
import org.matrix.android.sdk.internal.di.SessionId
import org.matrix.android.sdk.internal.di.UserMd5
import org.matrix.android.sdk.internal.di.WorkManagerProvider
import org.matrix.android.sdk.internal.session.SessionModule
import org.matrix.android.sdk.internal.session.cache.ClearCacheTask
-import io.realm.Realm
-import io.realm.RealmConfiguration
import timber.log.Timber
import java.io.File
import javax.inject.Inject
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/content/DefaultContentUrlResolver.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/content/DefaultContentUrlResolver.kt
index e4efdaa254..5c8cf99dc6 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/content/DefaultContentUrlResolver.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/content/DefaultContentUrlResolver.kt
@@ -16,14 +16,14 @@
package org.matrix.android.sdk.internal.session.content
+import org.matrix.android.sdk.api.MatrixUrls
+import org.matrix.android.sdk.api.MatrixUrls.isMxcUrl
import org.matrix.android.sdk.api.auth.data.HomeServerConnectionConfig
import org.matrix.android.sdk.api.session.content.ContentUrlResolver
import org.matrix.android.sdk.internal.network.NetworkConstants
import org.matrix.android.sdk.internal.util.ensureTrailingSlash
import javax.inject.Inject
-private const val MATRIX_CONTENT_URI_SCHEME = "mxc://"
-
internal class DefaultContentUrlResolver @Inject constructor(homeServerConnectionConfig: HomeServerConnectionConfig) : ContentUrlResolver {
private val baseUrl = homeServerConnectionConfig.homeServerUriBase.toString().ensureTrailingSlash()
@@ -33,7 +33,7 @@ internal class DefaultContentUrlResolver @Inject constructor(homeServerConnectio
override fun resolveFullSize(contentUrl: String?): String? {
return contentUrl
// do not allow non-mxc content URLs
- ?.takeIf { it.isValidMatrixContentUrl() }
+ ?.takeIf { it.isMxcUrl() }
?.let {
resolve(
contentUrl = it,
@@ -45,7 +45,7 @@ internal class DefaultContentUrlResolver @Inject constructor(homeServerConnectio
override fun resolveThumbnail(contentUrl: String?, width: Int, height: Int, method: ContentUrlResolver.ThumbnailMethod): String? {
return contentUrl
// do not allow non-mxc content URLs
- ?.takeIf { it.isValidMatrixContentUrl() }
+ ?.takeIf { it.isMxcUrl() }
?.let {
resolve(
contentUrl = it,
@@ -58,7 +58,7 @@ internal class DefaultContentUrlResolver @Inject constructor(homeServerConnectio
private fun resolve(contentUrl: String,
prefix: String,
params: String = ""): String? {
- var serverAndMediaId = contentUrl.removePrefix(MATRIX_CONTENT_URI_SCHEME)
+ var serverAndMediaId = contentUrl.removePrefix(MatrixUrls.MATRIX_CONTENT_URI_SCHEME)
val fragmentOffset = serverAndMediaId.indexOf("#")
var fragment = ""
if (fragmentOffset >= 0) {
@@ -68,8 +68,4 @@ internal class DefaultContentUrlResolver @Inject constructor(homeServerConnectio
return baseUrl + prefix + serverAndMediaId + params + fragment
}
-
- private fun String.isValidMatrixContentUrl(): Boolean {
- return startsWith(MATRIX_CONTENT_URI_SCHEME)
- }
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/content/FileUploader.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/content/FileUploader.kt
index 6a4dd26392..bdebb0addf 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/content/FileUploader.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/content/FileUploader.kt
@@ -67,8 +67,8 @@ internal class FileUploader @Inject constructor(
// Check size limit
val maxUploadFileSize = homeServerCapabilitiesService.getHomeServerCapabilities().maxUploadFileSize
- if (maxUploadFileSize != HomeServerCapabilities.MAX_UPLOAD_FILE_SIZE_UNKNOWN
- && file.length() > maxUploadFileSize) {
+ if (maxUploadFileSize != HomeServerCapabilities.MAX_UPLOAD_FILE_SIZE_UNKNOWN &&
+ file.length() > maxUploadFileSize) {
// Known limitation and file too big for the server, save the pain to upload it
throw Failure.ServerError(
error = MatrixError(
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/content/UploadContentWorker.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/content/UploadContentWorker.kt
index f14c85cf80..11c200c54b 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/content/UploadContentWorker.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/content/UploadContentWorker.kt
@@ -63,8 +63,8 @@ private data class NewAttachmentAttributes(
* Possible previous worker: None
* Possible next worker : Always [MultipleEventSendingDispatcherWorker]
*/
-internal class UploadContentWorker(val context: Context, params: WorkerParameters)
- : SessionSafeCoroutineWorker(context, params, Params::class.java) {
+internal class UploadContentWorker(val context: Context, params: WorkerParameters) :
+ SessionSafeCoroutineWorker(context, params, Params::class.java) {
@JsonClass(generateAdapter = true)
internal data class Params(
@@ -157,10 +157,10 @@ internal class UploadContentWorker(val context: Context, params: WorkerParameter
params.attachment.size
)
- if (attachment.type == ContentAttachmentData.Type.IMAGE
+ if (attachment.type == ContentAttachmentData.Type.IMAGE &&
// Do not compress gif
- && attachment.mimeType != MimeTypes.Gif
- && params.compressBeforeSending) {
+ attachment.mimeType != MimeTypes.Gif &&
+ params.compressBeforeSending) {
notifyTracker(params) { contentUploadStateTracker.setCompressingImage(it) }
fileToUpload = imageCompressor.compress(workingFile, MAX_IMAGE_SIZE, MAX_IMAGE_SIZE)
@@ -177,10 +177,10 @@ internal class UploadContentWorker(val context: Context, params: WorkerParameter
}
}
.also { filesToDelete.add(it) }
- } else if (attachment.type == ContentAttachmentData.Type.VIDEO
+ } else if (attachment.type == ContentAttachmentData.Type.VIDEO &&
// Do not compress gif
- && attachment.mimeType != MimeTypes.Gif
- && params.compressBeforeSending) {
+ attachment.mimeType != MimeTypes.Gif &&
+ params.compressBeforeSending) {
fileToUpload = videoCompressor.compress(workingFile, object : ProgressListener {
override fun onProgress(progress: Int, total: Int) {
notifyTracker(params) { contentUploadStateTracker.setCompressingVideo(it, progress.toFloat()) }
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/displayname/DisplayNameResolver.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/displayname/DisplayNameResolver.kt
new file mode 100644
index 0000000000..76d956f9a5
--- /dev/null
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/displayname/DisplayNameResolver.kt
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2021 The Matrix.org Foundation C.I.C.
+ *
+ * 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 org.matrix.android.sdk.internal.session.displayname
+
+import org.matrix.android.sdk.api.MatrixConfiguration
+import org.matrix.android.sdk.api.util.MatrixItem
+import javax.inject.Inject
+
+internal class DisplayNameResolver @Inject constructor(
+ private val matrixConfiguration: MatrixConfiguration
+) {
+ fun getBestName(matrixItem: MatrixItem): String {
+ return if (matrixItem is MatrixItem.GroupItem || matrixItem is MatrixItem.RoomAliasItem) {
+ // Best name is the id, and we keep the displayName of the room for the case we need the first letter
+ matrixItem.id
+ } else {
+ matrixItem.displayName?.takeIf { it.isNotBlank() }
+ ?: matrixConfiguration.matrixItemDisplayNameFallbackProvider?.getDefaultName(matrixItem)
+ ?: matrixItem.id
+ }
+ }
+}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/filter/DefaultFilterRepository.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/filter/DefaultFilterRepository.kt
index 095c39a485..1d1bb0e715 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/filter/DefaultFilterRepository.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/filter/DefaultFilterRepository.kt
@@ -17,14 +17,14 @@
package org.matrix.android.sdk.internal.session.filter
import com.zhuinden.monarchy.Monarchy
+import io.realm.Realm
+import io.realm.kotlin.where
import org.matrix.android.sdk.internal.database.model.FilterEntity
import org.matrix.android.sdk.internal.database.model.FilterEntityFields
import org.matrix.android.sdk.internal.database.query.get
import org.matrix.android.sdk.internal.database.query.getOrCreate
import org.matrix.android.sdk.internal.di.SessionDatabase
import org.matrix.android.sdk.internal.util.awaitTransaction
-import io.realm.Realm
-import io.realm.kotlin.where
import javax.inject.Inject
internal class DefaultFilterRepository @Inject constructor(@SessionDatabase private val monarchy: Monarchy) : FilterRepository {
@@ -33,9 +33,9 @@ internal class DefaultFilterRepository @Inject constructor(@SessionDatabase priv
return Realm.getInstance(monarchy.realmConfiguration).use { realm ->
val filterEntity = FilterEntity.get(realm)
// Filter has changed, or no filter Id yet
- filterEntity == null
- || filterEntity.filterBodyJson != filter.toJSONString()
- || filterEntity.filterId.isBlank()
+ filterEntity == null ||
+ filterEntity.filterBodyJson != filter.toJSONString() ||
+ filterEntity.filterId.isBlank()
}.also { hasChanged ->
if (hasChanged) {
// Filter is new or has changed, store it and reset the filter Id.
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/filter/EventFilter.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/filter/EventFilter.kt
index 1be62304a1..37630ef8ba 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/filter/EventFilter.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/filter/EventFilter.kt
@@ -50,10 +50,10 @@ data class EventFilter(
@Json(name = "not_types") val notTypes: List? = null
) {
fun hasData(): Boolean {
- return limit != null
- || senders != null
- || notSenders != null
- || types != null
- || notTypes != null
+ return limit != null ||
+ senders != null ||
+ notSenders != null ||
+ types != null ||
+ notTypes != null
}
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/filter/RoomEventFilter.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/filter/RoomEventFilter.kt
index d6089f9f5b..7047d38260 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/filter/RoomEventFilter.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/filter/RoomEventFilter.kt
@@ -73,14 +73,14 @@ data class RoomEventFilter(
}
fun hasData(): Boolean {
- return (limit != null
- || notSenders != null
- || notTypes != null
- || senders != null
- || types != null
- || rooms != null
- || notRooms != null
- || containsUrl != null
- || lazyLoadMembers != null)
+ return (limit != null ||
+ notSenders != null ||
+ notTypes != null ||
+ senders != null ||
+ types != null ||
+ rooms != null ||
+ notRooms != null ||
+ containsUrl != null ||
+ lazyLoadMembers != null)
}
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/filter/RoomFilter.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/filter/RoomFilter.kt
index fbf22fde51..2c56a30d39 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/filter/RoomFilter.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/filter/RoomFilter.kt
@@ -59,12 +59,12 @@ data class RoomFilter(
) {
fun hasData(): Boolean {
- return (notRooms != null
- || rooms != null
- || ephemeral != null
- || includeLeave != null
- || state != null
- || timeline != null
- || accountData != null)
+ return (notRooms != null ||
+ rooms != null ||
+ ephemeral != null ||
+ includeLeave != null ||
+ state != null ||
+ timeline != null ||
+ accountData != null)
}
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/group/DefaultGroupService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/group/DefaultGroupService.kt
index 425d6a9aca..8dc5f3931d 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/group/DefaultGroupService.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/group/DefaultGroupService.kt
@@ -18,6 +18,8 @@ package org.matrix.android.sdk.internal.session.group
import androidx.lifecycle.LiveData
import com.zhuinden.monarchy.Monarchy
+import io.realm.Realm
+import io.realm.RealmQuery
import org.matrix.android.sdk.api.session.group.Group
import org.matrix.android.sdk.api.session.group.GroupService
import org.matrix.android.sdk.api.session.group.GroupSummaryQueryParams
@@ -30,8 +32,6 @@ import org.matrix.android.sdk.internal.database.query.where
import org.matrix.android.sdk.internal.di.SessionDatabase
import org.matrix.android.sdk.internal.query.process
import org.matrix.android.sdk.internal.util.fetchCopyMap
-import io.realm.Realm
-import io.realm.RealmQuery
import javax.inject.Inject
internal class DefaultGroupService @Inject constructor(@SessionDatabase private val monarchy: Monarchy,
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/group/GetGroupDataWorker.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/group/GetGroupDataWorker.kt
index d6b9363d54..338f43bdbb 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/group/GetGroupDataWorker.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/group/GetGroupDataWorker.kt
@@ -28,8 +28,8 @@ import javax.inject.Inject
* Possible previous worker: None
* Possible next worker : None
*/
-internal class GetGroupDataWorker(context: Context, params: WorkerParameters)
- : SessionSafeCoroutineWorker(context, params, Params::class.java) {
+internal class GetGroupDataWorker(context: Context, params: WorkerParameters) :
+ SessionSafeCoroutineWorker(context, params, Params::class.java) {
@JsonClass(generateAdapter = true)
internal data class Params(
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/homeserver/HomeServerPinger.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/homeserver/HomeServerPinger.kt
index bb526adf4a..70e1e551aa 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/homeserver/HomeServerPinger.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/homeserver/HomeServerPinger.kt
@@ -16,10 +16,10 @@
package org.matrix.android.sdk.internal.session.homeserver
+import kotlinx.coroutines.launch
import org.matrix.android.sdk.api.failure.Failure
import org.matrix.android.sdk.internal.network.executeRequest
import org.matrix.android.sdk.internal.task.TaskExecutor
-import kotlinx.coroutines.launch
import javax.inject.Inject
internal class HomeServerPinger @Inject constructor(private val taskExecutor: TaskExecutor,
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/identity/DefaultIdentityService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/identity/DefaultIdentityService.kt
index acd163450c..da37948cd4 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/identity/DefaultIdentityService.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/identity/DefaultIdentityService.kt
@@ -320,12 +320,12 @@ internal class DefaultIdentityService @Inject constructor(
}
private fun Throwable.isInvalidToken(): Boolean {
- return this is Failure.ServerError
- && httpCode == HttpsURLConnection.HTTP_UNAUTHORIZED /* 401 */
+ return this is Failure.ServerError &&
+ httpCode == HttpsURLConnection.HTTP_UNAUTHORIZED /* 401 */
}
private fun Throwable.isTermsNotSigned(): Boolean {
- return this is Failure.ServerError
- && httpCode == HttpsURLConnection.HTTP_FORBIDDEN /* 403 */
- && error.code == MatrixError.M_TERMS_NOT_SIGNED
+ return this is Failure.ServerError &&
+ httpCode == HttpsURLConnection.HTTP_FORBIDDEN && /* 403 */
+ error.code == MatrixError.M_TERMS_NOT_SIGNED
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/identity/EnsureIdentityToken.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/identity/EnsureIdentityToken.kt
index 5e1434403e..657d1f3ac7 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/identity/EnsureIdentityToken.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/identity/EnsureIdentityToken.kt
@@ -17,13 +17,13 @@
package org.matrix.android.sdk.internal.session.identity
import dagger.Lazy
+import okhttp3.OkHttpClient
import org.matrix.android.sdk.api.session.identity.IdentityServiceError
import org.matrix.android.sdk.internal.di.UnauthenticatedWithCertificate
import org.matrix.android.sdk.internal.network.RetrofitFactory
import org.matrix.android.sdk.internal.session.identity.data.IdentityStore
import org.matrix.android.sdk.internal.session.openid.GetOpenIdTokenTask
import org.matrix.android.sdk.internal.task.Task
-import okhttp3.OkHttpClient
import javax.inject.Inject
internal interface EnsureIdentityTokenTask : Task
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/identity/IdentityBulkLookupTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/identity/IdentityBulkLookupTask.kt
index 114695062c..f6ef370f8d 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/identity/IdentityBulkLookupTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/identity/IdentityBulkLookupTask.kt
@@ -117,8 +117,8 @@ internal class DefaultIdentityBulkLookupTask @Inject constructor(
return withOlmUtility { olmUtility ->
threePids.map { threePid ->
base64ToBase64Url(
- olmUtility.sha256(threePid.value.lowercase(Locale.ROOT)
- + " " + threePid.toMedium() + " " + pepper)
+ olmUtility.sha256(threePid.value.lowercase(Locale.ROOT) +
+ " " + threePid.toMedium() + " " + pepper)
)
}
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/identity/IdentityModule.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/identity/IdentityModule.kt
index 4d664b76be..19e602d7a7 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/identity/IdentityModule.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/identity/IdentityModule.kt
@@ -19,6 +19,8 @@ package org.matrix.android.sdk.internal.session.identity
import dagger.Binds
import dagger.Module
import dagger.Provides
+import io.realm.RealmConfiguration
+import okhttp3.OkHttpClient
import org.matrix.android.sdk.internal.database.RealmKeysUtils
import org.matrix.android.sdk.internal.di.AuthenticatedIdentity
import org.matrix.android.sdk.internal.di.IdentityDatabase
@@ -32,8 +34,6 @@ import org.matrix.android.sdk.internal.session.SessionScope
import org.matrix.android.sdk.internal.session.identity.data.IdentityStore
import org.matrix.android.sdk.internal.session.identity.db.IdentityRealmModule
import org.matrix.android.sdk.internal.session.identity.db.RealmIdentityStore
-import io.realm.RealmConfiguration
-import okhttp3.OkHttpClient
import org.matrix.android.sdk.internal.session.identity.db.RealmIdentityStoreMigration
import java.io.File
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/identity/db/IdentityPendingBindingEntity.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/identity/db/IdentityPendingBindingEntity.kt
index be68e17a49..fcc91b0121 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/identity/db/IdentityPendingBindingEntity.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/identity/db/IdentityPendingBindingEntity.kt
@@ -16,10 +16,10 @@
package org.matrix.android.sdk.internal.session.identity.db
-import org.matrix.android.sdk.api.session.identity.ThreePid
-import org.matrix.android.sdk.api.session.identity.toMedium
import io.realm.RealmObject
import io.realm.annotations.PrimaryKey
+import org.matrix.android.sdk.api.session.identity.ThreePid
+import org.matrix.android.sdk.api.session.identity.toMedium
internal open class IdentityPendingBindingEntity(
@PrimaryKey var threePid: String = "",
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/identity/db/IdentityPendingBindingEntityQuery.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/identity/db/IdentityPendingBindingEntityQuery.kt
index aa2f4dd5b2..8d4afc7beb 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/identity/db/IdentityPendingBindingEntityQuery.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/identity/db/IdentityPendingBindingEntityQuery.kt
@@ -16,10 +16,10 @@
package org.matrix.android.sdk.internal.session.identity.db
-import org.matrix.android.sdk.api.session.identity.ThreePid
import io.realm.Realm
import io.realm.kotlin.createObject
import io.realm.kotlin.where
+import org.matrix.android.sdk.api.session.identity.ThreePid
internal fun IdentityPendingBindingEntity.Companion.get(realm: Realm, threePid: ThreePid): IdentityPendingBindingEntity? {
return realm.where()
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/identity/db/RealmIdentityStore.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/identity/db/RealmIdentityStore.kt
index 2fa3fc0cfb..ce8b78b2d0 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/identity/db/RealmIdentityStore.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/identity/db/RealmIdentityStore.kt
@@ -16,15 +16,15 @@
package org.matrix.android.sdk.internal.session.identity.db
+import io.realm.Realm
+import io.realm.RealmConfiguration
import org.matrix.android.sdk.api.session.identity.ThreePid
import org.matrix.android.sdk.internal.di.IdentityDatabase
import org.matrix.android.sdk.internal.session.SessionScope
-import org.matrix.android.sdk.internal.session.identity.data.IdentityPendingBinding
import org.matrix.android.sdk.internal.session.identity.data.IdentityData
+import org.matrix.android.sdk.internal.session.identity.data.IdentityPendingBinding
import org.matrix.android.sdk.internal.session.identity.data.IdentityStore
import org.matrix.android.sdk.internal.session.identity.model.IdentityHashDetailResponse
-import io.realm.Realm
-import io.realm.RealmConfiguration
import javax.inject.Inject
@SessionScope
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/initsync/DefaultSyncStatusService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/initsync/DefaultSyncStatusService.kt
index 6dac9bffd0..079b0d0115 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/initsync/DefaultSyncStatusService.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/initsync/DefaultSyncStatusService.kt
@@ -23,8 +23,8 @@ import org.matrix.android.sdk.internal.session.SessionScope
import javax.inject.Inject
@SessionScope
-internal class DefaultSyncStatusService @Inject constructor()
- : SyncStatusService,
+internal class DefaultSyncStatusService @Inject constructor() :
+ SyncStatusService,
ProgressReporter {
private val status = MutableLiveData()
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/integrationmanager/IntegrationManager.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/integrationmanager/IntegrationManager.kt
index b654b8610d..30b1589169 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/integrationmanager/IntegrationManager.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/integrationmanager/IntegrationManager.kt
@@ -22,6 +22,9 @@ import androidx.lifecycle.LifecycleRegistry
import com.zhuinden.monarchy.Monarchy
import org.matrix.android.sdk.api.MatrixConfiguration
import org.matrix.android.sdk.api.session.Session
+import org.matrix.android.sdk.api.session.SessionLifecycleObserver
+import org.matrix.android.sdk.api.session.accountdata.UserAccountDataEvent
+import org.matrix.android.sdk.api.session.accountdata.UserAccountDataTypes
import org.matrix.android.sdk.api.session.events.model.toModel
import org.matrix.android.sdk.api.session.integrationmanager.IntegrationManagerConfig
import org.matrix.android.sdk.api.session.integrationmanager.IntegrationManagerService
@@ -30,12 +33,9 @@ import org.matrix.android.sdk.api.session.widgets.model.WidgetType
import org.matrix.android.sdk.internal.database.model.WellknownIntegrationManagerConfigEntity
import org.matrix.android.sdk.internal.di.SessionDatabase
import org.matrix.android.sdk.internal.extensions.observeNotNull
-import org.matrix.android.sdk.api.session.SessionLifecycleObserver
import org.matrix.android.sdk.internal.session.SessionScope
-import org.matrix.android.sdk.api.session.accountdata.UserAccountDataTypes
-import org.matrix.android.sdk.api.session.accountdata.UserAccountDataEvent
-import org.matrix.android.sdk.internal.session.user.accountdata.UserAccountDataDataSource
import org.matrix.android.sdk.internal.session.user.accountdata.UpdateUserAccountDataTask
+import org.matrix.android.sdk.internal.session.user.accountdata.UserAccountDataDataSource
import org.matrix.android.sdk.internal.session.widgets.helper.WidgetFactory
import org.matrix.android.sdk.internal.session.widgets.helper.extractWidgetSequence
import timber.log.Timber
@@ -58,8 +58,8 @@ internal class IntegrationManager @Inject constructor(matrixConfiguration: Matri
@SessionDatabase private val monarchy: Monarchy,
private val updateUserAccountDataTask: UpdateUserAccountDataTask,
private val accountDataDataSource: UserAccountDataDataSource,
- private val widgetFactory: WidgetFactory)
- : SessionLifecycleObserver {
+ private val widgetFactory: WidgetFactory) :
+ SessionLifecycleObserver {
private val currentConfigs = ArrayList()
private val lifecycleOwner: LifecycleOwner = LifecycleOwner { lifecycleRegistry }
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/integrationmanager/IntegrationManagerConfigExtractor.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/integrationmanager/IntegrationManagerConfigExtractor.kt
index f7a8b68515..8c63dbeb0d 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/integrationmanager/IntegrationManagerConfigExtractor.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/integrationmanager/IntegrationManagerConfigExtractor.kt
@@ -29,9 +29,9 @@ internal class IntegrationManagerConfigExtractor @Inject constructor() {
(config as? Map<*, *>)?.let { map ->
val apiUrl = map["api_url"] as? String
val uiUrl = map["ui_url"] as? String ?: apiUrl
- if (apiUrl != null
- && apiUrl.startsWith("https://")
- && uiUrl!!.startsWith("https://")) {
+ if (apiUrl != null &&
+ apiUrl.startsWith("https://") &&
+ uiUrl!!.startsWith("https://")) {
return WellknownIntegrationManagerConfigEntity(
apiUrl = apiUrl,
uiUrl = uiUrl
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/media/UrlsExtractor.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/media/UrlsExtractor.kt
index d1fb5b98ff..85a126ef78 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/media/UrlsExtractor.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/media/UrlsExtractor.kt
@@ -33,9 +33,9 @@ internal class UrlsExtractor @Inject constructor() {
return event.takeIf { it.root.getClearType() == EventType.MESSAGE }
?.getLastMessageContent()
?.takeIf {
- it.msgType == MessageType.MSGTYPE_TEXT
- || it.msgType == MessageType.MSGTYPE_NOTICE
- || it.msgType == MessageType.MSGTYPE_EMOTE
+ it.msgType == MessageType.MSGTYPE_TEXT ||
+ it.msgType == MessageType.MSGTYPE_NOTICE ||
+ it.msgType == MessageType.MSGTYPE_EMOTE
}
?.let { messageContent ->
if (event.isReply()) {
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/notification/ProcessEventForPushTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/notification/ProcessEventForPushTask.kt
index 0ece07fc15..1321f8dd62 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/notification/ProcessEventForPushTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/notification/ProcessEventForPushTask.kt
@@ -18,8 +18,8 @@ package org.matrix.android.sdk.internal.session.notification
import org.matrix.android.sdk.api.pushrules.rest.PushRule
import org.matrix.android.sdk.api.session.events.model.EventType
+import org.matrix.android.sdk.api.session.sync.model.RoomsSyncResponse
import org.matrix.android.sdk.internal.di.UserId
-import org.matrix.android.sdk.internal.session.sync.model.RoomsSyncResponse
import org.matrix.android.sdk.internal.task.Task
import timber.log.Timber
import javax.inject.Inject
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/openid/DefaultOpenIdService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/openid/DefaultOpenIdService.kt
index b90a2435f7..afff0f3515 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/openid/DefaultOpenIdService.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/openid/DefaultOpenIdService.kt
@@ -20,7 +20,7 @@ import org.matrix.android.sdk.api.session.openid.OpenIdService
import org.matrix.android.sdk.api.session.openid.OpenIdToken
import javax.inject.Inject
-internal class DefaultOpenIdService @Inject constructor(private val getOpenIdTokenTask: GetOpenIdTokenTask): OpenIdService {
+internal class DefaultOpenIdService @Inject constructor(private val getOpenIdTokenTask: GetOpenIdTokenTask) : OpenIdService {
override suspend fun getOpenIdToken(): OpenIdToken {
return getOpenIdTokenTask.execute(Unit)
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/permalinks/DefaultPermalinkService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/permalinks/DefaultPermalinkService.kt
index 134da4ce51..144ebb5404 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/permalinks/DefaultPermalinkService.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/permalinks/DefaultPermalinkService.kt
@@ -18,33 +18,29 @@ package org.matrix.android.sdk.internal.session.permalinks
import org.matrix.android.sdk.api.session.events.model.Event
import org.matrix.android.sdk.api.session.permalinks.PermalinkService
-import org.matrix.android.sdk.api.session.permalinks.PermalinkService.Companion.MATRIX_TO_URL_BASE
import javax.inject.Inject
internal class DefaultPermalinkService @Inject constructor(
private val permalinkFactory: PermalinkFactory
) : PermalinkService {
- override fun createPermalink(event: Event): String? {
- return permalinkFactory.createPermalink(event)
+ override fun createPermalink(event: Event, forceMatrixTo: Boolean): String? {
+ return permalinkFactory.createPermalink(event, forceMatrixTo)
}
- override fun createPermalink(id: String): String? {
- return permalinkFactory.createPermalink(id)
+ override fun createPermalink(id: String, forceMatrixTo: Boolean): String? {
+ return permalinkFactory.createPermalink(id, forceMatrixTo)
}
- override fun createRoomPermalink(roomId: String, viaServers: List?): String? {
- return permalinkFactory.createRoomPermalink(roomId, viaServers)
+ override fun createRoomPermalink(roomId: String, viaServers: List?, forceMatrixTo: Boolean): String? {
+ return permalinkFactory.createRoomPermalink(roomId, viaServers, forceMatrixTo)
}
- override fun createPermalink(roomId: String, eventId: String): String {
- return permalinkFactory.createPermalink(roomId, eventId)
+ override fun createPermalink(roomId: String, eventId: String, forceMatrixTo: Boolean): String {
+ return permalinkFactory.createPermalink(roomId, eventId, forceMatrixTo)
}
override fun getLinkedId(url: String): String? {
- return url
- .takeIf { it.startsWith(MATRIX_TO_URL_BASE) }
- ?.substring(MATRIX_TO_URL_BASE.length)
- ?.substringBeforeLast("?")
+ return permalinkFactory.getLinkedId(url)
}
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/permalinks/PermalinkFactory.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/permalinks/PermalinkFactory.kt
index 639e45582a..39c1ddfdce 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/permalinks/PermalinkFactory.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/permalinks/PermalinkFactory.kt
@@ -16,7 +16,11 @@
package org.matrix.android.sdk.internal.session.permalinks
+import org.matrix.android.sdk.api.MatrixConfiguration
+import org.matrix.android.sdk.api.MatrixPatterns
import org.matrix.android.sdk.api.session.events.model.Event
+import org.matrix.android.sdk.api.session.permalinks.PermalinkData
+import org.matrix.android.sdk.api.session.permalinks.PermalinkParser
import org.matrix.android.sdk.api.session.permalinks.PermalinkService.Companion.MATRIX_TO_URL_BASE
import org.matrix.android.sdk.internal.di.UserId
import javax.inject.Inject
@@ -24,28 +28,44 @@ import javax.inject.Inject
internal class PermalinkFactory @Inject constructor(
@UserId
private val userId: String,
- private val viaParameterFinder: ViaParameterFinder
+ private val viaParameterFinder: ViaParameterFinder,
+ private val matrixConfiguration: MatrixConfiguration
) {
- fun createPermalink(event: Event): String? {
+ fun createPermalink(event: Event, forceMatrixTo: Boolean): String? {
if (event.roomId.isNullOrEmpty() || event.eventId.isNullOrEmpty()) {
return null
}
- return createPermalink(event.roomId, event.eventId)
+ return createPermalink(event.roomId, event.eventId, forceMatrixTo)
}
- fun createPermalink(id: String): String? {
- return if (id.isEmpty()) {
- null
- } else MATRIX_TO_URL_BASE + escape(id)
+ fun createPermalink(id: String, forceMatrixTo: Boolean): String? {
+ return when {
+ id.isEmpty() -> null
+ !useClientFormat(forceMatrixTo) -> MATRIX_TO_URL_BASE + escape(id)
+ else -> {
+ buildString {
+ append(matrixConfiguration.clientPermalinkBaseUrl)
+ when {
+ MatrixPatterns.isRoomId(id) || MatrixPatterns.isRoomAlias(id) -> append(ROOM_PATH)
+ MatrixPatterns.isUserId(id) -> append(USER_PATH)
+ MatrixPatterns.isGroupId(id) -> append(GROUP_PATH)
+ }
+ append(escape(id))
+ }
+ }
+ }
}
- fun createRoomPermalink(roomId: String, via: List? = null): String? {
+ fun createRoomPermalink(roomId: String, via: List? = null, forceMatrixTo: Boolean): String? {
return if (roomId.isEmpty()) {
null
} else {
buildString {
- append(MATRIX_TO_URL_BASE)
+ append(baseUrl(forceMatrixTo))
+ if (useClientFormat(forceMatrixTo)) {
+ append(ROOM_PATH)
+ }
append(escape(roomId))
append(
via?.takeIf { it.isNotEmpty() }?.let { viaParameterFinder.asUrlViaParameters(it) }
@@ -55,16 +75,34 @@ internal class PermalinkFactory @Inject constructor(
}
}
- fun createPermalink(roomId: String, eventId: String): String {
- return MATRIX_TO_URL_BASE + escape(roomId) + "/" + escape(eventId) + viaParameterFinder.computeViaParams(userId, roomId)
+ fun createPermalink(roomId: String, eventId: String, forceMatrixTo: Boolean): String {
+ return buildString {
+ append(baseUrl(forceMatrixTo))
+ if (useClientFormat(forceMatrixTo)) {
+ append(ROOM_PATH)
+ }
+ append(escape(roomId))
+ append("/")
+ append(escape(eventId))
+ append(viaParameterFinder.computeViaParams(userId, roomId))
+ }
}
fun getLinkedId(url: String): String? {
- val isSupported = url.startsWith(MATRIX_TO_URL_BASE)
-
- return if (isSupported) {
- url.substring(MATRIX_TO_URL_BASE.length)
- } else null
+ val clientBaseUrl = matrixConfiguration.clientPermalinkBaseUrl
+ return when {
+ url.startsWith(MATRIX_TO_URL_BASE) -> url.substring(MATRIX_TO_URL_BASE.length)
+ clientBaseUrl != null && url.startsWith(clientBaseUrl) -> {
+ when (PermalinkParser.parse(url)) {
+ is PermalinkData.GroupLink -> url.substring(clientBaseUrl.length + GROUP_PATH.length)
+ is PermalinkData.RoomLink -> url.substring(clientBaseUrl.length + ROOM_PATH.length)
+ is PermalinkData.UserLink -> url.substring(clientBaseUrl.length + USER_PATH.length)
+ else -> null
+ }
+ }
+ else -> null
+ }
+ ?.substringBeforeLast("?")
}
/**
@@ -86,4 +124,28 @@ internal class PermalinkFactory @Inject constructor(
private fun unescape(id: String): String {
return id.replace("%2F", "/")
}
+
+ /**
+ * Get the permalink base URL according to the potential one in [MatrixConfiguration.clientPermalinkBaseUrl]
+ * and the [forceMatrixTo] parameter.
+ *
+ * @param forceMatrixTo whether we should force using matrix.to base URL.
+ *
+ * @return the permalink base URL.
+ */
+ private fun baseUrl(forceMatrixTo: Boolean): String {
+ return matrixConfiguration.clientPermalinkBaseUrl
+ ?.takeUnless { forceMatrixTo }
+ ?: MATRIX_TO_URL_BASE
+ }
+
+ private fun useClientFormat(forceMatrixTo: Boolean): Boolean {
+ return !forceMatrixTo && matrixConfiguration.clientPermalinkBaseUrl != null
+ }
+
+ companion object {
+ private const val ROOM_PATH = "room/"
+ private const val USER_PATH = "user/"
+ private const val GROUP_PATH = "group/"
+ }
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/FinalizeAddingThreePidTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/FinalizeAddingThreePidTask.kt
index 5f063365e0..6ff4efaf11 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/FinalizeAddingThreePidTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/FinalizeAddingThreePidTask.kt
@@ -17,12 +17,12 @@
package org.matrix.android.sdk.internal.session.profile
import com.zhuinden.monarchy.Monarchy
+import org.matrix.android.sdk.api.auth.UIABaseAuth
import org.matrix.android.sdk.api.auth.UserInteractiveAuthInterceptor
import org.matrix.android.sdk.api.failure.Failure
import org.matrix.android.sdk.api.failure.toRegistrationFlowResponse
import org.matrix.android.sdk.api.session.identity.ThreePid
import org.matrix.android.sdk.internal.auth.registration.handleUIA
-import org.matrix.android.sdk.api.auth.UIABaseAuth
import org.matrix.android.sdk.internal.database.model.PendingThreePidEntity
import org.matrix.android.sdk.internal.database.model.PendingThreePidEntityFields
import org.matrix.android.sdk.internal.di.SessionDatabase
@@ -71,8 +71,8 @@ internal class DefaultFinalizeAddingThreePidTask @Inject constructor(
}
true
} catch (throwable: Throwable) {
- if (params.userInteractiveAuthInterceptor == null
- || !handleUIA(
+ if (params.userInteractiveAuthInterceptor == null ||
+ !handleUIA(
failure = throwable,
interceptor = params.userInteractiveAuthInterceptor,
retryBlock = { authUpdate ->
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/AddPusherWorker.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/AddPusherWorker.kt
index 079fd1d3e5..63fd855c08 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/AddPusherWorker.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/AddPusherWorker.kt
@@ -33,8 +33,8 @@ import org.matrix.android.sdk.internal.worker.SessionSafeCoroutineWorker
import org.matrix.android.sdk.internal.worker.SessionWorkerParams
import javax.inject.Inject
-internal class AddPusherWorker(context: Context, params: WorkerParameters)
- : SessionSafeCoroutineWorker(context, params, Params::class.java) {
+internal class AddPusherWorker(context: Context, params: WorkerParameters) :
+ SessionSafeCoroutineWorker(context, params, Params::class.java) {
@JsonClass(generateAdapter = true)
internal data class Params(
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/RemovePusherTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/RemovePusherTask.kt
index 3a2ebf40c2..057c309078 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/RemovePusherTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/RemovePusherTask.kt
@@ -17,16 +17,16 @@
package org.matrix.android.sdk.internal.session.pushers
import com.zhuinden.monarchy.Monarchy
+import io.realm.Realm
import org.matrix.android.sdk.api.session.pushers.PusherState
import org.matrix.android.sdk.internal.database.mapper.asDomain
import org.matrix.android.sdk.internal.database.model.PusherEntity
import org.matrix.android.sdk.internal.database.query.where
import org.matrix.android.sdk.internal.di.SessionDatabase
+import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
import org.matrix.android.sdk.internal.network.executeRequest
import org.matrix.android.sdk.internal.task.Task
import org.matrix.android.sdk.internal.util.awaitTransaction
-import io.realm.Realm
-import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
import javax.inject.Inject
internal interface RemovePusherTask : Task {
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/DefaultRoomService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/DefaultRoomService.kt
index f69949cbb6..5b2499c130 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/DefaultRoomService.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/DefaultRoomService.kt
@@ -93,13 +93,15 @@ internal class DefaultRoomService @Inject constructor(
return roomSummaryDataSource.getRoomSummariesLive(queryParams)
}
- override fun getPagedRoomSummariesLive(queryParams: RoomSummaryQueryParams, pagedListConfig: PagedList.Config, sortOrder: RoomSortOrder)
- : LiveData> {
+ override fun getPagedRoomSummariesLive(queryParams: RoomSummaryQueryParams,
+ pagedListConfig: PagedList.Config,
+ sortOrder: RoomSortOrder): LiveData> {
return roomSummaryDataSource.getSortedPagedRoomSummariesLive(queryParams, pagedListConfig, sortOrder)
}
- override fun getFilteredPagedRoomSummariesLive(queryParams: RoomSummaryQueryParams, pagedListConfig: PagedList.Config, sortOrder: RoomSortOrder)
- : UpdatableLivePageResult {
+ override fun getFilteredPagedRoomSummariesLive(queryParams: RoomSummaryQueryParams,
+ pagedListConfig: PagedList.Config,
+ sortOrder: RoomSortOrder): UpdatableLivePageResult {
return roomSummaryDataSource.getUpdatablePagedRoomSummariesLive(queryParams, pagedListConfig, sortOrder)
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/EventRelationsAggregationProcessor.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/EventRelationsAggregationProcessor.kt
index c7e09e5954..5a1eb190a8 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/EventRelationsAggregationProcessor.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/EventRelationsAggregationProcessor.kt
@@ -131,8 +131,8 @@ internal class EventRelationsAggregationProcessor @Inject constructor(
EventType.ENCRYPTED -> {
// Relation type is in clear
val encryptedEventContent = event.content.toModel()
- if (encryptedEventContent?.relatesTo?.type == RelationType.REPLACE
- || encryptedEventContent?.relatesTo?.type == RelationType.RESPONSE
+ if (encryptedEventContent?.relatesTo?.type == RelationType.REPLACE ||
+ encryptedEventContent?.relatesTo?.type == RelationType.RESPONSE
) {
event.getClearContent().toModel()?.let {
if (encryptedEventContent.relatesTo.type == RelationType.REPLACE) {
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/RoomAPI.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/RoomAPI.kt
index 98e7659238..efc5166a0c 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/RoomAPI.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/RoomAPI.kt
@@ -216,22 +216,6 @@ internal interface RoomAPI {
@GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/state")
suspend fun getRoomState(@Path("roomId") roomId: String): List
- /**
- * Send a relation event to a room.
- *
- * @param txId the transaction Id
- * @param roomId the room id
- * @param eventType the event type
- * @param content the event content
- */
- @POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/send_relation/{parent_id}/{relation_type}/{event_type}")
- suspend fun sendRelation(@Path("roomId") roomId: String,
- @Path("parent_id") parentId: String,
- @Path("relation_type") relationType: String,
- @Path("event_type") eventType: String,
- @Body content: Content?
- ): SendResponse
-
/**
* Paginate relations for event based in normal topological order
*
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/alias/DefaultAliasService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/alias/DefaultAliasService.kt
index 8f58094a2a..73a3b285e9 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/alias/DefaultAliasService.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/alias/DefaultAliasService.kt
@@ -17,8 +17,8 @@
package org.matrix.android.sdk.internal.session.room.alias
import dagger.assisted.Assisted
-import dagger.assisted.AssistedInject
import dagger.assisted.AssistedFactory
+import dagger.assisted.AssistedInject
import org.matrix.android.sdk.api.session.room.alias.AliasService
internal class DefaultAliasService @AssistedInject constructor(
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/call/DefaultRoomCallService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/call/DefaultRoomCallService.kt
index 9bde5054f6..675034531d 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/call/DefaultRoomCallService.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/call/DefaultRoomCallService.kt
@@ -17,8 +17,8 @@
package org.matrix.android.sdk.internal.session.room.call
import dagger.assisted.Assisted
-import dagger.assisted.AssistedInject
import dagger.assisted.AssistedFactory
+import dagger.assisted.AssistedInject
import org.matrix.android.sdk.api.extensions.orFalse
import org.matrix.android.sdk.api.session.room.call.RoomCallService
import org.matrix.android.sdk.internal.session.room.RoomGetter
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/create/CreateRoomBodyBuilder.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/create/CreateRoomBodyBuilder.kt
index 9bb3899f2f..84261e6ebf 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/create/CreateRoomBodyBuilder.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/create/CreateRoomBodyBuilder.kt
@@ -77,9 +77,9 @@ internal class CreateRoomBodyBuilder @Inject constructor(
buildHistoryVisibilityEvent(params),
buildAvatarEvent(params),
buildGuestAccess(params)
- )
- + params.featurePreset?.setupInitialStates().orEmpty()
- + buildCustomInitialStates(params)
+ ) +
+ params.featurePreset?.setupInitialStates().orEmpty() +
+ buildCustomInitialStates(params)
)
.takeIf { it.isNotEmpty() }
@@ -154,8 +154,8 @@ internal class CreateRoomBodyBuilder @Inject constructor(
* Add the crypto algorithm to the room creation parameters.
*/
private suspend fun buildEncryptionWithAlgorithmEvent(params: CreateRoomParams): Event? {
- if (params.algorithm == null
- && canEnableEncryption(params)) {
+ if (params.algorithm == null &&
+ canEnableEncryption(params)) {
// Enable the encryption
params.enableEncryption()
}
@@ -173,13 +173,13 @@ internal class CreateRoomBodyBuilder @Inject constructor(
}
private suspend fun canEnableEncryption(params: CreateRoomParams): Boolean {
- return params.enableEncryptionIfInvitedUsersSupportIt
+ return params.enableEncryptionIfInvitedUsersSupportIt &&
// Parity with web, enable if users have encryption ready devices
// for now remove checks on cross signing and 3pid invites
// && crossSigningService.isCrossSigningVerified()
- && params.invite3pids.isEmpty()
- && params.invitedUserIds.isNotEmpty()
- && params.invitedUserIds.let { userIds ->
+ params.invite3pids.isEmpty() &&
+ params.invitedUserIds.isNotEmpty() &&
+ params.invitedUserIds.let { userIds ->
val keys = deviceListManager.downloadKeys(userIds, forceDownload = false)
userIds.all { userId ->
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/create/CreateRoomTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/create/CreateRoomTask.kt
index 518f0a0a6d..ac6e0562b0 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/create/CreateRoomTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/create/CreateRoomTask.kt
@@ -81,13 +81,13 @@ internal class DefaultCreateRoomTask @Inject constructor(
}
} catch (throwable: Throwable) {
if (throwable is Failure.ServerError) {
- if (throwable.httpCode == 403
- && throwable.error.code == MatrixError.M_FORBIDDEN
- && throwable.error.message.startsWith("Federation denied with")) {
+ if (throwable.httpCode == 403 &&
+ throwable.error.code == MatrixError.M_FORBIDDEN &&
+ throwable.error.message.startsWith("Federation denied with")) {
throw CreateRoomFailure.CreatedWithFederationFailure(throwable.error)
- } else if (throwable.httpCode == 400
- && throwable.error.code == MatrixError.M_UNKNOWN
- && throwable.error.message == "Invalid characters in room alias") {
+ } else if (throwable.httpCode == 400 &&
+ throwable.error.code == MatrixError.M_UNKNOWN &&
+ throwable.error.message == "Invalid characters in room alias") {
throw CreateRoomFailure.AliasError(RoomAliasError.AliasInvalid)
}
}
@@ -138,8 +138,8 @@ internal class DefaultCreateRoomTask @Inject constructor(
* @return true if it is a direct chat
*/
private fun CreateRoomParams.isDirect(): Boolean {
- return preset == CreateRoomPreset.PRESET_TRUSTED_PRIVATE_CHAT
- && isDirect == true
+ return preset == CreateRoomPreset.PRESET_TRUSTED_PRIVATE_CHAT &&
+ isDirect == true
}
/**
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/create/RoomCreateEventProcessor.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/create/RoomCreateEventProcessor.kt
index cc66a0a2d2..eb966b684c 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/create/RoomCreateEventProcessor.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/create/RoomCreateEventProcessor.kt
@@ -16,6 +16,7 @@
package org.matrix.android.sdk.internal.session.room.create
+import io.realm.Realm
import org.matrix.android.sdk.api.session.events.model.Event
import org.matrix.android.sdk.api.session.events.model.EventType
import org.matrix.android.sdk.api.session.events.model.toModel
@@ -25,7 +26,6 @@ import org.matrix.android.sdk.internal.database.model.EventInsertType
import org.matrix.android.sdk.internal.database.model.RoomSummaryEntity
import org.matrix.android.sdk.internal.database.query.where
import org.matrix.android.sdk.internal.session.EventInsertLiveProcessor
-import io.realm.Realm
import javax.inject.Inject
internal class RoomCreateEventProcessor @Inject constructor() : EventInsertLiveProcessor {
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/draft/DefaultDraftService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/draft/DefaultDraftService.kt
index 1d4ab6d516..046f8ba8ba 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/draft/DefaultDraftService.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/draft/DefaultDraftService.kt
@@ -18,8 +18,8 @@ package org.matrix.android.sdk.internal.session.room.draft
import androidx.lifecycle.LiveData
import dagger.assisted.Assisted
-import dagger.assisted.AssistedInject
import dagger.assisted.AssistedFactory
+import dagger.assisted.AssistedInject
import kotlinx.coroutines.withContext
import org.matrix.android.sdk.api.session.room.send.DraftService
import org.matrix.android.sdk.api.session.room.send.UserDraft
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/DefaultMembershipService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/DefaultMembershipService.kt
index 41e891f78e..204deb72b4 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/DefaultMembershipService.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/DefaultMembershipService.kt
@@ -17,10 +17,12 @@
package org.matrix.android.sdk.internal.session.room.membership
import androidx.lifecycle.LiveData
-import dagger.assisted.Assisted
-import dagger.assisted.AssistedInject
-import dagger.assisted.AssistedFactory
import com.zhuinden.monarchy.Monarchy
+import dagger.assisted.Assisted
+import dagger.assisted.AssistedFactory
+import dagger.assisted.AssistedInject
+import io.realm.Realm
+import io.realm.RealmQuery
import org.matrix.android.sdk.api.session.identity.ThreePid
import org.matrix.android.sdk.api.session.room.members.MembershipService
import org.matrix.android.sdk.api.session.room.members.RoomMemberQueryParams
@@ -38,8 +40,6 @@ import org.matrix.android.sdk.internal.session.room.membership.joining.JoinRoomT
import org.matrix.android.sdk.internal.session.room.membership.leaving.LeaveRoomTask
import org.matrix.android.sdk.internal.session.room.membership.threepid.InviteThreePidTask
import org.matrix.android.sdk.internal.util.fetchCopied
-import io.realm.Realm
-import io.realm.RealmQuery
internal class DefaultMembershipService @AssistedInject constructor(
@Assisted private val roomId: String,
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/RoomDisplayNameResolver.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/RoomDisplayNameResolver.kt
index 3aa812d93d..5e77dd157a 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/RoomDisplayNameResolver.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/RoomDisplayNameResolver.kt
@@ -33,6 +33,7 @@ import org.matrix.android.sdk.internal.database.model.RoomSummaryEntity
import org.matrix.android.sdk.internal.database.query.getOrNull
import org.matrix.android.sdk.internal.database.query.where
import org.matrix.android.sdk.internal.di.UserId
+import org.matrix.android.sdk.internal.session.displayname.DisplayNameResolver
import javax.inject.Inject
/**
@@ -40,6 +41,7 @@ import javax.inject.Inject
*/
internal class RoomDisplayNameResolver @Inject constructor(
matrixConfiguration: MatrixConfiguration,
+ private val displayNameResolver: DisplayNameResolver,
@UserId private val userId: String
) {
@@ -83,7 +85,8 @@ internal class RoomDisplayNameResolver @Inject constructor(
activeMembers.where()
.equalTo(RoomMemberSummaryEntityFields.USER_ID, it)
.findFirst()
- ?.getBestName()
+ ?.toMatrixItem()
+ ?.let { matrixItem -> displayNameResolver.getBestName(matrixItem) }
}
?: roomDisplayNameFallbackProvider.getNameForRoomInvite()
} else if (roomEntity?.membership == Membership.JOIN) {
@@ -109,7 +112,7 @@ internal class RoomDisplayNameResolver @Inject constructor(
// Get left members if any
val leftMembersNames = roomMembers.queryLeftRoomMembersEvent()
.findAll()
- .map { it.getBestName() }
+ .map { displayNameResolver.getBestName(it.toMatrixItem()) }
roomDisplayNameFallbackProvider.getNameForEmptyRoom(roomSummary?.isDirect.orFalse(), leftMembersNames)
}
1 -> {
@@ -157,7 +160,7 @@ internal class RoomDisplayNameResolver @Inject constructor(
roomMemberHelper: RoomMemberHelper): String {
val isUnique = roomMemberHelper.isUniqueDisplayName(roomMemberSummary.displayName)
return if (isUnique) {
- roomMemberSummary.getBestName()
+ displayNameResolver.getBestName(roomMemberSummary.toMatrixItem())
} else {
"${roomMemberSummary.displayName} (${roomMemberSummary.userId})"
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/joining/JoinRoomTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/joining/JoinRoomTask.kt
index 209a904fad..82fea237db 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/joining/JoinRoomTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/joining/JoinRoomTask.kt
@@ -43,7 +43,7 @@ internal interface JoinRoomTask : Task {
val roomIdOrAlias: String,
val reason: String?,
val viaServers: List = emptyList(),
- val thirdPartySigned : SignInvitationResult? = null
+ val thirdPartySigned: SignInvitationResult? = null
)
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/notification/DefaultRoomPushRuleService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/notification/DefaultRoomPushRuleService.kt
index 5486d96e28..8f1aefb731 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/notification/DefaultRoomPushRuleService.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/notification/DefaultRoomPushRuleService.kt
@@ -18,10 +18,10 @@ package org.matrix.android.sdk.internal.session.room.notification
import androidx.lifecycle.LiveData
import androidx.lifecycle.Transformations
-import dagger.assisted.Assisted
-import dagger.assisted.AssistedInject
-import dagger.assisted.AssistedFactory
import com.zhuinden.monarchy.Monarchy
+import dagger.assisted.Assisted
+import dagger.assisted.AssistedFactory
+import dagger.assisted.AssistedInject
import org.matrix.android.sdk.api.pushrules.RuleScope
import org.matrix.android.sdk.api.session.room.notification.RoomNotificationState
import org.matrix.android.sdk.api.session.room.notification.RoomPushRuleService
@@ -31,8 +31,8 @@ import org.matrix.android.sdk.internal.di.SessionDatabase
internal class DefaultRoomPushRuleService @AssistedInject constructor(@Assisted private val roomId: String,
private val setRoomNotificationStateTask: SetRoomNotificationStateTask,
- @SessionDatabase private val monarchy: Monarchy)
- : RoomPushRuleService {
+ @SessionDatabase private val monarchy: Monarchy) :
+ RoomPushRuleService {
@AssistedFactory
interface Factory {
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/notification/SetRoomNotificationStateTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/notification/SetRoomNotificationStateTask.kt
index 9cea1fe425..feb8c27b09 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/notification/SetRoomNotificationStateTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/notification/SetRoomNotificationStateTask.kt
@@ -17,6 +17,7 @@
package org.matrix.android.sdk.internal.session.room.notification
import com.zhuinden.monarchy.Monarchy
+import io.realm.Realm
import org.matrix.android.sdk.api.pushrules.RuleScope
import org.matrix.android.sdk.api.session.room.notification.RoomNotificationState
import org.matrix.android.sdk.internal.database.model.PushRuleEntity
@@ -25,7 +26,6 @@ import org.matrix.android.sdk.internal.di.SessionDatabase
import org.matrix.android.sdk.internal.session.pushers.AddPushRuleTask
import org.matrix.android.sdk.internal.session.pushers.RemovePushRuleTask
import org.matrix.android.sdk.internal.task.Task
-import io.realm.Realm
import javax.inject.Inject
internal interface SetRoomNotificationStateTask : Task {
@@ -37,8 +37,8 @@ internal interface SetRoomNotificationStateTask : Task {
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/relation/SendRelationWorker.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/relation/SendRelationWorker.kt
deleted file mode 100644
index 5d0879d706..0000000000
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/relation/SendRelationWorker.kt
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright 2020 The Matrix.org Foundation C.I.C.
- *
- * 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 org.matrix.android.sdk.internal.session.room.relation
-
-import android.content.Context
-import androidx.work.WorkerParameters
-import com.squareup.moshi.JsonClass
-import org.matrix.android.sdk.api.failure.Failure
-import org.matrix.android.sdk.api.session.events.model.Event
-import org.matrix.android.sdk.api.session.events.model.toModel
-import org.matrix.android.sdk.api.session.room.model.relation.ReactionContent
-import org.matrix.android.sdk.api.session.room.model.relation.ReactionInfo
-import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
-import org.matrix.android.sdk.internal.network.executeRequest
-import org.matrix.android.sdk.internal.session.SessionComponent
-import org.matrix.android.sdk.internal.session.room.RoomAPI
-import org.matrix.android.sdk.internal.session.room.send.LocalEchoRepository
-import org.matrix.android.sdk.internal.worker.SessionSafeCoroutineWorker
-import org.matrix.android.sdk.internal.worker.SessionWorkerParams
-import javax.inject.Inject
-
-// TODO This is not used. Delete?
-internal class SendRelationWorker(context: Context, params: WorkerParameters)
- : SessionSafeCoroutineWorker(context, params, Params::class.java) {
-
- @JsonClass(generateAdapter = true)
- internal data class Params(
- override val sessionId: String,
- val roomId: String,
- val eventId: String,
- val relationType: String? = null,
- override val lastFailureMessage: String? = null
- ) : SessionWorkerParams
-
- @Inject lateinit var roomAPI: RoomAPI
- @Inject lateinit var globalErrorReceiver: GlobalErrorReceiver
- @Inject lateinit var localEchoRepository: LocalEchoRepository
-
- override fun injectWith(injector: SessionComponent) {
- injector.inject(this)
- }
-
- override suspend fun doSafeWork(params: Params): Result {
- val localEvent = localEchoRepository.getUpToDateEcho(params.eventId)
- if (localEvent?.eventId == null) {
- return Result.failure()
- }
- val relationContent = localEvent.content.toModel()
- ?: return Result.failure()
- val relatedEventId = relationContent.relatesTo?.eventId ?: return Result.failure()
- val relationType = (relationContent.relatesTo as? ReactionInfo)?.type ?: params.relationType
- ?: return Result.failure()
- return try {
- sendRelation(params.roomId, relationType, relatedEventId, localEvent)
- Result.success()
- } catch (exception: Throwable) {
- when (exception) {
- is Failure.NetworkConnection -> Result.retry()
- else -> {
- // TODO mark as failed to send?
- // always return success, or the chain will be stuck for ever!
- Result.success()
- }
- }
- }
- }
-
- override fun buildErrorParams(params: Params, message: String): Params {
- return params.copy(lastFailureMessage = params.lastFailureMessage ?: message)
- }
-
- private suspend fun sendRelation(roomId: String, relationType: String, relatedEventId: String, localEvent: Event) {
- executeRequest(globalErrorReceiver) {
- roomAPI.sendRelation(
- roomId = roomId,
- parentId = relatedEventId,
- relationType = relationType,
- eventType = localEvent.type!!,
- content = localEvent.content
- )
- }
- }
-}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/relation/UpdateQuickReactionTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/relation/UpdateQuickReactionTask.kt
index 32d6c5aa7e..d0ab430dad 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/relation/UpdateQuickReactionTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/relation/UpdateQuickReactionTask.kt
@@ -16,6 +16,7 @@
package org.matrix.android.sdk.internal.session.room.relation
import com.zhuinden.monarchy.Monarchy
+import io.realm.Realm
import org.matrix.android.sdk.internal.database.model.EventAnnotationsSummaryEntity
import org.matrix.android.sdk.internal.database.model.EventEntity
import org.matrix.android.sdk.internal.database.model.ReactionAggregatedSummaryEntityFields
@@ -23,7 +24,6 @@ import org.matrix.android.sdk.internal.database.query.where
import org.matrix.android.sdk.internal.di.SessionDatabase
import org.matrix.android.sdk.internal.di.UserId
import org.matrix.android.sdk.internal.task.Task
-import io.realm.Realm
import javax.inject.Inject
internal interface UpdateQuickReactionTask : Task {
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/reporting/DefaultReportingService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/reporting/DefaultReportingService.kt
index add17a9fa5..c961f718ef 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/reporting/DefaultReportingService.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/reporting/DefaultReportingService.kt
@@ -17,8 +17,8 @@
package org.matrix.android.sdk.internal.session.room.reporting
import dagger.assisted.Assisted
-import dagger.assisted.AssistedInject
import dagger.assisted.AssistedFactory
+import dagger.assisted.AssistedInject
import org.matrix.android.sdk.api.session.room.reporting.ReportingService
internal class DefaultReportingService @AssistedInject constructor(@Assisted private val roomId: String,
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/DefaultSendService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/DefaultSendService.kt
index 6dbb71e096..177c98541c 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/DefaultSendService.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/DefaultSendService.kt
@@ -22,9 +22,10 @@ import androidx.work.ExistingWorkPolicy
import androidx.work.OneTimeWorkRequest
import androidx.work.Operation
import dagger.assisted.Assisted
-import dagger.assisted.AssistedInject
import dagger.assisted.AssistedFactory
+import dagger.assisted.AssistedInject
import kotlinx.coroutines.launch
+import org.matrix.android.sdk.api.MatrixUrls.isMxcUrl
import org.matrix.android.sdk.api.session.content.ContentAttachmentData
import org.matrix.android.sdk.api.session.events.model.Event
import org.matrix.android.sdk.api.session.events.model.isAttachmentMessage
@@ -130,7 +131,7 @@ internal class DefaultSendService @AssistedInject constructor(
val messageContent = clearContent?.toModel() as? MessageWithAttachmentContent ?: return NoOpCancellable
val url = messageContent.getFileUrl() ?: return NoOpCancellable
- if (url.startsWith("mxc://")) {
+ if (url.isMxcUrl()) {
// We need to resend only the message as the attachment is ok
localEchoRepository.updateSendState(localEcho.eventId, roomId, SendState.UNSENT)
return sendEvent(localEcho.root)
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/LocalEchoEventFactory.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/LocalEchoEventFactory.kt
index c610326a94..8dd0c59387 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/LocalEchoEventFactory.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/LocalEchoEventFactory.kt
@@ -165,8 +165,8 @@ internal class LocalEchoEventFactory @Inject constructor(
newBodyAutoMarkdown: Boolean,
msgType: String,
compatibilityText: String): Event {
- val permalink = permalinkFactory.createPermalink(roomId, originalEvent.root.eventId ?: "")
- val userLink = originalEvent.root.senderId?.let { permalinkFactory.createPermalink(it) } ?: ""
+ val permalink = permalinkFactory.createPermalink(roomId, originalEvent.root.eventId ?: "", false)
+ val userLink = originalEvent.root.senderId?.let { permalinkFactory.createPermalink(it, false) } ?: ""
val body = bodyForReply(originalEvent.getLastMessageContent(), originalEvent.isReply())
val replyFormatted = REPLY_PATTERN.format(
@@ -350,9 +350,9 @@ internal class LocalEchoEventFactory @Inject constructor(
autoMarkdown: Boolean): Event? {
// Fallbacks and event representation
// TODO Add error/warning logs when any of this is null
- val permalink = permalinkFactory.createPermalink(eventReplied.root) ?: return null
+ val permalink = permalinkFactory.createPermalink(eventReplied.root, false) ?: return null
val userId = eventReplied.root.senderId ?: return null
- val userLink = permalinkFactory.createPermalink(userId) ?: return null
+ val userLink = permalinkFactory.createPermalink(userId, false) ?: return null
val body = bodyForReply(eventReplied.getLastMessageContent(), eventReplied.isReply())
val replyFormatted = REPLY_PATTERN.format(
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/MultipleEventSendingDispatcherWorker.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/MultipleEventSendingDispatcherWorker.kt
index e889f1a61b..16a9eba363 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/MultipleEventSendingDispatcherWorker.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/MultipleEventSendingDispatcherWorker.kt
@@ -38,8 +38,8 @@ import javax.inject.Inject
* Possible previous worker: Always [UploadContentWorker]
* Possible next worker : None, but it will post new work to send events, encrypted or not
*/
-internal class MultipleEventSendingDispatcherWorker(context: Context, params: WorkerParameters)
- : SessionSafeCoroutineWorker(context, params, Params::class.java) {
+internal class MultipleEventSendingDispatcherWorker(context: Context, params: WorkerParameters) :
+ SessionSafeCoroutineWorker(context, params, Params::class.java) {
@JsonClass(generateAdapter = true)
internal data class Params(
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/RedactEventWorker.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/RedactEventWorker.kt
index 306f865408..b4436bfcbf 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/RedactEventWorker.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/RedactEventWorker.kt
@@ -32,8 +32,8 @@ import javax.inject.Inject
* Possible previous worker: None
* Possible next worker : None
*/
-internal class RedactEventWorker(context: Context, params: WorkerParameters)
- : SessionSafeCoroutineWorker(context, params, Params::class.java) {
+internal class RedactEventWorker(context: Context, params: WorkerParameters) :
+ SessionSafeCoroutineWorker(context, params, Params::class.java) {
@JsonClass(generateAdapter = true)
internal data class Params(
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/SendEventWorker.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/SendEventWorker.kt
index cd7911910d..8b7fe4b907 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/SendEventWorker.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/SendEventWorker.kt
@@ -39,8 +39,8 @@ import javax.inject.Inject
* Possible next worker : None
*/
internal class SendEventWorker(context: Context,
- params: WorkerParameters)
- : SessionSafeCoroutineWorker(context, params, Params::class.java) {
+ params: WorkerParameters) :
+ SessionSafeCoroutineWorker(context, params, Params::class.java) {
@JsonClass(generateAdapter = true)
internal data class Params(
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/pills/TextPillsUtils.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/pills/TextPillsUtils.kt
index faf966edf4..33cb0db243 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/pills/TextPillsUtils.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/pills/TextPillsUtils.kt
@@ -17,6 +17,7 @@ package org.matrix.android.sdk.internal.session.room.send.pills
import android.text.SpannableString
import org.matrix.android.sdk.api.session.room.send.MatrixItemSpan
+import org.matrix.android.sdk.internal.session.displayname.DisplayNameResolver
import java.util.Collections
import javax.inject.Inject
@@ -25,7 +26,8 @@ import javax.inject.Inject
* formatted text to send them as a Matrix messages.
*/
internal class TextPillsUtils @Inject constructor(
- private val mentionLinkSpecComparator: MentionLinkSpecComparator
+ private val mentionLinkSpecComparator: MentionLinkSpecComparator,
+ private val displayNameResolver: DisplayNameResolver
) {
/**
@@ -63,7 +65,7 @@ internal class TextPillsUtils @Inject constructor(
// append text before pill
append(text, currIndex, start)
// append the pill
- append(String.format(template, urlSpan.matrixItem.id, urlSpan.matrixItem.getBestName()))
+ append(String.format(template, urlSpan.matrixItem.id, displayNameResolver.getBestName(urlSpan.matrixItem)))
currIndex = end
}
// append text after the last pill
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/queue/EventSenderProcessor.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/queue/EventSenderProcessor.kt
index cd5bf575db..050e321b9c 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/queue/EventSenderProcessor.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/queue/EventSenderProcessor.kt
@@ -16,11 +16,11 @@
package org.matrix.android.sdk.internal.session.room.send.queue
+import org.matrix.android.sdk.api.session.SessionLifecycleObserver
import org.matrix.android.sdk.api.session.events.model.Event
import org.matrix.android.sdk.api.util.Cancelable
-import org.matrix.android.sdk.api.session.SessionLifecycleObserver
-internal interface EventSenderProcessor: SessionLifecycleObserver {
+internal interface EventSenderProcessor : SessionLifecycleObserver {
fun postEvent(event: Event): Cancelable
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/summary/RoomSummaryUpdater.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/summary/RoomSummaryUpdater.kt
index 4a6e27b7c0..30014f4539 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/summary/RoomSummaryUpdater.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/summary/RoomSummaryUpdater.kt
@@ -34,6 +34,8 @@ import org.matrix.android.sdk.api.session.room.model.VersioningState
import org.matrix.android.sdk.api.session.room.model.create.RoomCreateContent
import org.matrix.android.sdk.api.session.room.powerlevels.PowerLevelsHelper
import org.matrix.android.sdk.api.session.room.send.SendState
+import org.matrix.android.sdk.api.session.sync.model.RoomSyncSummary
+import org.matrix.android.sdk.api.session.sync.model.RoomSyncUnreadNotifications
import org.matrix.android.sdk.internal.crypto.EventDecryptor
import org.matrix.android.sdk.internal.crypto.MXCRYPTO_ALGORITHM_MEGOLM
import org.matrix.android.sdk.internal.crypto.crosssigning.DefaultCrossSigningService
@@ -63,8 +65,6 @@ import org.matrix.android.sdk.internal.session.room.accountdata.RoomAccountDataD
import org.matrix.android.sdk.internal.session.room.membership.RoomDisplayNameResolver
import org.matrix.android.sdk.internal.session.room.membership.RoomMemberHelper
import org.matrix.android.sdk.internal.session.room.relationship.RoomChildRelationInfo
-import org.matrix.android.sdk.internal.session.sync.model.RoomSyncSummary
-import org.matrix.android.sdk.internal.session.sync.model.RoomSyncUnreadNotifications
import timber.log.Timber
import javax.inject.Inject
import kotlin.system.measureTimeMillis
@@ -105,8 +105,8 @@ internal class RoomSummaryUpdater @Inject constructor(
}
// Hard to filter from the app now we use PagedList...
- roomSummaryEntity.isHiddenFromUser = roomSummaryEntity.versioningState == VersioningState.UPGRADED_ROOM_JOINED
- || roomAccountDataDataSource.getAccountDataEvent(roomId, RoomAccountDataTypes.EVENT_TYPE_VIRTUAL_ROOM) != null
+ roomSummaryEntity.isHiddenFromUser = roomSummaryEntity.versioningState == VersioningState.UPGRADED_ROOM_JOINED ||
+ roomAccountDataDataSource.getAccountDataEvent(roomId, RoomAccountDataTypes.EVENT_TYPE_VIRTUAL_ROOM) != null
val lastNameEvent = CurrentStateEventEntity.getOrNull(realm, roomId, type = EventType.STATE_ROOM_NAME, stateKey = "")?.root
val lastTopicEvent = CurrentStateEventEntity.getOrNull(realm, roomId, type = EventType.STATE_ROOM_TOPIC, stateKey = "")?.root
@@ -132,9 +132,9 @@ internal class RoomSummaryUpdater @Inject constructor(
roomSummaryEntity.lastActivityTime = lastActivityFromEvent
}
- roomSummaryEntity.hasUnreadMessages = roomSummaryEntity.notificationCount > 0
+ roomSummaryEntity.hasUnreadMessages = roomSummaryEntity.notificationCount > 0 ||
// avoid this call if we are sure there are unread events
- || !isEventRead(realm.configuration, userId, roomId, latestPreviewableEvent?.eventId)
+ !isEventRead(realm.configuration, userId, roomId, latestPreviewableEvent?.eventId)
roomSummaryEntity.displayName = roomDisplayNameResolver.resolve(realm, roomId)
roomSummaryEntity.avatarUrl = roomAvatarResolver.resolve(realm, roomId)
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/tags/DefaultTagsService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/tags/DefaultTagsService.kt
index 02acaa0570..131bd40f1e 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/tags/DefaultTagsService.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/tags/DefaultTagsService.kt
@@ -17,8 +17,8 @@
package org.matrix.android.sdk.internal.session.room.tags
import dagger.assisted.Assisted
-import dagger.assisted.AssistedInject
import dagger.assisted.AssistedFactory
+import dagger.assisted.AssistedInject
import org.matrix.android.sdk.api.session.room.tags.TagsService
internal class DefaultTagsService @AssistedInject constructor(
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 8cc5d943b7..c0e428ec85 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
@@ -475,8 +475,8 @@ internal class DefaultTimeline(
val currentChunk = getLiveChunk()
val token = if (direction == Timeline.Direction.BACKWARDS) currentChunk?.prevToken else currentChunk?.nextToken
if (token == null) {
- if (direction == Timeline.Direction.BACKWARDS
- || (direction == Timeline.Direction.FORWARDS && currentChunk?.hasBeenALastForwardChunk().orFalse())) {
+ if (direction == Timeline.Direction.BACKWARDS ||
+ (direction == Timeline.Direction.FORWARDS && currentChunk?.hasBeenALastForwardChunk().orFalse())) {
// We are in the case where event exists, but we do not know the token.
// Fetch (again) the last event to get a token
val lastKnownEventId = if (direction == Timeline.Direction.FORWARDS) {
@@ -583,8 +583,8 @@ internal class DefaultTimeline(
val transactionId = timelineEvent.root.unsignedData?.transactionId
uiEchoManager.onSyncedEvent(transactionId)
- if (timelineEvent.isEncrypted()
- && timelineEvent.root.mxDecryptionResult == null) {
+ if (timelineEvent.isEncrypted() &&
+ timelineEvent.root.mxDecryptionResult == null) {
timelineEvent.root.eventId?.also { eventDecryptor.requestDecryption(TimelineEventDecryptor.DecryptionRequest(timelineEvent.root, timelineID)) }
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/timeline/LiveTimelineEvent.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/timeline/LiveTimelineEvent.kt
index eb4900553b..64b1a4ff1d 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/timeline/LiveTimelineEvent.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/timeline/LiveTimelineEvent.kt
@@ -40,8 +40,8 @@ internal class LiveTimelineEvent(private val monarchy: Monarchy,
private val coroutineScope: CoroutineScope,
private val timelineEventMapper: TimelineEventMapper,
private val roomId: String,
- private val eventId: String)
- : MediatorLiveData>() {
+ private val eventId: String) :
+ MediatorLiveData>() {
init {
buildAndObserveQuery()
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/timeline/TokenChunkEventPersistor.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/timeline/TokenChunkEventPersistor.kt
index a7cba2fe99..dbcc37a918 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/timeline/TokenChunkEventPersistor.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/timeline/TokenChunkEventPersistor.kt
@@ -238,8 +238,8 @@ internal class TokenChunkEventPersistor @Inject constructor(@SessionDatabase pri
it.deleteOnCascade(deleteStateEvents = false, canDeleteRoot = false)
}
val roomSummaryEntity = RoomSummaryEntity.getOrCreate(realm, roomId)
- val shouldUpdateSummary = roomSummaryEntity.latestPreviewableEvent == null
- || (chunksToDelete.isNotEmpty() && currentChunk.isLastForward && direction == PaginationDirection.FORWARDS)
+ val shouldUpdateSummary = roomSummaryEntity.latestPreviewableEvent == null ||
+ (chunksToDelete.isNotEmpty() && currentChunk.isLastForward && direction == PaginationDirection.FORWARDS)
if (shouldUpdateSummary) {
roomSummaryEntity.latestPreviewableEvent = RoomSummaryEventsHelper.getLatestPreviewableEvent(realm, roomId)
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/tombstone/RoomTombstoneEventProcessor.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/tombstone/RoomTombstoneEventProcessor.kt
index 8022d98975..2b404775f0 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/tombstone/RoomTombstoneEventProcessor.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/tombstone/RoomTombstoneEventProcessor.kt
@@ -16,6 +16,7 @@
package org.matrix.android.sdk.internal.session.room.tombstone
+import io.realm.Realm
import org.matrix.android.sdk.api.session.events.model.Event
import org.matrix.android.sdk.api.session.events.model.EventType
import org.matrix.android.sdk.api.session.events.model.toModel
@@ -25,7 +26,6 @@ import org.matrix.android.sdk.internal.database.model.EventInsertType
import org.matrix.android.sdk.internal.database.model.RoomSummaryEntity
import org.matrix.android.sdk.internal.database.query.where
import org.matrix.android.sdk.internal.session.EventInsertLiveProcessor
-import io.realm.Realm
import javax.inject.Inject
internal class RoomTombstoneEventProcessor @Inject constructor() : EventInsertLiveProcessor {
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/uploads/DefaultUploadsService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/uploads/DefaultUploadsService.kt
index 6d841644dc..99cf36faec 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/uploads/DefaultUploadsService.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/uploads/DefaultUploadsService.kt
@@ -17,8 +17,8 @@
package org.matrix.android.sdk.internal.session.room.uploads
import dagger.assisted.Assisted
-import dagger.assisted.AssistedInject
import dagger.assisted.AssistedFactory
+import dagger.assisted.AssistedInject
import org.matrix.android.sdk.api.session.crypto.CryptoService
import org.matrix.android.sdk.api.session.room.uploads.GetUploadsResult
import org.matrix.android.sdk.api.session.room.uploads.UploadsService
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/signout/SignOutTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/signout/SignOutTask.kt
index 9c25eccb3a..19f34746ab 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/signout/SignOutTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/signout/SignOutTask.kt
@@ -50,9 +50,9 @@ internal class DefaultSignOutTask @Inject constructor(
}
} catch (throwable: Throwable) {
// Maybe due to https://github.com/matrix-org/synapse/issues/5756
- if (throwable is Failure.ServerError
- && throwable.httpCode == HttpURLConnection.HTTP_UNAUTHORIZED /* 401 */
- && throwable.error.code == MatrixError.M_UNKNOWN_TOKEN) {
+ if (throwable is Failure.ServerError &&
+ throwable.httpCode == HttpURLConnection.HTTP_UNAUTHORIZED && /* 401 */
+ throwable.error.code == MatrixError.M_UNKNOWN_TOKEN) {
// Also throwable.error.isSoftLogout should be true
// Ignore
Timber.w("Ignore error due to https://github.com/matrix-org/synapse/issues/5755")
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/space/peeking/PeekSpaceTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/space/peeking/PeekSpaceTask.kt
index 5cbaaa45c4..c45d4420ae 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/space/peeking/PeekSpaceTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/space/peeking/PeekSpaceTask.kt
@@ -76,9 +76,9 @@ internal class DefaultPeekSpaceTask @Inject constructor(
if (depth >= maxDepth) return emptyList()
val childRoomsIds = stateEvents
.filter {
- it.type == EventType.STATE_SPACE_CHILD && !it.stateKey.isNullOrEmpty()
+ it.type == EventType.STATE_SPACE_CHILD && !it.stateKey.isNullOrEmpty() &&
// Children where via is not present are ignored.
- && it.content?.toModel()?.via != null
+ it.content?.toModel()?.via != null
}
.map { it.stateKey to it.content?.toModel() }
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/space/peeking/SpacePeekResult.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/space/peeking/SpacePeekResult.kt
index 44d879f05d..a2ffd8221a 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/space/peeking/SpacePeekResult.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/space/peeking/SpacePeekResult.kt
@@ -28,6 +28,7 @@ data class SpacePeekSummary(
interface ISpaceChild {
val id: String
val roomPeekResult: PeekResult
+
// val default: Boolean?
val order: String?
}
@@ -52,5 +53,5 @@ sealed class SpacePeekResult {
data class FailedToResolve(val spaceId: String, val roomPeekResult: PeekResult) : SpacePeekError()
data class NotSpaceType(val spaceId: String) : SpacePeekError()
- data class Success(val summary: SpacePeekSummary): SpacePeekResult()
+ data class Success(val summary: SpacePeekSummary) : SpacePeekResult()
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/CryptoSyncHandler.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/CryptoSyncHandler.kt
index 411a9c5c06..cec5689a82 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/CryptoSyncHandler.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/CryptoSyncHandler.kt
@@ -21,14 +21,14 @@ import org.matrix.android.sdk.api.session.events.model.Event
import org.matrix.android.sdk.api.session.events.model.EventType
import org.matrix.android.sdk.api.session.events.model.toModel
import org.matrix.android.sdk.api.session.room.model.message.MessageContent
+import org.matrix.android.sdk.api.session.sync.model.SyncResponse
+import org.matrix.android.sdk.api.session.sync.model.ToDeviceSyncResponse
import org.matrix.android.sdk.internal.crypto.DefaultCryptoService
import org.matrix.android.sdk.internal.crypto.MXEventDecryptionResult
import org.matrix.android.sdk.internal.crypto.algorithms.olm.OlmDecryptionResult
import org.matrix.android.sdk.internal.crypto.model.event.OlmEventContent
import org.matrix.android.sdk.internal.crypto.verification.DefaultVerificationService
import org.matrix.android.sdk.internal.session.initsync.ProgressReporter
-import org.matrix.android.sdk.internal.session.sync.model.SyncResponse
-import org.matrix.android.sdk.internal.session.sync.model.ToDeviceSyncResponse
import timber.log.Timber
import javax.inject.Inject
@@ -42,8 +42,8 @@ internal class CryptoSyncHandler @Inject constructor(private val cryptoService:
// Decrypt event if necessary
Timber.i("## CRYPTO | To device event from ${event.senderId} of type:${event.type}")
decryptToDeviceEvent(event, null)
- if (event.getClearType() == EventType.MESSAGE
- && event.getClearContent()?.toModel()?.msgType == "m.bad.encrypted") {
+ if (event.getClearType() == EventType.MESSAGE &&
+ event.getClearContent()?.toModel()?.msgType == "m.bad.encrypted") {
Timber.e("## CRYPTO | handleToDeviceEvent() : Warning: Unable to decrypt to-device event : ${event.content}")
} else {
verificationService.onToDeviceEvent(event)
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/GroupSyncHandler.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/GroupSyncHandler.kt
index 02362bf050..2b054e578f 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/GroupSyncHandler.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/GroupSyncHandler.kt
@@ -19,14 +19,14 @@ package org.matrix.android.sdk.internal.session.sync
import io.realm.Realm
import org.matrix.android.sdk.api.session.initsync.InitSyncStep
import org.matrix.android.sdk.api.session.room.model.Membership
+import org.matrix.android.sdk.api.session.sync.model.GroupsSyncResponse
+import org.matrix.android.sdk.api.session.sync.model.InvitedGroupSync
import org.matrix.android.sdk.internal.database.model.GroupEntity
import org.matrix.android.sdk.internal.database.model.GroupSummaryEntity
import org.matrix.android.sdk.internal.database.query.getOrCreate
import org.matrix.android.sdk.internal.database.query.where
import org.matrix.android.sdk.internal.session.initsync.ProgressReporter
import org.matrix.android.sdk.internal.session.initsync.mapWithProgress
-import org.matrix.android.sdk.internal.session.sync.model.GroupsSyncResponse
-import org.matrix.android.sdk.internal.session.sync.model.InvitedGroupSync
import javax.inject.Inject
internal class GroupSyncHandler @Inject constructor() {
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/InitialSyncStatusRepository.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/InitialSyncStatusRepository.kt
index cf67bbd805..bd20ada28b 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/InitialSyncStatusRepository.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/InitialSyncStatusRepository.kt
@@ -63,8 +63,8 @@ internal class FileInitialSyncStatusRepository(directory: File) : InitialSyncSta
override fun getStep(): Int {
ensureCache()
val state = cache?.step ?: InitialSyncStatus.STEP_INIT
- return if (state >= InitialSyncStatus.STEP_DOWNLOADED
- && System.currentTimeMillis() > (cache?.downloadedDate ?: 0) + INIT_SYNC_FILE_LIFETIME) {
+ return if (state >= InitialSyncStatus.STEP_DOWNLOADED &&
+ System.currentTimeMillis() > (cache?.downloadedDate ?: 0) + INIT_SYNC_FILE_LIFETIME) {
Timber.d("INIT_SYNC downloaded file is outdated, download it again")
// The downloaded file is outdated
setStep(InitialSyncStatus.STEP_INIT)
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/InitialSyncStrategy.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/InitialSyncStrategy.kt
index 7d93e30191..4bc866b36d 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/InitialSyncStrategy.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/InitialSyncStrategy.kt
@@ -39,7 +39,7 @@ sealed class InitialSyncStrategy {
* Limit to reach to decide to split the init sync response into smaller files
* Empiric value: 1 megabytes
*/
- val minSizeToSplit: Long = 1024 * 1024,
+ val minSizeToSplit: Long = 1_048_576, // 1024 * 1024
/**
* Limit per room to reach to decide to store a join room ephemeral Events into a file
* Empiric value: 1 kilobytes
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/RoomFullyReadHandler.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/RoomFullyReadHandler.kt
index e8934fdf21..3d0db212c2 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/RoomFullyReadHandler.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/RoomFullyReadHandler.kt
@@ -16,11 +16,11 @@
package org.matrix.android.sdk.internal.session.sync
+import io.realm.Realm
import org.matrix.android.sdk.internal.database.model.ReadMarkerEntity
import org.matrix.android.sdk.internal.database.model.RoomSummaryEntity
import org.matrix.android.sdk.internal.database.query.getOrCreate
import org.matrix.android.sdk.internal.session.room.read.FullyReadContent
-import io.realm.Realm
import timber.log.Timber
import javax.inject.Inject
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/RoomSyncEphemeralTemporaryStore.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/RoomSyncEphemeralTemporaryStore.kt
index c6ff71cfcf..e8f74bbd48 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/RoomSyncEphemeralTemporaryStore.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/RoomSyncEphemeralTemporaryStore.kt
@@ -20,8 +20,8 @@ import com.squareup.moshi.JsonReader
import com.squareup.moshi.Moshi
import okio.buffer
import okio.source
+import org.matrix.android.sdk.api.session.sync.model.RoomSyncEphemeral
import org.matrix.android.sdk.internal.di.SessionFilesDirectory
-import org.matrix.android.sdk.internal.session.sync.model.RoomSyncEphemeral
import org.matrix.android.sdk.internal.util.md5
import timber.log.Timber
import java.io.File
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/RoomSyncHandler.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/RoomSyncHandler.kt
index 830e666c95..52e5b6b58d 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/RoomSyncHandler.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/RoomSyncHandler.kt
@@ -26,6 +26,10 @@ import org.matrix.android.sdk.api.session.initsync.InitSyncStep
import org.matrix.android.sdk.api.session.room.model.Membership
import org.matrix.android.sdk.api.session.room.model.RoomMemberContent
import org.matrix.android.sdk.api.session.room.send.SendState
+import org.matrix.android.sdk.api.session.sync.model.InvitedRoomSync
+import org.matrix.android.sdk.api.session.sync.model.LazyRoomSyncEphemeral
+import org.matrix.android.sdk.api.session.sync.model.RoomSync
+import org.matrix.android.sdk.api.session.sync.model.RoomsSyncResponse
import org.matrix.android.sdk.internal.crypto.DefaultCryptoService
import org.matrix.android.sdk.internal.crypto.MXCRYPTO_ALGORITHM_MEGOLM
import org.matrix.android.sdk.internal.crypto.algorithms.olm.OlmDecryptionResult
@@ -58,10 +62,6 @@ import org.matrix.android.sdk.internal.session.room.summary.RoomSummaryUpdater
import org.matrix.android.sdk.internal.session.room.timeline.PaginationDirection
import org.matrix.android.sdk.internal.session.room.timeline.TimelineInput
import org.matrix.android.sdk.internal.session.room.typing.TypingEventContent
-import org.matrix.android.sdk.internal.session.sync.model.InvitedRoomSync
-import org.matrix.android.sdk.internal.session.sync.model.LazyRoomSyncEphemeral
-import org.matrix.android.sdk.internal.session.sync.model.RoomSync
-import org.matrix.android.sdk.internal.session.sync.model.RoomsSyncResponse
import org.matrix.android.sdk.internal.session.sync.parsing.RoomSyncAccountDataHandler
import org.matrix.android.sdk.internal.util.computeBestChunkSize
import timber.log.Timber
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/RoomTagHandler.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/RoomTagHandler.kt
index add5d841d1..8997435be4 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/RoomTagHandler.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/RoomTagHandler.kt
@@ -16,10 +16,10 @@
package org.matrix.android.sdk.internal.session.sync
+import io.realm.Realm
import org.matrix.android.sdk.api.session.room.model.tag.RoomTagContent
import org.matrix.android.sdk.internal.database.model.RoomSummaryEntity
import org.matrix.android.sdk.internal.database.model.RoomTagEntity
-import io.realm.Realm
import org.matrix.android.sdk.internal.database.query.getOrCreate
import javax.inject.Inject
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/RoomTypingUsersHandler.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/RoomTypingUsersHandler.kt
index b7851031ad..1433d89143 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/RoomTypingUsersHandler.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/RoomTypingUsersHandler.kt
@@ -16,11 +16,11 @@
package org.matrix.android.sdk.internal.session.sync
+import io.realm.Realm
import org.matrix.android.sdk.api.session.room.sender.SenderInfo
import org.matrix.android.sdk.internal.di.UserId
import org.matrix.android.sdk.internal.session.room.membership.RoomMemberHelper
import org.matrix.android.sdk.internal.session.typing.DefaultTypingUsersTracker
-import io.realm.Realm
import javax.inject.Inject
internal class RoomTypingUsersHandler @Inject constructor(@UserId private val userId: String,
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/SyncAPI.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/SyncAPI.kt
index 2616803463..73ec0aa7ef 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/SyncAPI.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/SyncAPI.kt
@@ -17,9 +17,9 @@
package org.matrix.android.sdk.internal.session.sync
import okhttp3.ResponseBody
+import org.matrix.android.sdk.api.session.sync.model.SyncResponse
import org.matrix.android.sdk.internal.network.NetworkConstants
import org.matrix.android.sdk.internal.network.TimeOutInterceptor
-import org.matrix.android.sdk.internal.session.sync.model.SyncResponse
import retrofit2.Call
import retrofit2.http.GET
import retrofit2.http.Header
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/SyncResponseHandler.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/SyncResponseHandler.kt
index a4468a96c9..8c7401ab47 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/SyncResponseHandler.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/SyncResponseHandler.kt
@@ -21,6 +21,9 @@ import com.zhuinden.monarchy.Monarchy
import org.matrix.android.sdk.api.pushrules.PushRuleService
import org.matrix.android.sdk.api.pushrules.RuleScope
import org.matrix.android.sdk.api.session.initsync.InitSyncStep
+import org.matrix.android.sdk.api.session.sync.model.GroupsSyncResponse
+import org.matrix.android.sdk.api.session.sync.model.RoomsSyncResponse
+import org.matrix.android.sdk.api.session.sync.model.SyncResponse
import org.matrix.android.sdk.internal.crypto.DefaultCryptoService
import org.matrix.android.sdk.internal.di.SessionDatabase
import org.matrix.android.sdk.internal.di.SessionId
@@ -30,9 +33,6 @@ import org.matrix.android.sdk.internal.session.group.GetGroupDataWorker
import org.matrix.android.sdk.internal.session.initsync.ProgressReporter
import org.matrix.android.sdk.internal.session.initsync.reportSubtask
import org.matrix.android.sdk.internal.session.notification.ProcessEventForPushTask
-import org.matrix.android.sdk.internal.session.sync.model.GroupsSyncResponse
-import org.matrix.android.sdk.internal.session.sync.model.RoomsSyncResponse
-import org.matrix.android.sdk.internal.session.sync.model.SyncResponse
import org.matrix.android.sdk.internal.util.awaitTransaction
import org.matrix.android.sdk.internal.worker.WorkerParamsFactory
import timber.log.Timber
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/SyncResponsePostTreatmentAggregator.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/SyncResponsePostTreatmentAggregator.kt
index 9bb2bfc9b1..cc4ccc2e46 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/SyncResponsePostTreatmentAggregator.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/SyncResponsePostTreatmentAggregator.kt
@@ -19,6 +19,7 @@ package org.matrix.android.sdk.internal.session.sync
internal class SyncResponsePostTreatmentAggregator {
// List of RoomId
val ephemeralFilesToDelete = mutableListOf()
+
// Map of roomId to directUserId
val directChatsToCheck = mutableMapOf()
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/SyncTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/SyncTask.kt
index df3d8492c3..621a08a414 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/SyncTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/SyncTask.kt
@@ -20,6 +20,8 @@ import okhttp3.ResponseBody
import org.matrix.android.sdk.api.logger.LoggerTag
import org.matrix.android.sdk.api.session.initsync.InitSyncStep
import org.matrix.android.sdk.api.session.initsync.SyncStatusService
+import org.matrix.android.sdk.api.session.sync.model.LazyRoomSyncEphemeral
+import org.matrix.android.sdk.api.session.sync.model.SyncResponse
import org.matrix.android.sdk.internal.di.SessionFilesDirectory
import org.matrix.android.sdk.internal.di.UserId
import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
@@ -30,7 +32,6 @@ import org.matrix.android.sdk.internal.session.filter.FilterRepository
import org.matrix.android.sdk.internal.session.homeserver.GetHomeServerCapabilitiesTask
import org.matrix.android.sdk.internal.session.initsync.DefaultSyncStatusService
import org.matrix.android.sdk.internal.session.initsync.reportSubtask
-import org.matrix.android.sdk.internal.session.sync.model.LazyRoomSyncEphemeral
import org.matrix.android.sdk.internal.session.sync.parsing.InitialSyncResponseParser
import org.matrix.android.sdk.internal.session.user.UserStore
import org.matrix.android.sdk.internal.task.Task
@@ -44,7 +45,7 @@ import javax.inject.Inject
private val loggerTag = LoggerTag("SyncTask", LoggerTag.SYNC)
-internal interface SyncTask : Task {
+internal interface SyncTask : Task {
data class Params(
val timeout: Long,
@@ -72,13 +73,13 @@ internal class DefaultSyncTask @Inject constructor(
private val workingDir = File(fileDirectory, "is")
private val initialSyncStatusRepository: InitialSyncStatusRepository = FileInitialSyncStatusRepository(workingDir)
- override suspend fun execute(params: SyncTask.Params) {
- syncTaskSequencer.post {
+ override suspend fun execute(params: SyncTask.Params): SyncResponse {
+ return syncTaskSequencer.post {
doSync(params)
}
}
- private suspend fun doSync(params: SyncTask.Params) {
+ private suspend fun doSync(params: SyncTask.Params): SyncResponse {
Timber.tag(loggerTag.value).d("Sync task started on Thread: ${Thread.currentThread().name}")
val requestParams = HashMap()
@@ -103,6 +104,7 @@ internal class DefaultSyncTask @Inject constructor(
val readTimeOut = (params.timeout + TIMEOUT_MARGIN).coerceAtLeast(TimeOutInterceptor.DEFAULT_LONG_TIMEOUT)
+ var syncResponseToReturn: SyncResponse? = null
if (isInitialSync) {
Timber.tag(loggerTag.value).d("INIT_SYNC with filter: ${requestParams["filter"]}")
val initSyncStrategy = initialSyncStrategy
@@ -111,7 +113,7 @@ internal class DefaultSyncTask @Inject constructor(
roomSyncEphemeralTemporaryStore.reset()
workingDir.mkdirs()
val file = downloadInitSyncResponse(requestParams)
- reportSubtask(defaultSyncStatusService, InitSyncStep.ImportingAccount, 1, 0.7F) {
+ syncResponseToReturn = reportSubtask(defaultSyncStatusService, InitSyncStep.ImportingAccount, 1, 0.7F) {
handleSyncFile(file, initSyncStrategy)
}
// Delete all files
@@ -125,10 +127,10 @@ internal class DefaultSyncTask @Inject constructor(
)
}
}
-
logDuration("INIT_SYNC Database insertion", loggerTag) {
syncResponseHandler.handleResponse(syncResponse, token, defaultSyncStatusService)
}
+ syncResponseToReturn = syncResponse
}
}
defaultSyncStatusService.endAll()
@@ -155,10 +157,13 @@ internal class DefaultSyncTask @Inject constructor(
toDevice = nbToDevice
))
syncResponseHandler.handleResponse(syncResponse, token, null)
+ syncResponseToReturn = syncResponse
Timber.tag(loggerTag.value).d("Incremental sync done")
defaultSyncStatusService.setStatus(SyncStatusService.Status.IncrementalSyncDone)
}
Timber.tag(loggerTag.value).d("Sync task finished on Thread: ${Thread.currentThread().name}")
+ // Should throw if null as it's a mandatory value.
+ return syncResponseToReturn!!
}
private suspend fun downloadInitSyncResponse(requestParams: Map): File {
@@ -215,8 +220,8 @@ internal class DefaultSyncTask @Inject constructor(
}
}
- private suspend fun handleSyncFile(workingFile: File, initSyncStrategy: InitialSyncStrategy.Optimized) {
- logDuration("INIT_SYNC handleSyncFile()", loggerTag) {
+ private suspend fun handleSyncFile(workingFile: File, initSyncStrategy: InitialSyncStrategy.Optimized): SyncResponse {
+ return logDuration("INIT_SYNC handleSyncFile()", loggerTag) {
val syncResponse = logDuration("INIT_SYNC Read file and parse", loggerTag) {
syncResponseParser.parse(initSyncStrategy, workingFile)
}
@@ -230,6 +235,7 @@ internal class DefaultSyncTask @Inject constructor(
syncResponseHandler.handleResponse(syncResponse, null, defaultSyncStatusService)
}
initialSyncStatusRepository.setStep(InitialSyncStatus.STEP_SUCCESS)
+ syncResponse
}
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/SyncTokenStore.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/SyncTokenStore.kt
index cf061586b7..35e561a106 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/SyncTokenStore.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/SyncTokenStore.kt
@@ -17,9 +17,9 @@
package org.matrix.android.sdk.internal.session.sync
import com.zhuinden.monarchy.Monarchy
+import io.realm.Realm
import org.matrix.android.sdk.internal.database.model.SyncEntity
import org.matrix.android.sdk.internal.di.SessionDatabase
-import io.realm.Realm
import javax.inject.Inject
internal class SyncTokenStore @Inject constructor(@SessionDatabase private val monarchy: Monarchy) {
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/UserAccountDataSyncHandler.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/UserAccountDataSyncHandler.kt
index 110e77813d..a9926c70aa 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/UserAccountDataSyncHandler.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/UserAccountDataSyncHandler.kt
@@ -29,6 +29,8 @@ import org.matrix.android.sdk.api.session.events.model.Content
import org.matrix.android.sdk.api.session.events.model.toModel
import org.matrix.android.sdk.api.session.room.model.RoomMemberContent
import org.matrix.android.sdk.api.session.room.model.RoomSummary
+import org.matrix.android.sdk.api.session.sync.model.InvitedRoomSync
+import org.matrix.android.sdk.api.session.sync.model.UserAccountDataSync
import org.matrix.android.sdk.internal.database.mapper.ContentMapper
import org.matrix.android.sdk.internal.database.mapper.PushRulesMapper
import org.matrix.android.sdk.internal.database.mapper.asDomain
@@ -48,11 +50,9 @@ import org.matrix.android.sdk.internal.di.UserId
import org.matrix.android.sdk.internal.session.room.RoomAvatarResolver
import org.matrix.android.sdk.internal.session.room.membership.RoomDisplayNameResolver
import org.matrix.android.sdk.internal.session.room.membership.RoomMemberHelper
-import org.matrix.android.sdk.internal.session.sync.model.InvitedRoomSync
import org.matrix.android.sdk.internal.session.sync.model.accountdata.BreadcrumbsContent
import org.matrix.android.sdk.internal.session.sync.model.accountdata.DirectMessagesContent
import org.matrix.android.sdk.internal.session.sync.model.accountdata.IgnoredUsersContent
-import org.matrix.android.sdk.internal.session.sync.model.accountdata.UserAccountDataSync
import org.matrix.android.sdk.internal.session.sync.model.accountdata.toMutable
import org.matrix.android.sdk.internal.session.user.accountdata.DirectChatsHelper
import org.matrix.android.sdk.internal.session.user.accountdata.UpdateUserAccountDataTask
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/job/SyncThread.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/job/SyncThread.kt
index b3a6cafb7d..e1150f2c47 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/job/SyncThread.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/job/SyncThread.kt
@@ -21,25 +21,28 @@ import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.Observer
import com.squareup.moshi.JsonEncodingException
import kotlinx.coroutines.CancellationException
-import org.matrix.android.sdk.api.failure.Failure
-import org.matrix.android.sdk.api.failure.isTokenError
-import org.matrix.android.sdk.api.session.sync.SyncState
-import org.matrix.android.sdk.internal.network.NetworkConnectivityChecker
-import org.matrix.android.sdk.internal.session.sync.SyncTask
-import org.matrix.android.sdk.internal.util.BackgroundDetectionObserver
-import org.matrix.android.sdk.internal.util.Debouncer
-import org.matrix.android.sdk.internal.util.createUIHandler
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.cancelChildren
import kotlinx.coroutines.delay
+import kotlinx.coroutines.flow.MutableSharedFlow
+import kotlinx.coroutines.flow.SharedFlow
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
+import org.matrix.android.sdk.api.failure.Failure
+import org.matrix.android.sdk.api.failure.isTokenError
import org.matrix.android.sdk.api.logger.LoggerTag
import org.matrix.android.sdk.api.session.call.MxCall
+import org.matrix.android.sdk.api.session.sync.SyncState
+import org.matrix.android.sdk.api.session.sync.model.SyncResponse
+import org.matrix.android.sdk.internal.network.NetworkConnectivityChecker
import org.matrix.android.sdk.internal.session.call.ActiveCallHandler
import org.matrix.android.sdk.internal.session.sync.SyncPresence
+import org.matrix.android.sdk.internal.session.sync.SyncTask
+import org.matrix.android.sdk.internal.util.BackgroundDetectionObserver
+import org.matrix.android.sdk.internal.util.Debouncer
+import org.matrix.android.sdk.internal.util.createUIHandler
import timber.log.Timber
import java.net.SocketTimeoutException
import java.util.Timer
@@ -75,6 +78,8 @@ internal class SyncThread @Inject constructor(private val syncTask: SyncTask,
}
}
+ private val _syncFlow = MutableSharedFlow()
+
init {
updateStateTo(SyncState.Idle)
}
@@ -118,6 +123,8 @@ internal class SyncThread @Inject constructor(private val syncTask: SyncTask,
return liveState
}
+ fun syncFlow(): SharedFlow = _syncFlow
+
override fun onConnectivityChanged() {
retryNoNetworkTask?.cancel()
synchronized(lock) {
@@ -195,7 +202,8 @@ internal class SyncThread @Inject constructor(private val syncTask: SyncTask,
private suspend fun doSync(params: SyncTask.Params) {
try {
- syncTask.execute(params)
+ val syncResponse = syncTask.execute(params)
+ _syncFlow.emit(syncResponse)
} catch (failure: Throwable) {
if (failure is Failure.NetworkConnection) {
canReachServer = false
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/parsing/DefaultLazyRoomSyncEphemeralJsonAdapter.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/parsing/DefaultLazyRoomSyncEphemeralJsonAdapter.kt
index 940ea219fb..012470a076 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/parsing/DefaultLazyRoomSyncEphemeralJsonAdapter.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/parsing/DefaultLazyRoomSyncEphemeralJsonAdapter.kt
@@ -21,10 +21,10 @@ import com.squareup.moshi.JsonAdapter
import com.squareup.moshi.JsonReader
import com.squareup.moshi.JsonWriter
import com.squareup.moshi.ToJson
+import org.matrix.android.sdk.api.session.sync.model.LazyRoomSyncEphemeral
+import org.matrix.android.sdk.api.session.sync.model.RoomSyncEphemeral
import org.matrix.android.sdk.internal.session.sync.InitialSyncStrategy
import org.matrix.android.sdk.internal.session.sync.RoomSyncEphemeralTemporaryStore
-import org.matrix.android.sdk.internal.session.sync.model.LazyRoomSyncEphemeral
-import org.matrix.android.sdk.internal.session.sync.model.RoomSyncEphemeral
import timber.log.Timber
internal class DefaultLazyRoomSyncEphemeralJsonAdapter {
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/parsing/InitialSyncResponseParser.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/parsing/InitialSyncResponseParser.kt
index 0b44887aed..f00cce2d5e 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/parsing/InitialSyncResponseParser.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/parsing/InitialSyncResponseParser.kt
@@ -19,9 +19,9 @@ package org.matrix.android.sdk.internal.session.sync.parsing
import com.squareup.moshi.Moshi
import okio.buffer
import okio.source
+import org.matrix.android.sdk.api.session.sync.model.SyncResponse
import org.matrix.android.sdk.internal.session.sync.InitialSyncStrategy
import org.matrix.android.sdk.internal.session.sync.RoomSyncEphemeralTemporaryStore
-import org.matrix.android.sdk.internal.session.sync.model.SyncResponse
import timber.log.Timber
import java.io.File
import javax.inject.Inject
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/parsing/RoomSyncAccountDataHandler.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/parsing/RoomSyncAccountDataHandler.kt
index 8bf9ad5b90..6ca008c5b1 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/parsing/RoomSyncAccountDataHandler.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/parsing/RoomSyncAccountDataHandler.kt
@@ -20,6 +20,7 @@ import io.realm.Realm
import org.matrix.android.sdk.api.session.events.model.toModel
import org.matrix.android.sdk.api.session.room.accountdata.RoomAccountDataTypes
import org.matrix.android.sdk.api.session.room.model.tag.RoomTagContent
+import org.matrix.android.sdk.api.session.sync.model.RoomSyncAccountData
import org.matrix.android.sdk.api.util.JsonDict
import org.matrix.android.sdk.internal.database.mapper.ContentMapper
import org.matrix.android.sdk.internal.database.model.RoomAccountDataEntity
@@ -29,7 +30,6 @@ import org.matrix.android.sdk.internal.database.query.getOrCreate
import org.matrix.android.sdk.internal.session.room.read.FullyReadContent
import org.matrix.android.sdk.internal.session.sync.RoomFullyReadHandler
import org.matrix.android.sdk.internal.session.sync.RoomTagHandler
-import org.matrix.android.sdk.internal.session.sync.model.RoomSyncAccountData
import javax.inject.Inject
internal class RoomSyncAccountDataHandler @Inject constructor(private val roomTagHandler: RoomTagHandler,
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/terms/DefaultTermsService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/terms/DefaultTermsService.kt
index 2c7dc92ddd..d40fd8d076 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/terms/DefaultTermsService.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/terms/DefaultTermsService.kt
@@ -30,8 +30,8 @@ import org.matrix.android.sdk.internal.session.identity.IdentityAuthAPI
import org.matrix.android.sdk.internal.session.identity.IdentityRegisterTask
import org.matrix.android.sdk.internal.session.openid.GetOpenIdTokenTask
import org.matrix.android.sdk.internal.session.sync.model.accountdata.AcceptedTermsContent
-import org.matrix.android.sdk.internal.session.user.accountdata.UserAccountDataDataSource
import org.matrix.android.sdk.internal.session.user.accountdata.UpdateUserAccountDataTask
+import org.matrix.android.sdk.internal.session.user.accountdata.UserAccountDataDataSource
import org.matrix.android.sdk.internal.util.ensureTrailingSlash
import javax.inject.Inject
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/terms/TermsModule.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/terms/TermsModule.kt
index b7cd7a4a97..d7b6f68add 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/terms/TermsModule.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/terms/TermsModule.kt
@@ -20,11 +20,11 @@ import dagger.Binds
import dagger.Lazy
import dagger.Module
import dagger.Provides
+import okhttp3.OkHttpClient
import org.matrix.android.sdk.api.session.terms.TermsService
import org.matrix.android.sdk.internal.di.UnauthenticatedWithCertificate
import org.matrix.android.sdk.internal.network.RetrofitFactory
import org.matrix.android.sdk.internal.session.SessionScope
-import okhttp3.OkHttpClient
@Module
internal abstract class TermsModule {
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/thirdparty/DefaultThirdPartyService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/thirdparty/DefaultThirdPartyService.kt
index 13829c400a..fdd5524fc2 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/thirdparty/DefaultThirdPartyService.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/thirdparty/DefaultThirdPartyService.kt
@@ -22,8 +22,8 @@ import org.matrix.android.sdk.api.session.thirdparty.model.ThirdPartyUser
import javax.inject.Inject
internal class DefaultThirdPartyService @Inject constructor(private val getThirdPartyProtocolTask: GetThirdPartyProtocolsTask,
- private val getThirdPartyUserTask: GetThirdPartyUserTask)
- : ThirdPartyService {
+ private val getThirdPartyUserTask: GetThirdPartyUserTask) :
+ ThirdPartyService {
override suspend fun getThirdPartyProtocols(): Map {
return getThirdPartyProtocolTask.execute(Unit)
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/user/accountdata/DefaultSessionAccountDataService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/user/accountdata/DefaultSessionAccountDataService.kt
index ff1750ce8e..e5c338d511 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/user/accountdata/DefaultSessionAccountDataService.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/user/accountdata/DefaultSessionAccountDataService.kt
@@ -19,13 +19,13 @@ package org.matrix.android.sdk.internal.session.user.accountdata
import androidx.lifecycle.LiveData
import com.zhuinden.monarchy.Monarchy
import org.matrix.android.sdk.api.session.accountdata.SessionAccountDataService
+import org.matrix.android.sdk.api.session.accountdata.UserAccountDataEvent
import org.matrix.android.sdk.api.session.events.model.Content
+import org.matrix.android.sdk.api.session.room.accountdata.RoomAccountDataEvent
import org.matrix.android.sdk.api.util.Optional
import org.matrix.android.sdk.internal.di.SessionDatabase
-import org.matrix.android.sdk.internal.session.sync.UserAccountDataSyncHandler
-import org.matrix.android.sdk.api.session.accountdata.UserAccountDataEvent
-import org.matrix.android.sdk.api.session.room.accountdata.RoomAccountDataEvent
import org.matrix.android.sdk.internal.session.room.accountdata.RoomAccountDataDataSource
+import org.matrix.android.sdk.internal.session.sync.UserAccountDataSyncHandler
import org.matrix.android.sdk.internal.task.TaskExecutor
import org.matrix.android.sdk.internal.task.configureWith
import org.matrix.android.sdk.internal.util.awaitCallback
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/user/accountdata/DirectChatsHelper.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/user/accountdata/DirectChatsHelper.kt
index 3703057643..c7b125b5d6 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/user/accountdata/DirectChatsHelper.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/user/accountdata/DirectChatsHelper.kt
@@ -16,11 +16,11 @@
package org.matrix.android.sdk.internal.session.user.accountdata
+import io.realm.Realm
+import io.realm.RealmConfiguration
import org.matrix.android.sdk.internal.database.model.RoomSummaryEntity
import org.matrix.android.sdk.internal.database.query.getDirectRooms
import org.matrix.android.sdk.internal.di.SessionDatabase
-import io.realm.Realm
-import io.realm.RealmConfiguration
import org.matrix.android.sdk.internal.session.sync.model.accountdata.DirectMessagesContent
import javax.inject.Inject
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/user/accountdata/SaveBreadcrumbsTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/user/accountdata/SaveBreadcrumbsTask.kt
index d6c95d6b52..22af56a169 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/user/accountdata/SaveBreadcrumbsTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/user/accountdata/SaveBreadcrumbsTask.kt
@@ -16,6 +16,7 @@
package org.matrix.android.sdk.internal.session.user.accountdata
import com.zhuinden.monarchy.Monarchy
+import io.realm.RealmList
import org.matrix.android.sdk.api.session.room.model.RoomSummary
import org.matrix.android.sdk.internal.database.model.BreadcrumbsEntity
import org.matrix.android.sdk.internal.database.model.RoomSummaryEntity
@@ -25,7 +26,6 @@ import org.matrix.android.sdk.internal.database.query.where
import org.matrix.android.sdk.internal.di.SessionDatabase
import org.matrix.android.sdk.internal.task.Task
import org.matrix.android.sdk.internal.util.awaitTransaction
-import io.realm.RealmList
import javax.inject.Inject
/**
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/user/accountdata/UpdateUserAccountDataTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/user/accountdata/UpdateUserAccountDataTask.kt
index 1a588d2245..88db381852 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/user/accountdata/UpdateUserAccountDataTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/user/accountdata/UpdateUserAccountDataTask.kt
@@ -16,15 +16,15 @@
package org.matrix.android.sdk.internal.session.user.accountdata
+import org.matrix.android.sdk.api.session.accountdata.UserAccountDataTypes
import org.matrix.android.sdk.internal.di.UserId
+import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
import org.matrix.android.sdk.internal.network.executeRequest
import org.matrix.android.sdk.internal.session.integrationmanager.AllowedWidgetsContent
import org.matrix.android.sdk.internal.session.integrationmanager.IntegrationProvisioningContent
import org.matrix.android.sdk.internal.session.sync.model.accountdata.AcceptedTermsContent
import org.matrix.android.sdk.internal.session.sync.model.accountdata.BreadcrumbsContent
import org.matrix.android.sdk.internal.session.sync.model.accountdata.IdentityServerContent
-import org.matrix.android.sdk.api.session.accountdata.UserAccountDataTypes
-import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
import org.matrix.android.sdk.internal.task.Task
import javax.inject.Inject
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/widgets/DefaultWidgetPostAPIMediator.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/widgets/DefaultWidgetPostAPIMediator.kt
index ba7a2be2a5..07f7c7cb86 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/widgets/DefaultWidgetPostAPIMediator.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/widgets/DefaultWidgetPostAPIMediator.kt
@@ -29,8 +29,8 @@ import java.util.HashMap
import javax.inject.Inject
internal class DefaultWidgetPostAPIMediator @Inject constructor(private val moshi: Moshi,
- private val widgetPostMessageAPIProvider: WidgetPostMessageAPIProvider)
- : WidgetPostAPIMediator {
+ private val widgetPostMessageAPIProvider: WidgetPostMessageAPIProvider) :
+ WidgetPostAPIMediator {
private val jsonAdapter = moshi.adapter(JSON_DICT_PARAMETERIZED_TYPE)
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/widgets/DefaultWidgetService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/widgets/DefaultWidgetService.kt
index dfe4b6b810..89e827aea0 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/widgets/DefaultWidgetService.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/widgets/DefaultWidgetService.kt
@@ -28,8 +28,8 @@ import javax.inject.Provider
internal class DefaultWidgetService @Inject constructor(private val widgetManager: WidgetManager,
private val widgetURLFormatter: WidgetURLFormatter,
- private val widgetPostAPIMediator: Provider)
- : WidgetService {
+ private val widgetPostAPIMediator: Provider) :
+ WidgetService {
override fun getWidgetURLFormatter(): WidgetURLFormatter {
return widgetURLFormatter
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/widgets/DefaultWidgetURLFormatter.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/widgets/DefaultWidgetURLFormatter.kt
index f7664bf3c2..5879b62446 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/widgets/DefaultWidgetURLFormatter.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/widgets/DefaultWidgetURLFormatter.kt
@@ -18,12 +18,12 @@ package org.matrix.android.sdk.internal.session.widgets
import org.matrix.android.sdk.api.MatrixConfiguration
import org.matrix.android.sdk.api.session.Session
+import org.matrix.android.sdk.api.session.SessionLifecycleObserver
import org.matrix.android.sdk.api.session.integrationmanager.IntegrationManagerConfig
import org.matrix.android.sdk.api.session.integrationmanager.IntegrationManagerService
import org.matrix.android.sdk.api.session.widgets.WidgetURLFormatter
import org.matrix.android.sdk.api.util.appendParamToUrl
import org.matrix.android.sdk.api.util.appendParamsToUrl
-import org.matrix.android.sdk.api.session.SessionLifecycleObserver
import org.matrix.android.sdk.internal.session.SessionScope
import org.matrix.android.sdk.internal.session.integrationmanager.IntegrationManager
import org.matrix.android.sdk.internal.session.widgets.token.GetScalarTokenTask
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/widgets/WidgetManager.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/widgets/WidgetManager.kt
index e0f43a11c5..9f5f91d917 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/widgets/WidgetManager.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/widgets/WidgetManager.kt
@@ -23,6 +23,7 @@ import androidx.lifecycle.LiveData
import androidx.lifecycle.Transformations
import org.matrix.android.sdk.api.query.QueryStringValue
import org.matrix.android.sdk.api.session.Session
+import org.matrix.android.sdk.api.session.SessionLifecycleObserver
import org.matrix.android.sdk.api.session.accountdata.UserAccountDataEvent
import org.matrix.android.sdk.api.session.accountdata.UserAccountDataTypes
import org.matrix.android.sdk.api.session.events.model.Content
@@ -35,7 +36,6 @@ import org.matrix.android.sdk.api.session.room.powerlevels.PowerLevelsHelper
import org.matrix.android.sdk.api.session.widgets.WidgetManagementFailure
import org.matrix.android.sdk.api.session.widgets.model.Widget
import org.matrix.android.sdk.internal.di.UserId
-import org.matrix.android.sdk.api.session.SessionLifecycleObserver
import org.matrix.android.sdk.internal.session.SessionScope
import org.matrix.android.sdk.internal.session.integrationmanager.IntegrationManager
import org.matrix.android.sdk.internal.session.room.state.StateEventDataSource
@@ -51,9 +51,9 @@ internal class WidgetManager @Inject constructor(private val integrationManager:
private val stateEventDataSource: StateEventDataSource,
private val createWidgetTask: CreateWidgetTask,
private val widgetFactory: WidgetFactory,
- @UserId private val userId: String)
+ @UserId private val userId: String) :
- : IntegrationManagerService.Listener, SessionLifecycleObserver {
+ IntegrationManagerService.Listener, SessionLifecycleObserver {
private val lifecycleOwner: LifecycleOwner = LifecycleOwner { lifecycleRegistry }
private val lifecycleRegistry: LifecycleRegistry = LifecycleRegistry(lifecycleOwner)
@@ -155,8 +155,8 @@ internal class WidgetManager @Inject constructor(private val integrationManager:
return extractWidgetSequence(widgetFactory)
.filter {
val widgetType = it.widgetContent.type ?: return@filter false
- (widgetTypes == null || widgetTypes.contains(widgetType))
- && (excludedTypes == null || !excludedTypes.contains(widgetType))
+ (widgetTypes == null || widgetTypes.contains(widgetType)) &&
+ (excludedTypes == null || !excludedTypes.contains(widgetType))
}
.toList()
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/widgets/WidgetsAPIProvider.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/widgets/WidgetsAPIProvider.kt
index 7f79f44767..48c8fcdb03 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/widgets/WidgetsAPIProvider.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/widgets/WidgetsAPIProvider.kt
@@ -17,10 +17,10 @@
package org.matrix.android.sdk.internal.session.widgets
import dagger.Lazy
+import okhttp3.OkHttpClient
import org.matrix.android.sdk.internal.di.Unauthenticated
import org.matrix.android.sdk.internal.network.RetrofitFactory
import org.matrix.android.sdk.internal.session.SessionScope
-import okhttp3.OkHttpClient
import javax.inject.Inject
@SessionScope
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/widgets/helper/UserAccountWidgets.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/widgets/helper/UserAccountWidgets.kt
index 6f423b38a0..21fbb77667 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/widgets/helper/UserAccountWidgets.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/widgets/helper/UserAccountWidgets.kt
@@ -16,11 +16,11 @@
package org.matrix.android.sdk.internal.session.widgets.helper
+import org.matrix.android.sdk.api.session.accountdata.UserAccountDataEvent
import org.matrix.android.sdk.api.session.events.model.Event
import org.matrix.android.sdk.api.session.events.model.toModel
-import org.matrix.android.sdk.api.util.JsonDict
-import org.matrix.android.sdk.api.session.accountdata.UserAccountDataEvent
import org.matrix.android.sdk.api.session.widgets.model.Widget
+import org.matrix.android.sdk.api.util.JsonDict
internal fun UserAccountDataEvent.extractWidgetSequence(widgetFactory: WidgetFactory): Sequence {
return content.asSequence()
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/widgets/helper/WidgetFactory.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/widgets/helper/WidgetFactory.kt
index a469a9fe97..a5e74a8af0 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/widgets/helper/WidgetFactory.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/widgets/helper/WidgetFactory.kt
@@ -20,11 +20,14 @@ import org.matrix.android.sdk.api.session.content.ContentUrlResolver
import org.matrix.android.sdk.api.session.events.model.Event
import org.matrix.android.sdk.api.session.events.model.toModel
import org.matrix.android.sdk.api.session.room.sender.SenderInfo
+import org.matrix.android.sdk.api.session.user.model.User
import org.matrix.android.sdk.api.session.widgets.model.Widget
import org.matrix.android.sdk.api.session.widgets.model.WidgetContent
import org.matrix.android.sdk.api.session.widgets.model.WidgetType
+import org.matrix.android.sdk.api.util.toMatrixItem
import org.matrix.android.sdk.internal.database.RealmSessionProvider
import org.matrix.android.sdk.internal.di.UserId
+import org.matrix.android.sdk.internal.session.displayname.DisplayNameResolver
import org.matrix.android.sdk.internal.session.room.membership.RoomMemberHelper
import org.matrix.android.sdk.internal.session.user.UserDataSource
import java.net.URLEncoder
@@ -32,6 +35,7 @@ import javax.inject.Inject
internal class WidgetFactory @Inject constructor(private val userDataSource: UserDataSource,
private val realmSessionProvider: RealmSessionProvider,
+ private val displayNameResolver: DisplayNameResolver,
private val urlResolver: ContentUrlResolver,
@UserId private val userId: String) {
@@ -68,13 +72,13 @@ internal class WidgetFactory @Inject constructor(private val userDataSource: Use
// Ref: https://github.com/matrix-org/matrix-widget-api/blob/master/src/templating/url-template.ts#L29-L33
fun computeURL(widget: Widget, isLightTheme: Boolean): String? {
var computedUrl = widget.widgetContent.url ?: return null
- val myUser = userDataSource.getUser(userId)
+ val myUser = userDataSource.getUser(userId) ?: User(userId)
val keyValue = widget.widgetContent.data.mapKeys { "\$${it.key}" }.toMutableMap()
keyValue[WIDGET_PATTERN_MATRIX_USER_ID] = userId
- keyValue[WIDGET_PATTERN_MATRIX_DISPLAY_NAME] = myUser?.getBestName() ?: userId
- keyValue[WIDGET_PATTERN_MATRIX_AVATAR_URL] = urlResolver.resolveFullSize(myUser?.avatarUrl) ?: ""
+ keyValue[WIDGET_PATTERN_MATRIX_DISPLAY_NAME] = displayNameResolver.getBestName(myUser.toMatrixItem())
+ keyValue[WIDGET_PATTERN_MATRIX_AVATAR_URL] = urlResolver.resolveFullSize(myUser.avatarUrl) ?: ""
keyValue[WIDGET_PATTERN_MATRIX_WIDGET_ID] = widget.widgetId
keyValue[WIDGET_PATTERN_MATRIX_ROOM_ID] = widget.event.roomId ?: ""
keyValue[WIDGET_PATTERN_THEME] = getTheme(isLightTheme)
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/widgets/token/GetScalarTokenTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/widgets/token/GetScalarTokenTask.kt
index 78a40d1977..17797cad52 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/widgets/token/GetScalarTokenTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/widgets/token/GetScalarTokenTask.kt
@@ -18,9 +18,9 @@ package org.matrix.android.sdk.internal.session.widgets.token
import org.matrix.android.sdk.api.failure.Failure
import org.matrix.android.sdk.api.failure.MatrixError
+import org.matrix.android.sdk.api.session.widgets.WidgetManagementFailure
import org.matrix.android.sdk.internal.network.executeRequest
import org.matrix.android.sdk.internal.session.openid.GetOpenIdTokenTask
-import org.matrix.android.sdk.api.session.widgets.WidgetManagementFailure
import org.matrix.android.sdk.internal.session.widgets.WidgetsAPI
import org.matrix.android.sdk.internal.session.widgets.WidgetsAPIProvider
import org.matrix.android.sdk.internal.task.Task
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/task/CoroutineToCallback.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/task/CoroutineToCallback.kt
index ca4b092e07..de6981ec03 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/task/CoroutineToCallback.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/task/CoroutineToCallback.kt
@@ -16,15 +16,15 @@
package org.matrix.android.sdk.internal.task
-import org.matrix.android.sdk.api.MatrixCallback
-import org.matrix.android.sdk.api.util.Cancelable
-import org.matrix.android.sdk.internal.extensions.foldToCallback
-import org.matrix.android.sdk.internal.util.toCancelable
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.CoroutineStart
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
+import org.matrix.android.sdk.api.MatrixCallback
+import org.matrix.android.sdk.api.util.Cancelable
+import org.matrix.android.sdk.internal.extensions.foldToCallback
+import org.matrix.android.sdk.internal.util.toCancelable
import kotlin.coroutines.CoroutineContext
import kotlin.coroutines.EmptyCoroutineContext
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/task/Task.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/task/Task.kt
index a5d031e02a..01066a6f7c 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/task/Task.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/task/Task.kt
@@ -25,7 +25,7 @@ internal interface Task {
suspend fun execute(params: PARAMS): RESULT
- suspend fun executeRetry(params: PARAMS, remainingRetry: Int) : RESULT {
+ suspend fun executeRetry(params: PARAMS, remainingRetry: Int): RESULT {
return try {
execute(params)
} catch (failure: Throwable) {
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/task/TaskExecutor.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/task/TaskExecutor.kt
index 4da16eff22..86848d1018 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/task/TaskExecutor.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/task/TaskExecutor.kt
@@ -16,16 +16,16 @@
package org.matrix.android.sdk.internal.task
-import org.matrix.android.sdk.api.util.Cancelable
-import org.matrix.android.sdk.internal.di.MatrixScope
-import org.matrix.android.sdk.internal.extensions.foldToCallback
-import org.matrix.android.sdk.internal.util.MatrixCoroutineDispatchers
-import org.matrix.android.sdk.internal.util.toCancelable
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.cancelChildren
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
+import org.matrix.android.sdk.api.util.Cancelable
+import org.matrix.android.sdk.internal.di.MatrixScope
+import org.matrix.android.sdk.internal.extensions.foldToCallback
+import org.matrix.android.sdk.internal.util.MatrixCoroutineDispatchers
+import org.matrix.android.sdk.internal.util.toCancelable
import timber.log.Timber
import javax.inject.Inject
import kotlin.coroutines.EmptyCoroutineContext
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/util/CancelableCoroutine.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/util/CancelableCoroutine.kt
index 860cf66c78..f398ee25d8 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/util/CancelableCoroutine.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/util/CancelableCoroutine.kt
@@ -16,8 +16,8 @@
package org.matrix.android.sdk.internal.util
-import org.matrix.android.sdk.api.util.Cancelable
import kotlinx.coroutines.Job
+import org.matrix.android.sdk.api.util.Cancelable
internal fun Job.toCancelable(): Cancelable {
return CancelableCoroutine(this)
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/util/JsonCanonicalizer.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/util/JsonCanonicalizer.kt
index 7b45bab365..a34b91a70b 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/util/JsonCanonicalizer.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/util/JsonCanonicalizer.kt
@@ -17,10 +17,10 @@
package org.matrix.android.sdk.internal.util
import androidx.annotation.VisibleForTesting
-import org.matrix.android.sdk.internal.di.MoshiProvider
import org.json.JSONArray
import org.json.JSONException
import org.json.JSONObject
+import org.matrix.android.sdk.internal.di.MoshiProvider
import timber.log.Timber
import java.util.TreeSet
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/util/StringUtils.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/util/StringUtils.kt
index aa0b92aa45..8a6ec18986 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/util/StringUtils.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/util/StringUtils.kt
@@ -78,7 +78,7 @@ internal val spaceChars = "[\u00A0\u2000-\u200B\u2800\u3000]".toRegex()
/**
* Strip all the UTF-8 chars which are actually spaces
*/
-internal fun String.replaceSpaceChars() = replace(spaceChars, "")
+internal fun String.replaceSpaceChars(replacement: String = "") = replace(spaceChars, replacement)
// String.capitalize is now deprecated
internal fun String.safeCapitalize(): String {
@@ -90,3 +90,5 @@ internal fun String.safeCapitalize(): String {
}
}
}
+
+internal fun String.removeInvalidRoomNameChars() = "[^a-z0-9._%#@=+-]".toRegex().replace(this, "")
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/util/system/DefaultBuildVersionSdkIntProvider.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/util/system/DefaultBuildVersionSdkIntProvider.kt
index d9f0064f38..2d5e4b944a 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/util/system/DefaultBuildVersionSdkIntProvider.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/util/system/DefaultBuildVersionSdkIntProvider.kt
@@ -19,7 +19,7 @@ package org.matrix.android.sdk.internal.util.system
import android.os.Build
import javax.inject.Inject
-internal class DefaultBuildVersionSdkIntProvider @Inject constructor()
- : BuildVersionSdkIntProvider {
+internal class DefaultBuildVersionSdkIntProvider @Inject constructor() :
+ BuildVersionSdkIntProvider {
override fun get() = Build.VERSION.SDK_INT
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/wellknown/GetWellknownTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/wellknown/GetWellknownTask.kt
index f11e87e1e7..82ff9a321f 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/wellknown/GetWellknownTask.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/wellknown/GetWellknownTask.kt
@@ -18,6 +18,7 @@ package org.matrix.android.sdk.internal.wellknown
import android.util.MalformedJsonException
import dagger.Lazy
+import okhttp3.OkHttpClient
import org.matrix.android.sdk.api.auth.data.HomeServerConnectionConfig
import org.matrix.android.sdk.api.auth.data.WellKnown
import org.matrix.android.sdk.api.auth.wellknown.WellknownResult
@@ -31,7 +32,6 @@ import org.matrix.android.sdk.internal.session.homeserver.CapabilitiesAPI
import org.matrix.android.sdk.internal.session.identity.IdentityAuthAPI
import org.matrix.android.sdk.internal.task.Task
import org.matrix.android.sdk.internal.util.isValidUrl
-import okhttp3.OkHttpClient
import java.io.EOFException
import javax.inject.Inject
import javax.net.ssl.HttpsURLConnection
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/worker/AlwaysSuccessfulWorker.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/worker/AlwaysSuccessfulWorker.kt
index 3506a76f75..856d3debcf 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/worker/AlwaysSuccessfulWorker.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/worker/AlwaysSuccessfulWorker.kt
@@ -19,8 +19,8 @@ import android.content.Context
import androidx.work.Worker
import androidx.work.WorkerParameters
-internal class AlwaysSuccessfulWorker(context: Context, params: WorkerParameters)
- : Worker(context, params) {
+internal class AlwaysSuccessfulWorker(context: Context, params: WorkerParameters) :
+ Worker(context, params) {
override fun doWork(): Result {
return Result.success()
diff --git a/matrix-sdk-android/src/release/java/org/matrix/android/sdk/internal/network/interceptors/CurlLoggingInterceptor.kt b/matrix-sdk-android/src/release/java/org/matrix/android/sdk/internal/network/interceptors/CurlLoggingInterceptor.kt
index f46e2ca35b..47f6869479 100644
--- a/matrix-sdk-android/src/release/java/org/matrix/android/sdk/internal/network/interceptors/CurlLoggingInterceptor.kt
+++ b/matrix-sdk-android/src/release/java/org/matrix/android/sdk/internal/network/interceptors/CurlLoggingInterceptor.kt
@@ -26,8 +26,8 @@ import javax.inject.Inject
* No op interceptor
*/
@MatrixScope
-internal class CurlLoggingInterceptor @Inject constructor()
- : Interceptor {
+internal class CurlLoggingInterceptor @Inject constructor() :
+ Interceptor {
@Throws(IOException::class)
override fun intercept(chain: Interceptor.Chain): Response {
diff --git a/matrix-sdk-android/src/test/java/org/matrix/android/sdk/MatrixTest.kt b/matrix-sdk-android/src/test/java/org/matrix/android/sdk/MatrixTest.kt
index f6a7f525db..84f09eb184 100644
--- a/matrix-sdk-android/src/test/java/org/matrix/android/sdk/MatrixTest.kt
+++ b/matrix-sdk-android/src/test/java/org/matrix/android/sdk/MatrixTest.kt
@@ -16,8 +16,8 @@
package org.matrix.android.sdk
-import org.matrix.android.sdk.test.shared.createTimberTestRule
import org.junit.Rule
+import org.matrix.android.sdk.test.shared.createTimberTestRule
interface MatrixTest {
diff --git a/matrix-sdk-android/src/test/java/org/matrix/android/sdk/api/auth/data/VersionsKtTest.kt b/matrix-sdk-android/src/test/java/org/matrix/android/sdk/api/auth/data/VersionsKtTest.kt
index c413d9ccae..96655b849d 100644
--- a/matrix-sdk-android/src/test/java/org/matrix/android/sdk/api/auth/data/VersionsKtTest.kt
+++ b/matrix-sdk-android/src/test/java/org/matrix/android/sdk/api/auth/data/VersionsKtTest.kt
@@ -16,10 +16,10 @@
package org.matrix.android.sdk.api.auth.data
-import org.matrix.android.sdk.internal.auth.version.Versions
-import org.matrix.android.sdk.internal.auth.version.isSupportedBySdk
import org.amshove.kluent.shouldBe
import org.junit.Test
+import org.matrix.android.sdk.internal.auth.version.Versions
+import org.matrix.android.sdk.internal.auth.version.isSupportedBySdk
class VersionsKtTest {
diff --git a/matrix-sdk-android/src/test/java/org/matrix/android/sdk/api/pushrules/PushRuleActionsTest.kt b/matrix-sdk-android/src/test/java/org/matrix/android/sdk/api/pushrules/PushRuleActionsTest.kt
index b734444990..9bfdea5414 100644
--- a/matrix-sdk-android/src/test/java/org/matrix/android/sdk/api/pushrules/PushRuleActionsTest.kt
+++ b/matrix-sdk-android/src/test/java/org/matrix/android/sdk/api/pushrules/PushRuleActionsTest.kt
@@ -16,15 +16,15 @@
package org.matrix.android.sdk.api.pushrules
-import org.matrix.android.sdk.MatrixTest
-import org.matrix.android.sdk.api.pushrules.rest.PushRule
-import org.matrix.android.sdk.internal.di.MoshiProvider
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertTrue
import org.junit.Test
+import org.matrix.android.sdk.MatrixTest
+import org.matrix.android.sdk.api.pushrules.rest.PushRule
+import org.matrix.android.sdk.internal.di.MoshiProvider
-class PushRuleActionsTest: MatrixTest {
+class PushRuleActionsTest : MatrixTest {
@Test
fun test_action_parsing() {
diff --git a/matrix-sdk-android/src/test/java/org/matrix/android/sdk/internal/crypto/keysbackup/util/Base58Test.kt b/matrix-sdk-android/src/test/java/org/matrix/android/sdk/internal/crypto/keysbackup/util/Base58Test.kt
index 2f01a43a67..a93883a344 100644
--- a/matrix-sdk-android/src/test/java/org/matrix/android/sdk/internal/crypto/keysbackup/util/Base58Test.kt
+++ b/matrix-sdk-android/src/test/java/org/matrix/android/sdk/internal/crypto/keysbackup/util/Base58Test.kt
@@ -16,15 +16,15 @@
package org.matrix.android.sdk.internal.crypto.keysbackup.util
-import org.matrix.android.sdk.MatrixTest
import org.junit.Assert.assertArrayEquals
import org.junit.Assert.assertEquals
import org.junit.FixMethodOrder
import org.junit.Test
import org.junit.runners.MethodSorters
+import org.matrix.android.sdk.MatrixTest
@FixMethodOrder(MethodSorters.JVM)
-class Base58Test: MatrixTest {
+class Base58Test : MatrixTest {
@Test
fun encode() {
diff --git a/matrix-sdk-android/src/test/java/org/matrix/android/sdk/internal/crypto/keysbackup/util/RecoveryKeyTest.kt b/matrix-sdk-android/src/test/java/org/matrix/android/sdk/internal/crypto/keysbackup/util/RecoveryKeyTest.kt
index 64ffe52acd..4e4548b197 100644
--- a/matrix-sdk-android/src/test/java/org/matrix/android/sdk/internal/crypto/keysbackup/util/RecoveryKeyTest.kt
+++ b/matrix-sdk-android/src/test/java/org/matrix/android/sdk/internal/crypto/keysbackup/util/RecoveryKeyTest.kt
@@ -16,14 +16,14 @@
package org.matrix.android.sdk.internal.crypto.keysbackup.util
-import org.matrix.android.sdk.MatrixTest
import org.junit.Assert.assertArrayEquals
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
import org.junit.Test
+import org.matrix.android.sdk.MatrixTest
-class RecoveryKeyTest: MatrixTest {
+class RecoveryKeyTest : MatrixTest {
private val curve25519Key = byteArrayOf(
0x77.toByte(), 0x07.toByte(), 0x6D.toByte(), 0x0A.toByte(), 0x73.toByte(), 0x18.toByte(), 0xA5.toByte(), 0x7D.toByte(),
diff --git a/matrix-sdk-android/src/test/java/org/matrix/android/sdk/internal/crypto/store/db/HelperTest.kt b/matrix-sdk-android/src/test/java/org/matrix/android/sdk/internal/crypto/store/db/HelperTest.kt
index 0bcc7983c5..b50d0581b0 100644
--- a/matrix-sdk-android/src/test/java/org/matrix/android/sdk/internal/crypto/store/db/HelperTest.kt
+++ b/matrix-sdk-android/src/test/java/org/matrix/android/sdk/internal/crypto/store/db/HelperTest.kt
@@ -16,12 +16,12 @@
package org.matrix.android.sdk.internal.crypto.store.db
-import org.matrix.android.sdk.MatrixTest
-import org.matrix.android.sdk.internal.util.md5
import org.junit.Assert.assertEquals
import org.junit.Test
+import org.matrix.android.sdk.MatrixTest
+import org.matrix.android.sdk.internal.util.md5
-class HelperTest: MatrixTest {
+class HelperTest : MatrixTest {
@Test
fun testHash_ok() {
diff --git a/matrix-sdk-android/src/test/java/org/matrix/android/sdk/internal/crypto/verification/qrcode/BinaryStringTest.kt b/matrix-sdk-android/src/test/java/org/matrix/android/sdk/internal/crypto/verification/qrcode/BinaryStringTest.kt
index b04834f9f4..5a82052d1a 100644
--- a/matrix-sdk-android/src/test/java/org/matrix/android/sdk/internal/crypto/verification/qrcode/BinaryStringTest.kt
+++ b/matrix-sdk-android/src/test/java/org/matrix/android/sdk/internal/crypto/verification/qrcode/BinaryStringTest.kt
@@ -16,11 +16,11 @@
package org.matrix.android.sdk.internal.crypto.verification.qrcode
-import org.matrix.android.sdk.MatrixTest
import org.amshove.kluent.shouldBeEqualTo
import org.junit.FixMethodOrder
import org.junit.Test
import org.junit.runners.MethodSorters
+import org.matrix.android.sdk.MatrixTest
@FixMethodOrder(MethodSorters.JVM)
class BinaryStringTest : MatrixTest {
diff --git a/matrix-sdk-android/src/test/java/org/matrix/android/sdk/internal/task/CoroutineSequencersTest.kt b/matrix-sdk-android/src/test/java/org/matrix/android/sdk/internal/task/CoroutineSequencersTest.kt
index 3572a1a546..0abca8bee3 100644
--- a/matrix-sdk-android/src/test/java/org/matrix/android/sdk/internal/task/CoroutineSequencersTest.kt
+++ b/matrix-sdk-android/src/test/java/org/matrix/android/sdk/internal/task/CoroutineSequencersTest.kt
@@ -16,7 +16,6 @@
package org.matrix.android.sdk.internal.task
-import org.matrix.android.sdk.MatrixTest
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.asCoroutineDispatcher
import kotlinx.coroutines.delay
@@ -25,9 +24,10 @@ import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import org.junit.Assert.assertEquals
import org.junit.Test
+import org.matrix.android.sdk.MatrixTest
import java.util.concurrent.Executors
-class CoroutineSequencersTest: MatrixTest {
+class CoroutineSequencersTest : MatrixTest {
private val dispatcher = Executors.newSingleThreadExecutor().asCoroutineDispatcher()
diff --git a/tools/check/forbidden_strings_in_code.txt b/tools/check/forbidden_strings_in_code.txt
index 4b0dd1f0a3..8f8625fe1c 100644
--- a/tools/check/forbidden_strings_in_code.txt
+++ b/tools/check/forbidden_strings_in_code.txt
@@ -141,8 +141,6 @@ android\.app\.AlertDialog
androidx\.appcompat\.app\.AlertDialog===4
### Put the operator at the beginning of next line
-&&$
-\|\|$
==$
### Use JsonUtils.getBasicGson()
diff --git a/vector/build.gradle b/vector/build.gradle
index 903798ce55..b3cf745584 100644
--- a/vector/build.gradle
+++ b/vector/build.gradle
@@ -14,7 +14,7 @@ kapt {
// Note: 2 digits max for each value
ext.versionMajor = 1
ext.versionMinor = 3
-ext.versionPatch = 1
+ext.versionPatch = 2
static def getGitTimestamp() {
def cmd = 'git show -s --format=%ct'
@@ -361,7 +361,7 @@ dependencies {
implementation 'com.facebook.stetho:stetho:1.6.0'
// Phone number https://github.com/google/libphonenumber
- implementation 'com.googlecode.libphonenumber:libphonenumber:8.12.33'
+ implementation 'com.googlecode.libphonenumber:libphonenumber:8.12.34'
// rx
implementation libs.rx.rxKotlin
@@ -412,7 +412,7 @@ dependencies {
implementation 'com.nulab-inc:zxcvbn:1.5.2'
// To convert voice message on old platforms
- implementation 'com.arthenica:ffmpeg-kit-audio:4.4.LTS'
+ implementation 'com.arthenica:ffmpeg-kit-audio:4.5.LTS'
// Alerter
implementation 'com.tapadoo.android:alerter:7.0.1'
diff --git a/vector/src/androidTest/java/im/vector/app/EspressoExt.kt b/vector/src/androidTest/java/im/vector/app/EspressoExt.kt
index d247d88caa..823ce83015 100644
--- a/vector/src/androidTest/java/im/vector/app/EspressoExt.kt
+++ b/vector/src/androidTest/java/im/vector/app/EspressoExt.kt
@@ -129,7 +129,7 @@ fun activityIdlingResource(activityClass: Class<*>): IdlingResource {
private var callback: IdlingResource.ResourceCallback? = null
var hasResumed = false
- private var currentActivity : Activity? = null
+ private var currentActivity: Activity? = null
val uniqTS = System.currentTimeMillis()
override fun getName() = "activityIdlingResource_${activityClass.name}_$uniqTS"
diff --git a/vector/src/androidTest/java/im/vector/app/VerifySessionInteractiveTest.kt b/vector/src/androidTest/java/im/vector/app/VerifySessionInteractiveTest.kt
index 571bcf474c..982a421425 100644
--- a/vector/src/androidTest/java/im/vector/app/VerifySessionInteractiveTest.kt
+++ b/vector/src/androidTest/java/im/vector/app/VerifySessionInteractiveTest.kt
@@ -44,14 +44,14 @@ import org.junit.runner.RunWith
import org.matrix.android.sdk.api.Matrix
import org.matrix.android.sdk.api.auth.UIABaseAuth
import org.matrix.android.sdk.api.auth.UserInteractiveAuthInterceptor
+import org.matrix.android.sdk.api.auth.UserPasswordAuth
+import org.matrix.android.sdk.api.auth.registration.RegistrationFlowResponse
import org.matrix.android.sdk.api.session.Session
import org.matrix.android.sdk.api.session.crypto.verification.SasVerificationTransaction
import org.matrix.android.sdk.api.session.crypto.verification.VerificationMethod
import org.matrix.android.sdk.api.session.crypto.verification.VerificationService
import org.matrix.android.sdk.api.session.crypto.verification.VerificationTransaction
import org.matrix.android.sdk.api.session.crypto.verification.VerificationTxState
-import org.matrix.android.sdk.api.auth.UserPasswordAuth
-import org.matrix.android.sdk.api.auth.registration.RegistrationFlowResponse
import kotlin.coroutines.Continuation
import kotlin.coroutines.resume
diff --git a/vector/src/androidTest/java/im/vector/app/espresso/tools/EspressoPreference.kt b/vector/src/androidTest/java/im/vector/app/espresso/tools/EspressoPreference.kt
index bf60ad681f..178b9fb9f6 100644
--- a/vector/src/androidTest/java/im/vector/app/espresso/tools/EspressoPreference.kt
+++ b/vector/src/androidTest/java/im/vector/app/espresso/tools/EspressoPreference.kt
@@ -30,9 +30,9 @@ import androidx.test.espresso.matcher.ViewMatchers.withClassName
import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.espresso.matcher.ViewMatchers.withText
import im.vector.app.R
-import org.hamcrest.Matchers.`is`
import org.hamcrest.Matchers.allOf
import org.hamcrest.Matchers.instanceOf
+import org.hamcrest.Matchers.`is`
fun clickOnPreference(@StringRes textResId: Int) {
onView(withId(R.id.recycler_view))
diff --git a/vector/src/androidTest/java/im/vector/app/ui/UiAllScreensSanityTest.kt b/vector/src/androidTest/java/im/vector/app/ui/UiAllScreensSanityTest.kt
index aef5d3fe49..a9cb5274ed 100644
--- a/vector/src/androidTest/java/im/vector/app/ui/UiAllScreensSanityTest.kt
+++ b/vector/src/androidTest/java/im/vector/app/ui/UiAllScreensSanityTest.kt
@@ -226,7 +226,7 @@ class UiAllScreensSanityTest {
// Filter
// TODO clickMenu(R.id.search)
// Wait for emoji to load, it's async now
- sleep(1_000)
+ sleep(2_000)
clickListItem(R.id.emojiRecyclerView, 4)
// Test Edit mode
diff --git a/vector/src/debug/java/im/vector/app/features/debug/DebugMenuActivity.kt b/vector/src/debug/java/im/vector/app/features/debug/DebugMenuActivity.kt
index 4b5228d199..303a3a14ba 100644
--- a/vector/src/debug/java/im/vector/app/features/debug/DebugMenuActivity.kt
+++ b/vector/src/debug/java/im/vector/app/features/debug/DebugMenuActivity.kt
@@ -235,8 +235,8 @@ class DebugMenuActivity : VectorBaseActivity() {
private val qrStartForActivityResult = registerStartForActivityResult { activityResult ->
if (activityResult.resultCode == Activity.RESULT_OK) {
- toast("QrCode: " + QrCodeScannerActivity.getResultText(activityResult.data)
- + " is QRCode: " + QrCodeScannerActivity.getResultIsQrCode(activityResult.data))
+ toast("QrCode: " + QrCodeScannerActivity.getResultText(activityResult.data) +
+ " is QRCode: " + QrCodeScannerActivity.getResultIsQrCode(activityResult.data))
// Also update the current QR Code (reverse operation)
// renderQrCode(QrCodeScannerActivity.getResultText(data) ?: "")
diff --git a/vector/src/debug/java/im/vector/app/features/debug/sas/SasEmojiItem.kt b/vector/src/debug/java/im/vector/app/features/debug/sas/SasEmojiItem.kt
index 408aebb186..a7b74f3b59 100644
--- a/vector/src/debug/java/im/vector/app/features/debug/sas/SasEmojiItem.kt
+++ b/vector/src/debug/java/im/vector/app/features/debug/sas/SasEmojiItem.kt
@@ -23,9 +23,9 @@ import com.airbnb.epoxy.EpoxyAttribute
import com.airbnb.epoxy.EpoxyModelClass
import im.vector.app.core.epoxy.VectorEpoxyHolder
import im.vector.app.core.epoxy.VectorEpoxyModel
-import org.matrix.android.sdk.api.session.crypto.verification.EmojiRepresentation
import me.gujun.android.span.image
import me.gujun.android.span.span
+import org.matrix.android.sdk.api.session.crypto.verification.EmojiRepresentation
@EpoxyModelClass(layout = im.vector.app.R.layout.item_sas_emoji)
abstract class SasEmojiItem : VectorEpoxyModel() {
diff --git a/vector/src/fdroid/java/im/vector/app/fdroid/features/settings/troubleshoot/TestAutoStartBoot.kt b/vector/src/fdroid/java/im/vector/app/fdroid/features/settings/troubleshoot/TestAutoStartBoot.kt
index e46a07f712..27a3f09ddc 100644
--- a/vector/src/fdroid/java/im/vector/app/fdroid/features/settings/troubleshoot/TestAutoStartBoot.kt
+++ b/vector/src/fdroid/java/im/vector/app/fdroid/features/settings/troubleshoot/TestAutoStartBoot.kt
@@ -27,8 +27,8 @@ import javax.inject.Inject
* Test that the application is started on boot
*/
class TestAutoStartBoot @Inject constructor(private val vectorPreferences: VectorPreferences,
- private val stringProvider: StringProvider)
- : TroubleshootTest(R.string.settings_troubleshoot_test_service_boot_title) {
+ private val stringProvider: StringProvider) :
+ TroubleshootTest(R.string.settings_troubleshoot_test_service_boot_title) {
override fun perform(activityResultLauncher: ActivityResultLauncher) {
if (vectorPreferences.autoStartOnBoot()) {
diff --git a/vector/src/fdroid/java/im/vector/app/fdroid/features/settings/troubleshoot/TestBackgroundRestrictions.kt b/vector/src/fdroid/java/im/vector/app/fdroid/features/settings/troubleshoot/TestBackgroundRestrictions.kt
index abdd696724..3725fc828d 100644
--- a/vector/src/fdroid/java/im/vector/app/fdroid/features/settings/troubleshoot/TestBackgroundRestrictions.kt
+++ b/vector/src/fdroid/java/im/vector/app/fdroid/features/settings/troubleshoot/TestBackgroundRestrictions.kt
@@ -27,8 +27,8 @@ import im.vector.app.features.settings.troubleshoot.TroubleshootTest
import javax.inject.Inject
class TestBackgroundRestrictions @Inject constructor(private val context: AppCompatActivity,
- private val stringProvider: StringProvider)
- : TroubleshootTest(R.string.settings_troubleshoot_test_bg_restricted_title) {
+ private val stringProvider: StringProvider) :
+ TroubleshootTest(R.string.settings_troubleshoot_test_bg_restricted_title) {
override fun perform(activityResultLauncher: ActivityResultLauncher) {
context.getSystemService()!!.apply {
diff --git a/vector/src/gplay/java/im/vector/app/gplay/features/settings/troubleshoot/TestPlayServices.kt b/vector/src/gplay/java/im/vector/app/gplay/features/settings/troubleshoot/TestPlayServices.kt
index 92e713de81..1f822d6060 100644
--- a/vector/src/gplay/java/im/vector/app/gplay/features/settings/troubleshoot/TestPlayServices.kt
+++ b/vector/src/gplay/java/im/vector/app/gplay/features/settings/troubleshoot/TestPlayServices.kt
@@ -30,8 +30,8 @@ import javax.inject.Inject
* Check that the play services APK is available an up-to-date. If needed provide quick fix to install it.
*/
class TestPlayServices @Inject constructor(private val context: AppCompatActivity,
- private val stringProvider: StringProvider)
- : TroubleshootTest(R.string.settings_troubleshoot_test_play_services_title) {
+ private val stringProvider: StringProvider) :
+ TroubleshootTest(R.string.settings_troubleshoot_test_play_services_title) {
override fun perform(activityResultLauncher: ActivityResultLauncher) {
val apiAvailability = GoogleApiAvailability.getInstance()
diff --git a/vector/src/gplay/java/im/vector/app/gplay/features/settings/troubleshoot/TestPushFromPushGateway.kt b/vector/src/gplay/java/im/vector/app/gplay/features/settings/troubleshoot/TestPushFromPushGateway.kt
index d429b293b2..e13b648dec 100644
--- a/vector/src/gplay/java/im/vector/app/gplay/features/settings/troubleshoot/TestPushFromPushGateway.kt
+++ b/vector/src/gplay/java/im/vector/app/gplay/features/settings/troubleshoot/TestPushFromPushGateway.kt
@@ -40,8 +40,8 @@ class TestPushFromPushGateway @Inject constructor(private val context: AppCompat
private val stringProvider: StringProvider,
private val errorFormatter: ErrorFormatter,
private val pushersManager: PushersManager,
- private val activeSessionHolder: ActiveSessionHolder)
- : TroubleshootTest(R.string.settings_troubleshoot_test_push_loop_title) {
+ private val activeSessionHolder: ActiveSessionHolder) :
+ TroubleshootTest(R.string.settings_troubleshoot_test_push_loop_title) {
private var action: Job? = null
private var pushReceived: Boolean = false
diff --git a/vector/src/gplay/java/im/vector/app/gplay/features/settings/troubleshoot/TestTokenRegistration.kt b/vector/src/gplay/java/im/vector/app/gplay/features/settings/troubleshoot/TestTokenRegistration.kt
index f400c17d46..966d79c59b 100644
--- a/vector/src/gplay/java/im/vector/app/gplay/features/settings/troubleshoot/TestTokenRegistration.kt
+++ b/vector/src/gplay/java/im/vector/app/gplay/features/settings/troubleshoot/TestTokenRegistration.kt
@@ -21,13 +21,13 @@ import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.Observer
import androidx.work.WorkInfo
import androidx.work.WorkManager
-import org.matrix.android.sdk.api.session.pushers.PusherState
import im.vector.app.R
import im.vector.app.core.di.ActiveSessionHolder
import im.vector.app.core.pushers.PushersManager
import im.vector.app.core.resources.StringProvider
import im.vector.app.features.settings.troubleshoot.TroubleshootTest
import im.vector.app.push.fcm.FcmHelper
+import org.matrix.android.sdk.api.session.pushers.PusherState
import javax.inject.Inject
/**
@@ -36,8 +36,8 @@ import javax.inject.Inject
class TestTokenRegistration @Inject constructor(private val context: AppCompatActivity,
private val stringProvider: StringProvider,
private val pushersManager: PushersManager,
- private val activeSessionHolder: ActiveSessionHolder)
- : TroubleshootTest(R.string.settings_troubleshoot_test_token_registration_title) {
+ private val activeSessionHolder: ActiveSessionHolder) :
+ TroubleshootTest(R.string.settings_troubleshoot_test_token_registration_title) {
override fun perform(activityResultLauncher: ActivityResultLauncher) {
// Check if we have a registered pusher for this token
diff --git a/vector/src/main/AndroidManifest.xml b/vector/src/main/AndroidManifest.xml
index 6c9453a564..7492da37e8 100644
--- a/vector/src/main/AndroidManifest.xml
+++ b/vector/src/main/AndroidManifest.xml
@@ -83,13 +83,19 @@
android:name="android.max_aspect"
android:value="9.9" />
+
+
+
@@ -103,10 +109,13 @@
+
+
@@ -120,10 +129,13 @@
android:scheme="element" />
+
+
@@ -143,7 +155,6 @@
android:name=".features.media.VectorAttachmentViewerActivity"
android:theme="@style/Theme.Vector.Black.Transparent"
tools:ignore="Instantiatable" />
-
-
@@ -180,7 +190,13 @@
-
+
+
+
+
@@ -196,8 +212,37 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ android:supportsPictureInPicture="true"
+ android:taskAffinity=".features.call.VectorCallActivity" />
@@ -365,7 +386,9 @@
A media button receiver receives and helps translate hardware media playback buttons,
such as those found on wired and wireless headsets, into the appropriate callbacks in your app.
-->
-
+
@@ -375,9 +398,15 @@
+ android:name="androidx.startup.InitializationProvider"
+ android:authorities="${applicationId}.androidx-startup"
+ android:exported="false"
+ tools:node="merge">
+
+
{
when {
- throwable.error.code == MatrixError.M_CONSENT_NOT_GIVEN -> {
+ throwable.error.code == MatrixError.M_CONSENT_NOT_GIVEN -> {
// Special case for terms and conditions
stringProvider.getString(R.string.error_terms_not_accepted)
}
- throwable.isInvalidPassword() -> {
+ throwable.isInvalidPassword() -> {
stringProvider.getString(R.string.auth_invalid_login_param)
}
- throwable.error.code == MatrixError.M_USER_IN_USE -> {
+ throwable.error.code == MatrixError.M_USER_IN_USE -> {
stringProvider.getString(R.string.login_signup_error_user_in_use)
}
- throwable.error.code == MatrixError.M_BAD_JSON -> {
+ throwable.error.code == MatrixError.M_BAD_JSON -> {
stringProvider.getString(R.string.login_error_bad_json)
}
- throwable.error.code == MatrixError.M_NOT_JSON -> {
+ throwable.error.code == MatrixError.M_NOT_JSON -> {
stringProvider.getString(R.string.login_error_not_json)
}
- throwable.error.code == MatrixError.M_THREEPID_DENIED -> {
+ throwable.error.code == MatrixError.M_THREEPID_DENIED -> {
stringProvider.getString(R.string.login_error_threepid_denied)
}
- throwable.error.code == MatrixError.M_LIMIT_EXCEEDED -> {
+ throwable.error.code == MatrixError.M_LIMIT_EXCEEDED -> {
limitExceededError(throwable.error)
}
- throwable.error.code == MatrixError.M_TOO_LARGE -> {
+ throwable.error.code == MatrixError.M_TOO_LARGE -> {
stringProvider.getString(R.string.error_file_too_big_simple)
}
- throwable.error.code == MatrixError.M_THREEPID_NOT_FOUND -> {
+ throwable.error.code == MatrixError.M_THREEPID_NOT_FOUND -> {
stringProvider.getString(R.string.login_reset_password_error_not_found)
}
- throwable.error.code == MatrixError.M_USER_DEACTIVATED -> {
+ throwable.error.code == MatrixError.M_USER_DEACTIVATED -> {
stringProvider.getString(R.string.auth_invalid_login_deactivated_account)
}
- throwable.error.code == MatrixError.M_THREEPID_IN_USE
- && throwable.error.message == "Email is already in use" -> {
+ throwable.error.code == MatrixError.M_THREEPID_IN_USE &&
+ throwable.error.message == "Email is already in use" -> {
stringProvider.getString(R.string.account_email_already_used_error)
}
- throwable.error.code == MatrixError.M_THREEPID_IN_USE
- && throwable.error.message == "MSISDN is already in use" -> {
+ throwable.error.code == MatrixError.M_THREEPID_IN_USE &&
+ throwable.error.message == "MSISDN is already in use" -> {
stringProvider.getString(R.string.account_phone_number_already_used_error)
}
- throwable.error.code == MatrixError.M_THREEPID_AUTH_FAILED -> {
+ throwable.error.code == MatrixError.M_THREEPID_AUTH_FAILED -> {
stringProvider.getString(R.string.error_threepid_auth_failed)
}
- else -> {
+ else -> {
throwable.error.message.takeIf { it.isNotEmpty() }
?: throwable.error.code.takeIf { it.isNotEmpty() }
}
diff --git a/vector/src/main/java/im/vector/app/core/extensions/BasicExtensions.kt b/vector/src/main/java/im/vector/app/core/extensions/BasicExtensions.kt
index 07a684abef..ee3d79d846 100644
--- a/vector/src/main/java/im/vector/app/core/extensions/BasicExtensions.kt
+++ b/vector/src/main/java/im/vector/app/core/extensions/BasicExtensions.kt
@@ -57,7 +57,7 @@ fun CharSequence.isMsisdn(): Boolean {
* - "fi.le.txt".insertBeforeLast("_foo") will return "fi.le_foo.txt"
* - null.insertBeforeLast("_foo") will return "_foo"
*/
-fun String?.insertBeforeLast(insert: String, delimiter: String = ".") : String {
+fun String?.insertBeforeLast(insert: String, delimiter: String = "."): String {
if (this == null) return insert
val idx = lastIndexOf(delimiter)
return if (idx == -1) {
diff --git a/vector/src/main/java/im/vector/app/core/extensions/EditText.kt b/vector/src/main/java/im/vector/app/core/extensions/EditText.kt
index 05b70def3d..0eb9dcdaf9 100644
--- a/vector/src/main/java/im/vector/app/core/extensions/EditText.kt
+++ b/vector/src/main/java/im/vector/app/core/extensions/EditText.kt
@@ -18,6 +18,7 @@ package im.vector.app.core.extensions
import android.text.Editable
import android.text.InputType
+import android.text.Spanned
import android.view.MotionEvent
import android.view.View
import android.view.inputmethod.EditorInfo
@@ -57,3 +58,38 @@ fun EditText.setupAsSearch(@DrawableRes searchIconRes: Int = R.drawable.ic_searc
return@OnTouchListener false
})
}
+
+fun EditText.setTextIfDifferent(newText: CharSequence?): Boolean {
+ if (!isTextDifferent(newText, text)) {
+ // Previous text is the same. No op
+ return false
+ }
+ setText(newText)
+ // Since the text changed we move the cursor to the end of the new text.
+ // This allows us to fill in text programmatically with a different value,
+ // but if the user is typing and the view is rebound we won't lose their cursor position.
+ setSelection(newText?.length ?: 0)
+ return true
+}
+
+private fun isTextDifferent(str1: CharSequence?, str2: CharSequence?): Boolean {
+ if (str1 === str2) {
+ return false
+ }
+ if (str1 == null || str2 == null) {
+ return true
+ }
+ val length = str1.length
+ if (length != str2.length) {
+ return true
+ }
+ if (str1 is Spanned) {
+ return str1 != str2
+ }
+ for (i in 0 until length) {
+ if (str1[i] != str2[i]) {
+ return true
+ }
+ }
+ return false
+}
diff --git a/vector/src/main/java/im/vector/app/core/extensions/Session.kt b/vector/src/main/java/im/vector/app/core/extensions/Session.kt
index 699247ab6d..215c421291 100644
--- a/vector/src/main/java/im/vector/app/core/extensions/Session.kt
+++ b/vector/src/main/java/im/vector/app/core/extensions/Session.kt
@@ -62,15 +62,15 @@ fun Session.startSyncing(context: Context) {
* Tell is the session has unsaved e2e keys in the backup
*/
fun Session.hasUnsavedKeys(): Boolean {
- return cryptoService().inboundGroupSessionsCount(false) > 0
- && cryptoService().keysBackupService().state != KeysBackupState.ReadyToBackUp
+ return cryptoService().inboundGroupSessionsCount(false) > 0 &&
+ cryptoService().keysBackupService().state != KeysBackupState.ReadyToBackUp
}
fun Session.cannotLogoutSafely(): Boolean {
// has some encrypted chat
- return hasUnsavedKeys()
+ return hasUnsavedKeys() ||
// has local cross signing keys
- || (cryptoService().crossSigningService().allPrivateKeysKnown()
+ (cryptoService().crossSigningService().allPrivateKeysKnown() &&
// That are not backed up
- && !sharedSecretStorageService.isRecoverySetup())
+ !sharedSecretStorageService.isRecoverySetup())
}
diff --git a/vector/src/main/java/im/vector/app/core/extensions/TextView.kt b/vector/src/main/java/im/vector/app/core/extensions/TextView.kt
index 0872edeafd..adb655f169 100644
--- a/vector/src/main/java/im/vector/app/core/extensions/TextView.kt
+++ b/vector/src/main/java/im/vector/app/core/extensions/TextView.kt
@@ -40,8 +40,8 @@ import im.vector.app.features.themes.ThemeUtils
* Set a text in the TextView, or set visibility to GONE if the text is null
*/
fun TextView.setTextOrHide(newText: CharSequence?, hideWhenBlank: Boolean = true, vararg relatedViews: View = emptyArray()) {
- if (newText == null
- || (newText.isBlank() && hideWhenBlank)) {
+ if (newText == null ||
+ (newText.isBlank() && hideWhenBlank)) {
isVisible = false
relatedViews.forEach { it.isVisible = false }
} else {
diff --git a/vector/src/main/java/im/vector/app/core/extensions/TimelineEvent.kt b/vector/src/main/java/im/vector/app/core/extensions/TimelineEvent.kt
index 48e3a488ed..43ff186e99 100644
--- a/vector/src/main/java/im/vector/app/core/extensions/TimelineEvent.kt
+++ b/vector/src/main/java/im/vector/app/core/extensions/TimelineEvent.kt
@@ -22,7 +22,7 @@ import org.matrix.android.sdk.api.session.room.timeline.TimelineEvent
fun TimelineEvent.canReact(): Boolean {
// Only event of type EventType.MESSAGE or EventType.STICKER are supported for the moment
- return root.getClearType() in listOf(EventType.MESSAGE, EventType.STICKER)
- && root.sendState == SendState.SYNCED
- && !root.isRedacted()
+ return root.getClearType() in listOf(EventType.MESSAGE, EventType.STICKER) &&
+ root.sendState == SendState.SYNCED &&
+ !root.isRedacted()
}
diff --git a/vector/src/main/java/im/vector/app/core/glide/AvatarPlaceholder.kt b/vector/src/main/java/im/vector/app/core/glide/AvatarPlaceholder.kt
index 32968c4f80..9675e30042 100644
--- a/vector/src/main/java/im/vector/app/core/glide/AvatarPlaceholder.kt
+++ b/vector/src/main/java/im/vector/app/core/glide/AvatarPlaceholder.kt
@@ -42,8 +42,8 @@ class AvatarPlaceholderModelLoaderFactory(private val context: Context) : ModelL
}
}
-class AvatarPlaceholderModelLoader(private val context: Context)
- : ModelLoader {
+class AvatarPlaceholderModelLoader(private val context: Context) :
+ ModelLoader {
override fun buildLoadData(model: AvatarPlaceholder, width: Int, height: Int, options: Options): ModelLoader.LoadData? {
return ModelLoader.LoadData(ObjectKey(model), AvatarPlaceholderDataFetcher(context, model))
@@ -54,8 +54,8 @@ class AvatarPlaceholderModelLoader(private val context: Context)
}
}
-class AvatarPlaceholderDataFetcher(context: Context, private val data: AvatarPlaceholder)
- : DataFetcher {
+class AvatarPlaceholderDataFetcher(context: Context, private val data: AvatarPlaceholder) :
+ DataFetcher {
private val avatarRenderer = context.vectorComponent().avatarRenderer()
diff --git a/vector/src/main/java/im/vector/app/core/glide/MyAppGlideModule.kt b/vector/src/main/java/im/vector/app/core/glide/MyAppGlideModule.kt
index 74c9d4f0f6..59bffd95fd 100644
--- a/vector/src/main/java/im/vector/app/core/glide/MyAppGlideModule.kt
+++ b/vector/src/main/java/im/vector/app/core/glide/MyAppGlideModule.kt
@@ -19,7 +19,6 @@ package im.vector.app.core.glide
import android.content.Context
import android.graphics.drawable.Drawable
import android.util.Log
-
import com.bumptech.glide.Glide
import com.bumptech.glide.GlideBuilder
import com.bumptech.glide.Registry
diff --git a/vector/src/main/java/im/vector/app/core/glide/VectorGlideModelLoader.kt b/vector/src/main/java/im/vector/app/core/glide/VectorGlideModelLoader.kt
index 5fae815dfb..7dfee7d981 100644
--- a/vector/src/main/java/im/vector/app/core/glide/VectorGlideModelLoader.kt
+++ b/vector/src/main/java/im/vector/app/core/glide/VectorGlideModelLoader.kt
@@ -48,8 +48,8 @@ class VectorGlideModelLoaderFactory(private val context: Context) : ModelLoaderF
}
}
-class VectorGlideModelLoader(private val context: Context)
- : ModelLoader {
+class VectorGlideModelLoader(private val context: Context) :
+ ModelLoader {
override fun handles(model: ImageContentRenderer.Data): Boolean {
// Always handle
return true
@@ -63,8 +63,8 @@ class VectorGlideModelLoader(private val context: Context)
class VectorGlideDataFetcher(context: Context,
private val data: ImageContentRenderer.Data,
private val width: Int,
- private val height: Int)
- : DataFetcher {
+ private val height: Int) :
+ DataFetcher {
private val localFilesHelper = LocalFilesHelper(context)
private val activeSessionHolder = context.vectorComponent().activeSessionHolder()
diff --git a/vector/src/main/java/im/vector/app/core/platform/ButtonStateView.kt b/vector/src/main/java/im/vector/app/core/platform/ButtonStateView.kt
index ee2933f542..e7e91dbfd9 100755
--- a/vector/src/main/java/im/vector/app/core/platform/ButtonStateView.kt
+++ b/vector/src/main/java/im/vector/app/core/platform/ButtonStateView.kt
@@ -28,8 +28,8 @@ import im.vector.app.core.epoxy.ClickListener
import im.vector.app.core.epoxy.onClick
import im.vector.app.databinding.ViewButtonStateBinding
-class ButtonStateView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyle: Int = 0)
- : FrameLayout(context, attrs, defStyle) {
+class ButtonStateView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyle: Int = 0) :
+ FrameLayout(context, attrs, defStyle) {
sealed class State {
object Button : State()
diff --git a/vector/src/main/java/im/vector/app/core/platform/MaxHeightScrollView.kt b/vector/src/main/java/im/vector/app/core/platform/MaxHeightScrollView.kt
index 139ccc8c05..8d4c5d8950 100644
--- a/vector/src/main/java/im/vector/app/core/platform/MaxHeightScrollView.kt
+++ b/vector/src/main/java/im/vector/app/core/platform/MaxHeightScrollView.kt
@@ -24,8 +24,8 @@ import im.vector.app.R
private const val DEFAULT_MAX_HEIGHT = 200
-class MaxHeightScrollView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyle: Int = 0)
- : NestedScrollView(context, attrs, defStyle) {
+class MaxHeightScrollView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyle: Int = 0) :
+ NestedScrollView(context, attrs, defStyle) {
var maxHeight: Int = 0
set(value) {
diff --git a/vector/src/main/java/im/vector/app/core/platform/SimpleFragmentActivity.kt b/vector/src/main/java/im/vector/app/core/platform/SimpleFragmentActivity.kt
index 066bd165a9..7573bf2e8e 100644
--- a/vector/src/main/java/im/vector/app/core/platform/SimpleFragmentActivity.kt
+++ b/vector/src/main/java/im/vector/app/core/platform/SimpleFragmentActivity.kt
@@ -21,7 +21,6 @@ import androidx.core.view.isVisible
import im.vector.app.core.di.ScreenComponent
import im.vector.app.core.extensions.hideKeyboard
import im.vector.app.databinding.ActivityBinding
-
import org.matrix.android.sdk.api.session.Session
/**
diff --git a/vector/src/main/java/im/vector/app/core/platform/StateView.kt b/vector/src/main/java/im/vector/app/core/platform/StateView.kt
index a935c56c51..b3d42dc38f 100755
--- a/vector/src/main/java/im/vector/app/core/platform/StateView.kt
+++ b/vector/src/main/java/im/vector/app/core/platform/StateView.kt
@@ -26,8 +26,8 @@ import im.vector.app.R
import im.vector.app.core.extensions.updateConstraintSet
import im.vector.app.databinding.ViewStateBinding
-class StateView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyle: Int = 0)
- : FrameLayout(context, attrs, defStyle) {
+class StateView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyle: Int = 0) :
+ FrameLayout(context, attrs, defStyle) {
sealed class State {
object Content : State()
diff --git a/vector/src/main/java/im/vector/app/core/platform/VectorEventViewModel.kt b/vector/src/main/java/im/vector/app/core/platform/VectorEventViewModel.kt
index 2d499db531..9ab46557a5 100644
--- a/vector/src/main/java/im/vector/app/core/platform/VectorEventViewModel.kt
+++ b/vector/src/main/java/im/vector/app/core/platform/VectorEventViewModel.kt
@@ -25,5 +25,5 @@ interface VectorSharedAction
/**
* Parent class to handle navigation events, action events, or other any events
*/
-open class VectorSharedActionViewModel(private val store: MutableDataSource = PublishDataSource())
- : ViewModel(), MutableDataSource by store
+open class VectorSharedActionViewModel(private val store: MutableDataSource = PublishDataSource()) :
+ ViewModel(), MutableDataSource by store
diff --git a/vector/src/main/java/im/vector/app/core/platform/VectorViewModel.kt b/vector/src/main/java/im/vector/app/core/platform/VectorViewModel.kt
index d6f43beaf7..bca462a92b 100644
--- a/vector/src/main/java/im/vector/app/core/platform/VectorViewModel.kt
+++ b/vector/src/main/java/im/vector/app/core/platform/VectorViewModel.kt
@@ -27,8 +27,8 @@ import im.vector.app.core.utils.PublishDataSource
import io.reactivex.Observable
import io.reactivex.Single
-abstract class VectorViewModel(initialState: S)
- : BaseMvRxViewModel(initialState, false) {
+abstract class VectorViewModel(initialState: S) :
+ BaseMvRxViewModel(initialState, false) {
interface Factory {
fun create(state: S): BaseMvRxViewModel
diff --git a/vector/src/main/java/im/vector/app/core/services/CallService.kt b/vector/src/main/java/im/vector/app/core/services/CallService.kt
index cd3845f41b..bda32e528b 100644
--- a/vector/src/main/java/im/vector/app/core/services/CallService.kt
+++ b/vector/src/main/java/im/vector/app/core/services/CallService.kt
@@ -33,6 +33,7 @@ import im.vector.app.features.call.telecom.CallConnection
import im.vector.app.features.call.webrtc.WebRtcCall
import im.vector.app.features.call.webrtc.WebRtcCallManager
import im.vector.app.features.call.webrtc.getOpponentAsMatrixItem
+import im.vector.app.features.displayname.getBestName
import im.vector.app.features.home.AvatarRenderer
import im.vector.app.features.notifications.NotificationUtils
import im.vector.app.features.popup.IncomingCallAlert
diff --git a/vector/src/main/java/im/vector/app/core/ui/bottomsheet/BottomSheetGeneric.kt b/vector/src/main/java/im/vector/app/core/ui/bottomsheet/BottomSheetGeneric.kt
index e773993b21..bd7a07c640 100644
--- a/vector/src/main/java/im/vector/app/core/ui/bottomsheet/BottomSheetGeneric.kt
+++ b/vector/src/main/java/im/vector/app/core/ui/bottomsheet/BottomSheetGeneric.kt
@@ -26,7 +26,6 @@ import im.vector.app.core.extensions.cleanup
import im.vector.app.core.extensions.configureWith
import im.vector.app.core.platform.VectorBaseBottomSheetDialogFragment
import im.vector.app.databinding.BottomSheetGenericListBinding
-
import javax.inject.Inject
/**
diff --git a/vector/src/main/java/im/vector/app/core/ui/bottomsheet/BottomSheetGenericController.kt b/vector/src/main/java/im/vector/app/core/ui/bottomsheet/BottomSheetGenericController.kt
index f0715e6bba..6e92549809 100644
--- a/vector/src/main/java/im/vector/app/core/ui/bottomsheet/BottomSheetGenericController.kt
+++ b/vector/src/main/java/im/vector/app/core/ui/bottomsheet/BottomSheetGenericController.kt
@@ -20,8 +20,8 @@ import com.airbnb.epoxy.TypedEpoxyController
/**
* Epoxy controller for generic bottom sheet actions
*/
-abstract class BottomSheetGenericController
- : TypedEpoxyController() {
+abstract class BottomSheetGenericController :
+ TypedEpoxyController() {
var listener: Listener? = null
diff --git a/vector/src/main/java/im/vector/app/core/ui/views/KeysBackupBanner.kt b/vector/src/main/java/im/vector/app/core/ui/views/KeysBackupBanner.kt
index 153cac2ac7..94c1ab6576 100755
--- a/vector/src/main/java/im/vector/app/core/ui/views/KeysBackupBanner.kt
+++ b/vector/src/main/java/im/vector/app/core/ui/views/KeysBackupBanner.kt
@@ -25,7 +25,6 @@ import androidx.core.view.isVisible
import im.vector.app.R
import im.vector.app.core.di.DefaultSharedPreferences
import im.vector.app.databinding.ViewKeysBackupBannerBinding
-
import timber.log.Timber
/**
@@ -137,8 +136,8 @@ class KeysBackupBanner @JvmOverloads constructor(
}
private fun renderSetup(nbOfKeys: Int) {
- if (nbOfKeys == 0
- || DefaultSharedPreferences.getInstance(context).getBoolean(BANNER_SETUP_DO_NOT_SHOW_AGAIN, false)) {
+ if (nbOfKeys == 0 ||
+ DefaultSharedPreferences.getInstance(context).getBoolean(BANNER_SETUP_DO_NOT_SHOW_AGAIN, false)) {
// Do not display the setup banner if there is no keys to backup, or if the user has already closed it
isVisible = false
} else {
diff --git a/vector/src/main/java/im/vector/app/core/ui/views/NotificationAreaView.kt b/vector/src/main/java/im/vector/app/core/ui/views/NotificationAreaView.kt
index 463d94b288..94809d2981 100644
--- a/vector/src/main/java/im/vector/app/core/ui/views/NotificationAreaView.kt
+++ b/vector/src/main/java/im/vector/app/core/ui/views/NotificationAreaView.kt
@@ -30,7 +30,6 @@ import im.vector.app.core.extensions.exhaustive
import im.vector.app.core.utils.DimensionConverter
import im.vector.app.databinding.ViewNotificationAreaBinding
import im.vector.app.features.themes.ThemeUtils
-
import me.gujun.android.span.span
import me.saket.bettermovementmethod.BetterLinkMovementMethod
import org.matrix.android.sdk.api.failure.MatrixError
@@ -50,7 +49,7 @@ class NotificationAreaView @JvmOverloads constructor(
var delegate: Delegate? = null
private var state: State = State.Initial
- private lateinit var views : ViewNotificationAreaBinding
+ private lateinit var views: ViewNotificationAreaBinding
init {
setupView()
diff --git a/vector/src/main/java/im/vector/app/core/ui/views/PasswordStrengthBar.kt b/vector/src/main/java/im/vector/app/core/ui/views/PasswordStrengthBar.kt
index 2f6c4b45cf..a984707bf7 100644
--- a/vector/src/main/java/im/vector/app/core/ui/views/PasswordStrengthBar.kt
+++ b/vector/src/main/java/im/vector/app/core/ui/views/PasswordStrengthBar.kt
@@ -35,8 +35,8 @@ import im.vector.app.databinding.ViewPasswordStrengthBarBinding
class PasswordStrengthBar @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
- defStyleAttr: Int = 0)
- : LinearLayout(context, attrs, defStyleAttr) {
+ defStyleAttr: Int = 0) :
+ LinearLayout(context, attrs, defStyleAttr) {
private val views: ViewPasswordStrengthBarBinding
diff --git a/vector/src/main/java/im/vector/app/core/ui/views/ReadReceiptsView.kt b/vector/src/main/java/im/vector/app/core/ui/views/ReadReceiptsView.kt
index 02b351737e..3a79e7e328 100644
--- a/vector/src/main/java/im/vector/app/core/ui/views/ReadReceiptsView.kt
+++ b/vector/src/main/java/im/vector/app/core/ui/views/ReadReceiptsView.kt
@@ -37,7 +37,7 @@ class ReadReceiptsView @JvmOverloads constructor(
defStyleAttr: Int = 0
) : LinearLayout(context, attrs, defStyleAttr) {
- private val views : ViewReadReceiptsBinding
+ private val views: ViewReadReceiptsBinding
init {
setupView()
diff --git a/vector/src/main/java/im/vector/app/core/utils/Dialogs.kt b/vector/src/main/java/im/vector/app/core/utils/Dialogs.kt
index c73fa70388..ed3ae00567 100644
--- a/vector/src/main/java/im/vector/app/core/utils/Dialogs.kt
+++ b/vector/src/main/java/im/vector/app/core/utils/Dialogs.kt
@@ -40,13 +40,16 @@ fun Context.displayInWebView(url: String) {
.show()
}
-fun Context.showIdentityServerConsentDialog(configuredIdentityServer: String?, consentCallBack: (() -> Unit)) {
+fun Context.showIdentityServerConsentDialog(configuredIdentityServer: String?, policyLinkCallback: () -> Unit, consentCallBack: (() -> Unit)) {
MaterialAlertDialogBuilder(this)
.setTitle(R.string.identity_server_consent_dialog_title)
.setMessage(getString(R.string.identity_server_consent_dialog_content, configuredIdentityServer ?: ""))
.setPositiveButton(R.string.yes) { _, _ ->
consentCallBack.invoke()
}
+ .setNeutralButton(R.string.identity_server_consent_dialog_neutral_policy) { _, _ ->
+ policyLinkCallback.invoke()
+ }
.setNegativeButton(R.string.no, null)
.show()
}
diff --git a/vector/src/main/java/im/vector/app/core/utils/PermissionsTools.kt b/vector/src/main/java/im/vector/app/core/utils/PermissionsTools.kt
index 9f1497a40a..ba396ed252 100644
--- a/vector/src/main/java/im/vector/app/core/utils/PermissionsTools.kt
+++ b/vector/src/main/java/im/vector/app/core/utils/PermissionsTools.kt
@@ -52,8 +52,7 @@ private var permissionDialogDisplayed = false
* So when the user does not grant the permission and check the box do not ask again, this boolean will be false.
* Only useful if the first boolean is false
*/
-fun ComponentActivity.registerForPermissionsResult(lambda: (allGranted: Boolean, deniedPermanently: Boolean) -> Unit)
- : ActivityResultLauncher> {
+fun ComponentActivity.registerForPermissionsResult(lambda: (allGranted: Boolean, deniedPermanently: Boolean) -> Unit): ActivityResultLauncher> {
return registerForActivityResult(ActivityResultContracts.RequestMultiplePermissions()) { result ->
onPermissionResult(result, lambda)
}
diff --git a/vector/src/main/java/im/vector/app/core/utils/SnapHelperUtils.kt b/vector/src/main/java/im/vector/app/core/utils/SnapHelperUtils.kt
index e039e0bde5..070c953a3f 100644
--- a/vector/src/main/java/im/vector/app/core/utils/SnapHelperUtils.kt
+++ b/vector/src/main/java/im/vector/app/core/utils/SnapHelperUtils.kt
@@ -59,8 +59,8 @@ class SnapOnScrollListener(
}
override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) {
- if (behavior == Behavior.NOTIFY_ON_SCROLL_STATE_IDLE
- && newState == RecyclerView.SCROLL_STATE_IDLE) {
+ if (behavior == Behavior.NOTIFY_ON_SCROLL_STATE_IDLE &&
+ newState == RecyclerView.SCROLL_STATE_IDLE) {
maybeNotifySnapPositionChange(recyclerView)
}
}
diff --git a/vector/src/main/java/im/vector/app/core/utils/SystemUtils.kt b/vector/src/main/java/im/vector/app/core/utils/SystemUtils.kt
index b12c1b7369..966b38828e 100644
--- a/vector/src/main/java/im/vector/app/core/utils/SystemUtils.kt
+++ b/vector/src/main/java/im/vector/app/core/utils/SystemUtils.kt
@@ -48,8 +48,8 @@ import im.vector.app.features.notifications.NotificationUtils
*/
fun isIgnoringBatteryOptimizations(context: Context): Boolean {
// no issue before Android M, battery optimisations did not exist
- return Build.VERSION.SDK_INT < Build.VERSION_CODES.M
- || context.getSystemService()?.isIgnoringBatteryOptimizations(context.packageName) == true
+ return Build.VERSION.SDK_INT < Build.VERSION_CODES.M ||
+ context.getSystemService()?.isIgnoringBatteryOptimizations(context.packageName) == true
}
fun isAirplaneModeOn(context: Context): Boolean {
diff --git a/vector/src/main/java/im/vector/app/features/MainActivity.kt b/vector/src/main/java/im/vector/app/features/MainActivity.kt
index 583aae260b..e124dbdf6e 100644
--- a/vector/src/main/java/im/vector/app/features/MainActivity.kt
+++ b/vector/src/main/java/im/vector/app/features/MainActivity.kt
@@ -45,10 +45,10 @@ import im.vector.app.features.signout.soft.SoftLogoutActivity
import im.vector.app.features.signout.soft.SoftLogoutActivity2
import im.vector.app.features.themes.ActivityOtherThemes
import im.vector.app.features.ui.UiStateRepository
-import kotlinx.parcelize.Parcelize
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
+import kotlinx.parcelize.Parcelize
import org.matrix.android.sdk.api.failure.GlobalError
import timber.log.Timber
import javax.inject.Inject
@@ -220,20 +220,20 @@ class MainActivity : VectorBaseActivity(), UnlockedActivity
private fun startNextActivityAndFinish(ignoreClearCredentials: Boolean = false) {
val intent = when {
- args.clearCredentials
- && !ignoreClearCredentials
- && (!args.isUserLoggedOut || args.isAccountDeactivated) -> {
+ args.clearCredentials &&
+ !ignoreClearCredentials &&
+ (!args.isUserLoggedOut || args.isAccountDeactivated) -> {
// User has explicitly asked to log out or deactivated his account
navigator.openLogin(this, null)
null
}
- args.isSoftLogout ->
+ args.isSoftLogout ->
// The homeserver has invalidated the token, with a soft logout
getSoftLogoutActivityIntent()
- args.isUserLoggedOut ->
+ args.isUserLoggedOut ->
// the homeserver has invalidated the token (password changed, device deleted, other security reasons)
SignedOutActivity.newIntent(this)
- sessionHolder.hasActiveSession() ->
+ sessionHolder.hasActiveSession() ->
// We have a session.
// Check it can be opened
if (sessionHolder.getActiveSession().isOpenable) {
@@ -242,7 +242,7 @@ class MainActivity : VectorBaseActivity(), UnlockedActivity
// The token is still invalid
getSoftLogoutActivityIntent()
}
- else -> {
+ else -> {
// First start, or no active session
navigator.openLogin(this, null)
null
diff --git a/vector/src/main/java/im/vector/app/features/attachments/AttachmentTypeSelectorView.kt b/vector/src/main/java/im/vector/app/features/attachments/AttachmentTypeSelectorView.kt
index eba5dadeda..35644e1843 100644
--- a/vector/src/main/java/im/vector/app/features/attachments/AttachmentTypeSelectorView.kt
+++ b/vector/src/main/java/im/vector/app/features/attachments/AttachmentTypeSelectorView.kt
@@ -53,8 +53,8 @@ private const val ANIMATION_DURATION = 250
*/
class AttachmentTypeSelectorView(context: Context,
inflater: LayoutInflater,
- var callback: Callback?)
- : PopupWindow(context) {
+ var callback: Callback?) :
+ PopupWindow(context) {
interface Callback {
fun onTypeSelected(type: Type)
diff --git a/vector/src/main/java/im/vector/app/features/attachments/ContentAttachmentData.kt b/vector/src/main/java/im/vector/app/features/attachments/ContentAttachmentData.kt
index 0502f2b0ad..9805b6f755 100644
--- a/vector/src/main/java/im/vector/app/features/attachments/ContentAttachmentData.kt
+++ b/vector/src/main/java/im/vector/app/features/attachments/ContentAttachmentData.kt
@@ -27,9 +27,9 @@ private val listOfPreviewableMimeTypes = listOf(
fun ContentAttachmentData.isPreviewable(): Boolean {
// Preview supports image and video
- return (type == ContentAttachmentData.Type.IMAGE
- && listOfPreviewableMimeTypes.contains(getSafeMimeType() ?: ""))
- || type == ContentAttachmentData.Type.VIDEO
+ return (type == ContentAttachmentData.Type.IMAGE &&
+ listOfPreviewableMimeTypes.contains(getSafeMimeType() ?: "")) ||
+ type == ContentAttachmentData.Type.VIDEO
}
data class GroupedContentAttachmentData(
diff --git a/vector/src/main/java/im/vector/app/features/attachments/preview/AttachmentsPreviewViewModel.kt b/vector/src/main/java/im/vector/app/features/attachments/preview/AttachmentsPreviewViewModel.kt
index 28d617e613..0a0e700ce9 100644
--- a/vector/src/main/java/im/vector/app/features/attachments/preview/AttachmentsPreviewViewModel.kt
+++ b/vector/src/main/java/im/vector/app/features/attachments/preview/AttachmentsPreviewViewModel.kt
@@ -20,8 +20,8 @@ package im.vector.app.features.attachments.preview
import im.vector.app.core.extensions.exhaustive
import im.vector.app.core.platform.VectorViewModel
-class AttachmentsPreviewViewModel(initialState: AttachmentsPreviewViewState)
- : VectorViewModel(initialState) {
+class AttachmentsPreviewViewModel(initialState: AttachmentsPreviewViewState) :
+ VectorViewModel(initialState) {
override fun handle(action: AttachmentsPreviewAction) {
when (action) {
diff --git a/vector/src/main/java/im/vector/app/features/attachments/preview/Extensions.kt b/vector/src/main/java/im/vector/app/features/attachments/preview/Extensions.kt
index 853f9f8997..672cde977d 100644
--- a/vector/src/main/java/im/vector/app/features/attachments/preview/Extensions.kt
+++ b/vector/src/main/java/im/vector/app/features/attachments/preview/Extensions.kt
@@ -24,7 +24,7 @@ import org.matrix.android.sdk.api.util.MimeTypes.isMimeTypeImage
* All images are editable, expect Gif
*/
fun ContentAttachmentData.isEditable(): Boolean {
- return type == ContentAttachmentData.Type.IMAGE
- && getSafeMimeType()?.isMimeTypeImage() == true
- && getSafeMimeType() != MimeTypes.Gif
+ return type == ContentAttachmentData.Type.IMAGE &&
+ getSafeMimeType()?.isMimeTypeImage() == true &&
+ getSafeMimeType() != MimeTypes.Gif
}
diff --git a/vector/src/main/java/im/vector/app/features/autocomplete/AutocompleteMatrixItem.kt b/vector/src/main/java/im/vector/app/features/autocomplete/AutocompleteMatrixItem.kt
index 3d70615abf..dba2661927 100644
--- a/vector/src/main/java/im/vector/app/features/autocomplete/AutocompleteMatrixItem.kt
+++ b/vector/src/main/java/im/vector/app/features/autocomplete/AutocompleteMatrixItem.kt
@@ -26,6 +26,7 @@ import im.vector.app.core.epoxy.VectorEpoxyHolder
import im.vector.app.core.epoxy.VectorEpoxyModel
import im.vector.app.core.epoxy.onClick
import im.vector.app.core.extensions.setTextOrHide
+import im.vector.app.features.displayname.getBestName
import im.vector.app.features.home.AvatarRenderer
import org.matrix.android.sdk.api.util.MatrixItem
diff --git a/vector/src/main/java/im/vector/app/features/autocomplete/command/CommandAutocompletePolicy.kt b/vector/src/main/java/im/vector/app/features/autocomplete/command/CommandAutocompletePolicy.kt
index 603ec64a7c..08f61be0f8 100644
--- a/vector/src/main/java/im/vector/app/features/autocomplete/command/CommandAutocompletePolicy.kt
+++ b/vector/src/main/java/im/vector/app/features/autocomplete/command/CommandAutocompletePolicy.kt
@@ -37,8 +37,8 @@ class CommandAutocompletePolicy @Inject constructor() : AutocompletePolicy {
// Only if text which starts with '/' and without space
override fun shouldShowPopup(text: Spannable?, cursorPos: Int): Boolean {
- return enabled && text?.startsWith("/") == true
- && !text.contains(" ")
+ return enabled && text?.startsWith("/") == true &&
+ !text.contains(" ")
}
override fun shouldDismissPopup(text: Spannable?, cursorPos: Int): Boolean {
diff --git a/vector/src/main/java/im/vector/app/features/call/VectorCallActivity.kt b/vector/src/main/java/im/vector/app/features/call/VectorCallActivity.kt
index f71dcc0635..42e14efad3 100644
--- a/vector/src/main/java/im/vector/app/features/call/VectorCallActivity.kt
+++ b/vector/src/main/java/im/vector/app/features/call/VectorCallActivity.kt
@@ -55,6 +55,7 @@ import im.vector.app.features.call.dialpad.DialPadFragment
import im.vector.app.features.call.utils.EglUtils
import im.vector.app.features.call.webrtc.WebRtcCall
import im.vector.app.features.call.webrtc.WebRtcCallManager
+import im.vector.app.features.displayname.getBestName
import im.vector.app.features.home.AvatarRenderer
import im.vector.app.features.home.room.detail.RoomDetailActivity
import im.vector.app.features.home.room.detail.RoomDetailArgs
diff --git a/vector/src/main/java/im/vector/app/features/call/VectorCallViewActions.kt b/vector/src/main/java/im/vector/app/features/call/VectorCallViewActions.kt
index 1834c05e41..67aa7bede2 100644
--- a/vector/src/main/java/im/vector/app/features/call/VectorCallViewActions.kt
+++ b/vector/src/main/java/im/vector/app/features/call/VectorCallViewActions.kt
@@ -25,9 +25,9 @@ sealed class VectorCallViewActions : VectorViewModelAction {
object DeclineCall : VectorCallViewActions()
object ToggleMute : VectorCallViewActions()
object ToggleVideo : VectorCallViewActions()
- object ToggleHoldResume: VectorCallViewActions()
+ object ToggleHoldResume : VectorCallViewActions()
data class ChangeAudioDevice(val device: CallAudioManager.Device) : VectorCallViewActions()
- object OpenDialPad: VectorCallViewActions()
+ object OpenDialPad : VectorCallViewActions()
data class SendDtmfDigit(val digit: String) : VectorCallViewActions()
data class SwitchCall(val callArgs: CallArgs) : VectorCallViewActions()
@@ -36,5 +36,5 @@ sealed class VectorCallViewActions : VectorViewModelAction {
object ToggleCamera : VectorCallViewActions()
object ToggleHDSD : VectorCallViewActions()
object InitiateCallTransfer : VectorCallViewActions()
- object TransferCall: VectorCallViewActions()
+ object TransferCall : VectorCallViewActions()
}
diff --git a/vector/src/main/java/im/vector/app/features/call/VectorCallViewEvents.kt b/vector/src/main/java/im/vector/app/features/call/VectorCallViewEvents.kt
index 9f19429c00..5a0a2f127c 100644
--- a/vector/src/main/java/im/vector/app/features/call/VectorCallViewEvents.kt
+++ b/vector/src/main/java/im/vector/app/features/call/VectorCallViewEvents.kt
@@ -27,8 +27,8 @@ sealed class VectorCallViewEvents : VectorViewEvents {
val available: Set,
val current: CallAudioManager.Device
) : VectorCallViewEvents()
- object ShowDialPad: VectorCallViewEvents()
- object ShowCallTransferScreen: VectorCallViewEvents()
+ object ShowDialPad : VectorCallViewEvents()
+ object ShowCallTransferScreen : VectorCallViewEvents()
// data class CallAnswered(val content: CallAnswerContent) : VectorCallViewEvents()
// data class CallHangup(val content: CallHangupContent) : VectorCallViewEvents()
// object CallAccepted : VectorCallViewEvents()
diff --git a/vector/src/main/java/im/vector/app/features/call/conference/ConferenceEvent.kt b/vector/src/main/java/im/vector/app/features/call/conference/ConferenceEvent.kt
index cfa076f31b..0a63ad6907 100644
--- a/vector/src/main/java/im/vector/app/features/call/conference/ConferenceEvent.kt
+++ b/vector/src/main/java/im/vector/app/features/call/conference/ConferenceEvent.kt
@@ -51,8 +51,8 @@ class ConferenceEventEmitter(private val context: Context) {
}
class ConferenceEventObserver(private val context: Context,
- private val onBroadcastEvent: (ConferenceEvent) -> Unit)
- : LifecycleObserver {
+ private val onBroadcastEvent: (ConferenceEvent) -> Unit) :
+ LifecycleObserver {
// See https://jitsi.github.io/handbook/docs/dev-guide/dev-guide-android-sdk#listening-for-broadcasted-events
private val broadcastReceiver = object : BroadcastReceiver() {
diff --git a/vector/src/main/java/im/vector/app/features/call/conference/JitsiCallViewActions.kt b/vector/src/main/java/im/vector/app/features/call/conference/JitsiCallViewActions.kt
index 830af7de01..7c9b9385f9 100644
--- a/vector/src/main/java/im/vector/app/features/call/conference/JitsiCallViewActions.kt
+++ b/vector/src/main/java/im/vector/app/features/call/conference/JitsiCallViewActions.kt
@@ -25,5 +25,5 @@ sealed class JitsiCallViewActions : VectorViewModelAction {
/**
* The ViewModel will either ask the View to finish, or to join another conf.
*/
- object OnConferenceLeft: JitsiCallViewActions()
+ object OnConferenceLeft : JitsiCallViewActions()
}
diff --git a/vector/src/main/java/im/vector/app/features/call/conference/JitsiCallViewEvents.kt b/vector/src/main/java/im/vector/app/features/call/conference/JitsiCallViewEvents.kt
index c8d570a73f..25062ffe15 100644
--- a/vector/src/main/java/im/vector/app/features/call/conference/JitsiCallViewEvents.kt
+++ b/vector/src/main/java/im/vector/app/features/call/conference/JitsiCallViewEvents.kt
@@ -34,6 +34,6 @@ sealed class JitsiCallViewEvents : VectorViewEvents {
) : JitsiCallViewEvents()
object LeaveConference : JitsiCallViewEvents()
- object FailJoiningConference: JitsiCallViewEvents()
+ object FailJoiningConference : JitsiCallViewEvents()
object Finish : JitsiCallViewEvents()
}
diff --git a/vector/src/main/java/im/vector/app/features/call/conference/JitsiCallViewModel.kt b/vector/src/main/java/im/vector/app/features/call/conference/JitsiCallViewModel.kt
index 0fc85cb58c..0b86114f6c 100644
--- a/vector/src/main/java/im/vector/app/features/call/conference/JitsiCallViewModel.kt
+++ b/vector/src/main/java/im/vector/app/features/call/conference/JitsiCallViewModel.kt
@@ -104,8 +104,8 @@ class JitsiCallViewModel @AssistedInject constructor(
private fun handleSwitchTo(action: JitsiCallViewActions.SwitchTo) = withState { state ->
// Check if it is the same conf
- if (action.args.roomId != state.roomId
- || action.args.widgetId != state.widgetId) {
+ if (action.args.roomId != state.roomId ||
+ action.args.widgetId != state.widgetId) {
if (action.withConfirmation) {
// Ask confirmation to switch, but wait a bit for the Activity to quit the PiP mode
viewModelScope.launch {
diff --git a/vector/src/main/java/im/vector/app/features/call/conference/JitsiService.kt b/vector/src/main/java/im/vector/app/features/call/conference/JitsiService.kt
index b8b6d83dd1..b691296ba3 100644
--- a/vector/src/main/java/im/vector/app/features/call/conference/JitsiService.kt
+++ b/vector/src/main/java/im/vector/app/features/call/conference/JitsiService.kt
@@ -22,6 +22,7 @@ import im.vector.app.core.resources.StringProvider
import im.vector.app.core.utils.ensureProtocol
import im.vector.app.core.utils.toBase32String
import im.vector.app.features.call.conference.jwt.JitsiJWTFactory
+import im.vector.app.features.displayname.getBestName
import im.vector.app.features.raw.wellknown.getElementWellknown
import im.vector.app.features.settings.VectorLocale
import im.vector.app.features.themes.ThemeProvider
diff --git a/vector/src/main/java/im/vector/app/features/call/conference/RemoveJitsiWidgetView.kt b/vector/src/main/java/im/vector/app/features/call/conference/RemoveJitsiWidgetView.kt
index 391471d2f2..fd7fc31e6d 100644
--- a/vector/src/main/java/im/vector/app/features/call/conference/RemoveJitsiWidgetView.kt
+++ b/vector/src/main/java/im/vector/app/features/call/conference/RemoveJitsiWidgetView.kt
@@ -87,10 +87,10 @@ import org.matrix.android.sdk.api.session.room.model.Membership
fun render(roomDetailViewState: RoomDetailViewState) {
val summary = roomDetailViewState.asyncRoomSummary()
- val newState = if (summary?.membership != Membership.JOIN
- || roomDetailViewState.isWebRTCCallOptionAvailable()
- || !roomDetailViewState.isAllowedToManageWidgets
- || roomDetailViewState.jitsiState.widgetId == null) {
+ val newState = if (summary?.membership != Membership.JOIN ||
+ roomDetailViewState.isWebRTCCallOptionAvailable() ||
+ !roomDetailViewState.isAllowedToManageWidgets ||
+ roomDetailViewState.jitsiState.widgetId == null) {
State.Unmount
} else if (roomDetailViewState.jitsiState.deleteWidgetInProgress) {
State.Progress
diff --git a/vector/src/main/java/im/vector/app/features/call/dialpad/CallDialPadBottomSheet.kt b/vector/src/main/java/im/vector/app/features/call/dialpad/CallDialPadBottomSheet.kt
index 3472d01c72..8bf2ce47bd 100644
--- a/vector/src/main/java/im/vector/app/features/call/dialpad/CallDialPadBottomSheet.kt
+++ b/vector/src/main/java/im/vector/app/features/call/dialpad/CallDialPadBottomSheet.kt
@@ -87,7 +87,7 @@ class CallDialPadBottomSheet : VectorBaseBottomSheetDialogFragment(initialState) {
+ private val callManager: WebRtcCallManager) :
+ VectorViewModel(initialState) {
@AssistedFactory
interface Factory {
diff --git a/vector/src/main/java/im/vector/app/features/call/webrtc/WebRtcCall.kt b/vector/src/main/java/im/vector/app/features/call/webrtc/WebRtcCall.kt
index 56368b8175..e632d00790 100644
--- a/vector/src/main/java/im/vector/app/features/call/webrtc/WebRtcCall.kt
+++ b/vector/src/main/java/im/vector/app/features/call/webrtc/WebRtcCall.kt
@@ -636,8 +636,8 @@ class WebRtcCall(
// We consider a call to be on hold only if *all* the tracks are on hold
// (is this the right thing to do?)
for (transceiver in peerConnection?.transceivers ?: emptyList()) {
- val trackOnHold = transceiver.currentDirection == RtpTransceiver.RtpTransceiverDirection.INACTIVE
- || transceiver.currentDirection == RtpTransceiver.RtpTransceiverDirection.RECV_ONLY
+ val trackOnHold = transceiver.currentDirection == RtpTransceiver.RtpTransceiverDirection.INACTIVE ||
+ transceiver.currentDirection == RtpTransceiver.RtpTransceiverDirection.RECV_ONLY
if (!trackOnHold) callOnHold = false
}
return callOnHold
@@ -891,8 +891,8 @@ class WebRtcCall(
val polite = !mxCall.isOutgoing
// Here we follow the perfect negotiation logic from
// https://developer.mozilla.org/en-US/docs/Web/API/WebRTC_API/Perfect_negotiation
- val offerCollision = description.type == SdpType.OFFER
- && (makingOffer || peerConnection.signalingState() != PeerConnection.SignalingState.STABLE)
+ val offerCollision = description.type == SdpType.OFFER &&
+ (makingOffer || peerConnection.signalingState() != PeerConnection.SignalingState.STABLE)
ignoreOffer = !polite && offerCollision
if (ignoreOffer) {
diff --git a/vector/src/main/java/im/vector/app/features/command/Command.kt b/vector/src/main/java/im/vector/app/features/command/Command.kt
index 206c5af17a..33ccd08d22 100644
--- a/vector/src/main/java/im/vector/app/features/command/Command.kt
+++ b/vector/src/main/java/im/vector/app/features/command/Command.kt
@@ -28,14 +28,20 @@ enum class Command(val command: String, val parameters: String, @StringRes val d
EMOTE("/me", "", R.string.command_description_emote, false),
BAN_USER("/ban", " [reason]", R.string.command_description_ban_user, false),
UNBAN_USER("/unban", " [reason]", R.string.command_description_unban_user, false),
+ IGNORE_USER("/ignore", " [reason]", R.string.command_description_ignore_user, false),
+ UNIGNORE_USER("/unignore", "", R.string.command_description_unignore_user, false),
SET_USER_POWER_LEVEL("/op", " []", R.string.command_description_op_user, false),
RESET_USER_POWER_LEVEL("/deop", "", R.string.command_description_deop_user, false),
+ ROOM_NAME("/roomname", "", R.string.command_description_room_name, false),
INVITE("/invite", " [reason]", R.string.command_description_invite_user, false),
JOIN_ROOM("/join", " [reason]", R.string.command_description_join_room, false),
PART("/part", " [reason]", R.string.command_description_part_room, false),
TOPIC("/topic", "", R.string.command_description_topic, false),
KICK_USER("/kick", " [reason]", R.string.command_description_kick_user, false),
CHANGE_DISPLAY_NAME("/nick", "", R.string.command_description_nick, false),
+ CHANGE_DISPLAY_NAME_FOR_ROOM("/myroomnick", "", R.string.command_description_nick_for_room, false),
+ ROOM_AVATAR("/roomavatar", "", R.string.command_description_room_avatar, true /* Since user has to know the mxc url */),
+ CHANGE_AVATAR_FOR_ROOM("/myroomavatar", "", R.string.command_description_avatar_for_room, true /* Since user has to know the mxc url */),
MARKDOWN("/markdown", "", R.string.command_description_markdown, false),
RAINBOW("/rainbow", "", R.string.command_description_rainbow, false),
RAINBOW_EMOTE("/rainbowme", "", R.string.command_description_rainbow_emote, false),
@@ -43,11 +49,13 @@ enum class Command(val command: String, val parameters: String, @StringRes val d
SPOILER("/spoiler", "", R.string.command_description_spoiler, false),
POLL("/poll", "Question | Option 1 | Option 2 ...", R.string.command_description_poll, false),
SHRUG("/shrug", "", R.string.command_description_shrug, false),
+ LENNY("/lenny", "", R.string.command_description_lenny, false),
PLAIN("/plain", "", R.string.command_description_plain, false),
+ WHOIS("/whois", "", R.string.command_description_whois, false),
DISCARD_SESSION("/discardsession", "", R.string.command_description_discard_session, false),
CONFETTI("/confetti", "", R.string.command_confetti, false),
SNOWFALL("/snowfall", "", R.string.command_snow, false),
- CREATE_SPACE("/createspace", "