diff --git a/.editorconfig b/.editorconfig
index 0a49eadc0bd..1966f917635 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 dcb9f0a7662..38885e9cc71 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 51fe7a7bd14..903c05c5d36 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
@@ -36,6 +36,7 @@ body:
- [ ] Push `main` and the new tag `v1.1.10` to origin
- [ ] Checkout `develop`
- [ ] Increase version in `./vector/build.gradle`
+ - [ ] Change the value of SDK_VERSION in the file `./matrix-sdk-android/build.gradle`
- [ ] Commit and push `develop`
- [ ] Wait for [Buildkite](https://buildkite.com/matrix-dot-org/element-android/builds?branch=main) to build the `main` branch.
- [ ] Run the script `~/scripts/releaseElement.sh`. It will download the APKs from Buildkite check them and sign them.
@@ -70,11 +71,27 @@ body:
https://github.com/matrix-org/matrix-android-sdk2
- [ ] Create a release with GitFlow
+ - [ ] Update the value of VERSION_NAME in the file gradle.properties
- [ ] Update the files `./build.gradle` and `./gradle/gradle-wrapper.properties` manually, to use the latest version for the dependency. You can get inspired by the same files on Element Android project.
- [ ] Run the script `./tools/import_from_element.sh`
- - [ ] Update the version in `./matrix-sdk-android/build.gradle` and let the script finish to build the library
+ - [ ] Check the diff in the file `./matrix-sdk-android/build.gradle` and restore what may have been erased (in particular the line `apply plugin: "com.vanniktech.maven.publish"` and the line about the version)
+ - [ ] Let the script finish to build the library
- [ ] Update the file `CHANGES.md`
- [ ] Finish the release using GitFlow
+ - [ ] Push the branch `main`, the new tag and the branch `develop` to origin
+
+ ##### Release on MavenCentral
+
+ - [ ] Run the command `./gradlew publish --no-daemon --no-parallel`. You'll need some non-public element to do so
+ - [ ] Connect to https://s01.oss.sonatype.org
+ - [ ] Click on Staging Repositories and check the the files have been uploaded
+ - [ ] Click on close
+ - [ ] Wait (check Activity tab until step "Repository closed" is displayed)
+ - [ ] Click on release. The staging repository will disappear
+ - [ ] Check that the release is available in https://repo1.maven.org/maven2/org/matrix/android/matrix-android-sdk2/ (it can take a few minutes)
+
+ ##### Release on GitHub
+
- [ ] Create the release on GitHub from [the tag](https://github.com/matrix-org/matrix-android-sdk2/tags)
- [ ] Upload the AAR on the GitHub release
@@ -82,7 +99,7 @@ body:
https://github.com/matrix-org/matrix-android-sdk2-sample
- - [ ] Update the dependency to the new version of the SDK2. Jitpack will have to build the AAR, it can take a few minutes. You can check status on https://jitpack.io/#matrix-org/matrix-android-sdk2
+ - [ ] Update the dependency to the new version of the SDK2. It can take some time for MavenCentral to make the librarie available. You can check status on https://repo1.maven.org/maven2/org/matrix/android/matrix-android-sdk2/
- [ ] Build and run the sample, you may have to fix some API break
- [ ] Commit and push directly on `main`
validations:
diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md
index 8fbc5602fee..2048b823f06 100644
--- a/.github/PULL_REQUEST_TEMPLATE.md
+++ b/.github/PULL_REQUEST_TEMPLATE.md
@@ -1,10 +1,16 @@
### Pull Request Checklist
-
+
- [ ] Changes has been tested on an Android device or Android emulator with API 21
- [ ] UI change has been tested on both light and dark themes
+- [ ] Accessibility has been taken into account. See https://github.com/vector-im/element-android/blob/develop/CONTRIBUTING.md#accessibility
- [ ] Pull request is based on the develop branch
- [ ] Pull request includes a new file under ./changelog.d. See https://github.com/vector-im/element-android/blob/develop/CONTRIBUTING.md#changelog
- [ ] Pull request includes screenshots or videos if containing UI changes
- [ ] Pull request includes a [sign off](https://github.com/matrix-org/synapse/blob/master/CONTRIBUTING.md#sign-off)
+- [ ] You've made a self review of your PR
+- [ ] If you have modified the screen flow, or added new screens to the application, you have updated the test [UiAllScreensSanityTest.allScreensTest()](https://github.com/vector-im/element-android/blob/main/vector/src/androidTest/java/im/vector/app/ui/UiAllScreensSanityTest.kt#L73)
\ No newline at end of file
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 85148a2632a..91dc6d830b5 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -5,6 +5,12 @@ on:
push:
branches: [ main, develop ]
+# Enrich gradle.properties for CI/CD
+env:
+ CI_GRADLE_ARG_PROPERTIES: >
+ -Porg.gradle.jvmargs=-Xmx2g
+ -Porg.gradle.parallel=false
+
jobs:
debug:
name: Build debug APKs (${{ matrix.target }})
@@ -25,7 +31,7 @@ jobs:
restore-keys: |
${{ runner.os }}-gradle-
- name: Assemble ${{ matrix.target }} debug apk
- run: ./gradlew assemble${{ matrix.target }}Debug --stacktrace
+ run: ./gradlew assemble${{ matrix.target }}Debug $CI_GRADLE_ARG_PROPERTIES --stacktrace
- name: Upload ${{ matrix.target }} debug APKs
uses: actions/upload-artifact@v2
with:
@@ -48,7 +54,7 @@ jobs:
restore-keys: |
${{ runner.os }}-gradle-
- name: Assemble GPlay unsigned apk
- run: ./gradlew clean assembleGplayRelease --stacktrace
+ run: ./gradlew clean assembleGplayRelease $CI_GRADLE_ARG_PROPERTIES --stacktrace
- name: Upload Gplay unsigned APKs
uses: actions/upload-artifact@v2
with:
diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml
index 984ae0748e1..c18ca69fdee 100644
--- a/.github/workflows/integration.yml
+++ b/.github/workflows/integration.yml
@@ -5,6 +5,12 @@ on:
push:
branches: [ main, develop ]
+# Enrich gradle.properties for CI/CD
+env:
+ CI_GRADLE_ARG_PROPERTIES: >
+ -Porg.gradle.jvmargs=-Xmx2g
+ -Porg.gradle.parallel=false
+
jobs:
# Temporary add build of Android tests, which cannot be run on the CI right now, but they need to at least compile
# So it will be mandatory for this action to be successful on every PRs
@@ -22,7 +28,7 @@ jobs:
restore-keys: |
${{ runner.os }}-gradle-
- name: Compile Android tests
- run: ./gradlew clean assembleAndroidTest --stacktrace -PallWarningsAsErrors=false
+ run: ./gradlew clean assembleAndroidTest $CI_GRADLE_ARG_PROPERTIES --stacktrace -PallWarningsAsErrors=false
integration-tests:
name: Integration Tests (Synapse)
@@ -30,9 +36,14 @@ jobs:
strategy:
fail-fast: false
matrix:
- api-level: [21, 28, 30]
+ api-level: [28]
steps:
- uses: actions/checkout@v2
+ - uses: gradle/wrapper-validation-action@v1
+ - uses: actions/setup-java@v2
+ with:
+ distribution: 'adopt'
+ java-version: 11
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
@@ -64,5 +75,12 @@ jobs:
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ matrix.api-level }}
+ #arch: x86_64
+ #disable-animations: true
# script: ./gradlew -PallWarningsAsErrors=false vector:connectedAndroidTest matrix-sdk-android:connectedAndroidTest
- script: ./gradlew -PallWarningsAsErrors=false connectedCheck
+ arch: x86
+ profile: Nexus 5X
+ force-avd-creation: false
+ emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
+ emulator-build: 7425822
+ script: ./gradlew $CI_GRADLE_ARG_PROPERTIES -PallWarningsAsErrors=false connectedCheck --stacktrace
diff --git a/.github/workflows/quality.yml b/.github/workflows/quality.yml
index 0f119152581..8c56edfa3a5 100644
--- a/.github/workflows/quality.yml
+++ b/.github/workflows/quality.yml
@@ -21,8 +21,12 @@ jobs:
- uses: actions/checkout@v2
- name: Run klint
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/.github/workflows/sanity_test.yml b/.github/workflows/sanity_test.yml
index 632dee8a582..3ab0017ce2e 100644
--- a/.github/workflows/sanity_test.yml
+++ b/.github/workflows/sanity_test.yml
@@ -5,6 +5,12 @@ on:
push:
branches: [ main, develop ]
+# Enrich gradle.properties for CI/CD
+env:
+ CI_GRADLE_ARG_PROPERTIES: >
+ -Porg.gradle.jvmargs=-Xmx2g
+ -Porg.gradle.parallel=false
+
jobs:
integration-tests:
name: Sanity Tests (Synapse)
@@ -46,5 +52,5 @@ jobs:
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ matrix.api-level }}
- script: ./gradlew -PallWarningsAsErrors=false connectedGplayDebugAndroidTest -Pandroid.testInstrumentationRunnerArguments.class=im.vector.app.ui.UiAllScreensSanityTest
+ script: ./gradlew $CI_GRADLE_ARG_PROPERTIES -PallWarningsAsErrors=false connectedGplayDebugAndroidTest -Pandroid.testInstrumentationRunnerArguments.class=im.vector.app.ui.UiAllScreensSanityTest
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index 6e51368ce5d..50195638de1 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -5,6 +5,12 @@ on:
push:
branches: [main, develop]
+# Enrich gradle.properties for CI/CD
+env:
+ CI_GRADLE_ARG_PROPERTIES: >
+ -Porg.gradle.jvmargs=-Xmx2g
+ -Porg.gradle.parallel=false
+
jobs:
unit-tests:
name: Run Unit Tests
@@ -20,4 +26,11 @@ jobs:
restore-keys: |
${{ runner.os }}-gradle-
- name: Run unit tests
- run: ./gradlew clean test --stacktrace -PallWarningsAsErrors=false
+ run: ./gradlew clean test $CI_GRADLE_ARG_PROPERTIES -PallWarningsAsErrors=false --stacktrace
+ - name: Publish Unit Test Results
+ uses: EnricoMi/publish-unit-test-result-action@v1
+ if: always() &&
+ github.event.sender.login != 'dependabot[bot]' &&
+ ( github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository )
+ with:
+ files: ./**/build/test-results/**/*.xml
diff --git a/.gitignore b/.gitignore
index 04d1b6fe06e..ff086d77234 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,6 +8,7 @@
.idea/*.xml
.DS_Store
/build
+/benchmark-out
/captures
.externalNativeBuild
@@ -15,4 +16,4 @@
/fastlane/private
/fastlane/report.xml
-ktlint
+/library/build
diff --git a/CHANGES.md b/CHANGES.md
index 640d56a9fda..8d4899e6fb5 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -1,3 +1,113 @@
+Changes in Element v1.3.1 (2021-09-29)
+======================================
+
+Bugfixes 🐛
+----------
+ - Verifying exported E2E keys to provide user feedback when the output is malformed ([#4082](https://github.com/vector-im/element-android/issues/4082))
+ - Fix settings crash when accelerometer not available ([#4103](https://github.com/vector-im/element-android/issues/4103))
+ - Crash while rendering failed message warning ([#4110](https://github.com/vector-im/element-android/issues/4110))
+
+
+Changes in Element v1.3.0 (2021-09-27)
+======================================
+
+Features ✨
+----------
+ - Spaces!
+ - Adds email notification registration to Settings ([#2243](https://github.com/vector-im/element-android/issues/2243))
+ - Spaces | M3.23 Invite by email in create private space flow ([#3678](https://github.com/vector-im/element-android/issues/3678))
+ - Improve space invite bottom sheet ([#4057](https://github.com/vector-im/element-android/issues/4057))
+ - Allow to also leave rooms when leaving a space ([#3692](https://github.com/vector-im/element-android/issues/3692))
+ - Better expose adding spaces as Subspaces ([#3752](https://github.com/vector-im/element-android/issues/3752))
+ - Push and syncs: add debug info on room list and on room detail screen and improves the log format. ([#4046](https://github.com/vector-im/element-android/issues/4046))
+
+Bugfixes 🐛
+----------
+ - Remove the "Teammate spaces aren't quite ready" bottom sheet ([#3945](https://github.com/vector-im/element-android/issues/3945))
+ - Restricted Room previews aren't working ([#3946](https://github.com/vector-im/element-android/issues/3946))
+ - A removed room from a space can't be re-added as it won't be shown in add-room ([#3947](https://github.com/vector-im/element-android/issues/3947))
+ - "Non-Admin" user able to invite others to Private Space (by default) ([#3951](https://github.com/vector-im/element-android/issues/3951))
+ - Kick user dialog for spaces talks about rooms ([#3956](https://github.com/vector-im/element-android/issues/3956))
+ - Messages are displayed as unable to decrypt then decrypted a few seconds later ([#4011](https://github.com/vector-im/element-android/issues/4011))
+ - Fix DTMF not working ([#4015](https://github.com/vector-im/element-android/issues/4015))
+ - Fix sticky end call notification ([#4019](https://github.com/vector-im/element-android/issues/4019))
+ - Fix call screen stuck with some hanging up scenarios ([#4026](https://github.com/vector-im/element-android/issues/4026))
+ - Fix other call not always refreshed when ended ([#4028](https://github.com/vector-im/element-android/issues/4028))
+ - Private space invite bottomsheet only offering inviting by username not by email ([#4042](https://github.com/vector-im/element-android/issues/4042))
+ - Spaces invitation system notifications don't take me to the join space toast ([#4043](https://github.com/vector-im/element-android/issues/4043))
+ - Space Invites are not lighting up the drawer menu ([#4059](https://github.com/vector-im/element-android/issues/4059))
+ - MessageActionsBottomSheet not being shown on local echos ([#4068](https://github.com/vector-im/element-android/issues/4068))
+
+SDK API changes ⚠️
+------------------
+ - InitialSyncProgressService has been renamed to SyncStatusService and its function getInitialSyncProgressStatus() has been renamed to getSyncStatusLive() ([#4046](https://github.com/vector-im/element-android/issues/4046))
+
+Other changes
+-------------
+ - Better support for Sdk2 version. Also slight change in the default user agent: `MatrixAndroidSDK_X` is replaced by `MatrixAndroidSdk2` ([#3994](https://github.com/vector-im/element-android/issues/3994))
+ - Introduces ConferenceEvent to abstract usage of Jitsi BroadcastEvent class. ([#4014](https://github.com/vector-im/element-android/issues/4014))
+ - Improve performances on RoomDetail screen ([#4065](https://github.com/vector-im/element-android/issues/4065))
+
+
+Changes in Element v1.2.2 (2021-09-13)
+======================================
+
+Bugfixes 🐛
+----------
+
+- Fix a security issue with message key sharing. See https://matrix.org/blog/2021/09/13/vulnerability-disclosure-key-sharing for details.
+
+
+Changes in Element v1.2.1 (2021-09-08)
+======================================
+
+Features ✨
+----------
+ - Support Android 11 Conversation features ([#1809](https://github.com/vector-im/element-android/issues/1809))
+ - Introduces AutoAcceptInvites which can be enabled at compile time. ([#3531](https://github.com/vector-im/element-android/issues/3531))
+ - New call designs ([#3599](https://github.com/vector-im/element-android/issues/3599))
+ - Restricted Join Rule | Inform admins of new option ([#3631](https://github.com/vector-im/element-android/issues/3631))
+ - Mention and Keyword Notification Settings: Turn on/off keyword notifications and edit keywords. ([#3650](https://github.com/vector-im/element-android/issues/3650))
+ - Support accept 3pid invite when email is not bound to account ([#3691](https://github.com/vector-im/element-android/issues/3691))
+ - Space summary pagination ([#3693](https://github.com/vector-im/element-android/issues/3693))
+ - Update Email invite to be aware of spaces ([#3695](https://github.com/vector-im/element-android/issues/3695))
+ - M11.12 Spaces | Default to 'Home' in settings ([#3754](https://github.com/vector-im/element-android/issues/3754))
+ - Call: show dialog for some ended reasons. ([#3853](https://github.com/vector-im/element-android/issues/3853))
+ - Add expired account error code in the matrix SDK ([#3900](https://github.com/vector-im/element-android/issues/3900))
+ - Add password errors in the matrix SDK ([#3927](https://github.com/vector-im/element-android/issues/3927))
+ - Upgrade AGP to 7.0.2.
+ When compiling using command line, make sure to use the JDK 11 by adding for instance `-Dorg.gradle.java.home=/Applications/Android\ Studio\ Preview.app/Contents/jre/Contents/Home` or by setting JAVA_HOME. ([#3954](https://github.com/vector-im/element-android/issues/3954))
+ - Check power level before displaying actions in the room details' timeline ([#3959](https://github.com/vector-im/element-android/issues/3959))
+
+Bugfixes 🐛
+----------
+ - Add mxid to autocomplete suggestion if more than one user in a room has the same displayname ([#1823](https://github.com/vector-im/element-android/issues/1823))
+ - Use WebView cache for widgets to avoid excessive data use ([#2648](https://github.com/vector-im/element-android/issues/2648))
+ - Jitsi-hosted jitsi conferences not loading ([#2846](https://github.com/vector-im/element-android/issues/2846))
+ - Space Explore Rooms no feedback on failed to join ([#3207](https://github.com/vector-im/element-android/issues/3207))
+ - Notifications - Fix missing sound on notifications. ([#3243](https://github.com/vector-im/element-android/issues/3243))
+ - 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 ([#3735](https://github.com/vector-im/element-android/issues/3735))
+ - Update the AccountData with the users' matrix Id instead of their email for those invited by email in a direct chat ([#3743](https://github.com/vector-im/element-android/issues/3743))
+ - Send an empty body for POST rooms/{roomId}/receipt/{receiptType}/{eventId} ([#3789](https://github.com/vector-im/element-android/issues/3789))
+ - Fix order in which the items of the attachment menu appear ([#3793](https://github.com/vector-im/element-android/issues/3793))
+ - Authenticated Jitsi not working in release ([#3841](https://github.com/vector-im/element-android/issues/3841))
+ - Home: Dial pad lost entry when config changes ([#3845](https://github.com/vector-im/element-android/issues/3845))
+ - Message edition is not rendered in e2e rooms after pagination ([#3887](https://github.com/vector-im/element-android/issues/3887))
+ - Crash on opening a room on Android 5.0 and 5.1 - Regression with Voice message ([#3897](https://github.com/vector-im/element-android/issues/3897))
+ - Fix a crash at start-up if translated string is empty ([#3910](https://github.com/vector-im/element-android/issues/3910))
+ - PushRule enabling request is not following the spec ([#3911](https://github.com/vector-im/element-android/issues/3911))
+ - Enable image preview in Android's share sheet (Android 11+) ([#3965](https://github.com/vector-im/element-android/issues/3965))
+ - Voice Message - Cannot render voice message if the waveform data is corrupted ([#3983](https://github.com/vector-im/element-android/issues/3983))
+ - Fix memory leak on RoomDetailFragment (ValueAnimator) ([#3990](https://github.com/vector-im/element-android/issues/3990))
+
+Other changes
+-------------
+ - VoIP: Merge virtual room timeline in corresponding native room (call events only). ([#3520](https://github.com/vector-im/element-android/issues/3520))
+ - Issue templates: modernise and sync with element-web ([#3883](https://github.com/vector-im/element-android/issues/3883))
+ - Issue templates: modernise SDK and release checklists, and add homeserver question for bugs ([#3889](https://github.com/vector-im/element-android/issues/3889))
+ - Issue templates: merge expected and actual results ([#3960](https://github.com/vector-im/element-android/issues/3960))
+
+
Changes in Element v1.2.0 (2021-08-12)
======================================
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 610a6227b78..dbc0ce9b725 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)
@@ -148,6 +147,8 @@ The string will be removed during the next sync with Weblate.
Please consider accessibility as an important point. As a minimum requirement, in layout XML files please use attributes such as `android:contentDescription` and `android:importantForAccessibility`, and test with a screen reader if it's working well. You can add new string resources, dedicated to accessibility, in this case, please prefix theirs id with `a11y_`.
+For instance, when updating the image `src` of an ImageView, please also consider updating its `contentDescription`. A good example is a play pause button.
+
### Layout
When adding or editing layouts, make sure the layout will render correctly if device uses a RTL (Right To Left) language.
diff --git a/attachment-viewer/build.gradle b/attachment-viewer/build.gradle
index d62062ae143..064f497dc75 100644
--- a/attachment-viewer/build.gradle
+++ b/attachment-viewer/build.gradle
@@ -18,13 +18,12 @@ apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
android {
- compileSdkVersion 30
+
+ compileSdk versions.compileSdk
defaultConfig {
- minSdkVersion 21
- targetSdkVersion 30
- versionCode 1
- versionName "1.0"
+ minSdk versions.minSdk
+ targetSdk versions.targetSdk
}
buildTypes {
@@ -34,8 +33,8 @@ android {
}
}
compileOptions {
- sourceCompatibility JavaVersion.VERSION_11
- targetCompatibility JavaVersion.VERSION_11
+ sourceCompatibility versions.sourceCompat
+ targetCompatibility versions.targetCompat
}
kotlinOptions {
jvmTarget = "11"
@@ -51,13 +50,13 @@ dependencies {
implementation 'com.github.chrisbanes:PhotoView:2.3.0'
- implementation 'io.reactivex.rxjava2:rxkotlin:2.4.0'
- implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
+ implementation libs.rx.rxKotlin
+ implementation libs.rx.rxAndroid
- implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
- implementation 'androidx.core:core-ktx:1.6.0'
- implementation 'androidx.appcompat:appcompat:1.3.1'
- implementation "androidx.recyclerview:recyclerview:1.2.1"
+ implementation libs.jetbrains.kotlinStdlib
+ implementation libs.androidx.core
+ implementation libs.androidx.appCompat
+ implementation libs.androidx.recyclerview
- implementation 'com.google.android.material:material:1.4.0'
+ implementation libs.google.material
}
\ No newline at end of file
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 f909418d6fe..4ca6ced8fe5 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 531e8171e15..99686eaabb2 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 ef26530298f..93f3e17f34c 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,9 +1,9 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
- // Ref: https://kotlinlang.org/releases.html
- ext.kotlin_version = '1.5.21'
- ext.kotlin_coroutines_version = "1.5.0"
+
+ apply from: 'dependencies.gradle'
+
repositories {
google()
jcenter()
@@ -11,12 +11,13 @@ buildscript {
url "https://plugins.gradle.org/m2/"
}
}
+
dependencies {
// Release notes of Android Gradle Plugin (AGP):
// https://developer.android.com/studio/releases/gradle-plugin
- classpath 'com.android.tools.build:gradle:7.0.2'
+ classpath libs.gradle.gradlePlugin
+ classpath libs.gradle.kotlinPlugin
classpath 'com.google.gms:google-services:4.3.10'
- classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:3.3'
classpath 'com.google.android.gms:oss-licenses-plugin:0.10.4'
classpath "com.likethesalad.android:string-reference:1.2.2"
@@ -26,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 {
@@ -74,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/changelog.d/1673.bugfix b/changelog.d/1673.bugfix
new file mode 100644
index 00000000000..b0459f34b85
--- /dev/null
+++ b/changelog.d/1673.bugfix
@@ -0,0 +1 @@
+Avoid resending notifications that are already shown
diff --git a/changelog.d/1809.feature b/changelog.d/1809.feature
deleted file mode 100644
index b037ffa6d31..00000000000
--- a/changelog.d/1809.feature
+++ /dev/null
@@ -1 +0,0 @@
-Support Android 11 Conversation features
\ No newline at end of file
diff --git a/changelog.d/1823.bugfix b/changelog.d/1823.bugfix
deleted file mode 100644
index 8252e1826f7..00000000000
--- a/changelog.d/1823.bugfix
+++ /dev/null
@@ -1 +0,0 @@
-- Add mxid to autocomplete suggestion if more than one user in a room has the same displayname
diff --git a/changelog.d/240.feature b/changelog.d/240.feature
new file mode 100644
index 00000000000..ee4d07a9759
--- /dev/null
+++ b/changelog.d/240.feature
@@ -0,0 +1 @@
+Android Auto notification support
diff --git a/changelog.d/2648.bugfix b/changelog.d/2648.bugfix
deleted file mode 100644
index 24853af1bc1..00000000000
--- a/changelog.d/2648.bugfix
+++ /dev/null
@@ -1 +0,0 @@
-Use WebView cache for widgets to avoid excessive data use
\ No newline at end of file
diff --git a/changelog.d/2846.bugfix b/changelog.d/2846.bugfix
deleted file mode 100644
index 1669ea1cf9f..00000000000
--- a/changelog.d/2846.bugfix
+++ /dev/null
@@ -1 +0,0 @@
-Jitsi-hosted jitsi conferences not loading
\ No newline at end of file
diff --git a/changelog.d/3048.bugfix b/changelog.d/3048.bugfix
new file mode 100644
index 00000000000..81fbe7b65eb
--- /dev/null
+++ b/changelog.d/3048.bugfix
@@ -0,0 +1 @@
+Room filter no results bad CTA in space mode when a space selected
\ No newline at end of file
diff --git a/changelog.d/3243.bugfix b/changelog.d/3243.bugfix
deleted file mode 100644
index 8c912a5c135..00000000000
--- a/changelog.d/3243.bugfix
+++ /dev/null
@@ -1 +0,0 @@
-Notifications - Fix missing sound on notifications.
\ No newline at end of file
diff --git a/changelog.d/3347.bugfix b/changelog.d/3347.bugfix
new file mode 100644
index 00000000000..8ba1d7af882
--- /dev/null
+++ b/changelog.d/3347.bugfix
@@ -0,0 +1 @@
+Fixes notifications not dismissing when reading messages on other devices
\ No newline at end of file
diff --git a/changelog.d/3599.feature b/changelog.d/3599.feature
deleted file mode 100644
index 7f09477f9c7..00000000000
--- a/changelog.d/3599.feature
+++ /dev/null
@@ -1 +0,0 @@
-New call designs
\ No newline at end of file
diff --git a/changelog.d/3631.feature b/changelog.d/3631.feature
deleted file mode 100644
index 01e1ee28cc6..00000000000
--- a/changelog.d/3631.feature
+++ /dev/null
@@ -1 +0,0 @@
-Restricted Join Rule | Inform admins of new option
\ No newline at end of file
diff --git a/changelog.d/3650.feature b/changelog.d/3650.feature
deleted file mode 100644
index 4ae065701fd..00000000000
--- a/changelog.d/3650.feature
+++ /dev/null
@@ -1 +0,0 @@
-Mention and Keyword Notification Settings: Turn on/off keyword notifications and edit keywords.
\ No newline at end of file
diff --git a/changelog.d/3691.feature b/changelog.d/3691.feature
deleted file mode 100644
index ae139681b01..00000000000
--- a/changelog.d/3691.feature
+++ /dev/null
@@ -1 +0,0 @@
- Support accept 3pid invite when email is not bound to account
\ No newline at end of file
diff --git a/changelog.d/3693.feature b/changelog.d/3693.feature
deleted file mode 100644
index 6351ded5223..00000000000
--- a/changelog.d/3693.feature
+++ /dev/null
@@ -1 +0,0 @@
-Space summary pagination
\ No newline at end of file
diff --git a/changelog.d/3695.feature b/changelog.d/3695.feature
deleted file mode 100644
index bd5934529d5..00000000000
--- a/changelog.d/3695.feature
+++ /dev/null
@@ -1 +0,0 @@
-Update Email invite to be aware of spaces
\ No newline at end of file
diff --git a/changelog.d/3732.feature b/changelog.d/3732.feature
new file mode 100644
index 00000000000..3352c30886d
--- /dev/null
+++ b/changelog.d/3732.feature
@@ -0,0 +1 @@
+Add a fallback for user displayName when this one is null or empty
\ No newline at end of file
diff --git a/changelog.d/3735.bugfix b/changelog.d/3735.bugfix
deleted file mode 100644
index 8262af627b5..00000000000
--- a/changelog.d/3735.bugfix
+++ /dev/null
@@ -1 +0,0 @@
-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
\ No newline at end of file
diff --git a/changelog.d/3743.bugfix b/changelog.d/3743.bugfix
deleted file mode 100644
index 87baf628343..00000000000
--- a/changelog.d/3743.bugfix
+++ /dev/null
@@ -1 +0,0 @@
-Update the AccountData with the users' matrix Id instead of their email for those invited by email in a direct chat
\ No newline at end of file
diff --git a/changelog.d/3754.feature b/changelog.d/3754.feature
deleted file mode 100644
index e997ac370dc..00000000000
--- a/changelog.d/3754.feature
+++ /dev/null
@@ -1 +0,0 @@
-M11.12 Spaces | Default to 'Home' in settings
\ No newline at end of file
diff --git a/changelog.d/3789.bugfix b/changelog.d/3789.bugfix
deleted file mode 100644
index fc3402e029d..00000000000
--- a/changelog.d/3789.bugfix
+++ /dev/null
@@ -1 +0,0 @@
-Send an empty body for POST rooms/{roomId}/receipt/{receiptType}/{eventId}
\ No newline at end of file
diff --git a/changelog.d/3793.bugfix b/changelog.d/3793.bugfix
deleted file mode 100644
index 8f812292624..00000000000
--- a/changelog.d/3793.bugfix
+++ /dev/null
@@ -1 +0,0 @@
-Fix order in which the items of the attachement menu appear
diff --git a/changelog.d/3841.bugfix b/changelog.d/3841.bugfix
deleted file mode 100644
index d0e84757dc7..00000000000
--- a/changelog.d/3841.bugfix
+++ /dev/null
@@ -1 +0,0 @@
-Authenticated Jitsi not working in release
\ No newline at end of file
diff --git a/changelog.d/3845.bugfix b/changelog.d/3845.bugfix
deleted file mode 100644
index ce820738fe4..00000000000
--- a/changelog.d/3845.bugfix
+++ /dev/null
@@ -1 +0,0 @@
-Home: Dial pad lost entry when config changes
\ No newline at end of file
diff --git a/changelog.d/3853.feature b/changelog.d/3853.feature
deleted file mode 100644
index 86c19d2c22b..00000000000
--- a/changelog.d/3853.feature
+++ /dev/null
@@ -1 +0,0 @@
-Call: show dialog for some ended reasons.
\ No newline at end of file
diff --git a/changelog.d/3883.misc b/changelog.d/3883.misc
deleted file mode 100644
index 468e5e49278..00000000000
--- a/changelog.d/3883.misc
+++ /dev/null
@@ -1 +0,0 @@
-Issue templates: modernise and sync with element-web
diff --git a/changelog.d/3887.bugfix b/changelog.d/3887.bugfix
deleted file mode 100644
index eecd2cea19e..00000000000
--- a/changelog.d/3887.bugfix
+++ /dev/null
@@ -1 +0,0 @@
-Message edition is not rendered in e2e rooms after pagination
\ No newline at end of file
diff --git a/changelog.d/3897.bugfix b/changelog.d/3897.bugfix
deleted file mode 100644
index cad8560ca41..00000000000
--- a/changelog.d/3897.bugfix
+++ /dev/null
@@ -1 +0,0 @@
-Crash on opening a room on Android 5.0 and 5.1 - Regression with Voice message
\ No newline at end of file
diff --git a/changelog.d/3898.bugfix b/changelog.d/3898.bugfix
new file mode 100644
index 00000000000..49cab4adad3
--- /dev/null
+++ b/changelog.d/3898.bugfix
@@ -0,0 +1,2 @@
+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.
\ No newline at end of file
diff --git a/changelog.d/3900.feature b/changelog.d/3900.feature
deleted file mode 100644
index 765f51f054d..00000000000
--- a/changelog.d/3900.feature
+++ /dev/null
@@ -1 +0,0 @@
-Add expired account error code in the matrix SDK
\ No newline at end of file
diff --git a/changelog.d/3910.bugfix b/changelog.d/3910.bugfix
deleted file mode 100644
index 3bca598e457..00000000000
--- a/changelog.d/3910.bugfix
+++ /dev/null
@@ -1 +0,0 @@
-Fix a crash at start-up if translated string is empty
\ No newline at end of file
diff --git a/changelog.d/3911.bugfix b/changelog.d/3911.bugfix
deleted file mode 100644
index 4cd40bdd7d9..00000000000
--- a/changelog.d/3911.bugfix
+++ /dev/null
@@ -1 +0,0 @@
-PushRule enabling request is not following the spec
\ No newline at end of file
diff --git a/changelog.d/3927.feature b/changelog.d/3927.feature
deleted file mode 100644
index 86091b6422b..00000000000
--- a/changelog.d/3927.feature
+++ /dev/null
@@ -1 +0,0 @@
-Add password errors in the matrix SDK
\ No newline at end of file
diff --git a/changelog.d/3933.bugfix b/changelog.d/3933.bugfix
new file mode 100644
index 00000000000..3396bd75e7b
--- /dev/null
+++ b/changelog.d/3933.bugfix
@@ -0,0 +1 @@
+App doesn't take you to a Space after choosing to Join it
\ No newline at end of file
diff --git a/changelog.d/3934.bugfix b/changelog.d/3934.bugfix
new file mode 100644
index 00000000000..989f96d004e
--- /dev/null
+++ b/changelog.d/3934.bugfix
@@ -0,0 +1 @@
+Validate public space addresses and room aliases length
\ No newline at end of file
diff --git a/changelog.d/3935.bugfix b/changelog.d/3935.bugfix
new file mode 100644
index 00000000000..f4b1d309b43
--- /dev/null
+++ b/changelog.d/3935.bugfix
@@ -0,0 +1 @@
+Save button for adding rooms to a space is hidden when scrolling through list of rooms
\ No newline at end of file
diff --git a/changelog.d/3954.feature b/changelog.d/3954.feature
deleted file mode 100644
index 132277032c2..00000000000
--- a/changelog.d/3954.feature
+++ /dev/null
@@ -1,2 +0,0 @@
-Upgrade AGP to 7.0.2.
-When compiling using command line, make sure to use the JDK 11 by adding for instance `-Dorg.gradle.java.home=/Applications/Android\ Studio\ Preview.app/Contents/jre/Contents/Home` or by setting JAVA_HOME.
\ No newline at end of file
diff --git a/changelog.d/3957.misc b/changelog.d/3957.misc
new file mode 100644
index 00000000000..bc6e417a49f
--- /dev/null
+++ b/changelog.d/3957.misc
@@ -0,0 +1 @@
+Use ktlint plugin. See [the documentation](https://github.com/vector-im/element-android/blob/develop/CONTRIBUTING.md#ktlint) for more detail.
\ No newline at end of file
diff --git a/changelog.d/3960.misc b/changelog.d/3960.misc
deleted file mode 100644
index d37fcc94595..00000000000
--- a/changelog.d/3960.misc
+++ /dev/null
@@ -1 +0,0 @@
-Issue templates: merge expected and actual results
diff --git a/changelog.d/3965.bugfix b/changelog.d/3965.bugfix
deleted file mode 100644
index 9d966c2ca34..00000000000
--- a/changelog.d/3965.bugfix
+++ /dev/null
@@ -1 +0,0 @@
-Enable image preview in Android's share sheet (Android 11+)
diff --git a/changelog.d/4018.misc b/changelog.d/4018.misc
new file mode 100644
index 00000000000..d0849d58420
--- /dev/null
+++ b/changelog.d/4018.misc
@@ -0,0 +1 @@
+Minimize the use of exported="true" in android Manifest (link: https://github.com/matrix-org/matrix-dinsic/issues/618)
diff --git a/changelog.d/4027.feature b/changelog.d/4027.feature
new file mode 100644
index 00000000000..fa45d07ef9e
--- /dev/null
+++ b/changelog.d/4027.feature
@@ -0,0 +1 @@
+Add client base url config to customize permalinks
\ No newline at end of file
diff --git a/changelog.d/4045.bugfix b/changelog.d/4045.bugfix
new file mode 100644
index 00000000000..c6798ae4928
--- /dev/null
+++ b/changelog.d/4045.bugfix
@@ -0,0 +1 @@
+Align new room encryption default to Web
\ No newline at end of file
diff --git a/changelog.d/4076.misc b/changelog.d/4076.misc
new file mode 100644
index 00000000000..97b50d8c546
--- /dev/null
+++ b/changelog.d/4076.misc
@@ -0,0 +1 @@
+Fix redundancy in heading in the bug report issue form
diff --git a/changelog.d/4077.bugfix b/changelog.d/4077.bugfix
new file mode 100644
index 00000000000..a8ab6b3c54d
--- /dev/null
+++ b/changelog.d/4077.bugfix
@@ -0,0 +1 @@
+Fix Reply/Edit mode animation is broken when sending
\ No newline at end of file
diff --git a/changelog.d/4092.bugfix b/changelog.d/4092.bugfix
new file mode 100644
index 00000000000..68ce5180604
--- /dev/null
+++ b/changelog.d/4092.bugfix
@@ -0,0 +1,4 @@
+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.
diff --git a/changelog.d/4109.bugfix b/changelog.d/4109.bugfix
new file mode 100644
index 00000000000..4f35dd7f557
--- /dev/null
+++ b/changelog.d/4109.bugfix
@@ -0,0 +1 @@
+Troubleshoot notification: Fix button not clickable
\ No newline at end of file
diff --git a/changelog.d/4113.misc b/changelog.d/4113.misc
new file mode 100644
index 00000000000..a5faa57b92e
--- /dev/null
+++ b/changelog.d/4113.misc
@@ -0,0 +1 @@
+Fix release label in the release issue template
diff --git a/changelog.d/4155.bugfix b/changelog.d/4155.bugfix
new file mode 100644
index 00000000000..59f5c564aa5
--- /dev/null
+++ b/changelog.d/4155.bugfix
@@ -0,0 +1 @@
+Harmonize wording in the message bottom sheet and move up the View Reactions item
\ No newline at end of file
diff --git a/changelog.d/4156.bugfix b/changelog.d/4156.bugfix
new file mode 100644
index 00000000000..a010398adc8
--- /dev/null
+++ b/changelog.d/4156.bugfix
@@ -0,0 +1 @@
+Remove unused SendRelationWorker and related API call (3588)
\ No newline at end of file
diff --git a/changelog.d/4157.feature b/changelog.d/4157.feature
new file mode 100644
index 00000000000..71cbe60b1f9
--- /dev/null
+++ b/changelog.d/4157.feature
@@ -0,0 +1 @@
+Check if DM exists before creating a new one
\ No newline at end of file
diff --git a/changelog.d/4158.feature b/changelog.d/4158.feature
new file mode 100644
index 00000000000..86d2c760c28
--- /dev/null
+++ b/changelog.d/4158.feature
@@ -0,0 +1 @@
+Handle 8 new slash commands: `/ignore`, `/unignore`, `/roomname`, `/myroomnick`, `/roomavatar`, `/myroomavatar`, `/lenny`, `/whois`.
\ No newline at end of file
diff --git a/changelog.d/4158.removal b/changelog.d/4158.removal
new file mode 100644
index 00000000000..557a85262e9
--- /dev/null
+++ b/changelog.d/4158.removal
@@ -0,0 +1 @@
+Create extension `String.isMxcUrl()`
\ No newline at end of file
diff --git a/changelog.d/983.bugfix b/changelog.d/983.bugfix
new file mode 100644
index 00000000000..7318f7f4cd2
--- /dev/null
+++ b/changelog.d/983.bugfix
@@ -0,0 +1 @@
+Ensure initial sync progress dialog is hidden when the initial sync is over
\ No newline at end of file
diff --git a/changelog.d/pr-3889.misc b/changelog.d/pr-3889.misc
deleted file mode 100644
index 361bd6419bc..00000000000
--- a/changelog.d/pr-3889.misc
+++ /dev/null
@@ -1 +0,0 @@
-Issue templates: modernise SDK and release checklists, and add homeserver question for bugs
diff --git a/dependencies.gradle b/dependencies.gradle
new file mode 100644
index 00000000000..92358952db5
--- /dev/null
+++ b/dependencies.gradle
@@ -0,0 +1,135 @@
+ext.versions = [
+
+ 'minSdk' : 21,
+ 'compileSdk' : 30,
+ 'targetSdk' : 30,
+ 'sourceCompat' : JavaVersion.VERSION_11,
+ 'targetCompat' : JavaVersion.VERSION_11,
+]
+
+def gradle = "7.0.2"
+// Ref: https://kotlinlang.org/releases.html
+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"
+def moshi = "1.12.0"
+def lifecycle = "2.2.0"
+def rxBinding = "3.1.0"
+def epoxy = "4.6.2"
+def glide = "4.12.0"
+def bigImageViewer = "1.8.1"
+def jjwt = "0.11.2"
+def vanniktechEmoji = "0.8.0"
+
+// Testing
+def mockk = "1.12.0"
+def espresso = "3.4.0"
+def androidxTest = "1.4.0"
+
+
+ext.libs = [
+ gradle : [
+ 'gradlePlugin' : "com.android.tools.build:gradle:$gradle",
+ 'kotlinPlugin' : "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin"
+ ],
+ jetbrains : [
+ 'kotlinStdlibJdk7' : "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin",
+ 'kotlinStdlib' : "org.jetbrains.kotlin:kotlin-stdlib:$kotlin",
+ 'coroutinesCore' : "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlinCoroutines",
+ 'coroutinesAndroid' : "org.jetbrains.kotlinx:kotlinx-coroutines-android:$kotlinCoroutines",
+ 'coroutinesRx2' : "org.jetbrains.kotlinx:kotlinx-coroutines-rx2:$kotlinCoroutines"
+ ],
+ androidx : [
+ 'appCompat' : "androidx.appcompat:appcompat:1.3.1",
+ 'core' : "androidx.core:core-ktx:1.6.0",
+ 'recyclerview' : "androidx.recyclerview:recyclerview:1.2.1",
+ '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.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",
+ 'lifecycleExtensions' : "androidx.lifecycle:lifecycle-extensions:$lifecycle",
+ 'lifecycleJava8' : "androidx.lifecycle:lifecycle-common-java8:$lifecycle",
+ 'lifecycleLivedata' : "androidx.lifecycle:lifecycle-livedata-ktx:2.3.1",
+ 'datastore' : "androidx.datastore:datastore:1.0.0",
+ 'datastorepreferences' : "androidx.datastore:datastore-preferences:1.0.0",
+ 'pagingRuntimeKtx' : "androidx.paging:paging-runtime-ktx:2.1.2",
+ 'coreTesting' : "androidx.arch.core:core-testing:2.1.0",
+ 'testCore' : "androidx.test:core:$androidxTest",
+ 'orchestrator' : "androidx.test:orchestrator:$androidxTest",
+ 'testRunner' : "androidx.test:runner:$androidxTest",
+ 'testRules' : "androidx.test:rules:$androidxTest",
+ 'espressoCore' : "androidx.test.espresso:espresso-core:$espresso",
+ 'espressoContrib' : "androidx.test.espresso:espresso-contrib:$espresso",
+ 'espressoIntents' : "androidx.test.espresso:espresso-intents:$espresso"
+ ],
+ google : [
+ 'material' : "com.google.android.material:material:1.4.0"
+ ],
+ dagger : [
+ 'dagger' : "com.google.dagger:dagger:$dagger",
+ 'daggerCompiler' : "com.google.dagger:dagger-compiler:$dagger"
+ ],
+ squareup : [
+ 'moshi' : "com.squareup.moshi:moshi-adapters:$moshi",
+ 'moshiKotlin' : "com.squareup.moshi:moshi-kotlin-codegen:$moshi",
+ 'retrofit' : "com.squareup.retrofit2:retrofit:$retrofit",
+ 'retrofitMoshi' : "com.squareup.retrofit2:converter-moshi:$retrofit"
+ ],
+ rx : [
+ 'rxKotlin' : "io.reactivex.rxjava2:rxkotlin:2.4.0",
+ 'rxAndroid' : "io.reactivex.rxjava2:rxandroid:2.1.1"
+ ],
+ arrow : [
+ 'core' : "io.arrow-kt:arrow-core:$arrow",
+ 'instances' : "io.arrow-kt:arrow-instances-core:$arrow"
+ ],
+ markwon : [
+ 'core' : "io.noties.markwon:core:$markwon",
+ 'html' : "io.noties.markwon:html:$markwon"
+ ],
+ airbnb : [
+ 'epoxy' : "com.airbnb.android:epoxy:$epoxy",
+ 'epoxyGlide' : "com.airbnb.android:epoxy-glide-preloading:$epoxy",
+ 'epoxyProcessor' : "com.airbnb.android:epoxy-processor:$epoxy",
+ 'epoxyPaging' : "com.airbnb.android:epoxy-paging:$epoxy",
+ 'mvrx' : "com.airbnb.android:mvrx:1.5.1"
+ ],
+ mockk : [
+ 'mockk' : "io.mockk:mockk:$mockk",
+ 'mockkAndroid' : "io.mockk:mockk-android:$mockk"
+ ],
+ github : [
+ 'glide' : "com.github.bumptech.glide:glide:$glide",
+ 'glideCompiler' : "com.github.bumptech.glide:compiler:$glide",
+ 'bigImageViewer' : "com.github.piasy:BigImageViewer:$bigImageViewer",
+ 'glideImageLoader' : "com.github.piasy:GlideImageLoader:$bigImageViewer",
+ 'progressPieIndicator' : "com.github.piasy:ProgressPieIndicator:$bigImageViewer",
+ 'glideImageViewFactory' : "com.github.piasy:GlideImageViewFactory:$bigImageViewer"
+ ],
+ jakewharton : [
+ 'timber' : "com.jakewharton.timber:timber:5.0.1",
+ 'rxbinding' : "com.jakewharton.rxbinding3:rxbinding:$rxBinding",
+ 'rxbindingAppcompat' : "com.jakewharton.rxbinding3:rxbinding-appcompat:$rxBinding",
+ 'rxbindingMaterial' : "com.jakewharton.rxbinding3:rxbinding-material:$rxBinding"
+ ],
+ jsonwebtoken: [
+ 'jjwtApi' : "io.jsonwebtoken:jjwt-api:$jjwt",
+ 'jjwtImpl' : "io.jsonwebtoken:jjwt-impl:$jjwt",
+ 'jjwtOrgjson' : "io.jsonwebtoken:jjwt-orgjson:$jjwt"
+ ],
+ vanniktech: [
+ 'emojiMaterial' : "com.vanniktech:emoji-material:$vanniktechEmoji",
+ 'emojiGoogle' : "com.vanniktech:emoji-google:$vanniktechEmoji"
+ ],
+ tests : [
+ 'kluent' : "org.amshove.kluent:kluent-android:1.68",
+ 'timberJunitRule' : "net.lachlanmckee:timber-junit-rule:1.0.1",
+ 'junit' : "junit:junit:4.13.2"
+ ]
+]
\ No newline at end of file
diff --git a/fastlane/README.md b/fastlane/README.md
index 54d3a005a6d..dc33f422d66 100644
--- a/fastlane/README.md
+++ b/fastlane/README.md
@@ -44,6 +44,6 @@ Get version code
----
-This README.md is auto-generated and will be re-generated every time [fastlane](https://fastlane.tools) is run.
+This README.md is auto-generated and will be re-generated every time [_fastlane_](https://fastlane.tools) is run.
More information about fastlane can be found on [fastlane.tools](https://fastlane.tools).
The documentation of fastlane can be found on [docs.fastlane.tools](https://docs.fastlane.tools).
diff --git a/fastlane/metadata/android/cs-CZ/changelogs/40102000.txt b/fastlane/metadata/android/cs-CZ/changelogs/40102000.txt
new file mode 100644
index 00000000000..929281c3888
--- /dev/null
+++ b/fastlane/metadata/android/cs-CZ/changelogs/40102000.txt
@@ -0,0 +1,2 @@
+Hlavní změny v této verzi: Hlasové zprávy jsou povoleny ve výchozím nastavení.
+Úplný seznam změn: https://github.com/vector-im/element-android/releases/tag/v1.2.0
diff --git a/fastlane/metadata/android/cs-CZ/changelogs/40102010.txt b/fastlane/metadata/android/cs-CZ/changelogs/40102010.txt
new file mode 100644
index 00000000000..ca75c6b5d82
--- /dev/null
+++ b/fastlane/metadata/android/cs-CZ/changelogs/40102010.txt
@@ -0,0 +1,2 @@
+Hlavní změny v této verzi: Mnohá vylepšení VoIP a prostorů (stále v beta verzi).
+Úplný seznam změn: https://github.com/vector-im/element-android/releases/tag/v1.2.1
diff --git a/fastlane/metadata/android/de-DE/changelogs/40102000.txt b/fastlane/metadata/android/de-DE/changelogs/40102000.txt
new file mode 100644
index 00000000000..cfa9f725f2f
--- /dev/null
+++ b/fastlane/metadata/android/de-DE/changelogs/40102000.txt
@@ -0,0 +1,2 @@
+Hauptänderungen: Sprachnachrichten standardmäßig aktiviert.
+Ganze Änderungsliste: https://github.com/vector-im/element-android/releases/tag/v1.2.0
diff --git a/fastlane/metadata/android/de-DE/changelogs/40102010.txt b/fastlane/metadata/android/de-DE/changelogs/40102010.txt
new file mode 100644
index 00000000000..2635704a81a
--- /dev/null
+++ b/fastlane/metadata/android/de-DE/changelogs/40102010.txt
@@ -0,0 +1,2 @@
+VoIP und Spaces verbessert
+Vollständige Änderungsliste: https://github.com/vector-im/element-android/releases/tag/v1.2.1
diff --git a/fastlane/metadata/android/en-US/changelogs/40102000.txt b/fastlane/metadata/android/en-US/changelogs/40102000.txt
index 46d9b078099..4fc02966cde 100644
--- a/fastlane/metadata/android/en-US/changelogs/40102000.txt
+++ b/fastlane/metadata/android/en-US/changelogs/40102000.txt
@@ -1,2 +1,2 @@
Main changes in this version: Voice Message is enabled by default.
-Full changelog: https://github.com/vector-im/element-android/releases/tag/v1.1.16
\ No newline at end of file
+Full changelog: https://github.com/vector-im/element-android/releases/tag/v1.2.0
\ No newline at end of file
diff --git a/fastlane/metadata/android/en-US/changelogs/40102010.txt b/fastlane/metadata/android/en-US/changelogs/40102010.txt
new file mode 100644
index 00000000000..799b7dc8b61
--- /dev/null
+++ b/fastlane/metadata/android/en-US/changelogs/40102010.txt
@@ -0,0 +1,2 @@
+Main changes in this version: Many improvements on VoIP and Spaces (still in beta).
+Full changelog: https://github.com/vector-im/element-android/releases/tag/v1.2.1
\ No newline at end of file
diff --git a/fastlane/metadata/android/en-US/changelogs/40103000.txt b/fastlane/metadata/android/en-US/changelogs/40103000.txt
new file mode 100644
index 00000000000..d4ef2f75a0c
--- /dev/null
+++ b/fastlane/metadata/android/en-US/changelogs/40103000.txt
@@ -0,0 +1,2 @@
+Main changes in this version: Organize your rooms using Spaces!
+Full changelog: https://github.com/vector-im/element-android/releases/tag/v1.3.0
\ No newline at end of file
diff --git a/fastlane/metadata/android/en-US/changelogs/40103010.txt b/fastlane/metadata/android/en-US/changelogs/40103010.txt
new file mode 100644
index 00000000000..e3760f18822
--- /dev/null
+++ b/fastlane/metadata/android/en-US/changelogs/40103010.txt
@@ -0,0 +1,2 @@
+Main changes in this version: Organize your rooms using Spaces! v1.3.1 is fixing a crash which can occurs in v1.3.0.
+Full changelog: https://github.com/vector-im/element-android/releases/tag/v1.3.1
\ No newline at end of file
diff --git a/fastlane/metadata/android/et/changelogs/40102000.txt b/fastlane/metadata/android/et/changelogs/40102000.txt
new file mode 100644
index 00000000000..57f28039c58
--- /dev/null
+++ b/fastlane/metadata/android/et/changelogs/40102000.txt
@@ -0,0 +1,2 @@
+Põhilised muutused selles versioonis: häälsõnumid on nüüd vaikimisi kasutusel.
+Kogu ingliskeelne muudatuste logi: https://github.com/vector-im/element-android/releases/tag/v1.2.0
diff --git a/fastlane/metadata/android/et/changelogs/40102010.txt b/fastlane/metadata/android/et/changelogs/40102010.txt
new file mode 100644
index 00000000000..0dc70c90afb
--- /dev/null
+++ b/fastlane/metadata/android/et/changelogs/40102010.txt
@@ -0,0 +1,2 @@
+Põhilised muutused selles versioonis: palju täiendusi kõnede ja veel testjärgus olevas kogukonnakeskuste loogikas.
+Kogu ingliskeelne muudatuste logi: https://github.com/vector-im/element-android/releases/tag/v1.2.1
diff --git a/fastlane/metadata/android/fa/changelogs/40102000.txt b/fastlane/metadata/android/fa/changelogs/40102000.txt
new file mode 100644
index 00000000000..9c9a7c51d07
--- /dev/null
+++ b/fastlane/metadata/android/fa/changelogs/40102000.txt
@@ -0,0 +1,2 @@
+تغییرهای اصلی در این نگارش: پیام صوتی به صورت پیشگزیده به کار افتاده.
+گزارش دگرگونی کامل: https://github.com/vector-im/element-android/releases/tag/v1.2.0
diff --git a/fastlane/metadata/android/fa/changelogs/40102010.txt b/fastlane/metadata/android/fa/changelogs/40102010.txt
new file mode 100644
index 00000000000..a2cc27d1b5b
--- /dev/null
+++ b/fastlane/metadata/android/fa/changelogs/40102010.txt
@@ -0,0 +1,2 @@
+تغییرات اصلی در این نگارش: چندین بهبود در ویپ و فضاها (همچنان در حالت آزمایشی).
+گزارش دگرگونی کامل: https://github.com/vector-im/element-android/releases/tag/v1.2.1
diff --git a/fastlane/metadata/android/fr-FR/changelogs/40102000.txt b/fastlane/metadata/android/fr-FR/changelogs/40102000.txt
new file mode 100644
index 00000000000..504c3e24bec
--- /dev/null
+++ b/fastlane/metadata/android/fr-FR/changelogs/40102000.txt
@@ -0,0 +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
diff --git a/fastlane/metadata/android/fy/changelogs/40101060.txt b/fastlane/metadata/android/fy/changelogs/40101060.txt
index 47ac5692d55..34b367f6a13 100644
--- a/fastlane/metadata/android/fy/changelogs/40101060.txt
+++ b/fastlane/metadata/android/fy/changelogs/40101060.txt
@@ -1,2 +1,2 @@
-Haadferoaring yn disse ferzje: feroaringen foar 1.1.5
-Folsleine feroaringslist: https://github.com/vector-im/element-android/releases/tag/v1.1.6
+Haadwiziging yn dizze ferzje: feroaringen foar 1.1.5
+Folsleine wizigingslist: https://github.com/vector-im/element-android/releases/tag/v1.1.6
diff --git a/fastlane/metadata/android/hu-HU/changelogs/40102000.txt b/fastlane/metadata/android/hu-HU/changelogs/40102000.txt
new file mode 100644
index 00000000000..87824693f7a
--- /dev/null
+++ b/fastlane/metadata/android/hu-HU/changelogs/40102000.txt
@@ -0,0 +1,2 @@
+Fő változás ebben a verzióban: Hangüzenetek alapértelmezetten engedélyezettek.
+Teljes változásnapló: https://github.com/vector-im/element-android/releases/tag/v1.2.0
diff --git a/fastlane/metadata/android/hu-HU/changelogs/40102010.txt b/fastlane/metadata/android/hu-HU/changelogs/40102010.txt
new file mode 100644
index 00000000000..1ccd51aa8af
--- /dev/null
+++ b/fastlane/metadata/android/hu-HU/changelogs/40102010.txt
@@ -0,0 +1,2 @@
+Fő változás ebben a verzióban: Sok fejlesztés a VoIP és Terek kapcsán (még béta)
+Teljes változásnapló: https://github.com/vector-im/element-android/releases/tag/v1.2.1
diff --git a/fastlane/metadata/android/id/changelogs/40101160.txt b/fastlane/metadata/android/id/changelogs/40101160.txt
new file mode 100644
index 00000000000..19209bacf2d
--- /dev/null
+++ b/fastlane/metadata/android/id/changelogs/40101160.txt
@@ -0,0 +1,2 @@
+Perubahan utama dalam versi ini: Memperbaiki kesalahan saat mengirim pesan terenkripsi jika seseorang yang ada di ruangan keluar.
+Changelog lanjutan: https://github.com/vector-im/element-android/releases/tag/v1.1.16
diff --git a/fastlane/metadata/android/id/changelogs/40102000.txt b/fastlane/metadata/android/id/changelogs/40102000.txt
new file mode 100644
index 00000000000..2258b114e8d
--- /dev/null
+++ b/fastlane/metadata/android/id/changelogs/40102000.txt
@@ -0,0 +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
diff --git a/fastlane/metadata/android/id/full_description.txt b/fastlane/metadata/android/id/full_description.txt
index 0a18b8d64aa..75249c6a204 100644
--- a/fastlane/metadata/android/id/full_description.txt
+++ b/fastlane/metadata/android/id/full_description.txt
@@ -8,10 +8,10 @@ Element adalah perpesanan yang aman dan aplikasi kolaborasi tim produktivitas ya
- Obrolan video dengan VoIP dan berbagi layar
- Integrasi yang mudah dengan alat kolaborasi online favorit Anda, alat manajemen proyek, layanan VoIP dan aplikasi perpesanan tim lainnya
-Element benar-benar berbeda dari aplikasi perpesanan dan kolaborasi lainnya. Ini beroperasi pada Matrix, jaringan terbuka untuk pengiriman pesan yang aman dan komunikasi terdesentralisasi. Ini memungkinkan hosting sendiri untuk memberi pengguna kepemilikan maksimum dan kontrol data dan pesan mereka.
+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. Ini juga mengamankan semua data Anda, komunikasi video dan suara satu-ke-satu melalui enkripsi ujung-ke-ujung dan verifikasi perangkat yang di-cross-signed.
+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 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.
@@ -30,7 +30,7 @@ Element menempatkan Anda dalam kendali dengan cara yang berbeda:
Anda dapat mengobrol dengan siapa saja di jaringan Matrix, apakah mereka menggunakan Element, aplikasi Matrix lain atau bahkan jika mereka menggunakan aplikasi perpesanan yang berbeda.
Sangat aman
-Enkripsi ujung-ke-ujung beneran (hanya mereka yang dalam percakapan dapat mendekripsi pesan), dan verifikasi perangkat yang di-cross-signed.
+Enkripsi ujung-ke-ujung beneran (hanya mereka yang dalam percakapan dapat mendekripsi pesan), dan verifikasi perangkat yang ditanda tangani silang.
Komunikasi dan integrasi lengkap
Perpesanan, panggilan suara dan video, berbagi file, berbagi layar dan banyak integrasi, bot dan widget. Buat ruangan, komunitas, tetap terhubung dan selesaikan hal-hal.
diff --git a/fastlane/metadata/android/it-IT/changelogs/40102000.txt b/fastlane/metadata/android/it-IT/changelogs/40102000.txt
new file mode 100644
index 00000000000..e10007a7b79
--- /dev/null
+++ b/fastlane/metadata/android/it-IT/changelogs/40102000.txt
@@ -0,0 +1,2 @@
+Modifiche principali in questa versione: i messaggi vocali sono attivi in modo predefinito.
+Cronologia completa: https://github.com/vector-im/element-android/releases/tag/v1.2.0
diff --git a/fastlane/metadata/android/it-IT/changelogs/40102010.txt b/fastlane/metadata/android/it-IT/changelogs/40102010.txt
new file mode 100644
index 00000000000..33c2d998a75
--- /dev/null
+++ b/fastlane/metadata/android/it-IT/changelogs/40102010.txt
@@ -0,0 +1,2 @@
+Modifiche principali in questa versione: molti miglioramenti nel VoIP e negli Spazi (ancora in beta).
+Cronologia completa: https://github.com/vector-im/element-android/releases/tag/v1.2.1
diff --git a/fastlane/metadata/android/pt-BR/changelogs/40102000.txt b/fastlane/metadata/android/pt-BR/changelogs/40102000.txt
new file mode 100644
index 00000000000..c6d01391da1
--- /dev/null
+++ b/fastlane/metadata/android/pt-BR/changelogs/40102000.txt
@@ -0,0 +1,2 @@
+Principais mudanças nesta versão: Mensagem de Voz está habilitada por default.
+Changelog completo: https://github.com/vector-im/element-android/releases/tag/v1.2.0
diff --git a/fastlane/metadata/android/pt-BR/changelogs/40102010.txt b/fastlane/metadata/android/pt-BR/changelogs/40102010.txt
new file mode 100644
index 00000000000..0894dd20220
--- /dev/null
+++ b/fastlane/metadata/android/pt-BR/changelogs/40102010.txt
@@ -0,0 +1,2 @@
+Principais mudanças nesta versão: Muitas melhorias em VoIP e Espaços (ainda em beta).
+Changelog completo: https://github.com/vector-im/element-android/releases/tag/v1.2.1
diff --git a/fastlane/metadata/android/ru-RU/changelogs/40101150.txt b/fastlane/metadata/android/ru-RU/changelogs/40101150.txt
new file mode 100644
index 00000000000..cbf64e470b9
--- /dev/null
+++ b/fastlane/metadata/android/ru-RU/changelogs/40101150.txt
@@ -0,0 +1,2 @@
+Основные изменения в этой версии: реализация голосовых сообщений в настройках лабораторий.
+Полный список изменений: https://github.com/vector-im/element-android/releases/tag/v1.1.15
diff --git a/fastlane/metadata/android/ru-RU/changelogs/40101160.txt b/fastlane/metadata/android/ru-RU/changelogs/40101160.txt
new file mode 100644
index 00000000000..5f0e555d946
--- /dev/null
+++ b/fastlane/metadata/android/ru-RU/changelogs/40101160.txt
@@ -0,0 +1,2 @@
+Основные изменения в этой версии: Исправление ошибки при отправке зашифрованного сообщения, если кто-то в комнате выходит.
+Полный список изменений: https://github.com/vector-im/element-android/releases/tag/v1.1.16
diff --git a/fastlane/metadata/android/ru-RU/changelogs/40102000.txt b/fastlane/metadata/android/ru-RU/changelogs/40102000.txt
new file mode 100644
index 00000000000..af0a444afa3
--- /dev/null
+++ b/fastlane/metadata/android/ru-RU/changelogs/40102000.txt
@@ -0,0 +1,2 @@
+Основные изменения в этой версии: Голосовое сообщение включено по умолчанию.
+Полный список изменений: https://github.com/vector-im/element-android/releases/tag/v1.2.0
diff --git a/fastlane/metadata/android/ru-RU/changelogs/40102010.txt b/fastlane/metadata/android/ru-RU/changelogs/40102010.txt
new file mode 100644
index 00000000000..167af260d54
--- /dev/null
+++ b/fastlane/metadata/android/ru-RU/changelogs/40102010.txt
@@ -0,0 +1,2 @@
+Основные изменения в этой версии: Множество улучшений в VoIP и пространствах (все еще в бета-версии).
+Полный список изменений: https://github.com/vector-im/element-android/releases/tag/v1.2.1
diff --git a/fastlane/metadata/android/sq/changelogs/40100100.txt b/fastlane/metadata/android/sq/changelogs/40100100.txt
new file mode 100644
index 00000000000..aba7bebd5a1
--- /dev/null
+++ b/fastlane/metadata/android/sq/changelogs/40100100.txt
@@ -0,0 +1,2 @@
+Ky version i ri përmban kryesisht ndreqje të metash dhe përmirësime. Dërgimi i një mesazhi tani është shumë i shpejtë.
+Regjistër i plotë ndryshimesh: https://github.com/vector-im/element-android/releases/tag/v1.0.10
diff --git a/fastlane/metadata/android/sq/changelogs/40100110.txt b/fastlane/metadata/android/sq/changelogs/40100110.txt
new file mode 100644
index 00000000000..d1b8e9f9d3a
--- /dev/null
+++ b/fastlane/metadata/android/sq/changelogs/40100110.txt
@@ -0,0 +1,2 @@
+Ky version i ri përmban kryesisht përmirësime të ndërfaqes dhe punimit të përdoruesit. Tani mund të ftoni shokë, dhe të krijoni MD shumë shpejt, përmes skanimit të kodesh QR.
+Regjistër i plotë ndryshimesh: https://github.com/vector-im/element-android/releases/tag/v1.0.11
diff --git a/fastlane/metadata/android/sq/changelogs/40100120.txt b/fastlane/metadata/android/sq/changelogs/40100120.txt
new file mode 100644
index 00000000000..d7d9998e0b2
--- /dev/null
+++ b/fastlane/metadata/android/sq/changelogs/40100120.txt
@@ -0,0 +1,2 @@
+Ndryshimet kryesore në këtë version: Paraparje URL-sh, tastierë e re për emoji, aftësi të reja për rregullime dhome, dhe dëborë për Krishtlindje!
+Regjistër i plotë ndryshimesh: https://github.com/vector-im/element-android/releases/tag/v1.0.12
diff --git a/fastlane/metadata/android/sq/changelogs/40100130.txt b/fastlane/metadata/android/sq/changelogs/40100130.txt
new file mode 100644
index 00000000000..5d50ff531d9
--- /dev/null
+++ b/fastlane/metadata/android/sq/changelogs/40100130.txt
@@ -0,0 +1,2 @@
+Ndryshimet kryesore në këtë version: Paraparje URL-sh, tastierë e re për emoji, aftësi të reja për rregullime dhome, dhe dëborë për Krishtlindje!
+Regjistër i plotë ndryshimesh: https://github.com/vector-im/element-android/releases/tag/v1.0.13
diff --git a/fastlane/metadata/android/sq/changelogs/40100140.txt b/fastlane/metadata/android/sq/changelogs/40100140.txt
new file mode 100644
index 00000000000..bdab3841b0f
--- /dev/null
+++ b/fastlane/metadata/android/sq/changelogs/40100140.txt
@@ -0,0 +1,2 @@
+Ndryshimet kryesore në këtë version: Përpunim lejesh dhome, temë e çelët/e errët e automatizuar, dhe një dorë ndreqjesh të metash.
+Regjistër i plotë ndryshimesh: https://github.com/vector-im/element-android/releases/tag/v1.0.14
diff --git a/fastlane/metadata/android/sq/changelogs/40100150.txt b/fastlane/metadata/android/sq/changelogs/40100150.txt
new file mode 100644
index 00000000000..045f2369b69
--- /dev/null
+++ b/fastlane/metadata/android/sq/changelogs/40100150.txt
@@ -0,0 +1,2 @@
+Ndryshimet kryesore në këtë version: Mbulim Hyrjesh nga rrjete shoqërorë.
+Regjistër i plotë ndryshimesh: https://github.com/vector-im/element-android/releases/tag/v1.0.15
diff --git a/fastlane/metadata/android/sq/changelogs/40100160.txt b/fastlane/metadata/android/sq/changelogs/40100160.txt
new file mode 100644
index 00000000000..ece7bbd2a64
--- /dev/null
+++ b/fastlane/metadata/android/sq/changelogs/40100160.txt
@@ -0,0 +1,2 @@
+Ndryshimet kryesore në këtë version: Mbulim Hyrjesh nga rrjete shoqërorë.
+Regjistër i plotë ndryshimesh: https://github.com/vector-im/element-android/releases/tag/v1.0.15 dhe https://github.com/vector-im/element-android/releases/tag/v1.0.16
diff --git a/fastlane/metadata/android/sq/changelogs/40100170.txt b/fastlane/metadata/android/sq/changelogs/40100170.txt
new file mode 100644
index 00000000000..76cf7a9ffab
--- /dev/null
+++ b/fastlane/metadata/android/sq/changelogs/40100170.txt
@@ -0,0 +1,2 @@
+Ndryshimet kryesore në këtë version: Ndreqje të metash!
+Regjistër i plotë ndryshimesh: https://github.com/vector-im/element-android/releases/tag/v1.0.17
diff --git a/fastlane/metadata/android/sq/changelogs/40101000.txt b/fastlane/metadata/android/sq/changelogs/40101000.txt
new file mode 100644
index 00000000000..b4424f55bcd
--- /dev/null
+++ b/fastlane/metadata/android/sq/changelogs/40101000.txt
@@ -0,0 +1,2 @@
+Ndryshimet kryesore në këtë version: Përmirësime për VoIP (thirrje audio dhe video në DM) dhe ndreqje të metash!
+Regjistër i plotë ndryshimesh: https://github.com/vector-im/element-android/releases/tag/v1.1.0
diff --git a/fastlane/metadata/android/sq/changelogs/40101010.txt b/fastlane/metadata/android/sq/changelogs/40101010.txt
new file mode 100644
index 00000000000..20b35d34394
--- /dev/null
+++ b/fastlane/metadata/android/sq/changelogs/40101010.txt
@@ -0,0 +1,2 @@
+Ndryshimet kryesore në këtë version: përmirësime funksionimi dhe ndreqje të metash!
+Regjistër i plotë ndryshimesh: https://github.com/vector-im/element-android/releases/tag/v1.1.1
diff --git a/fastlane/metadata/android/sq/changelogs/40101020.txt b/fastlane/metadata/android/sq/changelogs/40101020.txt
new file mode 100644
index 00000000000..6f53ec219e5
--- /dev/null
+++ b/fastlane/metadata/android/sq/changelogs/40101020.txt
@@ -0,0 +1,2 @@
+Ndryshimet kryesore në këtë version: përmirësime funksionimi dhe ndreqje të metash!
+Regjistër i plotë ndryshimesh: https://github.com/vector-im/element-android/releases/tag/v1.1.2
diff --git a/fastlane/metadata/android/sq/changelogs/40101030.txt b/fastlane/metadata/android/sq/changelogs/40101030.txt
new file mode 100644
index 00000000000..9dbc4f142ad
--- /dev/null
+++ b/fastlane/metadata/android/sq/changelogs/40101030.txt
@@ -0,0 +1,2 @@
+Ndryshimet kryesore në këtë version: përmirësime funksionimi dhe ndreqje të metash!
+Regjistër i plotë ndryshimesh: https://github.com/vector-im/element-android/releases/tag/v1.1.3
diff --git a/fastlane/metadata/android/sq/changelogs/40101040.txt b/fastlane/metadata/android/sq/changelogs/40101040.txt
new file mode 100644
index 00000000000..949fa629b95
--- /dev/null
+++ b/fastlane/metadata/android/sq/changelogs/40101040.txt
@@ -0,0 +1,2 @@
+Ndryshimet kryesore në këtë version: përmirësime funksionimi dhe ndreqje të metash!
+Regjistër i plotë ndryshimesh: https://github.com/vector-im/element-android/releases/tag/v1.1.4
diff --git a/fastlane/metadata/android/sq/changelogs/40101050.txt b/fastlane/metadata/android/sq/changelogs/40101050.txt
new file mode 100644
index 00000000000..28e28523568
--- /dev/null
+++ b/fastlane/metadata/android/sq/changelogs/40101050.txt
@@ -0,0 +1,2 @@
+Ndryshimet kryesore në këtë version: ndreqje të metash për 1.1.4
+Regjistër i plotë ndryshimesh: https://github.com/vector-im/element-android/releases/tag/v1.1.5
diff --git a/fastlane/metadata/android/sq/changelogs/40101060.txt b/fastlane/metadata/android/sq/changelogs/40101060.txt
new file mode 100644
index 00000000000..ab01eede45e
--- /dev/null
+++ b/fastlane/metadata/android/sq/changelogs/40101060.txt
@@ -0,0 +1,2 @@
+Ndryshimet kryesore në këtë version: ndreqje të metash për 1.1.5
+Regjistër i plotë ndryshimesh: https://github.com/vector-im/element-android/releases/tag/v1.1.6
diff --git a/fastlane/metadata/android/sq/changelogs/40101070.txt b/fastlane/metadata/android/sq/changelogs/40101070.txt
new file mode 100644
index 00000000000..8d23bb5b949
--- /dev/null
+++ b/fastlane/metadata/android/sq/changelogs/40101070.txt
@@ -0,0 +1,2 @@
+Ndryshimet kryesore në këtë version: mbulim për Hapësira, në fazë beta. Ngjeshje videosh, përpara dërgimi.
+Regjistër i plotë ndryshimesh: https://github.com/vector-im/element-android/releases/tag/v1.1.7
diff --git a/fastlane/metadata/android/sq/changelogs/40101080.txt b/fastlane/metadata/android/sq/changelogs/40101080.txt
new file mode 100644
index 00000000000..f9282142cbd
--- /dev/null
+++ b/fastlane/metadata/android/sq/changelogs/40101080.txt
@@ -0,0 +1,2 @@
+Ndryshimet kryesore në këtë version: përmirësime për Hapësira.
+Regjistër i plotë ndryshimesh: https://github.com/vector-im/element-android/releases/tag/v1.1.8
diff --git a/fastlane/metadata/android/sq/changelogs/40101090.txt b/fastlane/metadata/android/sq/changelogs/40101090.txt
new file mode 100644
index 00000000000..069ab4954de
--- /dev/null
+++ b/fastlane/metadata/android/sq/changelogs/40101090.txt
@@ -0,0 +1,2 @@
+Ndryshimet kryesore në këtë version: shtim mbulimi për rrjetin gitter.im.
+Regjistër i plotë ndryshimesh: https://github.com/vector-im/element-android/releases/tag/v1.1.9
diff --git a/fastlane/metadata/android/sq/changelogs/40101100.txt b/fastlane/metadata/android/sq/changelogs/40101100.txt
new file mode 100644
index 00000000000..bf5079bc9a6
--- /dev/null
+++ b/fastlane/metadata/android/sq/changelogs/40101100.txt
@@ -0,0 +1,2 @@
+Ndryshimet kryesore në këtë version: përditësime teme dhe stili dhe veçori të reja për hapësira.
+Regjistër i plotë ndryshimesh: https://github.com/vector-im/element-android/releases/tag/v1.1.10
diff --git a/fastlane/metadata/android/sq/changelogs/40101110.txt b/fastlane/metadata/android/sq/changelogs/40101110.txt
new file mode 100644
index 00000000000..44d03bb8cb5
--- /dev/null
+++ b/fastlane/metadata/android/sq/changelogs/40101110.txt
@@ -0,0 +1,2 @@
+Ndryshimet kryesore në këtë version: përditësime teme dhe stili dhe veçori të reja për hapësira (ndreqje të mete për 1.1.10)
+Regjistër i plotë ndryshimesh: https://github.com/vector-im/element-android/releases/tag/v1.1.11
diff --git a/fastlane/metadata/android/sq/changelogs/40101120.txt b/fastlane/metadata/android/sq/changelogs/40101120.txt
new file mode 100644
index 00000000000..aecede8d91b
--- /dev/null
+++ b/fastlane/metadata/android/sq/changelogs/40101120.txt
@@ -0,0 +1,2 @@
+Ndryshimet kryesore në këtë version: përditësime teme dhe stili dhe ndreqje e një vithisjeje pas një thirrjeje video
+Regjistër i plotë ndryshimesh: https://github.com/vector-im/element-android/releases/tag/v1.1.12
diff --git a/fastlane/metadata/android/sq/changelogs/40101130.txt b/fastlane/metadata/android/sq/changelogs/40101130.txt
new file mode 100644
index 00000000000..535ccd7518a
--- /dev/null
+++ b/fastlane/metadata/android/sq/changelogs/40101130.txt
@@ -0,0 +1,2 @@
+Ndryshimet kryesore në këtë version: përditësim kryesisht për qëndrueshmërinë dhe ndreqje të metash.
+Regjistër i plotë ndryshimesh: https://github.com/vector-im/element-android/releases/tag/v1.1.13
diff --git a/fastlane/metadata/android/sq/changelogs/40101140.txt b/fastlane/metadata/android/sq/changelogs/40101140.txt
new file mode 100644
index 00000000000..2dc279e1f74
--- /dev/null
+++ b/fastlane/metadata/android/sq/changelogs/40101140.txt
@@ -0,0 +1,2 @@
+Ndryshimet kryesore në këtë version: ndreqje e një problemi rreth mesazhesh të fshehtëzuar.
+Regjistër i plotë ndryshimesh: https://github.com/vector-im/element-android/releases/tag/v1.1.14
diff --git a/fastlane/metadata/android/sq/changelogs/40101150.txt b/fastlane/metadata/android/sq/changelogs/40101150.txt
new file mode 100644
index 00000000000..1fbf2bae7a7
--- /dev/null
+++ b/fastlane/metadata/android/sq/changelogs/40101150.txt
@@ -0,0 +1,2 @@
+Ndryshimet kryesore në këtë version: sendërtim mesazhesh zanore, nën mjedis laboratori.
+Regjistër i plotë ndryshimesh: https://github.com/vector-im/element-android/releases/tag/v1.1.15
diff --git a/fastlane/metadata/android/sq/changelogs/40101160.txt b/fastlane/metadata/android/sq/changelogs/40101160.txt
new file mode 100644
index 00000000000..ecb9a83918a
--- /dev/null
+++ b/fastlane/metadata/android/sq/changelogs/40101160.txt
@@ -0,0 +1,2 @@
+Ndryshimet kryesore në këtë version: Ndreqje gabimi, kur dërgohet mesazh i fshehtëzuar, nëse dikush nga dhoma bën dalje prej saj.
+Regjistër i plotë ndryshimesh: https://github.com/vector-im/element-android/releases/tag/v1.1.16
diff --git a/fastlane/metadata/android/sq/changelogs/40102000.txt b/fastlane/metadata/android/sq/changelogs/40102000.txt
new file mode 100644
index 00000000000..c1f2333f1ca
--- /dev/null
+++ b/fastlane/metadata/android/sq/changelogs/40102000.txt
@@ -0,0 +1,2 @@
+Ndryshimet kryesore në këtë version: Mesazh Zanor është i aktivizuar, si parazgjedhje.
+Regjistër i plotë ndryshimesh: https://github.com/vector-im/element-android/releases/tag/v1.2.0
diff --git a/fastlane/metadata/android/sq/changelogs/40102010.txt b/fastlane/metadata/android/sq/changelogs/40102010.txt
new file mode 100644
index 00000000000..6ffe456bd48
--- /dev/null
+++ b/fastlane/metadata/android/sq/changelogs/40102010.txt
@@ -0,0 +1,2 @@
+Ndryshimet kryesore në këtë version: Mjaft përmirësime në VoIP dhe Hapësira (ende në beta).
+Regjistër i plotë ndryshimesh: https://github.com/vector-im/element-android/releases/tag/v1.2.1
diff --git a/fastlane/metadata/android/sq/full_description.txt b/fastlane/metadata/android/sq/full_description.txt
new file mode 100644
index 00000000000..96cf102272e
--- /dev/null
+++ b/fastlane/metadata/android/sq/full_description.txt
@@ -0,0 +1,39 @@
+Element-i është si aplikacion shkëmbyes i sigurt mesazhesh, ashtu edhe bashkëpunimi prodhimtar ekipi, i cili është ideal për fjalosje në grup, teksa punohet së largët. Ky aplikacion fjalosjeje përdor fshehtëzim skaj-më-skaj për të furnizuar konferencë video, shkëmbim kartelash dhe thirrje me zë të fuqishme.
+
+Në veçoritë e Element-it përfshihen:
+- Mjete të thelluara komunikimi internetor
+- Mesazhe plotësisht të fshehtëzuar, për të lejuar komunikim në nivel korporate, madje edhe për punonjës së largëti
+- Fjalosje e decentralizuar, bazuar në platformën me burim të hapët Matrix
+- Shkëmbim i sigurt kartelash, me të dhëna të fshehtëzuara, teksa administrohen projekte
+- Fjalosje video të llojit VoIP dhe tregim ekrani
+- Integrim i kollajtë me mjetet tuaja të parapëlqyera të bashkëpunimit internetor, mjete administrimi projektesh, shërbime VoIP dhe aplikacione të tjera shkëmbimi mesazhesh në ekip
+
+Element-i është plotësisht i ndryshëm nga aplikacione të tjera shkëmbimi mesazhesh dhe bashkëpunimi. Funksionimi i tij bazohet në Matrix, një rrjet i hapët për mesazhe të siguruar dhe komunikim të decentralizuar. Lejon vetëstrehim, për t’u lejuar përdoruesve pronësi dhe kontroll maksimal të të dhënave dhe mesazheve të tyre.
+
+Privatësi dhe shkëmbim mesazhesh të fshehtëzuar
+Element-i ju mbron nga reklama të padëshiruara, shfrytëzim të dhënash dhe vatha dixhitale. Ai siguron gjithashtu krejt të dhënat tuaja, komunikime tek-për-tek me video dhe me zë, përmes fshehtëzimi skaj-më-skaj dhe verifikim “cross-signed” pajisjesh.
+
+Element-i ju jep kontrollin e privatësisë tuaj, teksa ju lejon të komunikoni në mënyrë të siguruar me këdo në rrjetin Matrix, ose me mjete të tjera bashkëpunimi në shkallë biznesi, duke u integruar me aplikacione të tillë si Slack.
+
+Element-i mund të vetëstrehohet
+Për të lejuar më tepër kontroll mbi të dhënat dhe bisedat tuaja rezervat, Element-i mund të vetëstrehohet, ose mund të zgjidhni cilëndo strehë të bazuar në Matrix - standardi për komunikim me burim të hapët, të decentralizuar. Element-i ju jep privatësi, pajtueshmëri sigurie dhe zhdërvjelltësi integrimesh.
+
+Jini zot i të dhënave tuaja
+Ju vendosni ku të mbahen të dhënat dhe mesazhet tuaja. Pa rrezikun e shfrytëzimit të të dhënave apo hyrjes në to nga palë të treta.
+
+Element-i ju vë ju në kontroll përmes rrugësh të ndryshme:
+1. Merrni një llogari falas te shërbyesi publik matrix.org strehuar nga zhvillues të Matrix-it, ose zgjidhni prej mijëra shërbyesish publikë të strehuar nga vullnetarë
+2. Vetëstrehoni llogarinë tuaj duke xhiruar një shërbyes në infrastrukturën tuaj TI
+3. Regjistrohuni për një llogari në një shërbyes vetjak, thjesht duke u pajtuar te platforma Element Matrix Services e strehimeve
+
+Shkëmbim mesazhesh dhe bashkëpunim me burim të hapët
+Mund të fjaloseni me këdo në rrjetin Matrix, qoftë kur përdorin Element, një tjetër aplikacion Matrix, apo edhe kur përdorin një tjetër aplikacion shkëmbimi mesazhesh.
+
+Super i sigurt
+Fshehtëzim i njëmendtë skaj-më-skaj (vetëm ata te biseda mund të shfshehtëzojnë mesazhe), dhe verifikim “cross-signed” pajisjesh.
+
+Komunikim dhe integrim i plotë
+Shkëmbim mesazhesh, thirrje me zë dhe me video, shkëmbim kartelash, tregim ekrani dhe një grup i tërë integrimesh, robotësh dhe widget-esh. Krijoni dhoma, bashkësi, mbani lidhjet dhe mbaroni punë.
+
+Rifillojani atje ku e latë
+Jini në dijeni, kudo ku gjendeni, me historik plotësisht të njëkohësuar mesazhesh nëpër krejt pajisjet tuaja dhe në internet te https://app.element.io
diff --git a/fastlane/metadata/android/sq/short_description.txt b/fastlane/metadata/android/sq/short_description.txt
new file mode 100644
index 00000000000..21937ccce5c
--- /dev/null
+++ b/fastlane/metadata/android/sq/short_description.txt
@@ -0,0 +1 @@
+Mesazhe grupi - mesazhe, fjalosje në grup dhe thirrje me video, të fshehtëzuara
diff --git a/fastlane/metadata/android/sq/title.txt b/fastlane/metadata/android/sq/title.txt
new file mode 100644
index 00000000000..097f9c48eaf
--- /dev/null
+++ b/fastlane/metadata/android/sq/title.txt
@@ -0,0 +1 @@
+Element - Shkëmbyes i Sigurt Mesazhesh
diff --git a/fastlane/metadata/android/sv-SE/changelogs/40102000.txt b/fastlane/metadata/android/sv-SE/changelogs/40102000.txt
new file mode 100644
index 00000000000..c31355dc09c
--- /dev/null
+++ b/fastlane/metadata/android/sv-SE/changelogs/40102000.txt
@@ -0,0 +1,2 @@
+Huvudsakliga ändringar i den här versionen: Röstmeddelanden är aktiverade som förval.
+Full ändringslogg: https://github.com/vector-im/element-android/releases/tag/v1.2.0
diff --git a/fastlane/metadata/android/uk/changelogs/40102000.txt b/fastlane/metadata/android/uk/changelogs/40102000.txt
new file mode 100644
index 00000000000..9abc8c0298f
--- /dev/null
+++ b/fastlane/metadata/android/uk/changelogs/40102000.txt
@@ -0,0 +1,2 @@
+Основні зміни в цій версії: голосові повідомлення типово увімкнено.
+Повний журнал змін: https://github.com/vector-im/element-android/releases/tag/v1.2.0
diff --git a/fastlane/metadata/android/uk/changelogs/40102010.txt b/fastlane/metadata/android/uk/changelogs/40102010.txt
new file mode 100644
index 00000000000..39a8d839b66
--- /dev/null
+++ b/fastlane/metadata/android/uk/changelogs/40102010.txt
@@ -0,0 +1,2 @@
+Основні зміни в цій версії: багато вдосконалень VoIP і просторів (досі бета)
+Повний журнал змін: https://github.com/vector-im/element-android/releases/tag/v1.2.1
diff --git a/fastlane/metadata/android/uk/full_description.txt b/fastlane/metadata/android/uk/full_description.txt
index df06315754b..285f5774524 100644
--- a/fastlane/metadata/android/uk/full_description.txt
+++ b/fastlane/metadata/android/uk/full_description.txt
@@ -33,7 +33,7 @@ Element надає такі можливості на вибір:
Справжнє наскрізне шифрування (лише учасники бесіди можуть розшифровувати повідомлення) та взаємне підписування пристроїв.
Повноцінні спілкування та інтеграція
-Обмін повідомленнями, голосові та відеовиклики, обмін файлами, спільний доступ до екрана та ціла купа інтеграцій, ботів та віджетів. Створюйте кімнати, спільноти, залишайтеся на зв’язку та виконуйте завдання.
+Обмін повідомленнями, голосові та відеовиклики, обмін файлами, спільний доступ до екрана та ціла купа інтеграцій, ботів та розширень. Створюйте кімнати, спільноти, залишайтеся на зв’язку та виконуйте завдання.
Продовжуйте, де зупинилися
Залишайтеся на зв'язку, де б ви не знаходились, з повністю синхронізованою історією повідомлень на всіх своїх пристроях та в Інтернеті за адресою https://app.element.io
diff --git a/fastlane/metadata/android/zh-CN/changelogs/40102000.txt b/fastlane/metadata/android/zh-CN/changelogs/40102000.txt
new file mode 100644
index 00000000000..fa1db168050
--- /dev/null
+++ b/fastlane/metadata/android/zh-CN/changelogs/40102000.txt
@@ -0,0 +1,2 @@
+此版本中的主要更改:默认启用语音消息。
+完整更新日志:https://github.com/vector-im/element-android/releases/tag/v1.2.0
diff --git a/fastlane/metadata/android/zh-CN/changelogs/40102010.txt b/fastlane/metadata/android/zh-CN/changelogs/40102010.txt
new file mode 100644
index 00000000000..2ec2ae22b3b
--- /dev/null
+++ b/fastlane/metadata/android/zh-CN/changelogs/40102010.txt
@@ -0,0 +1,2 @@
+这个版本的主要变化:VoIP和空间的许多改进(仍在测试中)。
+完整更新日志:https://github.com/vector-im/element-android/releases/tag/v1.2.1
diff --git a/fastlane/metadata/android/zh-TW/changelogs/40102000.txt b/fastlane/metadata/android/zh-TW/changelogs/40102000.txt
new file mode 100644
index 00000000000..993a59c825e
--- /dev/null
+++ b/fastlane/metadata/android/zh-TW/changelogs/40102000.txt
@@ -0,0 +1,2 @@
+此版本中的主要變動:語音訊息預設啟用。
+完整的變更紀錄:https://github.com/vector-im/element-android/releases/tag/v1.2.0
diff --git a/fastlane/metadata/android/zh-TW/changelogs/40102010.txt b/fastlane/metadata/android/zh-TW/changelogs/40102010.txt
new file mode 100644
index 00000000000..b520266a789
--- /dev/null
+++ b/fastlane/metadata/android/zh-TW/changelogs/40102010.txt
@@ -0,0 +1,2 @@
+此版本中的主要變動:對 VoIP 與空間功能的諸多改善(仍在測試中)。
+完整的變更紀錄:https://github.com/vector-im/element-android/releases/tag/v1.2.1
diff --git a/gradle.properties b/gradle.properties
index 200866be253..98d561815be 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -6,20 +6,20 @@
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
-android.enableJetifier=true
-android.useAndroidX=true
-org.gradle.jvmargs=-Xmx2048m
-# When configured, Gradle will run in incubating parallel mode.
-# This option should only be used with decoupled projects. More details, visit
-# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
-# org.gradle.parallel=true
-# Enable file system watch (https://docs.gradle.org/6.7/release-notes.html)
+# Build Time Optimizations
+org.gradle.jvmargs=-Xmx3g -Xms512M -XX:MaxPermSize=2048m -XX:MaxMetaspaceSize=1g -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 -XX:+UseParallelGC
+org.gradle.configureondemand=true
+org.gradle.parallel=true
org.gradle.vfs.watch=true
+# Android Settings
+android.enableJetifier=true
+android.useAndroidX=true
+
+#Project Settings
+# Change debugPrivateData to true for debugging
vector.debugPrivateData=false
+# httpLogLevel values: NONE, BASIC, HEADERS, BODY
vector.httpLogLevel=BASIC
-# Note: to debug, you can put and uncomment the following lines in the file ~/.gradle/gradle.properties to override the value above
-#vector.debugPrivateData=true
-#vector.httpLogLevel=BODY
diff --git a/library/ui-styles/build.gradle b/library/ui-styles/build.gradle
index 365e4b902c3..cee58414c78 100644
--- a/library/ui-styles/build.gradle
+++ b/library/ui-styles/build.gradle
@@ -20,14 +20,11 @@ plugins {
}
android {
- compileSdkVersion 30
- buildToolsVersion "30.0.3"
+ compileSdk versions.compileSdk
defaultConfig {
- minSdkVersion 21
- targetSdkVersion 30
- versionCode 1
- versionName "1.0"
+ minSdk versions.minSdk
+ targetSdk versions.targetSdk
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
@@ -41,8 +38,8 @@ android {
}
compileOptions {
- sourceCompatibility JavaVersion.VERSION_11
- targetCompatibility JavaVersion.VERSION_11
+ sourceCompatibility versions.sourceCompat
+ targetCompatibility versions.targetCompat
}
kotlinOptions {
@@ -55,10 +52,10 @@ android {
}
dependencies {
- implementation 'androidx.appcompat:appcompat:1.3.1'
- implementation 'com.google.android.material:material:1.4.0'
+ implementation libs.androidx.appCompat
+ implementation libs.google.material
// Pref theme
- implementation 'androidx.preference:preference-ktx:1.1.1'
+ implementation libs.androidx.preferenceKtx
// PFLockScreen attrs
implementation 'com.github.vector-im:PFLockScreen-Android:1.0.0-beta12'
// dialpad dimen
diff --git a/library/ui-styles/src/main/res/values/stylable_bottom_sheet_action.xml b/library/ui-styles/src/main/res/values/stylable_bottom_sheet_action.xml
index d6fa160d6b6..b0c45b1feac 100644
--- a/library/ui-styles/src/main/res/values/stylable_bottom_sheet_action.xml
+++ b/library/ui-styles/src/main/res/values/stylable_bottom_sheet_action.xml
@@ -8,6 +8,7 @@
+
diff --git a/matrix-sdk-android-rx/build.gradle b/matrix-sdk-android-rx/build.gradle
index d18e3b1d72f..dbd761cee36 100644
--- a/matrix-sdk-android-rx/build.gradle
+++ b/matrix-sdk-android-rx/build.gradle
@@ -3,13 +3,11 @@ apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
android {
- compileSdkVersion 30
+ compileSdk versions.compileSdk
defaultConfig {
- minSdkVersion 21
- targetSdkVersion 30
- versionCode 1
- versionName "1.0"
+ minSdk versions.minSdk
+ targetSdk versions.targetSdk
// Multidex is useful for tests
multiDexEnabled true
@@ -24,8 +22,8 @@ android {
}
compileOptions {
- sourceCompatibility JavaVersion.VERSION_11
- targetCompatibility JavaVersion.VERSION_11
+ sourceCompatibility versions.sourceCompat
+ targetCompatibility versions.targetCompat
}
kotlinOptions {
@@ -34,15 +32,16 @@ android {
}
dependencies {
+
implementation project(":matrix-sdk-android")
- implementation 'androidx.appcompat:appcompat:1.3.1'
- implementation 'io.reactivex.rxjava2:rxkotlin:2.4.0'
- implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
- implementation "org.jetbrains.kotlinx:kotlinx-coroutines-rx2:$kotlin_coroutines_version"
+ implementation libs.androidx.appCompat
+ implementation libs.rx.rxKotlin
+ implementation libs.rx.rxAndroid
+ implementation libs.jetbrains.coroutinesRx2
// Paging
- implementation "androidx.paging:paging-runtime-ktx:2.1.2"
+ implementation libs.androidx.pagingRuntimeKtx
// Logging
- implementation 'com.jakewharton.timber:timber:5.0.1'
+ implementation libs.jakewharton.timber
}
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 2174c6f1182..56b52facf93 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 ff4b0d755ca..936bd824e74 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-rx/src/main/java/org/matrix/android/sdk/rx/RxSession.kt b/matrix-sdk-android-rx/src/main/java/org/matrix/android/sdk/rx/RxSession.kt
index 58fb760ff5e..47203816b43 100644
--- a/matrix-sdk-android-rx/src/main/java/org/matrix/android/sdk/rx/RxSession.kt
+++ b/matrix-sdk-android-rx/src/main/java/org/matrix/android/sdk/rx/RxSession.kt
@@ -32,6 +32,7 @@ import org.matrix.android.sdk.api.session.crypto.crosssigning.SELF_SIGNING_KEY_S
import org.matrix.android.sdk.api.session.crypto.crosssigning.USER_SIGNING_KEY_SSSS_NAME
import org.matrix.android.sdk.api.session.group.GroupSummaryQueryParams
import org.matrix.android.sdk.api.session.group.model.GroupSummary
+import org.matrix.android.sdk.api.session.identity.FoundThreePid
import org.matrix.android.sdk.api.session.identity.ThreePid
import org.matrix.android.sdk.api.session.pushers.Pusher
import org.matrix.android.sdk.api.session.room.RoomSummaryQueryParams
@@ -239,6 +240,10 @@ class RxSession(private val session: Session) {
)
.distinctUntilChanged()
}
+
+ fun lookupThreePid(threePid: ThreePid): Single> = rxSingle {
+ session.identityService().lookUp(listOf(threePid)).firstOrNull().toOptional()
+ }
}
fun Session.rx(): RxSession {
diff --git a/matrix-sdk-android/build.gradle b/matrix-sdk-android/build.gradle
index 24bed6f9957..b493db3157f 100644
--- a/matrix-sdk-android/build.gradle
+++ b/matrix-sdk-android/build.gradle
@@ -14,14 +14,14 @@ buildscript {
}
android {
- compileSdkVersion 30
testOptions.unitTests.includeAndroidResources = true
+ compileSdk versions.compileSdk
+
defaultConfig {
- minSdkVersion 21
- targetSdkVersion 30
- versionCode 1
- versionName "0.0.1"
+ minSdk versions.minSdk
+ targetSdk versions.targetSdk
+
// Multidex is useful for tests
multiDexEnabled true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
@@ -31,9 +31,7 @@ android {
// that the app's state is completely cleared between tests.
testInstrumentationRunnerArguments clearPackageData: 'true'
- // Seems that the build tools 4.1.0 does not generate BuildConfig.VERSION_NAME anymore.
- // Add it manually here. We may remove this trick in the future
- buildConfigField "String", "VERSION_NAME", "\"0.0.1\""
+ buildConfigField "String", "SDK_VERSION", "\"1.3.2\""
buildConfigField "String", "GIT_SDK_REVISION", "\"${gitRevision()}\""
resValue "string", "git_sdk_revision", "\"${gitRevision()}\""
@@ -68,8 +66,8 @@ android {
}
compileOptions {
- sourceCompatibility JavaVersion.VERSION_11
- targetCompatibility JavaVersion.VERSION_11
+ sourceCompatibility versions.sourceCompat
+ targetCompatibility versions.targetCompat
}
kotlinOptions {
@@ -103,92 +101,83 @@ static def gitRevisionDate() {
dependencies {
- def arrow_version = "0.8.2"
- def moshi_version = '1.12.0'
- def lifecycle_version = '2.2.0'
- def arch_version = '2.1.0'
- def markwon_version = '3.1.0'
- def daggerVersion = '2.38.1'
- def work_version = '2.5.0'
- def retrofit_version = '2.9.0'
-
- implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
- implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlin_coroutines_version"
- implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$kotlin_coroutines_version"
+ implementation libs.jetbrains.kotlinStdlibJdk7
+ implementation libs.jetbrains.coroutinesCore
+ implementation libs.jetbrains.coroutinesAndroid
- implementation "androidx.appcompat:appcompat:1.3.1"
- implementation "androidx.core:core-ktx:1.6.0"
+ implementation libs.androidx.appCompat
+ implementation libs.androidx.core
- implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"
- implementation "androidx.lifecycle:lifecycle-common-java8:$lifecycle_version"
+ implementation libs.androidx.lifecycleExtensions
+ implementation libs.androidx.lifecycleJava8
// Network
- implementation "com.squareup.retrofit2:retrofit:$retrofit_version"
- implementation "com.squareup.retrofit2:converter-moshi:$retrofit_version"
+ 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'
- implementation "com.squareup.moshi:moshi-adapters:$moshi_version"
- kapt "com.squareup.moshi:moshi-kotlin-codegen:$moshi_version"
+ implementation libs.squareup.moshi
+ kapt libs.squareup.moshiKotlin
- implementation "ru.noties.markwon:core:$markwon_version"
+ implementation libs.markwon.core
// Image
- implementation 'androidx.exifinterface:exifinterface:1.3.3'
+ implementation libs.androidx.exifinterface
// Database
implementation 'com.github.Zhuinden:realm-monarchy:0.7.1'
kapt 'dk.ilios:realmfieldnameshelper:2.0.0'
// Work
- implementation "androidx.work:work-runtime-ktx:$work_version"
+ implementation libs.androidx.work
// FP
- implementation "io.arrow-kt:arrow-core:$arrow_version"
- implementation "io.arrow-kt:arrow-instances-core:$arrow_version"
+ implementation libs.arrow.core
+ implementation libs.arrow.instances
// olm lib is now hosted by jitpack: https://jitpack.io/#org.matrix.gitlab.matrix-org/olm
implementation 'org.matrix.gitlab.matrix-org:olm:3.2.6'
// DI
- implementation "com.google.dagger:dagger:$daggerVersion"
- kapt "com.google.dagger:dagger-compiler:$daggerVersion"
+ implementation libs.dagger.dagger
+ kapt libs.dagger.daggerCompiler
// Logging
- implementation 'com.jakewharton.timber:timber:5.0.1'
+ implementation libs.jakewharton.timber
implementation 'com.facebook.stetho:stetho-okhttp3:1.6.0'
// Video compression
- implementation 'com.otaliastudios:transcoder:0.10.3'
+ implementation 'com.otaliastudios:transcoder:0.10.4'
// Phone number https://github.com/google/libphonenumber
- implementation 'com.googlecode.libphonenumber:libphonenumber:8.12.31'
+ implementation 'com.googlecode.libphonenumber:libphonenumber:8.12.33'
- testImplementation 'junit:junit:4.13.2'
- testImplementation 'org.robolectric:robolectric:4.5.1'
+ testImplementation libs.tests.junit
+ testImplementation 'org.robolectric:robolectric:4.6.1'
//testImplementation 'org.robolectric:shadows-support-v4:3.0'
// Note: version sticks to 1.9.2 due to https://github.com/mockk/mockk/issues/281
- testImplementation 'io.mockk:mockk:1.12.0'
- testImplementation 'org.amshove.kluent:kluent-android:1.68'
- testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$kotlin_coroutines_version"
+ testImplementation libs.mockk.mockk
+ testImplementation libs.tests.kluent
+ implementation libs.jetbrains.coroutinesAndroid
// Plant Timber tree for test
testImplementation 'net.lachlanmckee:timber-junit-rule:1.0.1'
- kaptAndroidTest "com.google.dagger:dagger-compiler:$daggerVersion"
- androidTestImplementation 'androidx.test:core:1.4.0'
- androidTestImplementation 'androidx.test:runner:1.4.0'
- androidTestImplementation 'androidx.test:rules:1.4.0'
- androidTestImplementation 'androidx.test.ext:junit:1.1.3'
- androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
- androidTestImplementation 'org.amshove.kluent:kluent-android:1.68'
- androidTestImplementation 'io.mockk:mockk-android:1.12.0'
- androidTestImplementation "androidx.arch.core:core-testing:$arch_version"
- androidTestImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$kotlin_coroutines_version"
+ kaptAndroidTest libs.dagger.daggerCompiler
+ androidTestImplementation libs.androidx.testCore
+ androidTestImplementation libs.androidx.testRunner
+ androidTestImplementation libs.androidx.testRules
+ androidTestImplementation libs.androidx.junit
+ androidTestImplementation libs.androidx.espressoCore
+ androidTestImplementation libs.tests.kluent
+ androidTestImplementation libs.mockk.mockkAndroid
+ androidTestImplementation libs.androidx.coreTesting
+ androidTestImplementation libs.jetbrains.coroutinesAndroid
// Plant Timber tree for test
- androidTestImplementation 'net.lachlanmckee:timber-junit-rule:1.0.1'
+ androidTestImplementation libs.tests.timberJunitRule
- androidTestUtil 'androidx.test:orchestrator:1.4.0'
+ androidTestUtil libs.androidx.orchestrator
}
diff --git a/matrix-sdk-android/src/androidTest/AndroidManifest.xml b/matrix-sdk-android/src/androidTest/AndroidManifest.xml
index 274bd8c87b1..40360fcd197 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 583406346eb..a7637668210 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 9942ea9db33..192f6442b22 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 5dede9dcfdc..e0451bea386 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 103b638c397..d32bcb3fe5b 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 01c4f8ccb3b..f8d108fb739 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/api/Matrix.kt b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/api/Matrix.kt
index c439da8407b..8b9b6efa119 100644
--- a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/api/Matrix.kt
+++ b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/api/Matrix.kt
@@ -117,7 +117,7 @@ class Matrix private constructor(context: Context, matrixConfiguration: MatrixCo
}
fun getSdkVersion(): String {
- return BuildConfig.VERSION_NAME + " (" + BuildConfig.GIT_SDK_REVISION + ")"
+ return BuildConfig.SDK_VERSION + " (" + BuildConfig.GIT_SDK_REVISION + ")"
}
}
}
diff --git a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/common/CommonTestHelper.kt b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/common/CommonTestHelper.kt
index 7817351e534..cf9b8f87c1a 100644
--- a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/common/CommonTestHelper.kt
+++ b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/common/CommonTestHelper.kt
@@ -19,6 +19,8 @@ package org.matrix.android.sdk.common
import android.content.Context
import android.net.Uri
import androidx.lifecycle.Observer
+import androidx.test.internal.runner.junit4.statement.UiThreadStatement
+import androidx.test.internal.runner.junit4.statement.UiThreadStatement.runOnUiThread
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.delay
@@ -59,13 +61,15 @@ class CommonTestHelper(context: Context) {
fun getTestInterceptor(session: Session): MockOkHttpInterceptor? = TestNetworkModule.interceptorForSession(session.sessionId) as? MockOkHttpInterceptor
init {
- Matrix.initialize(
- context,
- MatrixConfiguration(
- applicationFlavor = "TestFlavor",
- roomDisplayNameFallbackProvider = TestRoomDisplayNameFallbackProvider()
- )
- )
+ UiThreadStatement.runOnUiThread {
+ Matrix.initialize(
+ context,
+ MatrixConfiguration(
+ applicationFlavor = "TestFlavor",
+ roomDisplayNameFallbackProvider = TestRoomDisplayNameFallbackProvider()
+ )
+ )
+ }
matrix = Matrix.getInstance(context)
}
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 e7978a9cb29..b6d833a77cd 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 c2e1ec0f926..9f6d6eb1368 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 b6cb7f9e790..aaf779212b6 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 75ccce0db97..c717c8e33fe 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 1d838b5c849..f43c425cc97 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 a2566c14149..825fba570a3 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 b2516ea2bee..c939952dc9f 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 cc71f88fc03..63e74603d04 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 89d297c5928..0785dba8b95 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 b6e5ae73647..a625ffc0e97 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 ff8ce43b55f..80e54d82ec7 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 74855b86309..b343d7334ac 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 4ea8cdc0744..e0d49b3f5e7 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 97b93dcf5a2..9b10f9e9afa 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 94303dda081..1ed2f899773 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 b5ab6589ff5..d38afc6b62f 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 3774e6f513f..7628f287c97 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 0fe341cad60..dfa6ec10ae0 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 03a4d419881..e865fe17da8 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/androidTest/java/org/matrix/android/sdk/session/space/SpaceHierarchyTest.kt b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/session/space/SpaceHierarchyTest.kt
index 301cdea4610..436daf001be 100644
--- a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/session/space/SpaceHierarchyTest.kt
+++ b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/session/space/SpaceHierarchyTest.kt
@@ -32,10 +32,19 @@ import org.junit.runners.JUnit4
import org.junit.runners.MethodSorters
import org.matrix.android.sdk.InstrumentedTest
import org.matrix.android.sdk.api.query.ActiveSpaceFilter
+import org.matrix.android.sdk.api.query.QueryStringValue
import org.matrix.android.sdk.api.session.Session
+import org.matrix.android.sdk.api.session.events.model.EventType
+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.PowerLevelsContent
+import org.matrix.android.sdk.api.session.room.model.RoomJoinRulesAllowEntry
import org.matrix.android.sdk.api.session.room.model.RoomSummary
import org.matrix.android.sdk.api.session.room.model.RoomType
import org.matrix.android.sdk.api.session.room.model.create.CreateRoomParams
+import org.matrix.android.sdk.api.session.room.model.create.RestrictedRoomPreset
+import org.matrix.android.sdk.api.session.room.powerlevels.PowerLevelsHelper
+import org.matrix.android.sdk.api.session.room.powerlevels.Role
import org.matrix.android.sdk.api.session.room.roomSummaryQueryParams
import org.matrix.android.sdk.common.CommonTestHelper
import org.matrix.android.sdk.common.SessionTestParams
@@ -386,6 +395,8 @@ class SpaceHierarchyTest : InstrumentedTest {
// The room should have disapear from flat children
GlobalScope.launch(Dispatchers.Main) { flatAChildren.observeForever(childObserver) }
}
+
+ commonTestHelper.signOutAndClose(session)
}
data class TestSpaceCreationResult(
@@ -434,6 +445,57 @@ class SpaceHierarchyTest : InstrumentedTest {
return TestSpaceCreationResult(spaceId, roomIds)
}
+ @Suppress("EXPERIMENTAL_API_USAGE")
+ private fun createPrivateSpace(session: Session,
+ spaceName: String,
+ childInfo: List>
+ /** Name, auto-join, canonical*/
+ ): TestSpaceCreationResult {
+ var spaceId = ""
+ commonTestHelper.waitWithLatch {
+ GlobalScope.launch {
+ spaceId = session.spaceService().createSpace(spaceName, "My Private Space", null, false)
+ it.countDown()
+ }
+ }
+
+ val syncedSpace = session.spaceService().getSpace(spaceId)
+ val viaServers = listOf(session.sessionParams.homeServerHost ?: "")
+
+ val roomIds =
+ childInfo.map { entry ->
+ var roomId = ""
+ commonTestHelper.waitWithLatch {
+ GlobalScope.launch {
+ val homeServerCapabilities = session
+ .getHomeServerCapabilities()
+ roomId = session.createRoom(CreateRoomParams().apply {
+ name = entry.first
+ this.featurePreset = RestrictedRoomPreset(
+ homeServerCapabilities,
+ listOf(
+ RoomJoinRulesAllowEntry.restrictedToRoom(spaceId)
+ )
+ )
+ })
+ it.countDown()
+ }
+ }
+ roomId
+ }
+
+ roomIds.forEachIndexed { index, roomId ->
+ runBlocking {
+ syncedSpace!!.addChildren(roomId, viaServers, null, childInfo[index].second)
+ val canonical = childInfo[index].third
+ if (canonical != null) {
+ session.spaceService().setSpaceParent(roomId, spaceId, canonical, viaServers)
+ }
+ }
+ }
+ return TestSpaceCreationResult(spaceId, roomIds)
+ }
+
@Test
fun testRootSpaces() {
val session = commonTestHelper.createAccount("John", SessionTestParams(true))
@@ -473,5 +535,111 @@ class SpaceHierarchyTest : InstrumentedTest {
val rootSpaces = session.spaceService().getRootSpaceSummaries()
assertEquals("Unexpected number of root spaces ${rootSpaces.map { it.name }}", 2, rootSpaces.size)
+
+ commonTestHelper.signOutAndClose(session)
+ }
+
+ @Test
+ fun testParentRelation() {
+ val aliceSession = commonTestHelper.createAccount("Alice", SessionTestParams(true))
+ val bobSession = commonTestHelper.createAccount("Bib", SessionTestParams(true))
+
+ val spaceAInfo = createPrivateSpace(aliceSession, "Private Space A", listOf(
+ Triple("General", true /*suggested*/, true/*canonical*/),
+ Triple("Random", true, true)
+ ))
+
+ commonTestHelper.runBlockingTest {
+ aliceSession.getRoom(spaceAInfo.spaceId)!!.invite(bobSession.myUserId, null)
+ }
+
+ commonTestHelper.runBlockingTest {
+ bobSession.joinRoom(spaceAInfo.spaceId, null, emptyList())
+ }
+
+ var bobRoomId = ""
+ commonTestHelper.waitWithLatch {
+ GlobalScope.launch {
+ bobRoomId = bobSession.createRoom(CreateRoomParams().apply { name = "A Bob Room" })
+ bobSession.getRoom(bobRoomId)!!.invite(aliceSession.myUserId)
+ it.countDown()
+ }
+ }
+
+ commonTestHelper.runBlockingTest {
+ aliceSession.joinRoom(bobRoomId)
+ }
+
+ commonTestHelper.waitWithLatch { latch ->
+ commonTestHelper.retryPeriodicallyWithLatch(latch) {
+ aliceSession.getRoomSummary(bobRoomId)?.membership?.isActive() == true
+ }
+ }
+
+ commonTestHelper.waitWithLatch {
+ GlobalScope.launch {
+ bobSession.spaceService().setSpaceParent(bobRoomId, spaceAInfo.spaceId, false, listOf(bobSession.sessionParams.homeServerHost ?: ""))
+ it.countDown()
+ }
+ }
+
+ commonTestHelper.waitWithLatch { latch ->
+ commonTestHelper.retryPeriodicallyWithLatch(latch) {
+ val stateEvent = aliceSession.getRoom(bobRoomId)!!.getStateEvent(EventType.STATE_SPACE_PARENT, QueryStringValue.Equals(spaceAInfo.spaceId))
+ stateEvent != null
+ }
+ }
+
+ // This should be an invalid space parent relation, because no opposite child and bob is not admin of the space
+ commonTestHelper.runBlockingTest {
+ // we can see the state event
+ // but it is not valid and room is not in hierarchy
+ assertTrue("Bob Room should not be listed as a child of the space", aliceSession.getRoomSummary(bobRoomId)?.flattenParentIds?.isEmpty() == true)
+ }
+
+ // Let's now try to make alice admin of the room
+
+ commonTestHelper.waitWithLatch {
+ GlobalScope.launch {
+ val room = bobSession.getRoom(bobRoomId)!!
+ val currentPLContent = room
+ .getStateEvent(EventType.STATE_ROOM_POWER_LEVELS)
+ ?.let { it.content.toModel() }
+
+ val newPowerLevelsContent = currentPLContent
+ ?.setUserPowerLevel(aliceSession.myUserId, Role.Admin.value)
+ ?.toContent()
+
+ room.sendStateEvent(EventType.STATE_ROOM_POWER_LEVELS, null, newPowerLevelsContent!!)
+ it.countDown()
+ }
+ }
+
+ commonTestHelper.waitWithLatch { latch ->
+ commonTestHelper.retryPeriodicallyWithLatch(latch) {
+ val powerLevelsHelper = aliceSession.getRoom(bobRoomId)!!
+ .getStateEvent(EventType.STATE_ROOM_POWER_LEVELS)
+ ?.content
+ ?.toModel()
+ ?.let { PowerLevelsHelper(it) }
+ powerLevelsHelper!!.isUserAllowedToSend(aliceSession.myUserId, true, EventType.STATE_SPACE_PARENT)
+ }
+ }
+
+ commonTestHelper.waitWithLatch {
+ GlobalScope.launch {
+ aliceSession.spaceService().setSpaceParent(bobRoomId, spaceAInfo.spaceId, false, listOf(bobSession.sessionParams.homeServerHost ?: ""))
+ it.countDown()
+ }
+ }
+
+ commonTestHelper.waitWithLatch { latch ->
+ commonTestHelper.retryPeriodicallyWithLatch(latch) {
+ bobSession.getRoomSummary(bobRoomId)?.flattenParentIds?.contains(spaceAInfo.spaceId) == true
+ }
+ }
+
+ commonTestHelper.signOutAndClose(aliceSession)
+ commonTestHelper.signOutAndClose(bobSession)
}
}
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 2103dc954d5..3add757efad 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/Matrix.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/Matrix.kt
index 99802592667..8a4526a5e12 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/Matrix.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/Matrix.kt
@@ -111,7 +111,7 @@ class Matrix private constructor(context: Context, matrixConfiguration: MatrixCo
}
fun getSdkVersion(): String {
- return BuildConfig.VERSION_NAME + " (" + BuildConfig.GIT_SDK_REVISION + ")"
+ return BuildConfig.SDK_VERSION + " (" + BuildConfig.GIT_SDK_REVISION + ")"
}
}
}
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 ed809cdb045..3359e253f64 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 00000000000..49520f36785
--- /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 00000000000..82008cda8c6
--- /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 9a5e40ffeba..2a26b612fb0 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 00000000000..dc4e0f152df
--- /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 d5e323e457f..3a8e6b10846 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 3149a0218bc..b2035bb2eb5 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/logger/LoggerTag.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/logger/LoggerTag.kt
index 51f9b50699b..0d204edceed 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/logger/LoggerTag.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/logger/LoggerTag.kt
@@ -24,6 +24,7 @@ package org.matrix.android.sdk.api.logger
*/
open class LoggerTag(_value: String, parentTag: LoggerTag? = null) {
+ object SYNC : LoggerTag("SYNC")
object VOIP : LoggerTag("VOIP")
val value: String = if (parentTag == null) {
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 db112a30b26..baf33a59c57 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 2f981ffbbed..bde68da9d7e 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
@@ -36,7 +37,7 @@ import org.matrix.android.sdk.api.session.file.FileService
import org.matrix.android.sdk.api.session.group.GroupService
import org.matrix.android.sdk.api.session.homeserver.HomeServerCapabilitiesService
import org.matrix.android.sdk.api.session.identity.IdentityService
-import org.matrix.android.sdk.api.session.initsync.InitialSyncProgressService
+import org.matrix.android.sdk.api.session.initsync.SyncStatusService
import org.matrix.android.sdk.api.session.integrationmanager.IntegrationManagerService
import org.matrix.android.sdk.api.session.media.MediaService
import org.matrix.android.sdk.api.session.openid.OpenIdService
@@ -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
@@ -75,7 +77,7 @@ interface Session :
ProfileService,
PushRuleService,
PushersService,
- InitialSyncProgressService,
+ SyncStatusService,
HomeServerCapabilitiesService,
SecureStorageService,
AccountService {
@@ -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 47a63b4a251..ff1df63300c 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 6327dd92fd3..20ee68d228d 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 810d28dd839..ba2d4ba3f69 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 1ee161724a2..be450b9d03c 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 3d82846e7e9..96b44ce8c90 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()?.toModel()?.msgType) {
+ 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()?.toModel()?.msgType) {
+ 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()?.toModel()?.msgType) {
+ 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()?.toModel()?.msgType) {
+ 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()?.toModel()?.msgType) {
+ 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()?.toModel()?.msgType) {
+ 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 9c3fdd57daa..d0ce55070e6 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 b49236c3382..3ed6a7ebb2d 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 1485ec478bb..a22cd572fa4 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
new file mode 100644
index 00000000000..daab6d97611
--- /dev/null
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/initsync/SyncStatusService.kt
@@ -0,0 +1,49 @@
+/*
+ * 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.initsync
+
+import androidx.lifecycle.LiveData
+
+interface SyncStatusService {
+
+ fun getSyncStatusLive(): LiveData
+
+ sealed class Status {
+ /**
+ * For initial sync
+ */
+ abstract class InitialSyncStatus : Status()
+
+ object Idle : InitialSyncStatus()
+ data class Progressing(
+ val initSyncStep: InitSyncStep,
+ val percentProgress: Int = 0
+ ) : InitialSyncStatus()
+
+ /**
+ * For incremental sync
+ */
+ abstract class IncrementalSyncStatus : Status()
+
+ object IncrementalSyncIdle : IncrementalSyncStatus()
+ data class IncrementalSyncParsing(
+ val rooms: Int,
+ val toDevice: Int
+ ) : IncrementalSyncStatus()
+ object IncrementalSyncError : IncrementalSyncStatus()
+ object IncrementalSyncDone : IncrementalSyncStatus()
+ }
+}
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 5e9f3e1eb93..3e27da0c41d 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 00000000000..a904e89681a
--- /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 005a2edae73..edb748c76eb 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 a6d4583c76f..920dc85c7a0 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/pushers/Pusher.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/pushers/Pusher.kt
index eed75c9dafb..b85ab32b210 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/pushers/Pusher.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/pushers/Pusher.kt
@@ -26,7 +26,14 @@ data class Pusher(
val data: PusherData,
val state: PusherState
-)
+) {
+ companion object {
+
+ const val KIND_EMAIL = "email"
+ const val KIND_HTTP = "http"
+ const val APP_ID_EMAIL = "m.email"
+ }
+}
enum class PusherState {
UNREGISTERED,
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/pushers/PushersService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/pushers/PushersService.kt
index a5ec100f64c..2cd17952c68 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/pushers/PushersService.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/pushers/PushersService.kt
@@ -27,14 +27,12 @@ interface PushersService {
/**
* Add a new HTTP pusher.
- * Note that only `http` kind is supported by the SDK for now.
* Ref: https://matrix.org/docs/spec/client_server/latest#post-matrix-client-r0-pushers-set
*
* @param pushkey This is a unique identifier for this pusher. The value you should use for
* this is the routing or destination address information for the notification,
* for example, the APNS token for APNS or the Registration ID for GCM. If your
* notification client has no such concept, use any unique identifier. Max length, 512 chars.
- * If the kind is "email", this is the email address to send notifications to.
* @param appId the application id
* This is a reverse-DNS style identifier for the application. It is recommended
* that this end with the platform, such that different platform versions get
@@ -64,6 +62,30 @@ interface PushersService {
append: Boolean,
withEventIdOnly: Boolean): UUID
+ /**
+ * Add a new Email pusher.
+ * Ref: https://matrix.org/docs/spec/client_server/latest#post-matrix-client-r0-pushers-set
+ *
+ * @param email The email address to send notifications to.
+ * @param lang The preferred language for receiving notifications (e.g. "en" or "en-US").
+ * @param emailBranding The branding placeholder to include in the email communications.
+ * @param appDisplayName A human readable string that will allow the user to identify what application owns this pusher.
+ * @param deviceDisplayName A human readable string that will allow the user to identify what device owns this pusher.
+ * @param append If true, the homeserver should add another pusher with the given pushkey and App ID in addition
+ * to any others with different user IDs. Otherwise, the homeserver must remove any other pushers
+ * with the same App ID and pushkey for different users. Typically We always want to append for
+ * email pushers since we don't want to stop other accounts notifying to the same email address.
+ * @return A work request uuid. Can be used to listen to the status
+ * (LiveData status = workManager.getWorkInfoByIdLiveData())
+ * @throws [InvalidParameterException] if a parameter is not correct
+ */
+ fun addEmailPusher(email: String,
+ lang: String,
+ emailBranding: String,
+ appDisplayName: String,
+ deviceDisplayName: String,
+ append: Boolean = true): UUID
+
/**
* Directly ask the push gateway to send a push to this device
* If successful, the push gateway has accepted the request. In this case, the app should receive a Push with the provided eventId.
@@ -80,10 +102,23 @@ interface PushersService {
eventId: String)
/**
- * Remove the http pusher
+ * Remove a registered pusher
+ * @param pusher the pusher to remove, can be http or email
+ */
+ suspend fun removePusher(pusher: Pusher)
+
+ /**
+ * Remove a Http pusher by its pushkey and appId
+ * @see addHttpPusher
*/
suspend fun removeHttpPusher(pushkey: String, appId: String)
+ /**
+ * Remove an Email pusher
+ * @see addEmailPusher
+ */
+ suspend fun removeEmailPusher(email: String)
+
/**
* Get the current pushers, as a LiveData
*/
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 6f607569c08..fff6adecbf4 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 f3e3913bc12..9446f0fdffd 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 5d26b213491..d80faa729c2 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/RoomStrippedState.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/RoomStrippedState.kt
new file mode 100644
index 00000000000..dc0c00b282c
--- /dev/null
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/RoomStrippedState.kt
@@ -0,0 +1,111 @@
+/*
+ * 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.session.room.model
+
+import com.squareup.moshi.Json
+import com.squareup.moshi.JsonClass
+
+/**
+ * These are the same fields as those returned by /publicRooms, with a few additions: room_type, membership and is_encrypted.
+ */
+@JsonClass(generateAdapter = true)
+data class RoomStrippedState(
+ /**
+ * Aliases of the room. May be empty.
+ */
+ @Json(name = "aliases")
+ val aliases: List? = null,
+
+ /**
+ * The canonical alias of the room, if any.
+ */
+ @Json(name = "canonical_alias")
+ val canonicalAlias: String? = null,
+
+ /**
+ * The name of the room, if any.
+ */
+ @Json(name = "name")
+ val name: String? = null,
+
+ /**
+ * Required. The number of members joined to the room.
+ */
+ @Json(name = "num_joined_members")
+ val numJoinedMembers: Int = 0,
+
+ /**
+ * Required. The ID of the room.
+ */
+ @Json(name = "room_id")
+ val roomId: String,
+
+ /**
+ * The topic of the room, if any.
+ */
+ @Json(name = "topic")
+ val topic: String? = null,
+
+ /**
+ * Required. Whether the room may be viewed by guest users without joining.
+ */
+ @Json(name = "world_readable")
+ val worldReadable: Boolean = false,
+
+ /**
+ * Required. Whether guest users may join the room and participate in it. If they can,
+ * they will be subject to ordinary power level rules like any other user.
+ */
+ @Json(name = "guest_can_join")
+ val guestCanJoin: Boolean = false,
+
+ /**
+ * The URL for the room's avatar, if one is set.
+ */
+ @Json(name = "avatar_url")
+ val avatarUrl: String? = null,
+
+ /**
+ * Undocumented item
+ */
+ @Json(name = "m.federate")
+ val isFederated: Boolean = false,
+
+ /**
+ * Optional. If the room is encrypted. This is already accessible as stripped state.
+ */
+ @Json(name = "is_encrypted")
+ val isEncrypted: Boolean?,
+
+ /**
+ * Optional. Type of the room, if any, i.e. m.space
+ */
+ @Json(name = "room_type")
+ val roomType: String?,
+
+ /**
+ * The current membership of this user in the room. Usually leave if the room is fetched over federation.
+ */
+ @Json(name = "membership")
+ val membership: String?
+) {
+ /**
+ * Return the canonical alias, or the first alias from the list of aliases, or null
+ */
+ fun getPrimaryAlias(): String? {
+ return canonicalAlias ?: aliases?.firstOrNull()
+ }
+}
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 180b32db054..6b4d7828326 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 dc0a1e3b2e3..deec80f4fff 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 e4332f0ea76..d70e63d1226 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 68dd5ef043e..bbbfbe68ab8 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 4559c5db6d5..7947b7d0bd1 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 795f3327111..634bee1d83e 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/model/message/AudioWaveformInfo.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/AudioWaveformInfo.kt
index d576f1057a2..aa05eb71892 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/AudioWaveformInfo.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/AudioWaveformInfo.kt
@@ -32,5 +32,5 @@ data class AudioWaveformInfo(
* List of integers between zero and 1024, inclusive.
*/
@Json(name = "waveform")
- val waveform: List? = null
+ val waveform: List? = null
)
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageAudioContent.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageAudioContent.kt
index 1bcb10d88cf..ebf3d127ce4 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageAudioContent.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageAudioContent.kt
@@ -28,7 +28,7 @@ data class MessageAudioContent(
/**
* Required. Must be 'm.audio'.
*/
- @Json(name = "msgtype") override val msgType: String,
+ @Json(name = MessageContent.MSG_TYPE_JSON_KEY) override val msgType: String,
/**
* Required. A description of the audio e.g. 'Bee Gees - Stayin' Alive', or some kind of content description for accessibility e.g. 'audio attachment'.
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageContent.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageContent.kt
index df5641a6220..5a1b66c91c1 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageContent.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageContent.kt
@@ -20,6 +20,11 @@ import org.matrix.android.sdk.api.session.events.model.Content
import org.matrix.android.sdk.api.session.room.model.relation.RelationDefaultContent
interface MessageContent {
+
+ companion object {
+ const val MSG_TYPE_JSON_KEY = "msgtype"
+ }
+
val msgType: String
val body: String
val relatesTo: RelationDefaultContent?
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageDefaultContent.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageDefaultContent.kt
index 65e89cdfee4..1dadc922717 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageDefaultContent.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageDefaultContent.kt
@@ -23,7 +23,7 @@ import org.matrix.android.sdk.api.session.room.model.relation.RelationDefaultCon
@JsonClass(generateAdapter = true)
data class MessageDefaultContent(
- @Json(name = "msgtype") override val msgType: String,
+ @Json(name = MessageContent.MSG_TYPE_JSON_KEY) override val msgType: String,
@Json(name = "body") override val body: String,
@Json(name = "m.relates_to") override val relatesTo: RelationDefaultContent? = null,
@Json(name = "m.new_content") override val newContent: Content? = null
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageEmoteContent.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageEmoteContent.kt
index 77983a031eb..a2ada416ba1 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageEmoteContent.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageEmoteContent.kt
@@ -26,7 +26,7 @@ data class MessageEmoteContent(
/**
* Required. Must be 'm.emote'.
*/
- @Json(name = "msgtype") override val msgType: String,
+ @Json(name = MessageContent.MSG_TYPE_JSON_KEY) override val msgType: String,
/**
* Required. The emote action to perform.
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageFileContent.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageFileContent.kt
index 96877b4d9f1..78f9a5d2f2d 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageFileContent.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageFileContent.kt
@@ -28,7 +28,7 @@ data class MessageFileContent(
/**
* Required. Must be 'm.file'.
*/
- @Json(name = "msgtype") override val msgType: String,
+ @Json(name = MessageContent.MSG_TYPE_JSON_KEY) override val msgType: String,
/**
* Required. A human-readable description of the file. This is recommended to be the filename of the original upload.
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageImageContent.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageImageContent.kt
index 73fd1eab565..ea7ab506887 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageImageContent.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageImageContent.kt
@@ -27,7 +27,7 @@ data class MessageImageContent(
/**
* Required. Must be 'm.image'.
*/
- @Json(name = "msgtype") override val msgType: String,
+ @Json(name = MessageContent.MSG_TYPE_JSON_KEY) override val msgType: String,
/**
* Required. A textual representation of the image. This could be the alt text of the image, the filename of the image,
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageLocationContent.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageLocationContent.kt
index bdb54910dd0..6881c099246 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageLocationContent.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageLocationContent.kt
@@ -26,7 +26,7 @@ data class MessageLocationContent(
/**
* Required. Must be 'm.location'.
*/
- @Json(name = "msgtype") override val msgType: String,
+ @Json(name = MessageContent.MSG_TYPE_JSON_KEY) override val msgType: String,
/**
* Required. A description of the location e.g. 'Big Ben, London, UK', or some kind
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageNoticeContent.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageNoticeContent.kt
index b2fd8cb0c0c..dd960355cad 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageNoticeContent.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageNoticeContent.kt
@@ -26,7 +26,7 @@ data class MessageNoticeContent(
/**
* Required. Must be 'm.notice'.
*/
- @Json(name = "msgtype") override val msgType: String,
+ @Json(name = MessageContent.MSG_TYPE_JSON_KEY) override val msgType: String,
/**
* Required. The notice text to send.
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageOptionsContent.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageOptionsContent.kt
index 7924469884c..7a1a99bd5fd 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageOptionsContent.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageOptionsContent.kt
@@ -30,7 +30,7 @@ const val OPTION_TYPE_BUTTONS = "org.matrix.buttons"
*/
@JsonClass(generateAdapter = true)
data class MessageOptionsContent(
- @Json(name = "msgtype") override val msgType: String = MessageType.MSGTYPE_OPTIONS,
+ @Json(name = MessageContent.MSG_TYPE_JSON_KEY) override val msgType: String = MessageType.MSGTYPE_OPTIONS,
@Json(name = "type") val optionType: String? = null,
@Json(name = "body") override val body: String,
@Json(name = "label") val label: String?,
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessagePollResponseContent.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessagePollResponseContent.kt
index d827475277e..9edfe118b09 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessagePollResponseContent.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessagePollResponseContent.kt
@@ -26,7 +26,7 @@ import org.matrix.android.sdk.api.session.room.model.relation.RelationDefaultCon
*/
@JsonClass(generateAdapter = true)
data class MessagePollResponseContent(
- @Json(name = "msgtype") override val msgType: String = MessageType.MSGTYPE_RESPONSE,
+ @Json(name = MessageContent.MSG_TYPE_JSON_KEY) override val msgType: String = MessageType.MSGTYPE_RESPONSE,
@Json(name = "body") override val body: String,
@Json(name = "m.relates_to") override val relatesTo: RelationDefaultContent? = null,
@Json(name = "m.new_content") override val newContent: Content? = null
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageTextContent.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageTextContent.kt
index e45245a9bf1..5968fecd43b 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageTextContent.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageTextContent.kt
@@ -26,7 +26,7 @@ data class MessageTextContent(
/**
* Required. Must be 'm.text'.
*/
- @Json(name = "msgtype") override val msgType: String,
+ @Json(name = MessageContent.MSG_TYPE_JSON_KEY) override val msgType: String,
/**
* Required. The body of the message.
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageVerificationRequestContent.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageVerificationRequestContent.kt
index 25b5f448150..b2b3cdac909 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageVerificationRequestContent.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageVerificationRequestContent.kt
@@ -24,7 +24,7 @@ import org.matrix.android.sdk.internal.crypto.verification.VerificationInfoReque
@JsonClass(generateAdapter = true)
data class MessageVerificationRequestContent(
- @Json(name = "msgtype") override val msgType: String = MessageType.MSGTYPE_VERIFICATION_REQUEST,
+ @Json(name = MessageContent.MSG_TYPE_JSON_KEY)override val msgType: String = MessageType.MSGTYPE_VERIFICATION_REQUEST,
@Json(name = "body") override val body: String,
@Json(name = "from_device") override val fromDevice: String?,
@Json(name = "methods") override val methods: List,
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageVideoContent.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageVideoContent.kt
index 3f5d2dab2e7..e1b0cd86074 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageVideoContent.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageVideoContent.kt
@@ -27,7 +27,7 @@ data class MessageVideoContent(
/**
* Required. Must be 'm.video'.
*/
- @Json(name = "msgtype") override val msgType: String,
+ @Json(name = MessageContent.MSG_TYPE_JSON_KEY)override val msgType: String,
/**
* Required. A description of the video e.g. 'Gangnam style', or some kind of content description for accessibility e.g. 'video attachment'.
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 ea67b55174c..d806e6007e5 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 59325f99032..a91b97b86cd 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/api/session/space/SpaceService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/space/SpaceService.kt
index bcc36b579a3..f40572518f0 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/space/SpaceService.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/space/SpaceService.kt
@@ -94,5 +94,7 @@ interface SpaceService {
*/
suspend fun setSpaceParent(childRoomId: String, parentSpaceId: String, canonical: Boolean, viaServers: List)
+ suspend fun removeSpaceParent(childRoomId: String, parentSpaceId: String)
+
fun getRootSpaceSummaries(): List
}
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 bfa8c342b6f..c05e1e51878 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 d5b435ac275..930cfb153ff 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 ee6aabb0a99..581e6824ee5 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 4c2dce3ba81..fd8710bbda4 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 148c2aeab92..d41df9f0f62 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 c21a73abc2a..dc63c5ba078 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 83006c646b2..087a5f52dc5 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 92d09aa4f50..d632552888f 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 ded9e2a3508..59b4b4fc327 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 9aed0d37d68..e3d07602c79 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 a2375507d8b..f2c4ed551c8 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 f2135db6b7f..f4d831c16ff 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 f86f05d0003..78224675648 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 228a71ec281..7216a0c992f 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 27bbc4343f7..82d29a52e2f 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 f01534b884d..6618bceacd9 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 dd2f96c9882..ff3ed542640 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 92%
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 55790d09792..d7dff72288f 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 8f3af56cde1..082460cc2d6 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 05b50ab2c5e..9e1b791919c 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 7cd939a5c25..54ae9e54f6a 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 3d2773fb4be..3396c4a6c98 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 e76dc28734a..641a8f1bb6e 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 bc3d8870007..94b301649f2 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 968ae22eda7..13f26e321da 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 edd3e2bed57..235ef6b7092 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 3888633723b..8f61afe3742 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 4e599516ed2..74cb3de2acf 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 0ec020bc461..c11d00278b0 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 84d4fef5afd..fe388b44e22 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 67d8ba4515c..dbcd5bdd58b 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
@@ -51,6 +51,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
@@ -89,7 +90,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
@@ -880,8 +880,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)
}
@@ -899,9 +899,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 79910c6de29..8a91376b607 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 8d86380e39e..fe17dd08e47 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/InboundGroupSessionStore.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/InboundGroupSessionStore.kt
index 06c667ee4ad..3825a5dab2e 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/InboundGroupSessionStore.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/InboundGroupSessionStore.kt
@@ -71,18 +71,24 @@ internal class InboundGroupSessionStore @Inject constructor(
}
@Synchronized
- fun storeInBoundGroupSession(wrapper: OlmInboundGroupSessionWrapper2) {
+ fun storeInBoundGroupSession(wrapper: OlmInboundGroupSessionWrapper2, sessionId: String, senderKey: String) {
Timber.v("## Inbound: getInboundGroupSession mark as dirty ${wrapper.roomId}-${wrapper.senderKey}")
// We want to batch this a bit for performances
dirtySession.add(wrapper)
+ if (sessionCache[CacheKey(sessionId, senderKey)] == null) {
+ // first time seen, put it in memory cache while waiting for batch insert
+ // If it's already known, no need to update cache it's already there
+ sessionCache.put(CacheKey(sessionId, senderKey), wrapper)
+ }
+
timerTask?.cancel()
timerTask = object : TimerTask() {
override fun run() {
batchSave()
}
}
- timer.schedule(timerTask!!, 2_000)
+ timer.schedule(timerTask!!, 300)
}
@Synchronized
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/MXOlmDevice.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/MXOlmDevice.kt
index b3c2cfae66c..6479a8ddced 100755
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/MXOlmDevice.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/MXOlmDevice.kt
@@ -595,7 +595,8 @@ internal class MXOlmDevice @Inject constructor(
session.keysClaimed = keysClaimed
session.forwardingCurve25519KeyChain = forwardingCurve25519KeyChain
- store.storeInboundGroupSessions(listOf(session))
+ inboundGroupSessionStore.storeInBoundGroupSession(session, sessionId, senderKey)
+// store.storeInboundGroupSessions(listOf(session))
return true
}
@@ -721,7 +722,7 @@ internal class MXOlmDevice @Inject constructor(
timelineSet.add(messageIndexKey)
}
- inboundGroupSessionStore.storeInBoundGroupSession(session)
+ inboundGroupSessionStore.storeInBoundGroupSession(session, sessionId, senderKey)
val payload = try {
val adapter = MoshiProvider.providesMoshi().adapter(JSON_DICT_PARAMETERIZED_TYPE)
val payloadString = convertFromUTF8(decryptResult.mDecryptedMessage)
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 ccdb5ab1376..6fc71036688 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 2e26720abb2..b2ba189b65e 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 c5c6d26f791..b96943e4aef 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 95b99c54e86..52876b0fff8 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 a276394eaf5..a3cfbd91f00 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 70d20222993..d2f6bd0382b 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 95a4342dbf4..91640523fc0 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 a7564444759..63fe678229f 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
}
@@ -170,7 +170,7 @@ internal class MXMegolmEncryption(
val deviceIds = devicesInRoom.getUserDeviceIds(userId)
for (deviceId in deviceIds!!) {
val deviceInfo = devicesInRoom.getObject(userId, deviceId)
- if (deviceInfo != null && !cryptoStore.getSharedSessionInfo(roomId, safeSession.sessionId, userId, deviceId).found) {
+ if (deviceInfo != null && !cryptoStore.getSharedSessionInfo(roomId, safeSession.sessionId, deviceInfo).found) {
val devices = shareMap.getOrPut(userId) { ArrayList() }
devices.add(deviceInfo)
}
@@ -270,8 +270,8 @@ internal class MXMegolmEncryption(
// for dead devices on every message.
val gossipingEventBuffer = arrayListOf()
for ((userId, devicesToShareWith) in devicesByUser) {
- for ((deviceId) in devicesToShareWith) {
- session.sharedWithHelper.markedSessionAsShared(userId, deviceId, chainIndex)
+ for (deviceInfo in devicesToShareWith) {
+ session.sharedWithHelper.markedSessionAsShared(deviceInfo, chainIndex)
gossipingEventBuffer.add(
Event(
type = EventType.ROOM_KEY,
@@ -279,7 +279,7 @@ internal class MXMegolmEncryption(
content = submap.apply {
this["session_key"] = ""
// we add a fake key for trail
- this["_dest"] = "$userId|$deviceId"
+ this["_dest"] = "$userId|${deviceInfo.deviceId}"
}
))
}
@@ -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()
@@ -429,7 +429,7 @@ internal class MXMegolmEncryption(
.also { Timber.w("## Crypto reshareKey: Device not found") }
// Get the chain index of the key we previously sent this device
- val wasSessionSharedWithUser = cryptoStore.getSharedSessionInfo(roomId, sessionId, userId, deviceId)
+ val wasSessionSharedWithUser = cryptoStore.getSharedSessionInfo(roomId, sessionId, deviceInfo)
if (!wasSessionSharedWithUser.found) {
// This session was never shared with this user
// Send a room key with held
@@ -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/megolm/SharedWithHelper.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/algorithms/megolm/SharedWithHelper.kt
index f17168a6d22..a64e5af0d33 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/algorithms/megolm/SharedWithHelper.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/algorithms/megolm/SharedWithHelper.kt
@@ -16,6 +16,7 @@
package org.matrix.android.sdk.internal.crypto.algorithms.megolm
+import org.matrix.android.sdk.internal.crypto.model.CryptoDeviceInfo
import org.matrix.android.sdk.internal.crypto.model.MXUsersDevicesMap
import org.matrix.android.sdk.internal.crypto.store.IMXCryptoStore
@@ -28,7 +29,13 @@ internal class SharedWithHelper(
return cryptoStore.getSharedWithInfo(roomId, sessionId)
}
- fun markedSessionAsShared(userId: String, deviceId: String, chainIndex: Int) {
- cryptoStore.markedSessionAsShared(roomId, sessionId, userId, deviceId, chainIndex)
+ fun markedSessionAsShared(deviceInfo: CryptoDeviceInfo, chainIndex: Int) {
+ cryptoStore.markedSessionAsShared(
+ roomId = roomId,
+ sessionId = sessionId,
+ userId = deviceInfo.userId,
+ deviceId = deviceInfo.deviceId,
+ deviceIdentityKey = deviceInfo.identityKey() ?: "",
+ chainIndex = chainIndex)
}
}
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 082b86c9da6..f1bca4fbc6b 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 65f78e11f02..63f2533ac32 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 c071384df46..3d00e178a0c 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 ee5aab977b0..113255bb7ea 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 0289fadbd8f..8a851b12674 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 76b63b7798e..3326d3707a5 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 fbcf5cfdeb2..c6e2c1217f8 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 7c0c741a2cf..78ef958bbff 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 fb10cf4482b..ad3bc012dfb 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/IMXCryptoStore.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/IMXCryptoStore.kt
index 3d12e74fcdd..238d06738cc 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/IMXCryptoStore.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/IMXCryptoStore.kt
@@ -450,7 +450,8 @@ internal interface IMXCryptoStore {
fun addWithHeldMegolmSession(withHeldContent: RoomKeyWithHeldContent)
fun getWithHeldMegolmSession(roomId: String, sessionId: String): RoomKeyWithHeldContent?
- fun markedSessionAsShared(roomId: String?, sessionId: String, userId: String, deviceId: String, chainIndex: Int)
+ fun markedSessionAsShared(roomId: String?, sessionId: String, userId: String, deviceId: String,
+ deviceIdentityKey: String, chainIndex: Int)
/**
* Query for information on this session sharing history.
@@ -459,7 +460,7 @@ internal interface IMXCryptoStore {
* in this case chainIndex is not nullindicates the ratchet position.
* In found is false, chainIndex is null
*/
- fun getSharedSessionInfo(roomId: String?, sessionId: String, userId: String, deviceId: String): SharedSessionResult
+ fun getSharedSessionInfo(roomId: String?, sessionId: String, deviceInfo: CryptoDeviceInfo): SharedSessionResult
data class SharedSessionResult(val found: Boolean, val chainIndex: Int?)
fun getSharedWithInfo(roomId: String?, sessionId: String): MXUsersDevicesMap
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 3c8353e83e3..3c8f74d419e 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) {
@@ -1681,7 +1681,12 @@ internal class RealmCryptoStore @Inject constructor(
}
}
- override fun markedSessionAsShared(roomId: String?, sessionId: String, userId: String, deviceId: String, chainIndex: Int) {
+ override fun markedSessionAsShared(roomId: String?,
+ sessionId: String,
+ userId: String,
+ deviceId: String,
+ deviceIdentityKey: String,
+ chainIndex: Int) {
doRealmTransaction(realmConfiguration) { realm ->
SharedSessionEntity.create(
realm = realm,
@@ -1689,14 +1694,22 @@ internal class RealmCryptoStore @Inject constructor(
sessionId = sessionId,
userId = userId,
deviceId = deviceId,
+ deviceIdentityKey = deviceIdentityKey,
chainIndex = chainIndex
)
}
}
- override fun getSharedSessionInfo(roomId: String?, sessionId: String, userId: String, deviceId: String): IMXCryptoStore.SharedSessionResult {
+ override fun getSharedSessionInfo(roomId: String?, sessionId: String, deviceInfo: CryptoDeviceInfo): IMXCryptoStore.SharedSessionResult {
return doWithRealm(realmConfiguration) { realm ->
- SharedSessionEntity.get(realm, roomId, sessionId, userId, deviceId)?.let {
+ SharedSessionEntity.get(
+ realm = realm,
+ roomId = roomId,
+ sessionId = sessionId,
+ userId = deviceInfo.userId,
+ deviceId = deviceInfo.deviceId,
+ deviceIdentityKey = deviceInfo.identityKey()
+ )?.let {
IMXCryptoStore.SharedSessionResult(true, it.chainIndex)
} ?: IMXCryptoStore.SharedSessionResult(false, null)
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/db/RealmCryptoStoreMigration.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/db/RealmCryptoStoreMigration.kt
index 2846be99325..f73cbaf480a 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/db/RealmCryptoStoreMigration.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/db/RealmCryptoStoreMigration.kt
@@ -55,7 +55,7 @@ internal object RealmCryptoStoreMigration : RealmMigration {
// 0, 1, 2: legacy Riot-Android
// 3: migrate to RiotX schema
// 4, 5, 6, 7, 8, 9: migrations from RiotX (which was previously 1, 2, 3, 4, 5, 6)
- const val CRYPTO_STORE_SCHEMA_VERSION = 13L
+ const val CRYPTO_STORE_SCHEMA_VERSION = 14L
private fun RealmObjectSchema.addFieldIfNotExists(fieldName: String, fieldType: Class<*>): RealmObjectSchema {
if (!hasField(fieldName)) {
@@ -94,6 +94,7 @@ internal object RealmCryptoStoreMigration : RealmMigration {
if (oldVersion <= 10) migrateTo11(realm)
if (oldVersion <= 11) migrateTo12(realm)
if (oldVersion <= 12) migrateTo13(realm)
+ if (oldVersion <= 13) migrateTo14(realm)
}
private fun migrateTo1Legacy(realm: DynamicRealm) {
@@ -554,4 +555,21 @@ internal object RealmCryptoStoreMigration : RealmMigration {
Timber.e("TrustLevelEntity cleanup: Something is not correct...")
}
}
+
+ // Version 14L Update the way we remember key sharing
+ private fun migrateTo14(realm: DynamicRealm) {
+ Timber.d("Step 13 -> 14")
+ realm.schema.get("SharedSessionEntity")
+ ?.addField(SharedSessionEntityFields.DEVICE_IDENTITY_KEY, String::class.java)
+ ?.addIndex(SharedSessionEntityFields.DEVICE_IDENTITY_KEY)
+ ?.transform {
+ val sharedUserId = it.getString(SharedSessionEntityFields.USER_ID)
+ val sharedDeviceId = it.getString(SharedSessionEntityFields.DEVICE_ID)
+ val knownDevice = realm.where("DeviceInfoEntity")
+ .equalTo(DeviceInfoEntityFields.USER_ID, sharedUserId)
+ .equalTo(DeviceInfoEntityFields.DEVICE_ID, sharedDeviceId)
+ .findFirst()
+ it.setString(SharedSessionEntityFields.DEVICE_IDENTITY_KEY, knownDevice?.getString(DeviceInfoEntityFields.IDENTITY_KEY))
+ }
+ }
}
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 6aae68c83ee..a2f2f8e97ae 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 9e739855927..c15414a8dd3 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 5166f6c31f3..35ae86db8bb 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 e226f3eaa8f..711b6984641 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 b8675d0823a..75094f01db5 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 df45568d18b..4457a44cb2d 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 d0e16bbe11c..f330e8822ac 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 8f410578077..0b69311c57d 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 442dda1d717..a19547fddc3 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/SharedSessionEntity.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/db/model/SharedSessionEntity.kt
index c0ed1ac409a..e2ae512afd3 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/db/model/SharedSessionEntity.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/db/model/SharedSessionEntity.kt
@@ -30,6 +30,7 @@ internal open class SharedSessionEntity(
@Index var sessionId: String? = null,
@Index var userId: String? = null,
@Index var deviceId: String? = null,
+ @Index var deviceIdentityKey: String? = null,
var chainIndex: Int? = null
) : RealmObject() {
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 2864ab768df..6d7889053b9 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 eea2f6f31b5..05eed9256e6 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 5ebf8b1ed5a..5750cc1f676 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 1d5ca2d3ccc..c9523d63ce3 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 fa37734fe58..2784e58425a 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
@@ -16,27 +16,31 @@
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.SharedSessionEntity
-import org.matrix.android.sdk.internal.crypto.store.db.model.SharedSessionEntityFields
import io.realm.Realm
import io.realm.RealmResults
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.SharedSessionEntity
+import org.matrix.android.sdk.internal.crypto.store.db.model.SharedSessionEntityFields
-internal fun SharedSessionEntity.Companion.get(realm: Realm, roomId: String?, sessionId: String, userId: String, deviceId: String)
- : SharedSessionEntity? {
+internal fun SharedSessionEntity.Companion.get(realm: Realm,
+ roomId: String?,
+ sessionId: String,
+ userId: String,
+ deviceId: String,
+ deviceIdentityKey: String?): SharedSessionEntity? {
return realm.where()
.equalTo(SharedSessionEntityFields.ROOM_ID, roomId)
.equalTo(SharedSessionEntityFields.SESSION_ID, sessionId)
.equalTo(SharedSessionEntityFields.ALGORITHM, MXCRYPTO_ALGORITHM_MEGOLM)
.equalTo(SharedSessionEntityFields.USER_ID, userId)
.equalTo(SharedSessionEntityFields.DEVICE_ID, deviceId)
+ .equalTo(SharedSessionEntityFields.DEVICE_IDENTITY_KEY, deviceIdentityKey)
.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)
@@ -44,14 +48,19 @@ internal fun SharedSessionEntity.Companion.get(realm: Realm, roomId: String?, se
.findAll()
}
-internal fun SharedSessionEntity.Companion.create(realm: Realm, roomId: String?, sessionId: String, userId: String, deviceId: String, chainIndex: Int)
- : SharedSessionEntity {
+internal fun SharedSessionEntity.Companion.create(realm: Realm, roomId: String?,
+ sessionId: String,
+ userId: String,
+ deviceId: String,
+ deviceIdentityKey: String,
+ chainIndex: Int): SharedSessionEntity {
return realm.createObject().apply {
this.roomId = roomId
this.algorithm = MXCRYPTO_ALGORITHM_MEGOLM
this.sessionId = sessionId
this.userId = userId
this.deviceId = deviceId
+ this.deviceIdentityKey = deviceIdentityKey
this.chainIndex = chainIndex
}
}
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 3c6c594a70b..b8a3e361371 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 bdb8e8d137a..ca04bac5d5d 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 1d40e5defd3..e2fd54f0d87 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 08c767ba348..6cb14ded631 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 fde9f70e7b7..68f1cf62d52 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 1a41f890066..e203f03b06f 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 d9da88770cd..768109979d3 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 538d7b56e92..481ce85f70b 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 21a6ba41b14..f727aff39d3 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 ee58880eb83..7341d4656a4 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 758c7aa5b9d..115025cc7d8 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 d5ff7a0f849..7c622146d34 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 c602ed70759..50eb086f9ab 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 52fbabb49fe..8c62c345d0c 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 e262b404194..f74e4b0f4c6 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 90e867749ee..3993e8e7991 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 5d7afc50d63..d704ecac8e0 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 b26e7e88e35..00998af9bbd 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 4dc8712afbe..bcd30cb54bb 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 25a041e3d07..527f7823590 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 8982436ccc4..4ba45dcda2d 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 571bc71c273..4125d908912 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 65483e05bf6..2997d5d7d8a 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 e970fab3979..75771ff12c7 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 0463d52fffc..3b24ff5f9d1 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 f7d2823303b..156a8dd767c 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 9a3622e2dcf..716783f2bab 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 c3cae3d2685..14cb7e22da2 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 57e24cf88fe..240b2a06911 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 c76e6068054..3968169e083 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 9a1f2b3782f..020592d1dd3 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 fbfd8bd19e1..8131598d95b 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 b0b4f5a83d4..4f8ac20e944 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 359b2568443..1f6b210252a 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 35fb2b068bf..d80fe86aae1 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 5423025823d..60096777d9f 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 1a5e8fcf89f..b180c06e2c2 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 97f84184033..a35df57b7b3 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 8b3929cd60f..14beb2d853c 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 a551f973793..08bb9e7ff32 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 0747b126650..a19a9cf725c 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 2af5dcf0ae5..5294f849afb 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 53fd5250921..a7d85d676c7 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 148232cf94e..aa1ce41bb7c 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 4af4da0a22a..aa9d409a2ac 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 6a5528e3db3..3159f89311f 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 b58fb3e6830..4cd960f4264 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 0d0892b608d..fa59b94c175 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 ad2aff4c9d9..445b6be8e87 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 56d372faa57..17fd0925f88 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 b11fb6a5ee5..a34606a6bbd 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 c149ed2591b..e32f6be6fcb 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 e045cebd3ed..927d9f7dd2c 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 8a031025279..60055be9ec1 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 1a884041280..00e15c283e2 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
@@ -36,7 +36,7 @@ internal class UserAgentHolder @Inject constructor(private val context: Context,
/**
* Create an user agent with the application version.
- * Ex: Element/1.0.0 (Linux; U; Android 6.0.1; SM-A510F Build/MMB29; Flavour GPlay; MatrixAndroidSDK_X 1.0)
+ * Ex: Element/1.0.0 (Linux; U; Android 6.0.1; SM-A510F Build/MMB29; Flavour GPlay; MatrixAndroidSdk2 1.0)
*
* @param flavorDescription the flavor description
*/
@@ -73,14 +73,14 @@ 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
- + "; MatrixAndroidSDK_X " + BuildConfig.VERSION_NAME + ")")
+ userAgent = (appName + "/" + appVersion + " ( Flavour " + flavorDescription +
+ "; MatrixAndroidSdk2 " + BuildConfig.SDK_VERSION + ")")
} else {
// update
userAgent = appName + "/" + appVersion + " " +
systemUserAgent.substring(systemUserAgent.indexOf("("), systemUserAgent.lastIndexOf(")") - 1) +
"; Flavour " + flavorDescription +
- "; MatrixAndroidSDK_X " + BuildConfig.VERSION_NAME + ")"
+ "; MatrixAndroidSdk2 " + BuildConfig.SDK_VERSION + ")"
}
}
}
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 b4a2d191e23..3920c3b527b 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 14d275e021b..27684bbf1af 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 976751446b1..92c7f3f2369 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 b1001bd39c8..6f245aa6d8d 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 c2bd1e24ede..d41bf8a7021 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
@@ -40,7 +40,7 @@ import org.matrix.android.sdk.api.session.file.ContentDownloadStateTracker
import org.matrix.android.sdk.api.session.file.FileService
import org.matrix.android.sdk.api.session.group.GroupService
import org.matrix.android.sdk.api.session.homeserver.HomeServerCapabilitiesService
-import org.matrix.android.sdk.api.session.initsync.InitialSyncProgressService
+import org.matrix.android.sdk.api.session.initsync.SyncStatusService
import org.matrix.android.sdk.api.session.integrationmanager.IntegrationManagerService
import org.matrix.android.sdk.api.session.media.MediaService
import org.matrix.android.sdk.api.session.openid.OpenIdService
@@ -115,7 +115,7 @@ internal class DefaultSession @Inject constructor(
private val contentUploadProgressTracker: ContentUploadStateTracker,
private val typingUsersTracker: TypingUsersTracker,
private val contentDownloadStateTracker: ContentDownloadStateTracker,
- private val initialSyncProgressService: Lazy,
+ private val syncStatusService: Lazy,
private val homeServerCapabilitiesService: Lazy,
private val accountDataService: Lazy,
private val _sharedSecretStorageService: Lazy,
@@ -141,7 +141,7 @@ internal class DefaultSession @Inject constructor(
PushersService by pushersService.get(),
EventService by eventService.get(),
TermsService by termsService.get(),
- InitialSyncProgressService by initialSyncProgressService.get(),
+ SyncStatusService by syncStatusService.get(),
SecureStorageService by secureStorageService.get(),
HomeServerCapabilitiesService by homeServerCapabilitiesService.get(),
ProfileService by profileService.get(),
@@ -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 7a687b774bf..a650fa2d64c 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 9a936b73c23..71031a4614e 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
@@ -43,10 +43,9 @@ import org.matrix.android.sdk.internal.session.integrationmanager.IntegrationMan
import org.matrix.android.sdk.internal.session.media.MediaModule
import org.matrix.android.sdk.internal.session.openid.OpenIdModule
import org.matrix.android.sdk.internal.session.profile.ProfileModule
-import org.matrix.android.sdk.internal.session.pushers.AddHttpPusherWorker
+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)
@@ -127,7 +124,7 @@ internal interface SessionComponent {
fun inject(worker: SyncWorker)
- fun inject(worker: AddHttpPusherWorker)
+ fun inject(worker: AddPusherWorker)
fun inject(worker: SendVerificationMessageWorker)
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 82a8f79fd51..2a741ddb9b1 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/SessionModule.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/SessionModule.kt
index cb29cb4819c..dc59277f64e 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/SessionModule.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/SessionModule.kt
@@ -37,7 +37,7 @@ import org.matrix.android.sdk.api.session.SessionLifecycleObserver
import org.matrix.android.sdk.api.session.accountdata.SessionAccountDataService
import org.matrix.android.sdk.api.session.events.EventService
import org.matrix.android.sdk.api.session.homeserver.HomeServerCapabilitiesService
-import org.matrix.android.sdk.api.session.initsync.InitialSyncProgressService
+import org.matrix.android.sdk.api.session.initsync.SyncStatusService
import org.matrix.android.sdk.api.session.openid.OpenIdService
import org.matrix.android.sdk.api.session.permalinks.PermalinkService
import org.matrix.android.sdk.api.session.securestorage.SecureStorageService
@@ -81,7 +81,7 @@ import org.matrix.android.sdk.internal.session.download.DownloadProgressIntercep
import org.matrix.android.sdk.internal.session.events.DefaultEventService
import org.matrix.android.sdk.internal.session.homeserver.DefaultHomeServerCapabilitiesService
import org.matrix.android.sdk.internal.session.identity.DefaultIdentityService
-import org.matrix.android.sdk.internal.session.initsync.DefaultInitialSyncProgressService
+import org.matrix.android.sdk.internal.session.initsync.DefaultSyncStatusService
import org.matrix.android.sdk.internal.session.integrationmanager.IntegrationManager
import org.matrix.android.sdk.internal.session.openid.DefaultOpenIdService
import org.matrix.android.sdk.internal.session.permalinks.DefaultPermalinkService
@@ -355,7 +355,7 @@ internal abstract class SessionModule {
abstract fun bindEventSenderProcessorAsSessionLifecycleObserver(processor: EventSenderProcessorCoroutine): SessionLifecycleObserver
@Binds
- abstract fun bindInitialSyncProgressService(service: DefaultInitialSyncProgressService): InitialSyncProgressService
+ abstract fun bindSyncStatusService(service: DefaultSyncStatusService): SyncStatusService
@Binds
abstract fun bindSecureStorageService(service: DefaultSecureStorageService): SecureStorageService
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 02c37359988..7b21ba2e63b 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 83c7d2b0b56..60adb212422 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 894c3a47237..7f6b545c979 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 bdc254fc99c..3f199c5cce9 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 8870d92a357..d4374e0702f 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 e4efdaa254f..5c8cf99dc6c 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 6a4dd263920..bdebb0addf5 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 f14c85cf804..11c200c54b0 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 00000000000..76d956f9a5c
--- /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 095c39a4850..1d1bb0e7150 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 1be62304a19..37630ef8bad 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 d6089f9f5b6..7047d38260e 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 fbf22fde51f..2c56a30d394 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 425d6a9acaa..8dc5f3931d2 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 d6b9363d54a..338f43bdbb5 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 bb526adf4a8..70e1e551aa0 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 fdb6caf53fe..da37948cd4f 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
@@ -20,10 +20,16 @@ import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.LifecycleRegistry
import dagger.Lazy
+import kotlinx.coroutines.withContext
+import okhttp3.OkHttpClient
import org.matrix.android.sdk.api.auth.data.SessionParams
+import org.matrix.android.sdk.api.extensions.orFalse
import org.matrix.android.sdk.api.extensions.tryOrNull
import org.matrix.android.sdk.api.failure.Failure
import org.matrix.android.sdk.api.failure.MatrixError
+import org.matrix.android.sdk.api.session.Session
+import org.matrix.android.sdk.api.session.SessionLifecycleObserver
+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.homeserver.HomeServerCapabilitiesService
import org.matrix.android.sdk.api.session.identity.FoundThreePid
@@ -36,23 +42,17 @@ import org.matrix.android.sdk.internal.di.AuthenticatedIdentity
import org.matrix.android.sdk.internal.di.UnauthenticatedWithCertificate
import org.matrix.android.sdk.internal.extensions.observeNotNull
import org.matrix.android.sdk.internal.network.RetrofitFactory
-import org.matrix.android.sdk.api.session.SessionLifecycleObserver
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.model.SignInvitationResult
import org.matrix.android.sdk.internal.session.openid.GetOpenIdTokenTask
import org.matrix.android.sdk.internal.session.profile.BindThreePidsTask
import org.matrix.android.sdk.internal.session.profile.UnbindThreePidsTask
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.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.MatrixCoroutineDispatchers
import org.matrix.android.sdk.internal.util.ensureProtocol
-import kotlinx.coroutines.withContext
-import okhttp3.OkHttpClient
-import org.matrix.android.sdk.api.extensions.orFalse
-import org.matrix.android.sdk.api.session.Session
-import org.matrix.android.sdk.internal.session.identity.model.SignInvitationResult
import timber.log.Timber
import javax.inject.Inject
import javax.net.ssl.HttpsURLConnection
@@ -202,6 +202,8 @@ internal class DefaultIdentityService @Inject constructor(
identityStore.setUrl(urlCandidate)
identityStore.setToken(token)
+ // could we remember if it was previously given?
+ identityStore.setUserConsent(false)
updateIdentityAPI(urlCandidate)
updateAccountData(urlCandidate)
@@ -230,6 +232,8 @@ internal class DefaultIdentityService @Inject constructor(
}
override suspend fun lookUp(threePids: List): List {
+ if (getCurrentIdentityServerUrl() == null) throw IdentityServiceError.NoIdentityServerConfigured
+
if (!getUserConsent()) {
throw IdentityServiceError.UserConsentNotProvided
}
@@ -316,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 5e1434403e3..657d1f3ac74 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 114695062c8..f6ef370f8d3 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 4d664b76bed..19e602d7a71 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 be68e17a495..fcc91b0121c 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 aa2f4dd5b29..8d4afc7beb8 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 2fa3fc0cfb2..ce8b78b2d0e 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/DefaultInitialSyncProgressService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/initsync/DefaultSyncStatusService.kt
similarity index 78%
rename from matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/initsync/DefaultInitialSyncProgressService.kt
rename to matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/initsync/DefaultSyncStatusService.kt
index eb3e3066b12..079b0d0115e 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/initsync/DefaultInitialSyncProgressService.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/initsync/DefaultSyncStatusService.kt
@@ -18,23 +18,28 @@ package org.matrix.android.sdk.internal.session.initsync
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import org.matrix.android.sdk.api.session.initsync.InitSyncStep
-import org.matrix.android.sdk.api.session.initsync.InitialSyncProgressService
+import org.matrix.android.sdk.api.session.initsync.SyncStatusService
import org.matrix.android.sdk.internal.session.SessionScope
import javax.inject.Inject
@SessionScope
-internal class DefaultInitialSyncProgressService @Inject constructor()
- : InitialSyncProgressService,
+internal class DefaultSyncStatusService @Inject constructor() :
+ SyncStatusService,
ProgressReporter {
- private val status = MutableLiveData()
+ private val status = MutableLiveData()
private var rootTask: TaskInfo? = null
- override fun getInitialSyncProgressStatus(): LiveData {
+ override fun getSyncStatusLive(): LiveData {
return status
}
+ // Only to be used for incremental sync
+ fun setStatus(newStatus: SyncStatusService.Status.IncrementalSyncStatus) {
+ status.postValue(newStatus)
+ }
+
/**
* Create a rootTask
*/
@@ -67,7 +72,7 @@ internal class DefaultInitialSyncProgressService @Inject constructor()
// Update the progress of the leaf and all its parents
leaf.setProgress(progress)
// Then update the live data using leaf wording and root progress
- status.postValue(InitialSyncProgressService.Status.Progressing(leaf.initSyncStep, root.currentProgress.toInt()))
+ status.postValue(SyncStatusService.Status.Progressing(leaf.initSyncStep, root.currentProgress.toInt()))
}
}
}
@@ -82,13 +87,13 @@ internal class DefaultInitialSyncProgressService @Inject constructor()
// And close it
endedTask.parent.child = null
} else {
- status.postValue(InitialSyncProgressService.Status.Idle)
+ status.postValue(SyncStatusService.Status.Idle)
}
}
}
fun endAll() {
rootTask = null
- status.postValue(InitialSyncProgressService.Status.Idle)
+ status.postValue(SyncStatusService.Status.Idle)
}
}
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 b654b8610de..30b15891696 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 f7a8b68515f..8c63dbeb0d9 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 d1fb5b98ffa..85a126ef782 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 0ece07fc157..1321f8dd624 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 b90a2435f7d..afff0f35152 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 134da4ce51b..144ebb54042 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 639e45582a0..39c1ddfdce3 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 5f063365e00..6ff4efaf113 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/AddHttpPusherWorker.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/AddPusherWorker.kt
similarity index 95%
rename from matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/AddHttpPusherWorker.kt
rename to matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/AddPusherWorker.kt
index c9d7ad21938..63fd855c08a 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/AddHttpPusherWorker.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 AddHttpPusherWorker(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/DefaultPushersService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/DefaultPushersService.kt
index a772cf5ebb1..9a50abfe357 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/DefaultPushersService.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/DefaultPushersService.kt
@@ -66,27 +66,45 @@ internal class DefaultPushersService @Inject constructor(
deviceDisplayName: String,
url: String,
append: Boolean,
- withEventIdOnly: Boolean)
- : UUID {
- // Do some parameter checks. It's ok to throw Exception, to inform developer of the problem
- if (pushkey.length > 512) throw InvalidParameterException("pushkey should not exceed 512 chars")
- if (appId.length > 64) throw InvalidParameterException("appId should not exceed 64 chars")
- if ("/_matrix/push/v1/notify" !in url) throw InvalidParameterException("url should contain '/_matrix/push/v1/notify'")
+ withEventIdOnly: Boolean
+ ) = addPusher(
+ JsonPusher(
+ pushKey = pushkey,
+ kind = Pusher.KIND_HTTP,
+ appId = appId,
+ profileTag = profileTag,
+ lang = lang,
+ appDisplayName = appDisplayName,
+ deviceDisplayName = deviceDisplayName,
+ data = JsonPusherData(url, EVENT_ID_ONLY.takeIf { withEventIdOnly }),
+ append = append
+ )
+ )
- val pusher = JsonPusher(
- pushKey = pushkey,
- kind = "http",
- appId = appId,
- appDisplayName = appDisplayName,
- deviceDisplayName = deviceDisplayName,
- profileTag = profileTag,
- lang = lang,
- data = JsonPusherData(url, EVENT_ID_ONLY.takeIf { withEventIdOnly }),
- append = append)
+ override fun addEmailPusher(email: String,
+ lang: String,
+ emailBranding: String,
+ appDisplayName: String,
+ deviceDisplayName: String,
+ append: Boolean
+ ) = addPusher(
+ JsonPusher(
+ pushKey = email,
+ kind = Pusher.KIND_EMAIL,
+ appId = Pusher.APP_ID_EMAIL,
+ profileTag = "",
+ lang = lang,
+ appDisplayName = appDisplayName,
+ deviceDisplayName = deviceDisplayName,
+ data = JsonPusherData(brand = emailBranding),
+ append = append
+ )
+ )
- val params = AddHttpPusherWorker.Params(sessionId, pusher)
-
- val request = workManagerProvider.matrixOneTimeWorkRequestBuilder()
+ private fun addPusher(pusher: JsonPusher): UUID {
+ pusher.validateParameters()
+ val params = AddPusherWorker.Params(sessionId, pusher)
+ val request = workManagerProvider.matrixOneTimeWorkRequestBuilder()
.setConstraints(WorkManagerProvider.workConstraints)
.setInputData(WorkerParamsFactory.toData(params))
.setBackoffCriteria(BackoffPolicy.LINEAR, WorkManagerProvider.BACKOFF_DELAY_MILLIS, TimeUnit.MILLISECONDS)
@@ -95,8 +113,27 @@ internal class DefaultPushersService @Inject constructor(
return request.id
}
+ private fun JsonPusher.validateParameters() {
+ // Do some parameter checks. It's ok to throw Exception, to inform developer of the problem
+ if (pushKey.length > 512) throw InvalidParameterException("pushkey should not exceed 512 chars")
+ if (appId.length > 64) throw InvalidParameterException("appId should not exceed 64 chars")
+ data?.url?.let { url -> if ("/_matrix/push/v1/notify" !in url) throw InvalidParameterException("url should contain '/_matrix/push/v1/notify'") }
+ }
+
+ override suspend fun removePusher(pusher: Pusher) {
+ removePusher(pusher.pushKey, pusher.appId)
+ }
+
override suspend fun removeHttpPusher(pushkey: String, appId: String) {
- val params = RemovePusherTask.Params(pushkey, appId)
+ removePusher(pushkey, appId)
+ }
+
+ override suspend fun removeEmailPusher(email: String) {
+ removePusher(pushKey = email, Pusher.APP_ID_EMAIL)
+ }
+
+ private suspend fun removePusher(pushKey: String, pushAppId: String) {
+ val params = RemovePusherTask.Params(pushKey, pushAppId)
removePusherTask.execute(params)
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/JsonPusherData.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/JsonPusherData.kt
index c8d4d77fb1a..42a8fa6ff39 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/JsonPusherData.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/JsonPusherData.kt
@@ -32,5 +32,8 @@ internal data class JsonPusherData(
* Currently the only format available is 'event_id_only'.
*/
@Json(name = "format")
- val format: String? = null
+ val format: String? = null,
+
+ @Json(name = "brand")
+ val brand: String? = null
)
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 3a2ebf40c2f..057c3090785 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 f69949cbb6c..5b2499c1300 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 c7e09e59545..5a1eb190a8d 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/GetRoomSummaryTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/GetRoomSummaryTask.kt
new file mode 100644
index 00000000000..d9547d9e3a7
--- /dev/null
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/GetRoomSummaryTask.kt
@@ -0,0 +1,42 @@
+/*
+ * 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.room
+
+import org.matrix.android.sdk.api.session.room.model.RoomStrippedState
+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 javax.inject.Inject
+
+internal interface GetRoomSummaryTask : Task {
+ data class Params(
+ val roomId: String,
+ val viaServers: List?
+ )
+}
+
+internal class DefaultGetRoomSummaryTask @Inject constructor(
+ private val roomAPI: RoomAPI,
+ private val globalErrorReceiver: GlobalErrorReceiver
+) : GetRoomSummaryTask {
+
+ override suspend fun execute(params: GetRoomSummaryTask.Params): RoomStrippedState {
+ return executeRequest(globalErrorReceiver) {
+ roomAPI.getRoomSummary(params.roomId, params.viaServers)
+ }
+ }
+}
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 535fa9df716..efc5166a0cf 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
@@ -19,6 +19,7 @@ package org.matrix.android.sdk.internal.session.room
import org.matrix.android.sdk.api.session.events.model.Content
import org.matrix.android.sdk.api.session.events.model.Event
import org.matrix.android.sdk.api.session.room.model.Membership
+import org.matrix.android.sdk.api.session.room.model.RoomStrippedState
import org.matrix.android.sdk.api.session.room.model.roomdirectory.PublicRoomsParams
import org.matrix.android.sdk.api.session.room.model.roomdirectory.PublicRoomsResponse
import org.matrix.android.sdk.api.util.JsonDict
@@ -215,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
*
@@ -254,7 +239,7 @@ internal interface RoomAPI {
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "join/{roomIdOrAlias}")
suspend fun join(@Path("roomIdOrAlias") roomIdOrAlias: String,
@Query("server_name") viaServers: List,
- @Body params: JsonDict): JoinRoomResponse
+ @Body params: JsonDict): JoinRoomResponse
/**
* Leave the given room.
@@ -381,4 +366,14 @@ internal interface RoomAPI {
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/upgrade")
suspend fun upgradeRoom(@Path("roomId") roomId: String,
@Body body: RoomUpgradeBody): RoomUpgradeResponse
+
+ /**
+ * The API returns the summary of the specified room, if the room could be found and the client should be able to view
+ * its contents according to the join_rules, history visibility, space membership and similar rules outlined in MSC3173
+ * as well as if the user is already a member of that room.
+ * https://github.com/deepbluev7/matrix-doc/blob/room-summaries/proposals/3266-room-summary.md
+ */
+ @GET(NetworkConstants.URI_API_PREFIX_PATH_UNSTABLE + "im.nheko.summary/rooms/{roomIdOrAlias}/summary")
+ suspend fun getRoomSummary(@Path("roomIdOrAlias") roomidOrAlias: String,
+ @Query("via") viaServers: List?): RoomStrippedState
}
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/RoomModule.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/RoomModule.kt
index 794970705cd..dbd0ae6f060 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/RoomModule.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/RoomModule.kt
@@ -253,4 +253,7 @@ internal abstract class RoomModule {
@Binds
abstract fun bindSign3pidInvitationTask(task: DefaultSign3pidInvitationTask): Sign3pidInvitationTask
+
+ @Binds
+ abstract fun bindGetRoomSummaryTask(task: DefaultGetRoomSummaryTask): GetRoomSummaryTask
}
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 8f58094a2af..73a3b285e94 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 9bde5054f6c..675034531d2 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 9bb3899f2fd..84261e6ebff 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 518f0a0a6df..ac6e0562b0a 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 cc66a0a2d2a..eb966b684c8 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 1d4ab6d516c..046f8ba8ba5 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 41e891f78e6..204deb72b4b 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 com.zhuinden.monarchy.Monarchy
import dagger.assisted.Assisted
-import dagger.assisted.AssistedInject
import dagger.assisted.AssistedFactory
-import com.zhuinden.monarchy.Monarchy
+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 3aa812d93db..5e77dd157ab 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 209a904fad8..82fea237dbd 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 5486d96e289..8f1aefb731e 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 com.zhuinden.monarchy.Monarchy
import dagger.assisted.Assisted
-import dagger.assisted.AssistedInject
import dagger.assisted.AssistedFactory
-import com.zhuinden.monarchy.Monarchy
+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 9cea1fe425f..feb8c27b09e 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 5d0879d706e..00000000000
--- 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 32d6c5aa7ee..d0ab430dad7 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 add17a9fa58..c961f718ef6 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 a64b9039474..177c98541c8 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)
@@ -185,7 +186,7 @@ internal class DefaultSendService @AssistedInject constructor(
name = messageContent.body,
queryUri = Uri.parse(messageContent.url),
type = ContentAttachmentData.Type.AUDIO,
- waveform = messageContent.audioWaveformInfo?.waveform
+ waveform = messageContent.audioWaveformInfo?.waveform?.filterNotNull()
)
localEchoRepository.updateSendState(localEcho.eventId, roomId, SendState.UNSENT)
internalSendMedia(listOf(localEcho.root), attachmentData, true)
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 c610326a940..8dd0c593872 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 e889f1a61ba..16a9eba3636 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 306f8654083..b4436bfcbf6 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 cd7911910dd..8b7fe4b9072 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 faf966edf4c..33cb0db243e 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 cd5bf575dba..050e321b9c7 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 89a3533946d..30014f4539f 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
@@ -23,6 +23,7 @@ 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.accountdata.RoomAccountDataTypes
import org.matrix.android.sdk.api.session.room.model.Membership
+import org.matrix.android.sdk.api.session.room.model.PowerLevelsContent
import org.matrix.android.sdk.api.session.room.model.RoomAliasesContent
import org.matrix.android.sdk.api.session.room.model.RoomCanonicalAliasContent
import org.matrix.android.sdk.api.session.room.model.RoomJoinRulesContent
@@ -31,7 +32,10 @@ import org.matrix.android.sdk.api.session.room.model.RoomTopicContent
import org.matrix.android.sdk.api.session.room.model.RoomType
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
@@ -61,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
@@ -103,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
@@ -130,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)
@@ -207,63 +209,102 @@ internal class RoomSummaryUpdater @Inject constructor(
}
.toMap()
- lookupMap.keys.forEach { lookedUp ->
- if (lookedUp.roomType == RoomType.SPACE) {
- // get childrens
+ // First handle child relations
+ lookupMap.keys.asSequence()
+ .filter { it.roomType == RoomType.SPACE }
+ .forEach { lookedUp ->
+ // get childrens
- lookedUp.children.clearWith { it.deleteFromRealm() }
+ lookedUp.children.clearWith { it.deleteFromRealm() }
- RoomChildRelationInfo(realm, lookedUp.roomId).getDirectChildrenDescriptions().forEach { child ->
+ RoomChildRelationInfo(realm, lookedUp.roomId).getDirectChildrenDescriptions().forEach { child ->
- lookedUp.children.add(
- realm.createObject().apply {
- this.childRoomId = child.roomId
- this.childSummaryEntity = RoomSummaryEntity.where(realm, child.roomId).findFirst()
- this.order = child.order
+ lookedUp.children.add(
+ realm.createObject().apply {
+ this.childRoomId = child.roomId
+ this.childSummaryEntity = RoomSummaryEntity.where(realm, child.roomId).findFirst()
+ this.order = child.order
// this.autoJoin = child.autoJoin
- this.viaServers.addAll(child.viaServers)
- }
- )
-
- RoomSummaryEntity.where(realm, child.roomId)
- .process(RoomSummaryEntityFields.MEMBERSHIP_STR, Membership.activeMemberships())
- .findFirst()
- ?.let { childSum ->
- lookupMap.entries.firstOrNull { it.key.roomId == lookedUp.roomId }?.let { entry ->
- if (entry.value.indexOfFirst { it.roomId == childSum.roomId } == -1) {
- // add looked up as a parent
- entry.value.add(childSum)
+ this.viaServers.addAll(child.viaServers)
+ }
+ )
+
+ RoomSummaryEntity.where(realm, child.roomId)
+ .process(RoomSummaryEntityFields.MEMBERSHIP_STR, Membership.activeMemberships())
+ .findFirst()
+ ?.let { childSum ->
+ lookupMap.entries.firstOrNull { it.key.roomId == lookedUp.roomId }?.let { entry ->
+ if (entry.value.indexOfFirst { it.roomId == childSum.roomId } == -1) {
+ // add looked up as a parent
+ entry.value.add(childSum)
+ }
}
}
+ }
+ }
+
+ // Now let's check parent relations
+
+ lookupMap.keys
+ .forEach { lookedUp ->
+ lookedUp.parents.clearWith { it.deleteFromRealm() }
+ // can we check parent relations here??
+ /**
+ * rooms can claim parents via the m.space.parent state event.
+ * canonical determines whether this is the main parent for the space.
+ *
+ * To avoid abuse where a room admin falsely claims that a room is part of a space that it should not be,
+ * clients could ignore such m.space.parent events unless either
+ * (a) there is a corresponding m.space.child event in the claimed parent, or
+ * (b) the sender of the m.space.child event has a sufficient power-level to send such an m.space.child event in the parent.
+ * (It is not necessarily required that that user currently be a member of the parent room -
+ * only the m.room.power_levels event is inspected.)
+ * [Checking the power-level rather than requiring an actual m.space.child event in the parent allows for "secret" rooms (see below).]
+ */
+ RoomChildRelationInfo(realm, lookedUp.roomId).getParentDescriptions()
+ .map { parentInfo ->
+ // Is it a valid parent relation?
+ // Check if it's a child of the parent?
+ val isValidRelation: Boolean
+ val parent = lookupMap.firstNotNullOfOrNull { if (it.key.roomId == parentInfo.roomId) it.value else null }
+ if (parent?.firstOrNull { it.roomId == lookedUp.roomId } != null) {
+ // there is a corresponding m.space.child event in the claimed parent
+ isValidRelation = true
+ } else {
+ // check if sender can post child relation in parent?
+ val senderId = parentInfo.stateEventSender
+ val parentRoomId = parentInfo.roomId
+ val powerLevelsHelper = CurrentStateEventEntity
+ .getOrNull(realm, parentRoomId, "", EventType.STATE_ROOM_POWER_LEVELS)
+ ?.root
+ ?.let { ContentMapper.map(it.content).toModel() }
+ ?.let { PowerLevelsHelper(it) }
+
+ isValidRelation = powerLevelsHelper?.isUserAllowedToSend(senderId, true, EventType.STATE_SPACE_CHILD) ?: false
+ }
+
+ if (isValidRelation) {
+ lookedUp.parents.add(
+ realm.createObject().apply {
+ this.parentRoomId = parentInfo.roomId
+ this.parentSummaryEntity = RoomSummaryEntity.where(realm, parentInfo.roomId).findFirst()
+ this.canonical = parentInfo.canonical
+ this.viaServers.addAll(parentInfo.viaServers)
+ }
+ )
+
+ RoomSummaryEntity.where(realm, parentInfo.roomId)
+ .process(RoomSummaryEntityFields.MEMBERSHIP_STR, Membership.activeMemberships())
+ .findFirst()
+ ?.let { parentSum ->
+ if (lookupMap[parentSum]?.indexOfFirst { it.roomId == lookedUp.roomId } == -1) {
+ // add lookedup as a parent
+ lookupMap[parentSum]?.add(lookedUp)
+ }
+ }
+ }
}
}
- } else {
- lookedUp.parents.clearWith { it.deleteFromRealm() }
- // can we check parent relations here??
- RoomChildRelationInfo(realm, lookedUp.roomId).getParentDescriptions()
- .map { parentInfo ->
-
- lookedUp.parents.add(
- realm.createObject().apply {
- this.parentRoomId = parentInfo.roomId
- this.parentSummaryEntity = RoomSummaryEntity.where(realm, parentInfo.roomId).findFirst()
- this.canonical = parentInfo.canonical
- this.viaServers.addAll(parentInfo.viaServers)
- }
- )
-
- RoomSummaryEntity.where(realm, parentInfo.roomId)
- .process(RoomSummaryEntityFields.MEMBERSHIP_STR, Membership.activeMemberships())
- .findFirst()
- ?.let { parentSum ->
- if (lookupMap[parentSum]?.indexOfFirst { it.roomId == lookedUp.roomId } == -1) {
- // add lookedup as a parent
- lookupMap[parentSum]?.add(lookedUp)
- }
- }
- }
- }
- }
// Simple algorithm to break cycles
// Need more work to decide how to break, probably need to be as consistent as possible
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 02acaa05704..131bd40f1ec 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 8cc5d943b7e..c0e428ec851 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 eb4900553b8..64b1a4ff1d5 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 a7cba2fe99c..dbcc37a918a 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 8022d989751..2b404775f0b 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 6d841644dc8..99cf36faec1 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 9c25eccb3a5..19f34746ab2 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/DefaultSpace.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/space/DefaultSpace.kt
index 8a6bbc18fd1..8589db27b15 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/space/DefaultSpace.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/space/DefaultSpace.kt
@@ -89,7 +89,6 @@ internal class DefaultSpace(
body = SpaceChildContent(
order = null,
via = null,
-// autoJoin = null,
suggested = null
).toContent()
)
diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/space/DefaultSpaceService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/space/DefaultSpaceService.kt
index 7be4cdcda95..ac20c790587 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/space/DefaultSpaceService.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/space/DefaultSpaceService.kt
@@ -33,6 +33,7 @@ import org.matrix.android.sdk.api.session.room.model.RoomSummary
import org.matrix.android.sdk.api.session.room.model.SpaceChildInfo
import org.matrix.android.sdk.api.session.room.model.create.CreateRoomPreset
import org.matrix.android.sdk.api.session.room.powerlevels.PowerLevelsHelper
+import org.matrix.android.sdk.api.session.room.powerlevels.Role
import org.matrix.android.sdk.api.session.space.CreateSpaceParams
import org.matrix.android.sdk.api.session.space.JoinSpaceResult
import org.matrix.android.sdk.api.session.space.Space
@@ -77,7 +78,7 @@ internal class DefaultSpaceService @Inject constructor(
if (isPublic) {
this.roomAliasName = roomAliasLocalPart
this.powerLevelContentOverride = (powerLevelContentOverride ?: PowerLevelsContent()).copy(
- invite = 0
+ invite = if (isPublic) Role.Default.value else Role.Moderator.value
)
this.preset = CreateRoomPreset.PRESET_PUBLIC_CHAT
this.historyVisibility = RoomHistoryVisibility.WORLD_READABLE
@@ -221,4 +222,23 @@ internal class DefaultSpaceService @Inject constructor(
).toContent()
)
}
+
+ override suspend fun removeSpaceParent(childRoomId: String, parentSpaceId: String) {
+ val room = roomGetter.getRoom(childRoomId)
+ ?: throw IllegalArgumentException("Unknown Room $childRoomId")
+
+ val existingEvent = room.getStateEvent(EventType.STATE_SPACE_PARENT, QueryStringValue.Equals(parentSpaceId))
+ if (existingEvent != null) {
+ // Should i check if it was sent by me?
+ // we don't check power level, it will throw if you cannot do that
+ room.sendStateEvent(
+ eventType = EventType.STATE_SPACE_PARENT,
+ stateKey = parentSpaceId,
+ body = SpaceParentContent(
+ via = null,
+ canonical = null
+ ).toContent()
+ )
+ }
+ }
}
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 5cbaaa45c40..c45d4420ae4 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 44d879f05d4..a2ffd8221ac 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 411a9c5c065..cec5689a828 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 02362bf050e..2b054e578f0 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 cf67bbd805d..bd20ada28b0 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 7d93e30191c..4bc866b36d4 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 e8934fdf215..3d0db212c25 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 c6ff71cfcfd..e8f74bbd487 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 830e666c950..52e5b6b58d8 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 add5d841d1b..8997435be4b 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 b7851031adc..1433d891434 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 2616803463a..73ec0aa7ef1 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 a4468a96c97..8c7401ab475 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 9bb2bfc9b17..cc4ccc2e464 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 c80fbe60c1b..621a08a414e 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
@@ -17,7 +17,11 @@
package org.matrix.android.sdk.internal.session.sync
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
@@ -26,9 +30,8 @@ import org.matrix.android.sdk.internal.network.executeRequest
import org.matrix.android.sdk.internal.network.toFailure
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.DefaultInitialSyncProgressService
+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
@@ -40,7 +43,9 @@ import java.io.File
import java.net.SocketTimeoutException
import javax.inject.Inject
-internal interface SyncTask : Task {
+private val loggerTag = LoggerTag("SyncTask", LoggerTag.SYNC)
+
+internal interface SyncTask : Task {
data class Params(
val timeout: Long,
@@ -53,7 +58,7 @@ internal class DefaultSyncTask @Inject constructor(
@UserId private val userId: String,
private val filterRepository: FilterRepository,
private val syncResponseHandler: SyncResponseHandler,
- private val initialSyncProgressService: DefaultInitialSyncProgressService,
+ private val defaultSyncStatusService: DefaultSyncStatusService,
private val syncTokenStore: SyncTokenStore,
private val getHomeServerCapabilitiesTask: GetHomeServerCapabilitiesTask,
private val userStore: UserStore,
@@ -68,14 +73,14 @@ 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) {
- Timber.v("Sync task started on Thread: ${Thread.currentThread().name}")
+ private suspend fun doSync(params: SyncTask.Params): SyncResponse {
+ Timber.tag(loggerTag.value).d("Sync task started on Thread: ${Thread.currentThread().name}")
val requestParams = HashMap()
var timeout = 0L
@@ -92,28 +97,29 @@ internal class DefaultSyncTask @Inject constructor(
if (isInitialSync) {
// We might want to get the user information in parallel too
userStore.createOrUpdate(userId)
- initialSyncProgressService.startRoot(InitSyncStep.ImportingAccount, 100)
+ defaultSyncStatusService.startRoot(InitSyncStep.ImportingAccount, 100)
}
// Maybe refresh the homeserver capabilities data we know
getHomeServerCapabilitiesTask.execute(GetHomeServerCapabilitiesTask.Params(forceRefresh = false))
val readTimeOut = (params.timeout + TIMEOUT_MARGIN).coerceAtLeast(TimeOutInterceptor.DEFAULT_LONG_TIMEOUT)
+ var syncResponseToReturn: SyncResponse? = null
if (isInitialSync) {
- Timber.d("INIT_SYNC with filter: ${requestParams["filter"]}")
+ Timber.tag(loggerTag.value).d("INIT_SYNC with filter: ${requestParams["filter"]}")
val initSyncStrategy = initialSyncStrategy
- logDuration("INIT_SYNC strategy: $initSyncStrategy") {
+ logDuration("INIT_SYNC strategy: $initSyncStrategy", loggerTag) {
if (initSyncStrategy is InitialSyncStrategy.Optimized) {
roomSyncEphemeralTemporaryStore.reset()
workingDir.mkdirs()
val file = downloadInitSyncResponse(requestParams)
- reportSubtask(initialSyncProgressService, InitSyncStep.ImportingAccount, 1, 0.7F) {
+ syncResponseToReturn = reportSubtask(defaultSyncStatusService, InitSyncStep.ImportingAccount, 1, 0.7F) {
handleSyncFile(file, initSyncStrategy)
}
// Delete all files
workingDir.deleteRecursively()
} else {
- val syncResponse = logDuration("INIT_SYNC Request") {
+ val syncResponse = logDuration("INIT_SYNC Request", loggerTag) {
executeRequest(globalErrorReceiver) {
syncAPI.sync(
params = requestParams,
@@ -121,44 +127,64 @@ internal class DefaultSyncTask @Inject constructor(
)
}
}
-
- logDuration("INIT_SYNC Database insertion") {
- syncResponseHandler.handleResponse(syncResponse, token, initialSyncProgressService)
+ logDuration("INIT_SYNC Database insertion", loggerTag) {
+ syncResponseHandler.handleResponse(syncResponse, token, defaultSyncStatusService)
}
+ syncResponseToReturn = syncResponse
}
}
- initialSyncProgressService.endAll()
+ defaultSyncStatusService.endAll()
} else {
- val syncResponse = executeRequest(globalErrorReceiver) {
- syncAPI.sync(
- params = requestParams,
- readTimeOut = readTimeOut
- )
+ Timber.tag(loggerTag.value).d("Start incremental sync request")
+ defaultSyncStatusService.setStatus(SyncStatusService.Status.IncrementalSyncIdle)
+ val syncResponse = try {
+ executeRequest(globalErrorReceiver) {
+ syncAPI.sync(
+ params = requestParams,
+ readTimeOut = readTimeOut
+ )
+ }
+ } catch (throwable: Throwable) {
+ Timber.tag(loggerTag.value).e(throwable, "Incremental sync request error")
+ defaultSyncStatusService.setStatus(SyncStatusService.Status.IncrementalSyncError)
+ throw throwable
}
+ val nbRooms = syncResponse.rooms?.invite.orEmpty().size + syncResponse.rooms?.join.orEmpty().size + syncResponse.rooms?.leave.orEmpty().size
+ val nbToDevice = syncResponse.toDevice?.events.orEmpty().size
+ Timber.tag(loggerTag.value).d("Incremental sync request parsing, $nbRooms room(s) $nbToDevice toDevice(s)")
+ defaultSyncStatusService.setStatus(SyncStatusService.Status.IncrementalSyncParsing(
+ rooms = nbRooms,
+ toDevice = nbToDevice
+ ))
syncResponseHandler.handleResponse(syncResponse, token, null)
+ syncResponseToReturn = syncResponse
+ Timber.tag(loggerTag.value).d("Incremental sync done")
+ defaultSyncStatusService.setStatus(SyncStatusService.Status.IncrementalSyncDone)
}
- Timber.v("Sync task finished on Thread: ${Thread.currentThread().name}")
+ 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 {
val workingFile = File(workingDir, "initSync.json")
val status = initialSyncStatusRepository.getStep()
if (workingFile.exists() && status >= InitialSyncStatus.STEP_DOWNLOADED) {
- Timber.d("INIT_SYNC file is already here")
- reportSubtask(initialSyncProgressService, InitSyncStep.Downloading, 1, 0.3f) {
+ Timber.tag(loggerTag.value).d("INIT_SYNC file is already here")
+ reportSubtask(defaultSyncStatusService, InitSyncStep.Downloading, 1, 0.3f) {
// Empty task
}
} else {
initialSyncStatusRepository.setStep(InitialSyncStatus.STEP_DOWNLOADING)
- val syncResponse = logDuration("INIT_SYNC Perform server request") {
- reportSubtask(initialSyncProgressService, InitSyncStep.ServerComputing, 1, 0.2f) {
+ val syncResponse = logDuration("INIT_SYNC Perform server request", loggerTag) {
+ reportSubtask(defaultSyncStatusService, InitSyncStep.ServerComputing, 1, 0.2f) {
getSyncResponse(requestParams, MAX_NUMBER_OF_RETRY_AFTER_TIMEOUT)
}
}
if (syncResponse.isSuccessful) {
- logDuration("INIT_SYNC Download and save to file") {
- reportSubtask(initialSyncProgressService, InitSyncStep.Downloading, 1, 0.1f) {
+ logDuration("INIT_SYNC Download and save to file", loggerTag) {
+ reportSubtask(defaultSyncStatusService, InitSyncStep.Downloading, 1, 0.1f) {
syncResponse.body()?.byteStream()?.use { inputStream ->
workingFile.outputStream().use { outputStream ->
inputStream.copyTo(outputStream)
@@ -168,7 +194,7 @@ internal class DefaultSyncTask @Inject constructor(
}
} else {
throw syncResponse.toFailure(globalErrorReceiver)
- .also { Timber.w("INIT_SYNC request failure: $this") }
+ .also { Timber.tag(loggerTag.value).w("INIT_SYNC request failure: $this") }
}
initialSyncStatusRepository.setStep(InitialSyncStatus.STEP_DOWNLOADED)
}
@@ -185,30 +211,31 @@ internal class DefaultSyncTask @Inject constructor(
).awaitResponse()
} catch (throwable: Throwable) {
if (throwable is SocketTimeoutException && retry > 0) {
- Timber.w("INIT_SYNC timeout retry left: $retry")
+ Timber.tag(loggerTag.value).w("INIT_SYNC timeout retry left: $retry")
} else {
- Timber.e(throwable, "INIT_SYNC timeout, no retry left, or other error")
+ Timber.tag(loggerTag.value).e(throwable, "INIT_SYNC timeout, no retry left, or other error")
throw throwable
}
}
}
}
- private suspend fun handleSyncFile(workingFile: File, initSyncStrategy: InitialSyncStrategy.Optimized) {
- logDuration("INIT_SYNC handleSyncFile()") {
- val syncResponse = logDuration("INIT_SYNC Read file and parse") {
+ 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)
}
initialSyncStatusRepository.setStep(InitialSyncStatus.STEP_PARSED)
// Log some stats
val nbOfJoinedRooms = syncResponse.rooms?.join?.size ?: 0
val nbOfJoinedRoomsInFile = syncResponse.rooms?.join?.values?.count { it.ephemeral is LazyRoomSyncEphemeral.Stored }
- Timber.d("INIT_SYNC $nbOfJoinedRooms rooms, $nbOfJoinedRoomsInFile ephemeral stored into files")
+ Timber.tag(loggerTag.value).d("INIT_SYNC $nbOfJoinedRooms rooms, $nbOfJoinedRoomsInFile ephemeral stored into files")
- logDuration("INIT_SYNC Database insertion") {
- syncResponseHandler.handleResponse(syncResponse, null, initialSyncProgressService)
+ logDuration("INIT_SYNC Database insertion", loggerTag) {
+ 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 cf061586b7a..35e561a1060 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 110e77813d1..a9926c70aa9 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 de8d009892f..e1150f2c474 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,24 +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
@@ -49,6 +53,8 @@ import kotlin.concurrent.schedule
private const val RETRY_WAIT_TIME_MS = 10_000L
private const val DEFAULT_LONG_POOL_TIMEOUT = 30_000L
+private val loggerTag = LoggerTag("SyncThread", LoggerTag.SYNC)
+
internal class SyncThread @Inject constructor(private val syncTask: SyncTask,
private val networkConnectivityChecker: NetworkConnectivityChecker,
private val backgroundDetectionObserver: BackgroundDetectionObserver,
@@ -72,6 +78,8 @@ internal class SyncThread @Inject constructor(private val syncTask: SyncTask,
}
}
+ private val _syncFlow = MutableSharedFlow()
+
init {
updateStateTo(SyncState.Idle)
}
@@ -83,7 +91,7 @@ internal class SyncThread @Inject constructor(private val syncTask: SyncTask,
fun restart() = synchronized(lock) {
if (!isStarted) {
- Timber.v("Resume sync...")
+ Timber.tag(loggerTag.value).d("Resume sync...")
isStarted = true
// Check again server availability and the token validity
canReachServer = true
@@ -94,7 +102,7 @@ internal class SyncThread @Inject constructor(private val syncTask: SyncTask,
fun pause() = synchronized(lock) {
if (isStarted) {
- Timber.v("Pause sync...")
+ Timber.tag(loggerTag.value).d("Pause sync...")
isStarted = false
retryNoNetworkTask?.cancel()
syncScope.coroutineContext.cancelChildren()
@@ -102,7 +110,7 @@ internal class SyncThread @Inject constructor(private val syncTask: SyncTask,
}
fun kill() = synchronized(lock) {
- Timber.v("Kill sync...")
+ Timber.tag(loggerTag.value).d("Kill sync...")
updateStateTo(SyncState.Killing)
retryNoNetworkTask?.cancel()
syncScope.coroutineContext.cancelChildren()
@@ -115,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) {
@@ -124,21 +134,21 @@ internal class SyncThread @Inject constructor(private val syncTask: SyncTask,
}
override fun run() {
- Timber.v("Start syncing...")
+ Timber.tag(loggerTag.value).d("Start syncing...")
isStarted = true
networkConnectivityChecker.register(this)
backgroundDetectionObserver.register(this)
registerActiveCallsObserver()
while (state != SyncState.Killing) {
- Timber.v("Entering loop, state: $state")
+ Timber.tag(loggerTag.value).d("Entering loop, state: $state")
if (!isStarted) {
- Timber.v("Sync is Paused. Waiting...")
+ Timber.tag(loggerTag.value).d("Sync is Paused. Waiting...")
updateStateTo(SyncState.Paused)
synchronized(lock) { lock.wait() }
- Timber.v("...unlocked")
+ Timber.tag(loggerTag.value).d("...unlocked")
} else if (!canReachServer) {
- Timber.v("No network. Waiting...")
+ Timber.tag(loggerTag.value).d("No network. Waiting...")
updateStateTo(SyncState.NoNetwork)
// We force retrying in RETRY_WAIT_TIME_MS maximum. Otherwise it will be unlocked by onConnectivityChanged() or restart()
retryNoNetworkTask = Timer(SyncState.NoNetwork.toString(), false).schedule(RETRY_WAIT_TIME_MS) {
@@ -148,19 +158,19 @@ internal class SyncThread @Inject constructor(private val syncTask: SyncTask,
}
}
synchronized(lock) { lock.wait() }
- Timber.v("...retry")
+ Timber.tag(loggerTag.value).d("...retry")
} else if (!isTokenValid) {
- Timber.v("Token is invalid. Waiting...")
+ Timber.tag(loggerTag.value).d("Token is invalid. Waiting...")
updateStateTo(SyncState.InvalidToken)
synchronized(lock) { lock.wait() }
- Timber.v("...unlocked")
+ Timber.tag(loggerTag.value).d("...unlocked")
} else {
if (state !is SyncState.Running) {
updateStateTo(SyncState.Running(afterPause = true))
}
// No timeout after a pause
val timeout = state.let { if (it is SyncState.Running && it.afterPause) 0 else DEFAULT_LONG_POOL_TIMEOUT }
- Timber.v("Execute sync request with timeout $timeout")
+ Timber.tag(loggerTag.value).d("Execute sync request with timeout $timeout")
val params = SyncTask.Params(timeout, SyncPresence.Online)
val sync = syncScope.launch {
doSync(params)
@@ -168,10 +178,10 @@ internal class SyncThread @Inject constructor(private val syncTask: SyncTask,
runBlocking {
sync.join()
}
- Timber.v("...Continue")
+ Timber.tag(loggerTag.value).d("...Continue")
}
}
- Timber.v("Sync killed")
+ Timber.tag(loggerTag.value).d("Sync killed")
updateStateTo(SyncState.Killed)
backgroundDetectionObserver.unregister(this)
networkConnectivityChecker.unregister(this)
@@ -192,26 +202,27 @@ 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
}
if (failure is Failure.NetworkConnection && failure.cause is SocketTimeoutException) {
// Timeout are not critical
- Timber.v("Timeout")
+ Timber.tag(loggerTag.value).d("Timeout")
} else if (failure is CancellationException) {
- Timber.v("Cancelled")
+ Timber.tag(loggerTag.value).d("Cancelled")
} else if (failure.isTokenError()) {
// No token or invalid token, stop the thread
- Timber.w(failure, "Token error")
+ Timber.tag(loggerTag.value).w(failure, "Token error")
isStarted = false
isTokenValid = false
} else {
- Timber.e(failure)
+ Timber.tag(loggerTag.value).e(failure)
if (failure !is Failure.NetworkConnection || failure.cause is JsonEncodingException) {
// Wait 10s before retrying
- Timber.v("Wait 10s")
+ Timber.tag(loggerTag.value).d("Wait 10s")
delay(RETRY_WAIT_TIME_MS)
}
}
@@ -225,7 +236,7 @@ internal class SyncThread @Inject constructor(private val syncTask: SyncTask,
}
private fun updateStateTo(newState: SyncState) {
- Timber.v("Update state from $state to $newState")
+ Timber.tag(loggerTag.value).d("Update state from $state to $newState")
if (newState == state) {
return
}
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 940ea219fb6..012470a0768 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 0b44887aedc..f00cce2d5e8 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 8bf9ad5b908..6ca008c5b18 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 2c7dc92dddc..d40fd8d076c 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 b7cd7a4a97a..d7b6f68add0 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 13829c400a1..fdd5524fc22 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 ff1750ce8e4..e5c338d5110 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 37030576439..c7b125b5d6d 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 d6c95d6b521..22af56a1696 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 1a588d2245b..88db381852f 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 ba7a2be2a50..07f7c7cb868 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 dfe4b6b8107..89e827aea00 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 f7664bf3c2c..5879b624467 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 e0f43a11c57..9f5f91d917a 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 7f79f44767e..48c8fcdb033 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 6f423b38a09..21fbb77667b 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 a469a9fe976..a5e74a8af0f 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 78a40d19775..17797cad52d 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 ca4b092e071..de6981ec030 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 a5d031e02ae..01066a6f7c6 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 4da16eff226..86848d10188 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 860cf66c781..f398ee25d8b 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 7b45bab3652..a34b91a70bb 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/LogUtil.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/util/LogUtil.kt
index 4656856bf78..6fd907d3972 100644
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/util/LogUtil.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/util/LogUtil.kt
@@ -17,6 +17,7 @@
package org.matrix.android.sdk.internal.util
import org.matrix.android.sdk.BuildConfig
+import org.matrix.android.sdk.api.logger.LoggerTag
import timber.log.Timber
internal fun Collection.logLimit(maxQuantity: Int = 5): String {
@@ -32,14 +33,15 @@ internal fun Collection.logLimit(maxQuantity: Int = 5): String {
}
internal suspend fun logDuration(message: String,
+ loggerTag: LoggerTag,
block: suspend () -> T): T {
- Timber.d("$message -- BEGIN")
+ Timber.tag(loggerTag.value).d("$message -- BEGIN")
val start = System.currentTimeMillis()
val result = logRamUsage(message) {
block()
}
val duration = System.currentTimeMillis() - start
- Timber.d("$message -- END duration: $duration ms")
+ Timber.tag(loggerTag.value).d("$message -- END duration: $duration ms")
return result
}
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 aa0b92aa458..8a6ec189863 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 d9f0064f38f..2d5e4b944a5 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 f11e87e1e72..82ff9a321fc 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 3506a76f758..856d3debcf3 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 f46e2ca35ba..47f6869479d 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 f6a7f525dbe..84f09eb1849 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 c413d9ccaeb..96655b849df 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 b734444990e..9bfdea54143 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 2f01a43a67a..a93883a3440 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 64ffe52acdd..4e4548b1972 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 0bcc7983c52..b50d0581b0c 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 b04834f9f4d..5a82052d1af 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 3572a1a5468..0abca8bee3d 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/multipicker/build.gradle b/multipicker/build.gradle
index b2a5148b4a9..437499df7bd 100644
--- a/multipicker/build.gradle
+++ b/multipicker/build.gradle
@@ -19,14 +19,11 @@ apply plugin: 'kotlin-android'
apply plugin: 'kotlin-parcelize'
android {
- compileSdkVersion 30
+ compileSdk versions.compileSdk
defaultConfig {
- minSdkVersion 19
- targetSdkVersion 30
- versionCode 1
- versionName "1.0"
-
+ minSdk versions.minSdk
+ targetSdk versions.targetSdk
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles 'consumer-rules.pro'
}
@@ -41,11 +38,11 @@ android {
}
dependencies {
- implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
- implementation 'androidx.appcompat:appcompat:1.3.1'
- implementation "androidx.fragment:fragment-ktx:1.3.6"
- implementation 'androidx.exifinterface:exifinterface:1.3.3'
+ implementation libs.jetbrains.kotlinStdlibJdk7
+ implementation libs.androidx.appCompat
+ implementation libs.androidx.fragmentKtx
+ implementation libs.androidx.exifinterface
// Log
- implementation 'com.jakewharton.timber:timber:5.0.1'
+ implementation libs.jakewharton.timber
}
diff --git a/newsfragment/3207.bugfix b/newsfragment/3207.bugfix
deleted file mode 100644
index 162485907b4..00000000000
--- a/newsfragment/3207.bugfix
+++ /dev/null
@@ -1 +0,0 @@
-Space Explore Rooms no feedback on failed to join
\ No newline at end of file
diff --git a/newsfragment/3520.misc b/newsfragment/3520.misc
deleted file mode 100644
index d015c3e03d8..00000000000
--- a/newsfragment/3520.misc
+++ /dev/null
@@ -1 +0,0 @@
-VoIP: Merge virtual room timeline in corresponding native room (call events only).
\ No newline at end of file
diff --git a/newsfragment/3531.feature b/newsfragment/3531.feature
deleted file mode 100644
index e8b63584e33..00000000000
--- a/newsfragment/3531.feature
+++ /dev/null
@@ -1 +0,0 @@
-Introduces AutoAcceptInvites which can be enabled at compile time.
\ No newline at end of file
diff --git a/tools/benchmark/benchmark.profile b/tools/benchmark/benchmark.profile
new file mode 100644
index 00000000000..ae27dc9f59c
--- /dev/null
+++ b/tools/benchmark/benchmark.profile
@@ -0,0 +1,39 @@
+#
+# Copyright 2021 New Vector Ltd
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+clean_assemble {
+ tasks = ["clean", ":vector:assembleGPlayDebug"]
+}
+
+clean_assemble_build_cache {
+ tasks = ["clean", ":vector:assembleGPlayDebug"]
+ gradle-args = ["--build-cache"]
+}
+
+clean_assemble_without_cache {
+ tasks = ["clean", ":vector:assembleGPlayDebug"]
+ gradle-args = ["--no-build-cache"]
+}
+
+incremental_assemble_sdk_abi {
+ tasks = [":vector:assembleGPlayDebug"]
+ apply-abi-change-to = "matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/Matrix.kt"
+}
+
+incremental_assemble_sdk_no_abi {
+ tasks = [":vector:assembleGPlayDebug"]
+ apply-non-abi-change-to = "matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/Matrix.kt"
+}
diff --git a/tools/benchmark/run_benchmark.sh b/tools/benchmark/run_benchmark.sh
new file mode 100755
index 00000000000..b6c81ee513a
--- /dev/null
+++ b/tools/benchmark/run_benchmark.sh
@@ -0,0 +1,33 @@
+#!/usr/bin/env bash
+
+#
+# Copyright 2021 New Vector Ltd
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+if ! command -v gradle-profiler &> /dev/null
+then
+ echo "gradle-profiler could not be found https://github.com/gradle/gradle-profiler"
+ exit
+fi
+
+gradle-profiler \
+ --benchmark \
+ --project-dir . \
+ --scenario-file tools/benchmark/benchmark.profile \
+ --output-dir benchmark-out/output \
+ --gradle-user-home benchmark-out/gradle-home \
+ --warmups 3 \
+ --iterations 3 \
+ $1
diff --git a/tools/check/forbidden_strings_in_code.txt b/tools/check/forbidden_strings_in_code.txt
index 391140b9f32..8f8625fe1cf 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()
@@ -162,7 +160,7 @@ Formatter\.formatShortFileSize===1
# android\.text\.TextUtils
### This is not a rule, but a warning: the number of "enum class" has changed. For Json classes, it is mandatory that they have `@JsonClass(generateAdapter = false)`. If the enum is not used as a Json class, change the value in file forbidden_strings_in_code.txt
-enum class===105
+enum class===106
### Do not import temporary legacy classes
import org.matrix.android.sdk.internal.legacy.riot===3
diff --git a/tools/release/pushPlayStoreMetaData.sh b/tools/release/pushPlayStoreMetaData.sh
index ad7288ac36b..fe7cf7eca65 100755
--- a/tools/release/pushPlayStoreMetaData.sh
+++ b/tools/release/pushPlayStoreMetaData.sh
@@ -29,7 +29,8 @@ mv ./fastlane/metadata/android/ga ./fastlane_tmp
mv ./fastlane/metadata/android/kab ./fastlane_tmp
mv ./fastlane/metadata/android/nb ./fastlane_tmp
-# Fastlane / PlayStore require longDescription and shortDescription file to be set, so copy the default one for
+# Fastlane / PlayStore require longDescription and shortDescription file to be set, so copy the default
+# one for languages where they are missing
echo "Copying default description when missing"
if [[ -f "./fastlane/metadata/android/ro/full_description.txt" ]]; then
echo "It appears that file ./fastlane/metadata/android/ro/full_description.txt now exists. This can be removed."
diff --git a/vector/build.gradle b/vector/build.gradle
index 9d3cc7ec3ce..f2cb2831bd1 100644
--- a/vector/build.gradle
+++ b/vector/build.gradle
@@ -13,8 +13,8 @@ kapt {
// Note: 2 digits max for each value
ext.versionMajor = 1
-ext.versionMinor = 2
-ext.versionPatch = 1
+ext.versionMinor = 3
+ext.versionPatch = 2
static def getGitTimestamp() {
def cmd = 'git show -s --format=%ct'
@@ -102,17 +102,20 @@ ext.abiVersionCodes = ["armeabi-v7a": 1, "arm64-v8a": 2, "x86": 3, "x86_64": 4].
def buildNumber = System.env.BUILDKITE_BUILD_NUMBER as Integer ?: 0
android {
- compileSdkVersion 30
+
+
// Due to a bug introduced in Android gradle plugin 3.6.0, we have to specify the ndk version to use
// Ref: https://issuetracker.google.com/issues/144111441
ndkVersion "21.3.6528147"
+ compileSdk versions.compileSdk
+
defaultConfig {
applicationId "im.vector.app"
// Set to API 21: see #405
- minSdkVersion 21
- targetSdkVersion 30
+ minSdk versions.minSdk
+ targetSdk versions.targetSdk
multiDexEnabled true
renderscriptTargetApi 24
@@ -289,8 +292,8 @@ android {
}
compileOptions {
- sourceCompatibility JavaVersion.VERSION_11
- targetCompatibility JavaVersion.VERSION_11
+ sourceCompatibility versions.sourceCompat
+ targetCompatibility versions.targetCompat
}
kotlinOptions {
@@ -311,27 +314,12 @@ android {
}
}
-dependencies {
+configurations {
+ // videocache includes a sl4j logger which causes mockk to attempt to call the static android Log
+ testImplementation.exclude group: 'org.slf4j', module: 'slf4j-android'
+}
- def epoxy_version = '4.6.2'
- def fragment_version = '1.3.6'
- def arrow_version = "0.8.2"
- def markwon_version = '4.1.2'
- def big_image_viewer_version = '1.8.1'
- def glide_version = '4.12.0'
- def moshi_version = '1.12.0'
- def daggerVersion = '2.38.1'
- def autofill_version = "1.1.0"
- def work_version = '2.5.0'
- def arch_version = '2.1.0'
- def lifecycle_version = '2.2.0'
- def rxbinding_version = '3.1.0'
- def jjwt_version = '0.11.2'
-
- // Tests
- def kluent_version = '1.68'
- def androidxTest_version = '1.4.0'
- def espresso_version = '3.4.0'
+dependencies {
implementation project(":matrix-sdk-android")
implementation project(":matrix-sdk-android-rx")
@@ -341,73 +329,77 @@ dependencies {
implementation project(":library:ui-styles")
implementation 'androidx.multidex:multidex:2.0.1'
- implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
- implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlin_coroutines_version"
- implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$kotlin_coroutines_version"
+ implementation libs.jetbrains.kotlinStdlibJdk7
+ implementation libs.jetbrains.coroutinesCore
+ implementation libs.jetbrains.coroutinesAndroid
- implementation "androidx.recyclerview:recyclerview:1.2.1"
- implementation 'androidx.appcompat:appcompat:1.3.1'
- implementation "androidx.fragment:fragment-ktx:$fragment_version"
- implementation 'androidx.constraintlayout:constraintlayout:2.1.0'
+ implementation libs.androidx.recyclerview
+ implementation libs.androidx.appCompat
+ implementation libs.androidx.fragmentKtx
+ implementation libs.androidx.constraintLayout
implementation "androidx.sharetarget:sharetarget:1.1.0"
- implementation 'androidx.core:core-ktx:1.6.0'
- implementation "androidx.media:media:1.4.1"
+ implementation libs.androidx.core
+ implementation "androidx.media:media:1.4.2"
implementation "androidx.transition:transition:1.4.1"
implementation "org.threeten:threetenbp:1.4.0:no-tzdb"
implementation "com.gabrielittner.threetenbp:lazythreetenbp:0.9.0"
- implementation "com.squareup.moshi:moshi-adapters:$moshi_version"
- implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"
- implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.3.1"
- kapt "com.squareup.moshi:moshi-kotlin-codegen:$moshi_version"
+ implementation libs.squareup.moshi
+ kapt libs.squareup.moshiKotlin
+ implementation libs.androidx.lifecycleExtensions
+ implementation libs.androidx.lifecycleLivedata
+
+ implementation libs.androidx.datastore
+ implementation libs.androidx.datastorepreferences
+
// Log
- implementation 'com.jakewharton.timber:timber:5.0.1'
+ implementation libs.jakewharton.timber
// Debug
implementation 'com.facebook.stetho:stetho:1.6.0'
// Phone number https://github.com/google/libphonenumber
- implementation 'com.googlecode.libphonenumber:libphonenumber:8.12.31'
+ implementation 'com.googlecode.libphonenumber:libphonenumber:8.12.33'
// rx
- implementation 'io.reactivex.rxjava2:rxkotlin:2.4.0'
- implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
+ implementation libs.rx.rxKotlin
+ implementation libs.rx.rxAndroid
implementation 'com.jakewharton.rxrelay2:rxrelay:2.1.1'
// RXBinding
- implementation "com.jakewharton.rxbinding3:rxbinding:$rxbinding_version"
- implementation "com.jakewharton.rxbinding3:rxbinding-appcompat:$rxbinding_version"
- implementation "com.jakewharton.rxbinding3:rxbinding-material:$rxbinding_version"
+ implementation libs.jakewharton.rxbinding
+ implementation libs.jakewharton.rxbindingAppcompat
+ implementation libs.jakewharton.rxbindingMaterial
- implementation("com.airbnb.android:epoxy:$epoxy_version")
- implementation "com.airbnb.android:epoxy-glide-preloading:$epoxy_version"
- kapt "com.airbnb.android:epoxy-processor:$epoxy_version"
- implementation "com.airbnb.android:epoxy-paging:$epoxy_version"
- implementation 'com.airbnb.android:mvrx:1.5.1'
+ implementation libs.airbnb.epoxy
+ implementation libs.airbnb.epoxyGlide
+ kapt libs.airbnb.epoxyProcessor
+ implementation libs.airbnb.epoxyPaging
+ implementation libs.airbnb.mvrx
// Work
- implementation "androidx.work:work-runtime-ktx:$work_version"
+ implementation libs.androidx.work
// Paging
- implementation "androidx.paging:paging-runtime-ktx:2.1.2"
+ implementation libs.androidx.pagingRuntimeKtx
// Functional Programming
- implementation "io.arrow-kt:arrow-core:$arrow_version"
+ implementation libs.arrow.core
// Pref
- implementation 'androidx.preference:preference-ktx:1.1.1'
+ implementation libs.androidx.preferenceKtx
// UI
implementation 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
- implementation 'com.google.android.material:material:1.4.0'
+ implementation libs.google.material
implementation 'me.gujun.android:span:1.7'
- implementation "io.noties.markwon:core:$markwon_version"
- implementation "io.noties.markwon:html:$markwon_version"
+ implementation libs.markwon.core
+ implementation libs.markwon.html
implementation 'com.googlecode.htmlcompressor:htmlcompressor:1.5.2'
implementation 'me.saket:better-link-movement-method:2.2.0'
implementation 'com.google.android:flexbox:2.0.1'
- implementation "androidx.autofill:autofill:$autofill_version"
+ implementation libs.androidx.autoFill
implementation 'jp.wasabeef:glide-transformations:4.3.0'
implementation 'com.github.vector-im:PFLockScreen-Android:1.0.0-beta12'
implementation 'com.github.hyuwah:DraggableView:1.0.0'
@@ -420,27 +412,27 @@ 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
+ // Alerter
implementation 'com.tapadoo.android:alerter:7.0.1'
implementation 'com.otaliastudios:autocomplete:1.1.0'
// Shake detection
- implementation 'com.squareup:seismic:1.0.2'
+ implementation 'com.squareup:seismic:1.0.3'
// Image Loading
- implementation "com.github.piasy:BigImageViewer:$big_image_viewer_version"
- implementation "com.github.piasy:GlideImageLoader:$big_image_viewer_version"
- implementation "com.github.piasy:ProgressPieIndicator:$big_image_viewer_version"
- implementation "com.github.piasy:GlideImageViewFactory:$big_image_viewer_version"
+ implementation libs.github.bigImageViewer
+ implementation libs.github.glideImageLoader
+ implementation libs.github.progressPieIndicator
+ implementation libs.github.glideImageViewFactory
// implementation 'com.github.MikeOrtiz:TouchImageView:3.0.2'
implementation 'com.github.chrisbanes:PhotoView:2.3.0'
- implementation "com.github.bumptech.glide:glide:$glide_version"
- kapt "com.github.bumptech.glide:compiler:$glide_version"
+ implementation libs.github.glide
+ kapt libs.github.glideCompiler
implementation 'com.danikula:videocache:2.7.1'
implementation 'com.github.yalantis:ucrop:2.2.7'
@@ -451,8 +443,8 @@ dependencies {
implementation 'nl.dionsegijn:konfetti:1.3.2'
implementation 'com.github.jetradarmobile:android-snowfall:1.2.1'
// DI
- implementation "com.google.dagger:dagger:$daggerVersion"
- kapt "com.google.dagger:dagger-compiler:$daggerVersion"
+ implementation libs.dagger.dagger
+ kapt libs.dagger.daggerCompiler
// gplay flavor only
gplayImplementation('com.google.firebase:firebase-messaging:22.0.0') {
@@ -486,42 +478,44 @@ dependencies {
implementation 'me.dm7.barcodescanner:zxing:1.9.13'
// Emoji Keyboard
- implementation 'com.vanniktech:emoji-material:0.7.0'
- implementation 'com.vanniktech:emoji-google:0.7.0'
+ implementation libs.vanniktech.emojiMaterial
+ implementation libs.vanniktech.emojiGoogle
implementation 'im.dlg:android-dialer:1.2.5'
// JWT
- api "io.jsonwebtoken:jjwt-api:$jjwt_version"
- runtimeOnly "io.jsonwebtoken:jjwt-impl:$jjwt_version"
- runtimeOnly("io.jsonwebtoken:jjwt-orgjson:$jjwt_version") {
+ api libs.jsonwebtoken.jjwtApi
+ runtimeOnly libs.jsonwebtoken.jjwtImpl
+ runtimeOnly(libs.jsonwebtoken.jjwtOrgjson) {
exclude group: 'org.json', module: 'json' //provided by Android natively
}
implementation 'commons-codec:commons-codec:1.15'
// TESTS
- testImplementation 'junit:junit:4.13.2'
- testImplementation "org.amshove.kluent:kluent-android:$kluent_version"
+ testImplementation libs.tests.junit
+ testImplementation libs.tests.kluent
+ testImplementation libs.mockk.mockk
// Plant Timber tree for test
- testImplementation 'net.lachlanmckee:timber-junit-rule:1.0.1'
+ testImplementation libs.tests.timberJunitRule
// Activate when you want to check for leaks, from time to time.
//debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.3'
- androidTestImplementation "androidx.test:core:$androidxTest_version"
- androidTestImplementation "androidx.test:runner:$androidxTest_version"
- androidTestImplementation "androidx.test:rules:$androidxTest_version"
- androidTestImplementation 'androidx.test.ext:junit:1.1.3'
- androidTestImplementation "androidx.test.espresso:espresso-core:$espresso_version"
- androidTestImplementation "androidx.test.espresso:espresso-contrib:$espresso_version"
- androidTestImplementation "androidx.test.espresso:espresso-intents:$espresso_version"
- androidTestImplementation "org.amshove.kluent:kluent-android:$kluent_version"
- androidTestImplementation "androidx.arch.core:core-testing:$arch_version"
+ androidTestImplementation libs.androidx.testCore
+ androidTestImplementation libs.androidx.testRunner
+ androidTestImplementation libs.androidx.testRules
+ androidTestImplementation libs.androidx.junit
+ androidTestImplementation libs.androidx.espressoCore
+ androidTestImplementation libs.androidx.espressoContrib
+ androidTestImplementation libs.androidx.espressoIntents
+ androidTestImplementation libs.tests.kluent
+ androidTestImplementation libs.androidx.coreTesting
// Plant Timber tree for test
- androidTestImplementation 'net.lachlanmckee:timber-junit-rule:1.0.1'
+ androidTestImplementation libs.tests.timberJunitRule
// "The one who serves a great Espresso"
- androidTestImplementation('com.adevinta.android:barista:4.1.0') {
+ androidTestImplementation('com.adevinta.android:barista:4.2.0') {
exclude group: 'org.jetbrains.kotlin'
}
+ androidTestUtil libs.androidx.orchestrator
}
diff --git a/vector/lint.xml b/vector/lint.xml
index a8eed30160f..dde29af62e1 100644
--- a/vector/lint.xml
+++ b/vector/lint.xml
@@ -21,12 +21,12 @@
+
-
@@ -47,6 +47,7 @@
+
diff --git a/vector/src/androidTest/java/im/vector/app/EspressoExt.kt b/vector/src/androidTest/java/im/vector/app/EspressoExt.kt
index d247d88caa3..823ce830158 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 571bcf474ce..982a421425a 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 bf60ad681f8..178b9fb9f63 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/features/reactions/data/EmojiDataSourceTest.kt b/vector/src/androidTest/java/im/vector/app/features/reactions/data/EmojiDataSourceTest.kt
index 79090c42dd0..a880b17e0c8 100644
--- a/vector/src/androidTest/java/im/vector/app/features/reactions/data/EmojiDataSourceTest.kt
+++ b/vector/src/androidTest/java/im/vector/app/features/reactions/data/EmojiDataSourceTest.kt
@@ -17,6 +17,10 @@
package im.vector.app.features.reactions.data
import im.vector.app.InstrumentedTest
+import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.SupervisorJob
+import kotlinx.coroutines.runBlocking
import org.junit.Assert.assertEquals
import org.junit.Assert.assertTrue
import org.junit.FixMethodOrder
@@ -30,64 +34,80 @@ import kotlin.system.measureTimeMillis
@FixMethodOrder(MethodSorters.JVM)
class EmojiDataSourceTest : InstrumentedTest {
+ private val coroutineScope = CoroutineScope(SupervisorJob() + Dispatchers.Main)
+
@Test
fun checkParsingTime() {
val time = measureTimeMillis {
- EmojiDataSource(context().resources)
+ createEmojiDataSource()
}
-
assertTrue("Too long to parse", time < 100)
}
@Test
fun checkNumberOfResult() {
- val emojiDataSource = EmojiDataSource(context().resources)
- assertTrue("Wrong number of emojis", emojiDataSource.rawData.emojis.size >= 500)
- assertTrue("Wrong number of categories", emojiDataSource.rawData.categories.size >= 8)
+ val emojiDataSource = createEmojiDataSource()
+ val rawData = runBlocking {
+ emojiDataSource.rawData.await()
+ }
+ assertTrue("Wrong number of emojis", rawData.emojis.size >= 500)
+ assertTrue("Wrong number of categories", rawData.categories.size >= 8)
}
@Test
fun searchTestEmptySearch() {
- val emojiDataSource = EmojiDataSource(context().resources)
-
- assertTrue("Empty search should return at least 500 results", emojiDataSource.filterWith("").size >= 500)
+ val emojiDataSource = createEmojiDataSource()
+ val result = runBlocking {
+ emojiDataSource.filterWith("")
+ }
+ assertTrue("Empty search should return at least 500 results", result.size >= 500)
}
@Test
fun searchTestNoResult() {
- val emojiDataSource = EmojiDataSource(context().resources)
-
- assertTrue("Should not have result", emojiDataSource.filterWith("noresult").isEmpty())
+ val emojiDataSource = createEmojiDataSource()
+ val result = runBlocking {
+ emojiDataSource.filterWith("noresult")
+ }
+ assertTrue("Should not have result", result.isEmpty())
}
@Test
fun searchTestOneResult() {
- val emojiDataSource = EmojiDataSource(context().resources)
-
- assertEquals("Should have 1 result", 1, emojiDataSource.filterWith("france").size)
+ val emojiDataSource = createEmojiDataSource()
+ val result = runBlocking {
+ emojiDataSource.filterWith("france")
+ }
+ assertEquals("Should have 1 result", 1, result.size)
}
@Test
fun searchTestManyResult() {
- val emojiDataSource = EmojiDataSource(context().resources)
-
- assertTrue("Should have many result", emojiDataSource.filterWith("fra").size > 1)
+ val emojiDataSource = createEmojiDataSource()
+ val result = runBlocking {
+ emojiDataSource.filterWith("fra")
+ }
+ assertTrue("Should have many result", result.size > 1)
}
@Test
fun testTada() {
- val emojiDataSource = EmojiDataSource(context().resources)
-
- val result = emojiDataSource.filterWith("tada")
-
+ val emojiDataSource = createEmojiDataSource()
+ val result = runBlocking {
+ emojiDataSource.filterWith("tada")
+ }
assertEquals("Should find tada emoji", 1, result.size)
assertEquals("Should find tada emoji", "🎉", result[0].emoji)
}
@Test
fun testQuickReactions() {
- val emojiDataSource = EmojiDataSource(context().resources)
-
- assertEquals("Should have 8 quick reactions", 8, emojiDataSource.getQuickReactions().size)
+ val emojiDataSource = createEmojiDataSource()
+ val result = runBlocking {
+ emojiDataSource.getQuickReactions()
+ }
+ assertEquals("Should have 8 quick reactions", 8, result.size)
}
+
+ private fun createEmojiDataSource() = EmojiDataSource(coroutineScope, context().resources)
}
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 bad5d29e06d..aef5d3fe495 100644
--- a/vector/src/androidTest/java/im/vector/app/ui/UiAllScreensSanityTest.kt
+++ b/vector/src/androidTest/java/im/vector/app/ui/UiAllScreensSanityTest.kt
@@ -225,6 +225,8 @@ class UiAllScreensSanityTest {
clickOn(R.string.message_add_reaction)
// Filter
// TODO clickMenu(R.id.search)
+ // Wait for emoji to load, it's async now
+ sleep(1_000)
clickListItem(R.id.emojiRecyclerView, 4)
// Test Edit mode
@@ -283,6 +285,7 @@ class UiAllScreensSanityTest {
clickListItem(R.id.matrixProfileRecyclerView, 9)
// File tab
clickOn(R.string.uploads_files_title)
+ sleep(1000)
pressBack()
assertDisplayed(R.id.roomProfileAvatarView)
@@ -334,6 +337,7 @@ class UiAllScreensSanityTest {
private fun navigateToRoomPeople() {
// Open first user
clickListItem(R.id.roomSettingsRecyclerView, 1)
+ sleep(1000)
assertDisplayed(R.id.memberProfilePowerLevelView)
// Verification
@@ -342,8 +346,9 @@ class UiAllScreensSanityTest {
// Role
clickListItem(R.id.matrixProfileRecyclerView, 3)
+ sleep(1000)
clickDialogNegativeButton()
-
+ sleep(1000)
clickBack()
}
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 4b5228d1991..303a3a14ba9 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 408aebb1867..a7b74f3b593 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 e46a07f7126..27a3f09ddc9 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 abdd696724d..3725fc828d4 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 92e713de814..1f822d60606 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 d429b293b2b..e13b648dec9 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 f400c17d468..966d79c59b2 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/gplay/java/im/vector/app/gplay/push/fcm/VectorFirebaseMessagingService.kt b/vector/src/gplay/java/im/vector/app/gplay/push/fcm/VectorFirebaseMessagingService.kt
index 4cefeadb623..ddedfb93e36 100755
--- a/vector/src/gplay/java/im/vector/app/gplay/push/fcm/VectorFirebaseMessagingService.kt
+++ b/vector/src/gplay/java/im/vector/app/gplay/push/fcm/VectorFirebaseMessagingService.kt
@@ -39,17 +39,22 @@ import im.vector.app.features.notifications.NotifiableMessageEvent
import im.vector.app.features.notifications.NotificationDrawerManager
import im.vector.app.features.notifications.NotificationUtils
import im.vector.app.features.notifications.SimpleNotifiableEvent
+import im.vector.app.features.settings.VectorDataStore
import im.vector.app.features.settings.VectorPreferences
import im.vector.app.push.fcm.FcmHelper
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.launch
+import kotlinx.coroutines.runBlocking
import org.matrix.android.sdk.api.extensions.tryOrNull
+import org.matrix.android.sdk.api.logger.LoggerTag
import org.matrix.android.sdk.api.pushrules.Action
import org.matrix.android.sdk.api.session.Session
import org.matrix.android.sdk.api.session.events.model.Event
import timber.log.Timber
+private val loggerTag = LoggerTag("Push", LoggerTag.SYNC)
+
/**
* Class extending FirebaseMessagingService.
*/
@@ -60,6 +65,7 @@ class VectorFirebaseMessagingService : FirebaseMessagingService() {
private lateinit var pusherManager: PushersManager
private lateinit var activeSessionHolder: ActiveSessionHolder
private lateinit var vectorPreferences: VectorPreferences
+ private lateinit var vectorDataStore: VectorDataStore
private lateinit var wifiDetector: WifiDetector
private val coroutineScope = CoroutineScope(SupervisorJob())
@@ -77,6 +83,7 @@ class VectorFirebaseMessagingService : FirebaseMessagingService() {
pusherManager = pusherManager()
activeSessionHolder = activeSessionHolder()
vectorPreferences = vectorPreferences()
+ vectorDataStore = vectorDataStore()
wifiDetector = wifiDetector()
}
}
@@ -88,9 +95,13 @@ class VectorFirebaseMessagingService : FirebaseMessagingService() {
*/
override fun onMessageReceived(message: RemoteMessage) {
if (BuildConfig.LOW_PRIVACY_LOG_ENABLE) {
- Timber.d("## onMessageReceived() %s", message.data.toString())
+ Timber.tag(loggerTag.value).d("## onMessageReceived() %s", message.data.toString())
+ }
+ Timber.tag(loggerTag.value).d("## onMessageReceived() from FCM with priority %s", message.priority)
+
+ runBlocking {
+ vectorDataStore.incrementPushCounter()
}
- Timber.d("## onMessageReceived() from FCM with priority %s", message.priority)
// Diagnostic Push
if (message.data["event_id"] == PushersManager.TEST_EVENT_ID) {
@@ -100,14 +111,14 @@ class VectorFirebaseMessagingService : FirebaseMessagingService() {
}
if (!vectorPreferences.areNotificationEnabledForDevice()) {
- Timber.i("Notification are disabled for this device")
+ Timber.tag(loggerTag.value).i("Notification are disabled for this device")
return
}
mUIHandler.post {
if (ProcessLifecycleOwner.get().lifecycle.currentState.isAtLeast(Lifecycle.State.STARTED)) {
// we are in foreground, let the sync do the things?
- Timber.d("PUSH received in a foreground state, ignore")
+ Timber.tag(loggerTag.value).d("PUSH received in a foreground state, ignore")
} else {
onMessageReceivedInternal(message.data)
}
@@ -121,7 +132,7 @@ class VectorFirebaseMessagingService : FirebaseMessagingService() {
* you retrieve the token.
*/
override fun onNewToken(refreshedToken: String) {
- Timber.i("onNewToken: FCM Token has been updated")
+ Timber.tag(loggerTag.value).i("onNewToken: FCM Token has been updated")
FcmHelper.storeFcmToken(this, refreshedToken)
if (vectorPreferences.areNotificationEnabledForDevice() && activeSessionHolder.hasActiveSession()) {
pusherManager.registerPusherWithFcmKey(refreshedToken)
@@ -138,7 +149,7 @@ class VectorFirebaseMessagingService : FirebaseMessagingService() {
* It is recommended that the app do a full sync with the app server after receiving this call.
*/
override fun onDeletedMessages() {
- Timber.v("## onDeletedMessages()")
+ Timber.tag(loggerTag.value).v("## onDeletedMessages()")
}
/**
@@ -150,9 +161,9 @@ class VectorFirebaseMessagingService : FirebaseMessagingService() {
private fun onMessageReceivedInternal(data: Map) {
try {
if (BuildConfig.LOW_PRIVACY_LOG_ENABLE) {
- Timber.d("## onMessageReceivedInternal() : $data")
+ Timber.tag(loggerTag.value).d("## onMessageReceivedInternal() : $data")
} else {
- Timber.d("## onMessageReceivedInternal() : $data")
+ Timber.tag(loggerTag.value).d("## onMessageReceivedInternal()")
}
// update the badge counter
@@ -162,24 +173,24 @@ class VectorFirebaseMessagingService : FirebaseMessagingService() {
val session = activeSessionHolder.getSafeActiveSession()
if (session == null) {
- Timber.w("## Can't sync from push, no current session")
+ Timber.tag(loggerTag.value).w("## Can't sync from push, no current session")
} else {
val eventId = data["event_id"]
val roomId = data["room_id"]
if (isEventAlreadyKnown(eventId, roomId)) {
- Timber.d("Ignoring push, event already known")
+ Timber.tag(loggerTag.value).d("Ignoring push, event already known")
} else {
// Try to get the Event content faster
- Timber.d("Requesting event in fast lane")
+ Timber.tag(loggerTag.value).d("Requesting event in fast lane")
getEventFastLane(session, roomId, eventId)
- Timber.d("Requesting background sync")
+ Timber.tag(loggerTag.value).d("Requesting background sync")
session.requireBackgroundSync()
}
}
} catch (e: Exception) {
- Timber.e(e, "## onMessageReceivedInternal() failed")
+ Timber.tag(loggerTag.value).e(e, "## onMessageReceivedInternal() failed")
}
}
@@ -193,18 +204,18 @@ class VectorFirebaseMessagingService : FirebaseMessagingService() {
}
if (wifiDetector.isConnectedToWifi().not()) {
- Timber.d("No WiFi network, do not get Event")
+ Timber.tag(loggerTag.value).d("No WiFi network, do not get Event")
return
}
coroutineScope.launch {
- Timber.d("Fast lane: start request")
+ Timber.tag(loggerTag.value).d("Fast lane: start request")
val event = tryOrNull { session.getEvent(roomId, eventId) } ?: return@launch
val resolvedEvent = notifiableEventResolver.resolveInMemoryEvent(session, event)
resolvedEvent
- ?.also { Timber.d("Fast lane: notify drawer") }
+ ?.also { Timber.tag(loggerTag.value).d("Fast lane: notify drawer") }
?.let {
it.isPushGatewayEvent = true
notificationDrawerManager.onNotifiableEventReceived(it)
@@ -222,7 +233,7 @@ class VectorFirebaseMessagingService : FirebaseMessagingService() {
val room = session.getRoom(roomId) ?: return false
return room.getTimeLineEvent(eventId) != null
} catch (e: Exception) {
- Timber.e(e, "## isEventAlreadyKnown() : failed to check if the event was already defined")
+ Timber.tag(loggerTag.value).e(e, "## isEventAlreadyKnown() : failed to check if the event was already defined")
}
}
return false
@@ -230,7 +241,7 @@ class VectorFirebaseMessagingService : FirebaseMessagingService() {
private fun handleNotificationWithoutSyncingMode(data: Map, session: Session?) {
if (session == null) {
- Timber.e("## handleNotificationWithoutSyncingMode cannot find session")
+ Timber.tag(loggerTag.value).e("## handleNotificationWithoutSyncingMode cannot find session")
return
}
@@ -263,9 +274,9 @@ class VectorFirebaseMessagingService : FirebaseMessagingService() {
val notifiableEvent = notifiableEventResolver.resolveEvent(event, session)
if (notifiableEvent == null) {
- Timber.e("Unsupported notifiable event $eventId")
+ Timber.tag(loggerTag.value).e("Unsupported notifiable event $eventId")
if (BuildConfig.LOW_PRIVACY_LOG_ENABLE) {
- Timber.e("--> $event")
+ Timber.tag(loggerTag.value).e("--> $event")
}
} else {
if (notifiableEvent is NotifiableMessageEvent) {
diff --git a/vector/src/main/AndroidManifest.xml b/vector/src/main/AndroidManifest.xml
index 5aec41e46f9..7492da37e8d 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" />
@@ -364,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.
-->
-
+
@@ -374,9 +398,15 @@
+ android:name="androidx.startup.InitializationProvider"
+ android:authorities="${applicationId}.androidx-startup"
+ android:exported="false"
+ tools:node="merge">
+
+
() {
@@ -54,7 +55,7 @@ abstract class RadioButtonItem : VectorEpoxyModel() {
}
if (selected) {
- holder.radioImage.setImageDrawable(ContextCompat.getDrawable(holder.view.context, R.drawable.ic_radio_on))
+ holder.radioImage.setAttributeTintedImageResource(R.drawable.ic_radio_on, R.attr.colorPrimary)
holder.radioImage.contentDescription = holder.view.context.getString(R.string.a11y_checked)
} else {
holder.radioImage.setImageDrawable(ContextCompat.getDrawable(holder.view.context, R.drawable.ic_radio_off))
diff --git a/vector/src/main/java/im/vector/app/core/error/ErrorFormatter.kt b/vector/src/main/java/im/vector/app/core/error/ErrorFormatter.kt
index f0ba79e31cc..6494f31336a 100644
--- a/vector/src/main/java/im/vector/app/core/error/ErrorFormatter.kt
+++ b/vector/src/main/java/im/vector/app/core/error/ErrorFormatter.kt
@@ -58,49 +58,49 @@ class DefaultErrorFormatter @Inject constructor(
}
is Failure.ServerError -> {
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 07a684abefa..ee3d79d8461 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 05b70def3d5..0eb9dcdaf94 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 699247ab6d8..215c4212919 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 1c424f7071c..adb655f169e 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
@@ -39,13 +39,15 @@ 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) {
- if (newText == null
- || (newText.isBlank() && hideWhenBlank)) {
+fun TextView.setTextOrHide(newText: CharSequence?, hideWhenBlank: Boolean = true, vararg relatedViews: View = emptyArray()) {
+ if (newText == null ||
+ (newText.isBlank() && hideWhenBlank)) {
isVisible = false
+ relatedViews.forEach { it.isVisible = false }
} else {
this.text = newText
isVisible = true
+ relatedViews.forEach { it.isVisible = true }
}
}
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 48e3a488edd..43ff186e994 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/extensions/ViewExtensions.kt b/vector/src/main/java/im/vector/app/core/extensions/ViewExtensions.kt
index 92dc76670fb..54fcac42d19 100644
--- a/vector/src/main/java/im/vector/app/core/extensions/ViewExtensions.kt
+++ b/vector/src/main/java/im/vector/app/core/extensions/ViewExtensions.kt
@@ -16,12 +16,20 @@
package im.vector.app.core.extensions
+import android.graphics.drawable.Drawable
import android.text.InputType
import android.view.View
import android.view.ViewGroup
import android.widget.EditText
+import android.widget.ImageView
+import androidx.annotation.AttrRes
+import androidx.annotation.DrawableRes
import androidx.appcompat.widget.SearchView
+import androidx.core.content.ContextCompat
+import androidx.core.graphics.drawable.DrawableCompat
+import androidx.core.view.isVisible
import im.vector.app.R
+import im.vector.app.features.themes.ThemeUtils
/**
* Remove left margin of a SearchView
@@ -50,3 +58,25 @@ fun View.getMeasurements(): Pair {
val height = measuredHeight
return width to height
}
+
+fun ImageView.setDrawableOrHide(drawableRes: Drawable?) {
+ setImageDrawable(drawableRes)
+ isVisible = drawableRes != null
+}
+
+fun View.setAttributeTintedBackground(@DrawableRes drawableRes: Int, @AttrRes tint: Int) {
+ val drawable = ContextCompat.getDrawable(context, drawableRes)!!
+ DrawableCompat.setTint(drawable, ThemeUtils.getColor(context, tint))
+ background = drawable
+}
+
+fun ImageView.setAttributeTintedImageResource(@DrawableRes drawableRes: Int, @AttrRes tint: Int) {
+ val drawable = ContextCompat.getDrawable(context, drawableRes)!!
+ DrawableCompat.setTint(drawable, ThemeUtils.getColor(context, tint))
+ setImageDrawable(drawable)
+}
+
+fun View.setAttributeBackground(@AttrRes attributeId: Int) {
+ val attribute = ThemeUtils.getAttribute(context, attributeId)!!
+ setBackgroundResource(attribute.resourceId)
+}
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 32968c4f80b..9675e30042c 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 74c9d4f0f68..59bffd95fdf 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 5fae815dfbe..7dfee7d981f 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 ee2933f5426..e7e91dbfd92 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/LifecycleAwareLazy.kt b/vector/src/main/java/im/vector/app/core/platform/LifecycleAwareLazy.kt
new file mode 100644
index 00000000000..283106232ef
--- /dev/null
+++ b/vector/src/main/java/im/vector/app/core/platform/LifecycleAwareLazy.kt
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2021 New Vector Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package im.vector.app.core.platform
+
+import androidx.annotation.MainThread
+import androidx.fragment.app.Fragment
+import androidx.lifecycle.Lifecycle
+import androidx.lifecycle.LifecycleObserver
+import androidx.lifecycle.LifecycleOwner
+import androidx.lifecycle.OnLifecycleEvent
+
+fun LifecycleOwner.lifecycleAwareLazy(initializer: () -> T): Lazy = LifecycleAwareLazy(this, initializer)
+
+private object UninitializedValue
+
+class LifecycleAwareLazy(
+ private val owner: LifecycleOwner,
+ initializer: () -> T
+) : Lazy