Merge branch 'develop' into feature/aris/threads

# Conflicts:
#	matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/timeline/TokenChunkEventPersistor.kt
#	tools/check/forbidden_strings_in_code.txt
This commit is contained in:
ariskotsomitopoulos 2022-01-11 14:09:49 +02:00
commit 3bd21d04d8
136 changed files with 1764 additions and 181 deletions

View file

@ -32,13 +32,13 @@ jobs:
*/build/reports/ktlint/ktlint*/ktlint*.txt
- name: Handle Results
if: always()
id: get-comment-body
id: ktlint-results
run: |
results="$(cat */*/build/reports/ktlint/ktlint*/ktlint*.txt */build/reports/ktlint/ktlint*/ktlint*.txt | sed -r "s/\x1B\[([0-9]{1,3}(;[0-9]{1,2})?)?[mGK]//g")"
if [ -z "$results" ]; then
body="👍 ✅ 👍"
echo "::set-output name=add_comment::false"
else
body="👎 ❌ 👎 \`Failed${results}\`"
body="👎\`Failed${results}\`"
body="${body//'%'/'%25'}"
body="${body//$'\n'/'%0A'}"
body="${body//$'\r'/'%0D'}"
@ -50,8 +50,9 @@ jobs:
body="$( echo $body | sed 's/im\/vector\/lib\///g')"
body="$( echo $body | sed 's/org\/matrix\/android\/sdk\///g')"
body="$( echo $body | sed 's/\/src\/androidTest\/java\// 🔸 /g')"
echo "::set-output name=add_comment::true"
echo "::set-output name=body::$body"
fi
echo "::set-output name=body::$body"
- name: Find Comment
if: always()
uses: peter-evans/find-comment@v1
@ -60,8 +61,8 @@ jobs:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: Ktlint Results
- name: Publish ktlint results to PR
if: always()
- name: Add comment if needed
if: always() && steps.ktlint-results.outputs.add_comment == 'true'
uses: peter-evans/create-or-update-comment@v1
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
@ -69,8 +70,18 @@ jobs:
body: |
### Ktlint Results
${{ steps.get-comment-body.outputs.body }}
${{ steps.ktlint-results.outputs.body }}
edit-mode: replace
- name: Delete comment if needed
if: always() && steps.fc.outputs.comment-id != '' && steps.ktlint-results.outputs.add_comment == 'false'
uses: actions/github-script@v5.1.0
with:
script: |
github.issues.deleteComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: ${{ steps.fc.outputs.comment-id }}
})
# Lint for main module
android-lint:

View file

@ -36,6 +36,7 @@
<w>ssss</w>
<w>sygnal</w>
<w>threepid</w>
<w>uisi</w>
<w>unpublish</w>
<w>unwedging</w>
<w>vctr</w>

View file

@ -36,14 +36,6 @@ allprojects {
apply plugin: "org.jlleitschuh.gradle.ktlint"
repositories {
// For olm library.
maven {
url 'https://gitlab.matrix.org/api/v4/projects/27/packages/maven'
content {
groups.olm.regex.each { includeGroupByRegex it }
groups.olm.group.each { includeGroup it }
}
}
maven {
url 'https://jitpack.io'
content {

1
changelog.d/4735.bugfix Normal file
View file

@ -0,0 +1 @@
Polls: unable to create a poll with more than 10 answers

1
changelog.d/4882.misc Normal file
View file

@ -0,0 +1 @@
Olm lib is now hosted in MavenCentral - upgrade to 3.2.10

1
changelog.d/4888.misc Normal file
View file

@ -0,0 +1 @@
Add ktlint results on github as a comment only on fail

1
changelog.d/4889.removal Normal file
View file

@ -0,0 +1 @@
Remove deprecated experimental restricted space lab option

1
changelog.d/4892.feature Normal file
View file

@ -0,0 +1 @@
Display Analytics opt-in screen at first start-up of the app

View file

@ -14,13 +14,6 @@ ext.groups = [
'com.github.Zhuinden',
]
],
olm : [
regex: [
],
group: [
'org.matrix.android',
]
],
jitsi : [
regex: [
],
@ -166,6 +159,7 @@ ext.groups = [
'org.junit.jupiter',
'org.junit.platform',
'org.jvnet.staxex',
'org.matrix.android',
'org.mockito',
'org.mongodb',
'org.objenesis',

View file

@ -1,2 +1,2 @@
Hlavní změny v této verzi: implementace hlasových zpráv dosupných v rámci laboratoře.
Hlavní změny v této verzi: implementace hlasových zpráv dosupných v experimentálních funkcích.
Úplný seznam změn: https://github.com/vector-im/element-android/releases/tag/v1.1.15

View file

@ -0,0 +1,2 @@
Hlavní změny v této verzi: Přidání podpory pro hlasování (v experimentálních funkcích). Nový design náhledu URL.
Úplný seznam změn: https://github.com/vector-im/element-android/releases/tag/v1.3.10

View file

@ -0,0 +1,2 @@
Hlavní změny v této verzi: Opravy chyb!
Úplný seznam změn: https://github.com/vector-im/element-android/releases/tag/v1.3.11

View file

@ -0,0 +1,2 @@
Hlavní změny v této verzi: Opravy chyb!
Úplný seznam změn: https://github.com/vector-im/element-android/releases/tag/v1.3.12

View file

@ -0,0 +1,2 @@
Põhilised muutused selles versioonis: katseline küsitluste tugi ja linkide eelvaate uus visuaal.
Kogu ingliskeelne muudatuste logi: https://github.com/vector-im/element-android/releases/tag/v1.3.10

View file

@ -0,0 +1,2 @@
Põhilised muutused selles versioonis: pinu veaparandusi!
Kogu ingliskeelne muudatuste logi: https://github.com/vector-im/element-android/releases/tag/v1.3.11

View file

@ -0,0 +1,2 @@
Põhilised muutused selles versioonis: pinu veaparandusi!
Kogu ingliskeelne muudatuste logi: https://github.com/vector-im/element-android/releases/tag/v1.3.12

View file

@ -0,0 +1,2 @@
تغییرات عمده در این نگارش: افزودن پشتیبانی نظرسنجی‌ها (در آزمایشگاه‌ها). طرّاحی جدید پیش‌نمای نشانی.
گزارش دگرگونی کامل: https://github.com/vector-im/element-android/releases/tag/v1.3.10

View file

@ -0,0 +1,2 @@
تغییرات عمده در این نگارش: تعمیر مشکلات!
گزارش دگرگونی کامل: https://github.com/vector-im/element-android/releases/tag/v1.3.11

View file

@ -0,0 +1,2 @@
تغییرات عمده در این نگارش: تعمیر مشکلات!
گزارش دگرگونی کامل: https://github.com/vector-im/element-android/releases/tag/v1.3.12

View file

@ -0,0 +1,2 @@
Fő változás ebben a verzióban: Szavazások támogatása (a laborok között). Új URL előnézet.
Teljes változásnapló: https://github.com/vector-im/element-android/releases/tag/v1.3.10

View file

@ -0,0 +1,2 @@
Fő változás ebben a verzióban: Hibajavítások!
Teljes változásnapló: https://github.com/vector-im/element-android/releases/tag/v1.3.11

View file

@ -0,0 +1,2 @@
Fő változás ebben a verzióban: Hibajavítások!
Teljes változásnapló: https://github.com/vector-im/element-android/releases/tag/v1.3.12

View file

@ -0,0 +1,2 @@
Perubahan utama dalam versi ini: Dukungan untuk fitur poll (dalam Uji Coba), dan desain tampilan URL baru.
Changelog lanjutan: https://github.com/vector-im/element-android/releases/tag/v1.3.10

View file

@ -0,0 +1,2 @@
Perubahan utama dalam versi ini: Perbaikan bug!
Changelog lanjutan: https://github.com/vector-im/element-android/releases/tag/v1.3.11

View file

@ -0,0 +1,2 @@
Perubahan utama dalam versi ini: Perbaikan bug!
Changelog lanjutan: https://github.com/vector-im/element-android/releases/tag/v1.3.12

View file

@ -0,0 +1,2 @@
Modifiche principali in questa versione: aggiunto supporto per i sondaggi (in labs). Nuovo design anteprime URL.
Cronologia completa: https://github.com/vector-im/element-android/releases/tag/v1.3.10

View file

@ -0,0 +1,2 @@
Modifiche principali in questa versione: correzioni di errori!
Cronologia completa: https://github.com/vector-im/element-android/releases/tag/v1.3.11

View file

@ -0,0 +1,2 @@
Modifiche principali in questa versione: correzioni di errori!
Cronologia completa: https://github.com/vector-im/element-android/releases/tag/v1.3.12

View file

@ -0,0 +1,2 @@
Belangrijkste wijzigingen in deze versie: Bugfixes voornamelijk met betrekking tot de meldingen.
Volledige changelog: https://github.com/vector-im/element-android/releases/tag/v1.3.7-RC2

View file

@ -0,0 +1,2 @@
Belangrijkste wijzigingen in deze versie: Bugfixes!
Volledige changelog: https://github.com/vector-im/element-android/releases/tag/v1.3.8

View file

@ -0,0 +1,2 @@
Belangrijkste wijzigingen in deze versie: Ondersteuning toevoegen voor spraakberichtconcept. Veel bugfixes!
Volledige changelog: https://github.com/vector-im/element-android/releases/tag/v1.3.9

View file

@ -0,0 +1,2 @@
Belangrijkste wijzigingen in deze versie: Ondersteuning toevoegen voor polls (in labs). Nieuw URL-voorbeeldontwerp.
Volledige changelog: https://github.com/vector-im/element-android/releases/tag/v1.3.10

View file

@ -0,0 +1,2 @@
Belangrijkste wijzigingen in deze versie: Bugfixes!
Volledige changelog: https://github.com/vector-im/element-android/releases/tag/v1.3.11

View file

@ -0,0 +1,2 @@
Belangrijkste wijzigingen in deze versie: Bugfixes!
Volledige changelog: https://github.com/vector-im/element-android/releases/tag/v1.3.12

View file

@ -0,0 +1 @@
Groepsberichten - versleutelde berichten, groepschat en videogesprekken

View file

@ -0,0 +1 @@
Element - Veilige Berichten

View file

@ -0,0 +1,2 @@
Principais mudanças nesta versão: Adicionar suporte para sondagens (em labs). Novo design de previsualização de URL.
Changelog completo: https://github.com/vector-im/element-android/releases/tag/v1.3.10

View file

@ -0,0 +1,2 @@
Principais mudanças nesta versão: Consertos de bugs!
Changelog completo: https://github.com/vector-im/element-android/releases/tag/v1.3.11

View file

@ -0,0 +1,2 @@
Principais mudanças nesta versão: Consertos de bugs!
Changelog completo: https://github.com/vector-im/element-android/releases/tag/v1.3.12

View file

@ -0,0 +1,2 @@
Hlavné zmeny v tejto verzii: Vylepšenie VoIP (audio a video hovory v priamych správach) a opravy chýb!
Úplný zoznam zmien: https://github.com/vector-im/element-android/releases/tag/v1.1.0

View file

@ -0,0 +1,2 @@
Hlavné zmeny v tejto verzii: zlepšenie výkonu a opravy chýb!
Úplný zoznam zmien: https://github.com/vector-im/element-android/releases/tag/v1.1.1

View file

@ -0,0 +1,2 @@
Hlavné zmeny v tejto verzii: zlepšenie výkonu a opravy chýb!
Úplný zoznam zmien: https://github.com/vector-im/element-android/releases/tag/v1.1.2

View file

@ -0,0 +1,2 @@
Hlavné zmeny v tejto verzii: zlepšenie výkonu a opravy chýb!
Úplný zoznam zmien: https://github.com/vector-im/element-android/releases/tag/v1.1.3

View file

@ -0,0 +1,2 @@
Hlavné zmeny v tejto verzii: zlepšenie výkonu a opravy chýb!
Úplný zoznam zmien: https://github.com/vector-im/element-android/releases/tag/v1.1.4

View file

@ -0,0 +1,2 @@
Hlavné zmeny v tejto verzii: rýchle opravy pre verziu 1.1.4
Úplný zoznam zmien: https://github.com/vector-im/element-android/releases/tag/v1.1.5

View file

@ -0,0 +1,2 @@
Hlavné zmeny v tejto verzii: rýchle opravy pre verziu 1.1.5
Úplný zoznam zmien: https://github.com/vector-im/element-android/releases/tag/v1.1.6

View file

@ -0,0 +1,2 @@
Hlavné zmeny v tejto verzii: beta podpora pre priestory Spaces. Kompresia videa pred odoslaním.
Úplný zoznam zmien: https://github.com/vector-im/element-android/releases/tag/v1.1.7

View file

@ -0,0 +1,2 @@
Hlavné zmeny v tejto verzii: vylepšenie pre Priestory.
Úplný zoznam zmien: https://github.com/vector-im/element-android/releases/tag/v1.1.8

View file

@ -0,0 +1,2 @@
Hlavné zmeny v tejto verzii: pridanie podpory pre sieť gitter.im.
Úplný zoznam zmien: https://github.com/vector-im/element-android/releases/tag/v1.1.9

View file

@ -0,0 +1,2 @@
Hlavné zmeny v tejto verzii: aktualizácia témy a štýlu a nové funkcie pre priestory.
Úplný zoznam zmien: https://github.com/vector-im/element-android/releases/tag/v1.1.10

View file

@ -0,0 +1,2 @@
Hlavné zmeny v tejto verzii: aktualizácia témy a štýlu a nové funkcie pre priestory (oprava chyby pre verziu 1.1.10)
Úplný zoznam zmien: https://github.com/vector-im/element-android/releases/tag/v1.1.11

View file

@ -0,0 +1,2 @@
Hlavné zmeny v tejto verzii: aktualizácia témy a štýlu a oprava pádu po videohovore
Úplný zoznam zmien: https://github.com/vector-im/element-android/releases/tag/v1.1.12

View file

@ -0,0 +1,2 @@
Hlavné zmeny v tejto verzii: hlavne aktualizácia stability a opravy chýb.
Úplný zoznam zmien: https://github.com/vector-im/element-android/releases/tag/v1.1.13

View file

@ -0,0 +1,2 @@
Hlavné zmeny v tejto verzii: oprava problému so šifrovanými správami.
Úplný zoznam zmien: https://github.com/vector-im/element-android/releases/tag/v1.1.14

View file

@ -0,0 +1,2 @@
Hlavné zmeny v tejto verzii: implementácia hlasových správ v rámci nastavení laboratórií.
Úplný zoznam zmien: https://github.com/vector-im/element-android/releases/tag/v1.1.15

View file

@ -0,0 +1,2 @@
Hlavné zmeny v tejto verzii: Oprava chyby pri odosielaní zašifrovanej správy, ak sa niekto v miestnosti odhlási.
Úplný zoznam zmien: https://github.com/vector-im/element-android/releases/tag/v1.1.16

View file

@ -0,0 +1,2 @@
Hlavné zmeny v tejto verzii: Hlasová správa je predvolene povolená.
Úplný zoznam zmien: https://github.com/vector-im/element-android/releases/tag/v1.2.0

View file

@ -0,0 +1,2 @@
Hlavné zmeny v tejto verzii: Mnohé vylepšenia v oblasti VoIP a Priestorov (stále v beta verzii).
Úplný zoznam zmien: https://github.com/vector-im/element-android/releases/tag/v1.2.1

View file

@ -0,0 +1,2 @@
Hlavné zmeny v tejto verzii: Usporiadajte svoje miestnosti pomocou Priestorov!
Úplný zoznam zmien: https://github.com/vector-im/element-android/releases/tag/v1.3.0

View file

@ -0,0 +1,2 @@
Hlavné zmeny v tejto verzii: Usporiadajte svoje miestnosti pomocou Priestorov! Verzia v1.3.1 opravuje pád, ktorý sa môže vyskytnúť vo verzii v1.3.0.
Úplný zoznam zmien: https://github.com/vector-im/element-android/releases/tag/v1.3.1

View file

@ -0,0 +1,2 @@
Hlavné zmeny v tejto verzii: Pridanie podpory pre Android Auto. Množstvo opráv chýb!
Úplný zoznam zmien: https://github.com/vector-im/element-android/releases/tag/v1.3.2

View file

@ -0,0 +1,2 @@
Hlavné zmeny v tejto verzii: Zviditeľnite zásad servera totožností v nastaveniach. Dočasne odstránenie podpory Android Auto.
Úplný zoznam zmien: https://github.com/vector-im/element-android/releases/tag/v1.3.3

View file

@ -0,0 +1,2 @@
Hlavné zmeny v tejto verzii: Pridanie podpory prítomnosti pre miestnosť s priamymi správami (poznámka: prítomnosť je na matrix.org vypnutá). Opätovné pridanie podpory Android Auto.
Úplný zoznam zmien: https://github.com/vector-im/element-android/releases/tag/v1.3.4

View file

@ -0,0 +1,2 @@
Hlavné zmeny v tejto verzii: Pridanie podpory prítomnosti pre miestnosť s priamymi správami (poznámka: prítomnosť je na matrix.org vypnutá). Opätovné pridanie podpory Android Auto.
Úplný zoznam zmien: https://github.com/vector-im/element-android/releases/tag/v1.3.5

View file

@ -0,0 +1,2 @@
Hlavné zmeny v tejto verzii: Pridanie podpory pre ankety (v laboratóriách). Nový dizajn náhľadu URL.
Úplný zoznam zmien: https://github.com/vector-im/element-android/releases/tag/v1.3.10

View file

@ -0,0 +1,2 @@
Hlavné zmeny v tejto verzii: Opravy chýb!
Úplný zoznam zmien: https://github.com/vector-im/element-android/releases/tag/v1.3.11

View file

@ -0,0 +1,2 @@
Hlavné zmeny v tejto verzii: Opravy chýb!
Úplný zoznam zmien: https://github.com/vector-im/element-android/releases/tag/v1.3.12

View file

@ -0,0 +1,2 @@
Huvudsakliga ändringar i den här versionen: Lägg till stöd för omröstningar (i experiment). Ny design för URL-förhandsgranskning.
Full ändringslogg: https://github.com/vector-im/element-android/releases/tag/v1.3.10

View file

@ -0,0 +1,2 @@
Huvudsakliga ändringar i den här versionen: Buggfixar!
Full ändringslogg: https://github.com/vector-im/element-android/releases/tag/v1.3.11

View file

@ -0,0 +1,2 @@
Huvudsakliga ändringar i den här versionen: Buggfixar!
Full ändringslogg: https://github.com/vector-im/element-android/releases/tag/v1.3.12

View file

@ -0,0 +1,2 @@
Основні зміни в цій версії: Додано підтримку опитувань (в експериментальних). Новий вигляд попереднього перегляду посилань.
Повний журнал змін: https://github.com/vector-im/element-android/releases/tag/v1.3.10

View file

@ -0,0 +1,2 @@
Основні зміни у цій версії: Виправлення помилок!
Повний перелік змін: https://github.com/vector-im/element-android/releases/tag/v1.3.11

View file

@ -0,0 +1,2 @@
Основні зміни у цій версії: Виправлення помилок!
Повний перелік змін: https://github.com/vector-im/element-android/releases/tag/v1.3.12

View file

@ -0,0 +1,2 @@
此版本中的主要變動:新增對投票(在實驗室中)的支援。新的 URL 預覽設計。
完整的變更紀錄https://github.com/vector-im/element-android/releases/tag/v1.3.10

View file

@ -0,0 +1,2 @@
此版本中的主要變動:臭蟲修復!
完整的變更紀錄https://github.com/vector-im/element-android/releases/tag/v1.3.11

View file

@ -0,0 +1,2 @@
此版本中的主要變動:臭蟲修復!
完整的變更紀錄https://github.com/vector-im/element-android/releases/tag/v1.3.12

View file

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:angle="@integer/rtl_mirror_flip"
android:endColor="#3372C7DA"
android:startColor="#33BBE7CF" />
</shape>

View file

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:angle="@integer/rtl_mirror_flip"
android:endColor="#33B972DA"
android:startColor="#3372C7DA" />
</shape>

View file

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:angle="@integer/rtl_mirror_flip"
android:endColor="#330DBD8B"
android:startColor="#33B972DA" />
</shape>

View file

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:angle="@integer/rtl_mirror_flip"
android:endColor="#33BBE7CF"
android:startColor="#330DBD8B" />
</shape>

View file

@ -142,8 +142,8 @@ dependencies {
implementation libs.arrow.core
implementation libs.arrow.instances
// olm lib is now hosted by maven at https://gitlab.matrix.org/api/v4/projects/27/packages/maven
implementation 'org.matrix.android:olm:3.2.7'
// olm lib is now hosted in MavenCentral
implementation 'org.matrix.android:olm-sdk:3.2.10'
// DI
implementation libs.dagger.dagger

View file

@ -0,0 +1,24 @@
/*
* 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
interface EventStreamService {
fun addEventStreamListener(streamListener: LiveEventListener)
fun removeEventStreamListener(streamListener: LiveEventListener)
}

View file

@ -0,0 +1,35 @@
/*
* 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
import org.matrix.android.sdk.api.session.events.model.Event
import org.matrix.android.sdk.api.util.JsonDict
interface LiveEventListener {
fun onLiveEvent(roomId: String, event: Event)
fun onPaginatedEvent(roomId: String, event: Event)
fun onEventDecrypted(eventId: String, roomId: String, clearEvent: JsonDict)
fun onEventDecryptionError(eventId: String, roomId: String, throwable: Throwable)
fun onLiveToDeviceEvent(event: Event)
// Maybe later add more, like onJoin, onLeave..
}

View file

@ -84,7 +84,9 @@ interface Session :
SyncStatusService,
HomeServerCapabilitiesService,
SecureStorageService,
AccountService {
AccountService,
ToDeviceService,
EventStreamService {
val coroutineDispatchers: MatrixCoroutineDispatchers

View file

@ -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.api.session
import org.matrix.android.sdk.api.session.events.model.Content
import org.matrix.android.sdk.internal.crypto.model.MXUsersDevicesMap
import java.util.UUID
interface ToDeviceService {
/**
* Send an event to a specific list of devices
*/
suspend fun sendToDevice(eventType: String, contentMap: MXUsersDevicesMap<Any>, txnId: String? = UUID.randomUUID().toString())
suspend fun sendToDevice(eventType: String, userId: String, deviceId: String, content: Content, txnId: String? = UUID.randomUUID().toString()) {
sendToDevice(eventType, mapOf(userId to listOf(deviceId)), content, txnId)
}
suspend fun sendToDevice(eventType: String, targets: Map<String, List<String>>, content: Content, txnId: String? = UUID.randomUUID().toString())
suspend fun sendEncryptedToDevice(eventType: String, targets: Map<String, List<String>>, content: Content, txnId: String? = UUID.randomUUID().toString())
}

View file

@ -90,6 +90,7 @@ import org.matrix.android.sdk.internal.di.MoshiProvider
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.StreamEventsManager
import org.matrix.android.sdk.internal.session.room.membership.LoadRoomMembersTask
import org.matrix.android.sdk.internal.task.TaskExecutor
import org.matrix.android.sdk.internal.task.TaskThread
@ -168,7 +169,8 @@ internal class DefaultCryptoService @Inject constructor(
private val coroutineDispatchers: MatrixCoroutineDispatchers,
private val taskExecutor: TaskExecutor,
private val cryptoCoroutineScope: CoroutineScope,
private val eventDecryptor: EventDecryptor
private val eventDecryptor: EventDecryptor,
private val liveEventManager: Lazy<StreamEventsManager>
) : CryptoService {
private val isStarting = AtomicBoolean(false)
@ -782,6 +784,7 @@ internal class DefaultCryptoService @Inject constructor(
}
}
}
liveEventManager.get().dispatchOnLiveToDevice(event)
}
/**

View file

@ -16,6 +16,7 @@
package org.matrix.android.sdk.internal.crypto.algorithms.megolm
import dagger.Lazy
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.launch
import org.matrix.android.sdk.api.MatrixCoroutineDispatchers
@ -43,6 +44,7 @@ import org.matrix.android.sdk.internal.crypto.model.rest.ForwardedRoomKeyContent
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.session.StreamEventsManager
import timber.log.Timber
private val loggerTag = LoggerTag("MXMegolmDecryption", LoggerTag.CRYPTO)
@ -56,7 +58,8 @@ internal class MXMegolmDecryption(private val userId: String,
private val cryptoStore: IMXCryptoStore,
private val sendToDeviceTask: SendToDeviceTask,
private val coroutineDispatchers: MatrixCoroutineDispatchers,
private val cryptoCoroutineScope: CoroutineScope
private val cryptoCoroutineScope: CoroutineScope,
private val liveEventManager: Lazy<StreamEventsManager>
) : IMXDecrypting, IMXWithHeldExtension {
var newSessionListener: NewSessionListener? = null
@ -108,12 +111,15 @@ internal class MXMegolmDecryption(private val userId: String,
claimedEd25519Key = olmDecryptionResult.keysClaimed?.get("ed25519"),
forwardingCurve25519KeyChain = olmDecryptionResult.forwardingCurve25519KeyChain
.orEmpty()
)
).also {
liveEventManager.get().dispatchLiveEventDecrypted(event, it)
}
} else {
throw MXCryptoError.Base(MXCryptoError.ErrorType.MISSING_FIELDS, MXCryptoError.MISSING_FIELDS_REASON)
}
},
{ throwable ->
liveEventManager.get().dispatchLiveEventDecryptionFailed(event, throwable)
if (throwable is MXCryptoError.OlmError) {
// TODO Check the value of .message
if (throwable.olmException.message == "UNKNOWN_MESSAGE_INDEX") {

View file

@ -16,6 +16,7 @@
package org.matrix.android.sdk.internal.crypto.algorithms.megolm
import dagger.Lazy
import kotlinx.coroutines.CoroutineScope
import org.matrix.android.sdk.api.MatrixCoroutineDispatchers
import org.matrix.android.sdk.internal.crypto.DeviceListManager
@ -26,6 +27,7 @@ import org.matrix.android.sdk.internal.crypto.actions.MessageEncrypter
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.session.StreamEventsManager
import javax.inject.Inject
internal class MXMegolmDecryptionFactory @Inject constructor(
@ -38,7 +40,8 @@ internal class MXMegolmDecryptionFactory @Inject constructor(
private val cryptoStore: IMXCryptoStore,
private val sendToDeviceTask: SendToDeviceTask,
private val coroutineDispatchers: MatrixCoroutineDispatchers,
private val cryptoCoroutineScope: CoroutineScope
private val cryptoCoroutineScope: CoroutineScope,
private val eventsManager: Lazy<StreamEventsManager>
) {
fun create(): MXMegolmDecryption {
@ -52,6 +55,7 @@ internal class MXMegolmDecryptionFactory @Inject constructor(
cryptoStore,
sendToDeviceTask,
coroutineDispatchers,
cryptoCoroutineScope)
cryptoCoroutineScope,
eventsManager)
}
}

View file

@ -0,0 +1,34 @@
/*
* 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
import org.matrix.android.sdk.api.session.EventStreamService
import org.matrix.android.sdk.api.session.LiveEventListener
import javax.inject.Inject
internal class DefaultEventStreamService @Inject constructor(
private val streamEventsManager: StreamEventsManager
) : EventStreamService {
override fun addEventStreamListener(streamListener: LiveEventListener) {
streamEventsManager.addLiveEventListener(streamListener)
}
override fun removeEventStreamListener(streamListener: LiveEventListener) {
streamEventsManager.removeLiveEventListener(streamListener)
}
}

View file

@ -27,8 +27,10 @@ import org.matrix.android.sdk.api.auth.data.SessionParams
import org.matrix.android.sdk.api.failure.GlobalError
import org.matrix.android.sdk.api.federation.FederationService
import org.matrix.android.sdk.api.pushrules.PushRuleService
import org.matrix.android.sdk.api.session.EventStreamService
import org.matrix.android.sdk.api.session.Session
import org.matrix.android.sdk.api.session.SessionLifecycleObserver
import org.matrix.android.sdk.api.session.ToDeviceService
import org.matrix.android.sdk.api.session.account.AccountService
import org.matrix.android.sdk.api.session.accountdata.SessionAccountDataService
import org.matrix.android.sdk.api.session.cache.CacheService
@ -133,6 +135,8 @@ internal class DefaultSession @Inject constructor(
private val spaceService: Lazy<SpaceService>,
private val openIdService: Lazy<OpenIdService>,
private val presenceService: Lazy<PresenceService>,
private val toDeviceService: Lazy<ToDeviceService>,
private val eventStreamService: Lazy<EventStreamService>,
@UnauthenticatedWithCertificate
private val unauthenticatedWithCertificateOkHttpClient: Lazy<OkHttpClient>
) : Session,
@ -152,7 +156,9 @@ internal class DefaultSession @Inject constructor(
HomeServerCapabilitiesService by homeServerCapabilitiesService.get(),
ProfileService by profileService.get(),
PresenceService by presenceService.get(),
AccountService by accountService.get() {
AccountService by accountService.get(),
ToDeviceService by toDeviceService.get(),
EventStreamService by eventStreamService.get() {
override val sharedSecretStorageService: SharedSecretStorageService
get() = _sharedSecretStorageService.get()

View file

@ -0,0 +1,73 @@
/*
* 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
import org.matrix.android.sdk.api.session.ToDeviceService
import org.matrix.android.sdk.api.session.events.model.Content
import org.matrix.android.sdk.api.session.events.model.EventType
import org.matrix.android.sdk.internal.crypto.actions.MessageEncrypter
import org.matrix.android.sdk.internal.crypto.model.MXUsersDevicesMap
import org.matrix.android.sdk.internal.crypto.store.IMXCryptoStore
import org.matrix.android.sdk.internal.crypto.tasks.SendToDeviceTask
import javax.inject.Inject
internal class DefaultToDeviceService @Inject constructor(
private val sendToDeviceTask: SendToDeviceTask,
private val messageEncrypter: MessageEncrypter,
private val cryptoStore: IMXCryptoStore
) : ToDeviceService {
override suspend fun sendToDevice(eventType: String, targets: Map<String, List<String>>, content: Content, txnId: String?) {
val sendToDeviceMap = MXUsersDevicesMap<Any>()
targets.forEach { (userId, deviceIdList) ->
deviceIdList.forEach { deviceId ->
sendToDeviceMap.setObject(userId, deviceId, content)
}
}
sendToDevice(eventType, sendToDeviceMap, txnId)
}
override suspend fun sendToDevice(eventType: String, contentMap: MXUsersDevicesMap<Any>, txnId: String?) {
sendToDeviceTask.executeRetry(
SendToDeviceTask.Params(
eventType = eventType,
contentMap = contentMap,
transactionId = txnId
),
3
)
}
override suspend fun sendEncryptedToDevice(eventType: String, targets: Map<String, List<String>>, content: Content, txnId: String?) {
val payloadJson = mapOf(
"type" to eventType,
"content" to content
)
val sendToDeviceMap = MXUsersDevicesMap<Any>()
// Should I do an ensure olm session?
targets.forEach { (userId, deviceIdList) ->
deviceIdList.forEach { deviceId ->
cryptoStore.getUserDevice(userId, deviceId)?.let { deviceInfo ->
sendToDeviceMap.setObject(userId, deviceId, messageEncrypter.encryptMessage(payloadJson, listOf(deviceInfo)))
}
}
}
sendToDevice(EventType.ENCRYPTED, sendToDeviceMap, txnId)
}
}

View file

@ -32,8 +32,10 @@ import org.matrix.android.sdk.api.auth.data.HomeServerConnectionConfig
import org.matrix.android.sdk.api.auth.data.SessionParams
import org.matrix.android.sdk.api.auth.data.sessionId
import org.matrix.android.sdk.api.crypto.MXCryptoConfig
import org.matrix.android.sdk.api.session.EventStreamService
import org.matrix.android.sdk.api.session.Session
import org.matrix.android.sdk.api.session.SessionLifecycleObserver
import org.matrix.android.sdk.api.session.ToDeviceService
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
@ -374,6 +376,12 @@ internal abstract class SessionModule {
@Binds
abstract fun bindOpenIdTokenService(service: DefaultOpenIdService): OpenIdService
@Binds
abstract fun bindToDeviceService(service: DefaultToDeviceService): ToDeviceService
@Binds
abstract fun bindEventStreamService(service: DefaultEventStreamService): EventStreamService
@Binds
abstract fun bindTypingUsersTracker(tracker: DefaultTypingUsersTracker): TypingUsersTracker

View file

@ -0,0 +1,101 @@
/*
* 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
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.launch
import org.matrix.android.sdk.api.extensions.tryOrNull
import org.matrix.android.sdk.api.session.LiveEventListener
import org.matrix.android.sdk.api.session.events.model.Event
import org.matrix.android.sdk.internal.crypto.MXEventDecryptionResult
import timber.log.Timber
import javax.inject.Inject
@SessionScope
internal class StreamEventsManager @Inject constructor() {
private val coroutineScope = CoroutineScope(SupervisorJob() + Dispatchers.Default)
private val listeners = mutableListOf<LiveEventListener>()
fun addLiveEventListener(listener: LiveEventListener) {
listeners.add(listener)
}
fun removeLiveEventListener(listener: LiveEventListener) {
listeners.remove(listener)
}
fun dispatchLiveEventReceived(event: Event, roomId: String, initialSync: Boolean) {
Timber.v("## dispatchLiveEventReceived ${event.eventId}")
coroutineScope.launch {
if (!initialSync) {
listeners.forEach {
tryOrNull {
it.onLiveEvent(roomId, event)
}
}
}
}
}
fun dispatchPaginatedEventReceived(event: Event, roomId: String) {
Timber.v("## dispatchPaginatedEventReceived ${event.eventId}")
coroutineScope.launch {
listeners.forEach {
tryOrNull {
it.onPaginatedEvent(roomId, event)
}
}
}
}
fun dispatchLiveEventDecrypted(event: Event, result: MXEventDecryptionResult) {
Timber.v("## dispatchLiveEventDecrypted ${event.eventId}")
coroutineScope.launch {
listeners.forEach {
tryOrNull {
it.onEventDecrypted(event.eventId ?: "", event.roomId ?: "", result.clearEvent)
}
}
}
}
fun dispatchLiveEventDecryptionFailed(event: Event, error: Throwable) {
Timber.v("## dispatchLiveEventDecryptionFailed ${event.eventId}")
coroutineScope.launch {
listeners.forEach {
tryOrNull {
it.onEventDecryptionError(event.eventId ?: "", event.roomId ?: "", error)
}
}
}
}
fun dispatchOnLiveToDevice(event: Event) {
Timber.v("## dispatchOnLiveToDevice ${event.eventId}")
coroutineScope.launch {
listeners.forEach {
tryOrNull {
it.onLiveToDeviceEvent(event)
}
}
}
}
}

View file

@ -17,6 +17,7 @@
package org.matrix.android.sdk.internal.session.room.timeline
import com.zhuinden.monarchy.Monarchy
import dagger.Lazy
import io.realm.Realm
import org.matrix.android.sdk.api.session.events.model.EventType
import org.matrix.android.sdk.api.session.events.model.toModel
@ -38,6 +39,7 @@ import org.matrix.android.sdk.internal.database.query.find
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.session.StreamEventsManager
import org.matrix.android.sdk.internal.util.awaitTransaction
import timber.log.Timber
import javax.inject.Inject
@ -47,7 +49,8 @@ import javax.inject.Inject
*/
internal class TokenChunkEventPersistor @Inject constructor(
@SessionDatabase private val monarchy: Monarchy,
@UserId private val userId: String) {
@UserId private val userId: String,
private val liveEventManager: Lazy<StreamEventsManager> ) {
enum class Result {
SHOULD_FETCH_MORE,
@ -177,6 +180,7 @@ internal class TokenChunkEventPersistor @Inject constructor(
}
roomMemberContentsByUser[event.stateKey] = contentToUse.toModel<RoomMemberContent>()
}
liveEventManager.get().dispatchPaginatedEventReceived(event, roomId)
currentChunk.addTimelineEvent(roomId, eventEntity, direction, roomMemberContentsByUser)
eventEntity.rootThreadEventId?.let {
// This is a thread event

View file

@ -16,6 +16,7 @@
package org.matrix.android.sdk.internal.session.sync.handler.room
import dagger.Lazy
import io.realm.Realm
import io.realm.kotlin.createObject
import org.matrix.android.sdk.BuildConfig
@ -55,6 +56,7 @@ import org.matrix.android.sdk.internal.database.query.where
import org.matrix.android.sdk.internal.di.MoshiProvider
import org.matrix.android.sdk.internal.di.UserId
import org.matrix.android.sdk.internal.extensions.clearWith
import org.matrix.android.sdk.internal.session.StreamEventsManager
import org.matrix.android.sdk.internal.session.events.getFixedRoomMemberContent
import org.matrix.android.sdk.internal.session.initsync.ProgressReporter
import org.matrix.android.sdk.internal.session.initsync.mapWithProgress
@ -82,7 +84,8 @@ internal class RoomSyncHandler @Inject constructor(private val readReceiptHandle
private val threadsAwarenessHandler: ThreadsAwarenessHandler,
private val roomChangeMembershipStateDataSource: RoomChangeMembershipStateDataSource,
@UserId private val userId: String,
private val timelineInput: TimelineInput) {
private val timelineInput: TimelineInput,
private val liveEventService: Lazy<StreamEventsManager>) {
sealed class HandlingStrategy {
data class JOINED(val data: Map<String, RoomSync>) : HandlingStrategy()
@ -368,6 +371,7 @@ internal class RoomSyncHandler @Inject constructor(private val readReceiptHandle
continue
}
eventIds.add(event.eventId)
liveEventService.get().dispatchLiveEventReceived(event, roomId, insertType == EventInsertType.INITIAL_SYNC)
val isInitialSync = insertType == EventInsertType.INITIAL_SYNC

View file

@ -160,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===121
enum class===122
### Do not import temporary legacy classes
import org.matrix.android.sdk.internal.legacy.riot===3

View file

@ -26,7 +26,6 @@ import im.vector.app.activityIdlingResource
import im.vector.app.waitForView
import im.vector.app.withIdlingResource
import org.hamcrest.Matcher
import org.hamcrest.Matchers.not
inline fun <reified T : Activity> waitUntilActivityVisible(noinline block: (() -> Unit) = {}) {
withIdlingResource(activityIdlingResource(T::class.java), block)

View file

@ -0,0 +1,48 @@
/*
* Copyright (c) 2022 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.ui.robot
import androidx.test.espresso.matcher.ViewMatchers.withId
import com.adevinta.android.barista.assertion.BaristaVisibilityAssertions.assertDisplayed
import com.adevinta.android.barista.interaction.BaristaClickInteractions.clickOn
import im.vector.app.R
import im.vector.app.espresso.tools.waitUntilActivityVisible
import im.vector.app.espresso.tools.waitUntilViewVisible
import im.vector.app.features.analytics.ui.consent.AnalyticsOptInActivity
class AnalyticsRobot {
fun optIn() {
answerOptIn(true)
}
fun optOut() {
answerOptIn(false)
}
private fun answerOptIn(optIn: Boolean) {
waitUntilActivityVisible<AnalyticsOptInActivity> {
waitUntilViewVisible(withId(R.id.title))
}
assertDisplayed(R.id.title, R.string.analytics_opt_in_title)
if (optIn) {
clickOn(R.id.submit)
} else {
clickOn(R.id.later)
}
}
}

View file

@ -32,7 +32,7 @@ import im.vector.app.espresso.tools.waitUntilDialogVisible
import im.vector.app.espresso.tools.waitUntilViewVisible
import im.vector.app.features.createdirect.CreateDirectRoomActivity
import im.vector.app.features.home.HomeActivity
import im.vector.app.features.login.LoginActivity
import im.vector.app.features.onboarding.OnboardingActivity
import im.vector.app.initialSyncIdlingResource
import im.vector.app.ui.robot.settings.SettingsRobot
import im.vector.app.withIdlingResource
@ -43,6 +43,8 @@ class ElementRobot {
fun signUp(userId: String) {
val onboardingRobot = OnboardingRobot()
onboardingRobot.createAccount(userId = userId)
val analyticsRobot = AnalyticsRobot()
analyticsRobot.optOut()
waitForHome()
}
@ -121,7 +123,7 @@ class ElementRobot {
clickDialogPositiveButton()
}
waitUntilActivityVisible<LoginActivity> {
waitUntilActivityVisible<OnboardingActivity> {
assertDisplayed(R.id.loginSplashLogo)
}
}

View file

@ -45,7 +45,11 @@ class OnboardingRobot {
homeServerUrl: String) {
waitUntilViewVisible(withId(R.id.loginSplashSubmit))
assertDisplayed(R.id.loginSplashSubmit, R.string.login_splash_submit)
clickOn(R.id.loginSplashSubmit)
if (createAccount) {
clickOn(R.id.loginSplashSubmit)
} else {
clickOn(R.id.loginSplashAlreadyHaveAccount)
}
assertDisplayed(R.id.loginServerTitle, R.string.login_server_title)
// Chose custom server
clickOn(R.id.loginServerChoiceOther)
@ -54,17 +58,7 @@ class OnboardingRobot {
assertEnabled(R.id.loginServerUrlFormSubmit)
closeSoftKeyboard()
clickOn(R.id.loginServerUrlFormSubmit)
onView(isRoot()).perform(waitForView(withId(R.id.loginSignupSigninSubmit)))
if (createAccount) {
// Click on the signup button
assertDisplayed(R.id.loginSignupSigninSubmit)
clickOn(R.id.loginSignupSigninSubmit)
} else {
// Click on the signin button
assertDisplayed(R.id.loginSignupSigninSignIn)
clickOn(R.id.loginSignupSigninSignIn)
}
onView(isRoot()).perform(waitForView(withId(R.id.loginField)))
// Ensure password flow supported
assertDisplayed(R.id.loginField)

Some files were not shown because too many files have changed in this diff Show more