From a8bbf29b426b66b4c5f9c21fbc192310f799f207 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olive=CC=81r=20Falvai?= Date: Fri, 15 Apr 2022 22:50:54 +0200 Subject: [PATCH 001/457] Remove unused dependencies --- build.gradle | 17 +++++++++++++++++ dependencies.gradle | 2 +- library/attachment-viewer/build.gradle | 6 ++++-- library/core-utils/build.gradle | 3 +-- library/multipicker/build.gradle | 2 +- library/ui-styles/build.gradle | 6 +----- matrix-sdk-android-flow/build.gradle | 5 ----- matrix-sdk-android/build.gradle | 10 +--------- vector/build.gradle | 3 --- 9 files changed, 26 insertions(+), 28 deletions(-) diff --git a/build.gradle b/build.gradle index 1ff1da7427..6cbc11351e 100644 --- a/build.gradle +++ b/build.gradle @@ -31,6 +31,7 @@ buildscript { // ktlint Plugin plugins { id "org.jlleitschuh.gradle.ktlint" version "10.2.1" + id 'com.autonomousapps.dependency-analysis' version "1.0.0" } // https://github.com/jeremylong/DependencyCheck @@ -193,3 +194,19 @@ project(":library:diff-match-patch") { // } // } //} + +dependencyAnalysis { + dependencies { + bundle("kotlin-stdlib") { + includeGroup("org.jetbrains.kotlin") + } + bundle("react") { + includeGroup("com.facebook.react") + } + } + issues { + all { + ignoreKtx(true) // default is false + } + } +} diff --git a/dependencies.gradle b/dependencies.gradle index 7666a3bf9f..be1b888502 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -81,7 +81,7 @@ ext.libs = [ 'hiltCompiler' : "com.google.dagger:hilt-compiler:$dagger" ], squareup : [ - 'moshi' : "com.squareup.moshi:moshi-adapters:$moshi", + 'moshi' : "com.squareup.moshi:moshi:$moshi", 'moshiKotlin' : "com.squareup.moshi:moshi-kotlin-codegen:$moshi", 'retrofit' : "com.squareup.retrofit2:retrofit:$retrofit", 'retrofitMoshi' : "com.squareup.retrofit2:converter-moshi:$retrofit" diff --git a/library/attachment-viewer/build.gradle b/library/attachment-viewer/build.gradle index 048710f62c..b51136a993 100644 --- a/library/attachment-viewer/build.gradle +++ b/library/attachment-viewer/build.gradle @@ -55,5 +55,7 @@ dependencies { implementation libs.androidx.appCompat implementation libs.androidx.recyclerview - implementation libs.google.material -} \ No newline at end of file + api("androidx.viewpager2:viewpager2:1.0.0") + implementation("androidx.core:core:1.7.0") + implementation("androidx.transition:transition:1.2.0") +} diff --git a/library/core-utils/build.gradle b/library/core-utils/build.gradle index ad3a948808..1cc518c432 100644 --- a/library/core-utils/build.gradle +++ b/library/core-utils/build.gradle @@ -50,6 +50,5 @@ android { } dependencies { - implementation libs.androidx.appCompat implementation libs.jetbrains.coroutinesAndroid -} \ No newline at end of file +} diff --git a/library/multipicker/build.gradle b/library/multipicker/build.gradle index bb98a2f852..861238c02b 100644 --- a/library/multipicker/build.gradle +++ b/library/multipicker/build.gradle @@ -39,8 +39,8 @@ android { dependencies { implementation libs.androidx.appCompat - implementation libs.androidx.fragmentKtx implementation libs.androidx.exifinterface + implementation libs.androidx.core // Log implementation libs.jakewharton.timber diff --git a/library/ui-styles/build.gradle b/library/ui-styles/build.gradle index 0ac513b252..debfdf8649 100644 --- a/library/ui-styles/build.gradle +++ b/library/ui-styles/build.gradle @@ -54,10 +54,6 @@ android { dependencies { implementation libs.androidx.appCompat implementation libs.google.material - // Pref theme - implementation libs.androidx.preferenceKtx - // PFLockScreen attrs - implementation 'com.github.vector-im:PFLockScreen-Android:1.0.0-beta12' // dialpad dimen implementation 'im.dlg:android-dialer:1.2.5' -} \ No newline at end of file +} diff --git a/matrix-sdk-android-flow/build.gradle b/matrix-sdk-android-flow/build.gradle index ea43ce20c8..fb69af2d82 100644 --- a/matrix-sdk-android-flow/build.gradle +++ b/matrix-sdk-android-flow/build.gradle @@ -31,9 +31,7 @@ android { } dependencies { - implementation project(":matrix-sdk-android") - implementation libs.androidx.appCompat implementation libs.jetbrains.coroutinesCore implementation libs.jetbrains.coroutinesAndroid @@ -41,7 +39,4 @@ dependencies { // Paging implementation libs.androidx.pagingRuntimeKtx - - // Logging - implementation libs.jakewharton.timber } diff --git a/matrix-sdk-android/build.gradle b/matrix-sdk-android/build.gradle index 0cffa4148e..e9c8804bac 100644 --- a/matrix-sdk-android/build.gradle +++ b/matrix-sdk-android/build.gradle @@ -109,7 +109,6 @@ dependencies { implementation libs.jetbrains.coroutinesCore implementation libs.jetbrains.coroutinesAndroid - implementation libs.androidx.appCompat implementation libs.androidx.core // Lifecycle @@ -128,12 +127,11 @@ dependencies { implementation(platform("com.squareup.okhttp3:okhttp-bom:4.9.3")) implementation 'com.squareup.okhttp3:okhttp' implementation 'com.squareup.okhttp3:logging-interceptor' - implementation 'com.squareup.okhttp3:okhttp-urlconnection' implementation libs.squareup.moshi kapt libs.squareup.moshiKotlin - implementation libs.markwon.core + api "com.atlassian.commonmark:commonmark:0.13.0" // Image implementation libs.androidx.exifinterface @@ -149,10 +147,6 @@ dependencies { // Work implementation libs.androidx.work - // FP - implementation libs.arrow.core - implementation libs.arrow.instances - // olm lib is now hosted in MavenCentral implementation 'org.matrix.android:olm-sdk:3.2.10' @@ -174,8 +168,6 @@ dependencies { implementation 'com.googlecode.libphonenumber:libphonenumber:8.12.46' testImplementation libs.tests.junit - testImplementation 'org.robolectric:robolectric:4.7.3' - //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 libs.mockk.mockk testImplementation libs.tests.kluent diff --git a/vector/build.gradle b/vector/build.gradle index c7950da28e..237754d2d1 100644 --- a/vector/build.gradle +++ b/vector/build.gradle @@ -6,7 +6,6 @@ apply plugin: 'kotlin-android' apply plugin: 'kotlin-parcelize' apply plugin: 'kotlin-kapt' apply plugin: 'com.likethesalad.stem' -apply plugin: 'dagger.hilt.android.plugin' kapt { correctErrorTypes = true @@ -373,7 +372,6 @@ dependencies { // FlowBinding implementation libs.github.flowBinding implementation libs.github.flowBindingAppcompat - implementation libs.github.flowBindingMaterial implementation libs.airbnb.epoxy implementation libs.airbnb.epoxyGlide @@ -448,7 +446,6 @@ dependencies { implementation 'com.github.jetradarmobile:android-snowfall:1.2.1' // DI implementation libs.dagger.hilt - kapt libs.dagger.hiltCompiler // Analytics implementation 'com.posthog.android:posthog:1.1.2' From b3cfc88773075b3ef64ca89ed3fa18708eff10b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olive=CC=81r=20Falvai?= Date: Fri, 15 Apr 2022 23:36:42 +0200 Subject: [PATCH 002/457] Fix androidTest --- library/attachment-viewer/build.gradle | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/library/attachment-viewer/build.gradle b/library/attachment-viewer/build.gradle index b51136a993..b89d9c6cca 100644 --- a/library/attachment-viewer/build.gradle +++ b/library/attachment-viewer/build.gradle @@ -55,7 +55,5 @@ dependencies { implementation libs.androidx.appCompat implementation libs.androidx.recyclerview - api("androidx.viewpager2:viewpager2:1.0.0") - implementation("androidx.core:core:1.7.0") - implementation("androidx.transition:transition:1.2.0") + implementation libs.google.material } From cdd7db417409bac50ff24db741dcdc80c963219e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olive=CC=81r=20Falvai?= Date: Sat, 16 Apr 2022 09:40:15 +0200 Subject: [PATCH 003/457] Fix unused resource references properly --- library/attachment-viewer/build.gradle | 3 ++- .../src/main/res/values/styles_pin_code.xml | 14 +------------- .../ui-styles/src/main/res/values/theme_dark.xml | 11 ----------- .../ui-styles/src/main/res/values/theme_light.xml | 11 ----------- 4 files changed, 3 insertions(+), 36 deletions(-) diff --git a/library/attachment-viewer/build.gradle b/library/attachment-viewer/build.gradle index b89d9c6cca..57e5f30887 100644 --- a/library/attachment-viewer/build.gradle +++ b/library/attachment-viewer/build.gradle @@ -55,5 +55,6 @@ dependencies { implementation libs.androidx.appCompat implementation libs.androidx.recyclerview - implementation libs.google.material + api "androidx.viewpager2:viewpager2:1.0.0" + implementation "androidx.transition:transition:1.2.0" } diff --git a/library/ui-styles/src/main/res/values/styles_pin_code.xml b/library/ui-styles/src/main/res/values/styles_pin_code.xml index 2b6c113359..edec029faf 100644 --- a/library/ui-styles/src/main/res/values/styles_pin_code.xml +++ b/library/ui-styles/src/main/res/values/styles_pin_code.xml @@ -21,18 +21,6 @@ 24dp - - - - @@ -41,4 +29,4 @@ ?vctr_content_primary - \ No newline at end of file + diff --git a/library/ui-styles/src/main/res/values/theme_dark.xml b/library/ui-styles/src/main/res/values/theme_dark.xml index 7177687fdd..185e5b919c 100644 --- a/library/ui-styles/src/main/res/values/theme_dark.xml +++ b/library/ui-styles/src/main/res/values/theme_dark.xml @@ -106,17 +106,6 @@ never - @style/PreferenceThemeOverlay.v14.Material - - @style/PinCodeScreenStyle - @style/PinCodeKeyButtonStyle - @style/PinCodeTitleStyle - @style/PinCodeHintStyle - @style/PinCodeDotsViewStyle - @style/PinCodeDeleteButtonStyle - @style/PinCodeFingerprintButtonStyle - @style/PinCodeNextButtonStyle - @color/android_status_bar_background_dark @color/android_navigation_bar_background_dark diff --git a/library/ui-styles/src/main/res/values/theme_light.xml b/library/ui-styles/src/main/res/values/theme_light.xml index c90c021591..0eb11a139c 100644 --- a/library/ui-styles/src/main/res/values/theme_light.xml +++ b/library/ui-styles/src/main/res/values/theme_light.xml @@ -106,17 +106,6 @@ never - @style/PreferenceThemeOverlay.v14.Material - - @style/PinCodeScreenStyle - @style/PinCodeKeyButtonStyle - @style/PinCodeTitleStyle - @style/PinCodeHintStyle - @style/PinCodeDotsViewStyle - @style/PinCodeDeleteButtonStyle - @style/PinCodeFingerprintButtonStyle - @style/PinCodeNextButtonStyle - @color/android_status_bar_background_dark From 2138ec07992af8f153367daaaf937d8d7847fdf4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olive=CC=81r=20Falvai?= Date: Sat, 16 Apr 2022 11:14:04 +0200 Subject: [PATCH 004/457] Remove unused resource to make lint happy --- .../ui-styles/src/main/res/drawable/bg_pin_key.xml | 13 ------------- .../src/main/res/values/styles_pin_code.xml | 6 ------ 2 files changed, 19 deletions(-) delete mode 100644 library/ui-styles/src/main/res/drawable/bg_pin_key.xml diff --git a/library/ui-styles/src/main/res/drawable/bg_pin_key.xml b/library/ui-styles/src/main/res/drawable/bg_pin_key.xml deleted file mode 100644 index d4a54577be..0000000000 --- a/library/ui-styles/src/main/res/drawable/bg_pin_key.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/library/ui-styles/src/main/res/values/styles_pin_code.xml b/library/ui-styles/src/main/res/values/styles_pin_code.xml index edec029faf..c69819f7ba 100644 --- a/library/ui-styles/src/main/res/values/styles_pin_code.xml +++ b/library/ui-styles/src/main/res/values/styles_pin_code.xml @@ -5,12 +5,6 @@ ?android:colorBackground - - From 4305b21ba85a785c2947784a1ea46f88a69facf0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olive=CC=81r=20Falvai?= Date: Sat, 16 Apr 2022 20:36:43 +0200 Subject: [PATCH 005/457] Remove unused resource to make lint happy --- .../main/res/drawable/pin_code_dot_empty.xml | 13 ---------- .../main/res/drawable/pin_code_dot_fill.xml | 12 --------- .../src/main/res/drawable/pin_code_dots.xml | 9 ------- .../src/main/res/values/styles_pin_code.xml | 26 ------------------- 4 files changed, 60 deletions(-) delete mode 100644 library/ui-styles/src/main/res/drawable/pin_code_dot_empty.xml delete mode 100644 library/ui-styles/src/main/res/drawable/pin_code_dot_fill.xml delete mode 100644 library/ui-styles/src/main/res/drawable/pin_code_dots.xml delete mode 100644 library/ui-styles/src/main/res/values/styles_pin_code.xml diff --git a/library/ui-styles/src/main/res/drawable/pin_code_dot_empty.xml b/library/ui-styles/src/main/res/drawable/pin_code_dot_empty.xml deleted file mode 100644 index 1827a7682b..0000000000 --- a/library/ui-styles/src/main/res/drawable/pin_code_dot_empty.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/library/ui-styles/src/main/res/drawable/pin_code_dot_fill.xml b/library/ui-styles/src/main/res/drawable/pin_code_dot_fill.xml deleted file mode 100644 index 799ea30174..0000000000 --- a/library/ui-styles/src/main/res/drawable/pin_code_dot_fill.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/library/ui-styles/src/main/res/drawable/pin_code_dots.xml b/library/ui-styles/src/main/res/drawable/pin_code_dots.xml deleted file mode 100644 index 29e445e511..0000000000 --- a/library/ui-styles/src/main/res/drawable/pin_code_dots.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/library/ui-styles/src/main/res/values/styles_pin_code.xml b/library/ui-styles/src/main/res/values/styles_pin_code.xml deleted file mode 100644 index c69819f7ba..0000000000 --- a/library/ui-styles/src/main/res/values/styles_pin_code.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - - - - - From 2c84f234a600eedca62b37e9dd63f994da758401 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olive=CC=81r=20Falvai?= Date: Sun, 17 Apr 2022 11:09:10 +0200 Subject: [PATCH 006/457] Cleanup --- dependencies.gradle | 5 ++++- library/attachment-viewer/build.gradle | 4 ++-- library/multipicker/build.gradle | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/dependencies.gradle b/dependencies.gradle index be1b888502..ec27184d5c 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -45,6 +45,7 @@ ext.libs = [ 'coroutinesTest' : "org.jetbrains.kotlinx:kotlinx-coroutines-test:$kotlinCoroutines" ], androidx : [ + 'activity' : "androidx.activity:activity:1.2.4", 'appCompat' : "androidx.appcompat:appcompat:1.4.0", 'core' : "androidx.core:core-ktx:1.7.0", 'recyclerview' : "androidx.recyclerview:recyclerview:1.2.1", @@ -69,7 +70,9 @@ ext.libs = [ '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" + 'espressoIntents' : "androidx.test.espresso:espresso-intents:$espresso", + 'viewpager2' : "androidx.viewpager2:viewpager2:1.0.0", + 'transition' : "androidx.transition:transition:1.2.0", ], google : [ 'material' : "com.google.android.material:material:1.5.0" diff --git a/library/attachment-viewer/build.gradle b/library/attachment-viewer/build.gradle index 57e5f30887..8bbafd3387 100644 --- a/library/attachment-viewer/build.gradle +++ b/library/attachment-viewer/build.gradle @@ -55,6 +55,6 @@ dependencies { implementation libs.androidx.appCompat implementation libs.androidx.recyclerview - api "androidx.viewpager2:viewpager2:1.0.0" - implementation "androidx.transition:transition:1.2.0" + api libs.androidx.viewpager2 + implementation libs.androidx.transition } diff --git a/library/multipicker/build.gradle b/library/multipicker/build.gradle index 861238c02b..2de99d5c20 100644 --- a/library/multipicker/build.gradle +++ b/library/multipicker/build.gradle @@ -38,7 +38,7 @@ android { } dependencies { - implementation libs.androidx.appCompat + api libs.androidx.activity implementation libs.androidx.exifinterface implementation libs.androidx.core From 2bbecd4cc5d3bf245575ce0816a4f4829ac4f9d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olive=CC=81r=20Falvai?= Date: Sun, 17 Apr 2022 11:35:30 +0200 Subject: [PATCH 007/457] Fix regressions --- library/ui-styles/build.gradle | 4 ++ .../src/main/res/drawable/bg_pin_key.xml | 13 ++++++ .../main/res/drawable/pin_code_dot_empty.xml | 13 ++++++ .../main/res/drawable/pin_code_dot_fill.xml | 12 +++++ .../src/main/res/drawable/pin_code_dots.xml | 9 ++++ .../src/main/res/values/styles_pin_code.xml | 44 +++++++++++++++++++ .../src/main/res/values/theme_dark.xml | 11 +++++ .../src/main/res/values/theme_light.xml | 11 +++++ vector/build.gradle | 2 + 9 files changed, 119 insertions(+) create mode 100644 library/ui-styles/src/main/res/drawable/bg_pin_key.xml create mode 100644 library/ui-styles/src/main/res/drawable/pin_code_dot_empty.xml create mode 100644 library/ui-styles/src/main/res/drawable/pin_code_dot_fill.xml create mode 100644 library/ui-styles/src/main/res/drawable/pin_code_dots.xml create mode 100644 library/ui-styles/src/main/res/values/styles_pin_code.xml diff --git a/library/ui-styles/build.gradle b/library/ui-styles/build.gradle index debfdf8649..31cfdd24c7 100644 --- a/library/ui-styles/build.gradle +++ b/library/ui-styles/build.gradle @@ -54,6 +54,10 @@ android { dependencies { implementation libs.androidx.appCompat implementation libs.google.material + // Pref theme + implementation libs.androidx.preferenceKtx + // PFLockScreen attrs + implementation 'com.github.vector-im:PFLockScreen-Android:1.0.0-beta12' // dialpad dimen implementation 'im.dlg:android-dialer:1.2.5' } diff --git a/library/ui-styles/src/main/res/drawable/bg_pin_key.xml b/library/ui-styles/src/main/res/drawable/bg_pin_key.xml new file mode 100644 index 0000000000..5bf293aab0 --- /dev/null +++ b/library/ui-styles/src/main/res/drawable/bg_pin_key.xml @@ -0,0 +1,13 @@ + + + + + + + + + diff --git a/library/ui-styles/src/main/res/drawable/pin_code_dot_empty.xml b/library/ui-styles/src/main/res/drawable/pin_code_dot_empty.xml new file mode 100644 index 0000000000..879cac15ca --- /dev/null +++ b/library/ui-styles/src/main/res/drawable/pin_code_dot_empty.xml @@ -0,0 +1,13 @@ + + + + + + + diff --git a/library/ui-styles/src/main/res/drawable/pin_code_dot_fill.xml b/library/ui-styles/src/main/res/drawable/pin_code_dot_fill.xml new file mode 100644 index 0000000000..83bdac5126 --- /dev/null +++ b/library/ui-styles/src/main/res/drawable/pin_code_dot_fill.xml @@ -0,0 +1,12 @@ + + + + + + + diff --git a/library/ui-styles/src/main/res/drawable/pin_code_dots.xml b/library/ui-styles/src/main/res/drawable/pin_code_dots.xml new file mode 100644 index 0000000000..c4b1073f85 --- /dev/null +++ b/library/ui-styles/src/main/res/drawable/pin_code_dots.xml @@ -0,0 +1,9 @@ + + + + + + diff --git a/library/ui-styles/src/main/res/values/styles_pin_code.xml b/library/ui-styles/src/main/res/values/styles_pin_code.xml new file mode 100644 index 0000000000..cb22863694 --- /dev/null +++ b/library/ui-styles/src/main/res/values/styles_pin_code.xml @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/library/ui-styles/src/main/res/values/theme_dark.xml b/library/ui-styles/src/main/res/values/theme_dark.xml index 185e5b919c..7177687fdd 100644 --- a/library/ui-styles/src/main/res/values/theme_dark.xml +++ b/library/ui-styles/src/main/res/values/theme_dark.xml @@ -106,6 +106,17 @@ never + @style/PreferenceThemeOverlay.v14.Material + + @style/PinCodeScreenStyle + @style/PinCodeKeyButtonStyle + @style/PinCodeTitleStyle + @style/PinCodeHintStyle + @style/PinCodeDotsViewStyle + @style/PinCodeDeleteButtonStyle + @style/PinCodeFingerprintButtonStyle + @style/PinCodeNextButtonStyle + @color/android_status_bar_background_dark @color/android_navigation_bar_background_dark diff --git a/library/ui-styles/src/main/res/values/theme_light.xml b/library/ui-styles/src/main/res/values/theme_light.xml index 0eb11a139c..c90c021591 100644 --- a/library/ui-styles/src/main/res/values/theme_light.xml +++ b/library/ui-styles/src/main/res/values/theme_light.xml @@ -106,6 +106,17 @@ never + @style/PreferenceThemeOverlay.v14.Material + + @style/PinCodeScreenStyle + @style/PinCodeKeyButtonStyle + @style/PinCodeTitleStyle + @style/PinCodeHintStyle + @style/PinCodeDotsViewStyle + @style/PinCodeDeleteButtonStyle + @style/PinCodeFingerprintButtonStyle + @style/PinCodeNextButtonStyle + @color/android_status_bar_background_dark diff --git a/vector/build.gradle b/vector/build.gradle index 237754d2d1..6d318f82b9 100644 --- a/vector/build.gradle +++ b/vector/build.gradle @@ -6,6 +6,7 @@ apply plugin: 'kotlin-android' apply plugin: 'kotlin-parcelize' apply plugin: 'kotlin-kapt' apply plugin: 'com.likethesalad.stem' +apply plugin: 'dagger.hilt.android.plugin' kapt { correctErrorTypes = true @@ -446,6 +447,7 @@ dependencies { implementation 'com.github.jetradarmobile:android-snowfall:1.2.1' // DI implementation libs.dagger.hilt + kapt libs.dagger.hiltCompiler // Analytics implementation 'com.posthog.android:posthog:1.1.2' From 6b9b6880724f18146b1315b5f6d60a9833d8a553 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Loipf=C3=BChrer?= Date: Sat, 23 Apr 2022 00:06:18 +0200 Subject: [PATCH 008/457] do not switch away from home space on notification MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If the preference "Show all Rooms in Home" is selected element should not switch away from the home space when clicking a notification for a room in some other space. With this change one stays in the home space when the said preference is active. fixes #5180 Signed-off-by: Michael Loipführer --- changelog.d/5827.bugfix | 1 + .../vector/app/features/home/room/detail/TimelineViewModel.kt | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 changelog.d/5827.bugfix diff --git a/changelog.d/5827.bugfix b/changelog.d/5827.bugfix new file mode 100644 index 0000000000..0bd55e33ec --- /dev/null +++ b/changelog.d/5827.bugfix @@ -0,0 +1 @@ +Do not switch away from home space on notification when "Show all Rooms in Home" is selected. diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineViewModel.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineViewModel.kt index b79b55b248..1c55da2656 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineViewModel.kt @@ -207,7 +207,8 @@ class TimelineViewModel @AssistedInject constructor( appStateHandler.getCurrentRoomGroupingMethod()?.space().let { currentSpace -> val currentRoomSummary = room.roomSummary() ?: return@let // nothing we are good - if (currentSpace == null || !currentRoomSummary.flattenParentIds.contains(currentSpace.roomId)) { + if ((currentSpace == null && !vectorPreferences.prefSpacesShowAllRoomInHome()) + || (currentSpace != null && !currentRoomSummary.flattenParentIds.contains(currentSpace.roomId))) { // take first one or switch to home appStateHandler.setCurrentSpace( currentRoomSummary From 0250f61d10d4a0cb0963d35556d9ae322788d29c Mon Sep 17 00:00:00 2001 From: ericdecanini Date: Tue, 26 Apr 2022 15:48:34 +0200 Subject: [PATCH 009/457] Replaces izPublic with isPublic --- .../home/room/list/RoomSummaryItem.kt | 68 ++++++++++++++----- .../home/room/list/RoomSummaryItemFactory.kt | 2 +- 2 files changed, 51 insertions(+), 19 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryItem.kt b/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryItem.kt index 70c5846646..e5a4e374c9 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryItem.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryItem.kt @@ -45,24 +45,56 @@ import org.matrix.android.sdk.api.util.MatrixItem @EpoxyModelClass(layout = R.layout.item_room) abstract class RoomSummaryItem : VectorEpoxyModel() { - @EpoxyAttribute lateinit var typingMessage: String - @EpoxyAttribute lateinit var avatarRenderer: AvatarRenderer - @EpoxyAttribute lateinit var matrixItem: MatrixItem + @EpoxyAttribute + lateinit var typingMessage: String - @EpoxyAttribute lateinit var lastFormattedEvent: EpoxyCharSequence - @EpoxyAttribute lateinit var lastEventTime: String - @EpoxyAttribute var encryptionTrustLevel: RoomEncryptionTrustLevel? = null - @EpoxyAttribute var userPresence: UserPresence? = null - @EpoxyAttribute var showPresence: Boolean = false - @EpoxyAttribute var izPublic: Boolean = false - @EpoxyAttribute var unreadNotificationCount: Int = 0 - @EpoxyAttribute var hasUnreadMessage: Boolean = false - @EpoxyAttribute var hasDraft: Boolean = false - @EpoxyAttribute var showHighlighted: Boolean = false - @EpoxyAttribute var hasFailedSending: Boolean = false - @EpoxyAttribute(EpoxyAttribute.Option.DoNotHash) var itemLongClickListener: View.OnLongClickListener? = null - @EpoxyAttribute(EpoxyAttribute.Option.DoNotHash) var itemClickListener: ClickListener? = null - @EpoxyAttribute var showSelected: Boolean = false + @EpoxyAttribute + lateinit var avatarRenderer: AvatarRenderer + + @EpoxyAttribute + lateinit var matrixItem: MatrixItem + + @EpoxyAttribute + lateinit var lastFormattedEvent: EpoxyCharSequence + + @EpoxyAttribute + lateinit var lastEventTime: String + + @EpoxyAttribute + var encryptionTrustLevel: RoomEncryptionTrustLevel? = null + + @EpoxyAttribute + var userPresence: UserPresence? = null + + @EpoxyAttribute + var showPresence: Boolean = false + + @EpoxyAttribute @JvmField + var isPublic: Boolean = false + + @EpoxyAttribute + var unreadNotificationCount: Int = 0 + + @EpoxyAttribute + var hasUnreadMessage: Boolean = false + + @EpoxyAttribute + var hasDraft: Boolean = false + + @EpoxyAttribute + var showHighlighted: Boolean = false + + @EpoxyAttribute + var hasFailedSending: Boolean = false + + @EpoxyAttribute(EpoxyAttribute.Option.DoNotHash) + var itemLongClickListener: View.OnLongClickListener? = null + + @EpoxyAttribute(EpoxyAttribute.Option.DoNotHash) + var itemClickListener: ClickListener? = null + + @EpoxyAttribute + var showSelected: Boolean = false override fun bind(holder: Holder) { super.bind(holder) @@ -79,7 +111,7 @@ abstract class RoomSummaryItem : VectorEpoxyModel() { holder.draftView.isVisible = hasDraft avatarRenderer.render(matrixItem, holder.avatarImageView) holder.roomAvatarDecorationImageView.render(encryptionTrustLevel) - holder.roomAvatarPublicDecorationImageView.isVisible = izPublic + holder.roomAvatarPublicDecorationImageView.isVisible = isPublic holder.roomAvatarFailSendingImageView.isVisible = hasFailedSending renderSelection(holder, showSelected) holder.typingView.setTextOrHide(typingMessage) diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryItemFactory.kt b/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryItemFactory.kt index 6326d9c97a..cd3a8b0890 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryItemFactory.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryItemFactory.kt @@ -124,7 +124,7 @@ class RoomSummaryItemFactory @Inject constructor(private val displayableEventFor .avatarRenderer(avatarRenderer) // We do not display shield in the room list anymore // .encryptionTrustLevel(roomSummary.roomEncryptionTrustLevel) - .izPublic(roomSummary.isPublic) + .isPublic(roomSummary.isPublic) .showPresence(roomSummary.isDirect) .userPresence(roomSummary.directUserPresence) .matrixItem(roomSummary.toMatrixItem()) From a3367d4075f54a06f0d7601d3432ad1fef081aea Mon Sep 17 00:00:00 2001 From: ericdecanini Date: Tue, 26 Apr 2022 15:48:49 +0200 Subject: [PATCH 010/457] Replaces else cases in when branches to RoomListDisplayMode.FILTERED --- .../features/home/room/list/RoomListFragment.kt | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/RoomListFragment.kt b/vector/src/main/java/im/vector/app/features/home/room/list/RoomListFragment.kt index aaa469f68d..ef7a1012df 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/RoomListFragment.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/RoomListFragment.kt @@ -204,7 +204,7 @@ class RoomListFragment @Inject constructor( RoomListDisplayMode.NOTIFICATIONS -> views.createChatFabMenu.isVisible = true RoomListDisplayMode.PEOPLE -> views.createChatRoomButton.isVisible = true RoomListDisplayMode.ROOMS -> views.createGroupRoomButton.isVisible = true - else -> Unit // No button in this mode + RoomListDisplayMode.FILTERED -> Unit // No button in this mode } views.createChatRoomButton.debouncedClicks { @@ -230,7 +230,7 @@ class RoomListFragment @Inject constructor( RoomListDisplayMode.NOTIFICATIONS -> views.createChatFabMenu.hide() RoomListDisplayMode.PEOPLE -> views.createChatRoomButton.hide() RoomListDisplayMode.ROOMS -> views.createGroupRoomButton.hide() - else -> Unit + RoomListDisplayMode.FILTERED -> Unit } } } @@ -309,7 +309,7 @@ class RoomListFragment @Inject constructor( ) } } - section.isExpanded.observe(viewLifecycleOwner) { _ -> + section.isExpanded.observe(viewLifecycleOwner) { refreshCollapseStates() } controller.listener = this @@ -330,7 +330,7 @@ class RoomListFragment @Inject constructor( checkEmptyState() } observeItemCount(section, sectionAdapter) - section.isExpanded.observe(viewLifecycleOwner) { _ -> + section.isExpanded.observe(viewLifecycleOwner) { refreshCollapseStates() } controller.listener = this @@ -359,7 +359,7 @@ class RoomListFragment @Inject constructor( ) } } - section.isExpanded.observe(viewLifecycleOwner) { _ -> + section.isExpanded.observe(viewLifecycleOwner) { refreshCollapseStates() } controller.listener = this @@ -395,7 +395,7 @@ class RoomListFragment @Inject constructor( RoomListDisplayMode.NOTIFICATIONS -> views.createChatFabMenu.show() RoomListDisplayMode.PEOPLE -> views.createChatRoomButton.show() RoomListDisplayMode.ROOMS -> views.createGroupRoomButton.show() - else -> Unit + RoomListDisplayMode.FILTERED -> Unit } } } @@ -474,7 +474,8 @@ class RoomListFragment @Inject constructor( StateView.State.Empty( title = getString(R.string.room_list_catchup_empty_title), image = ContextCompat.getDrawable(requireContext(), R.drawable.ic_noun_party_popper), - message = getString(R.string.room_list_catchup_empty_body)) + message = getString(R.string.room_list_catchup_empty_body) + ) } RoomListDisplayMode.PEOPLE -> StateView.State.Empty( @@ -490,7 +491,7 @@ class RoomListFragment @Inject constructor( isBigImage = true, message = getString(R.string.room_list_rooms_empty_body) ) - else -> + RoomListDisplayMode.FILTERED -> // Always display the content in this mode, because if the footer StateView.State.Content } From 45afc044212ffb3a71818f8266c769d3e0d7496e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olive=CC=81r=20Falvai?= Date: Wed, 27 Apr 2022 20:24:57 +0200 Subject: [PATCH 011/457] Use fixed text size in read receipt counter --- vector/src/main/res/layout/view_read_receipts.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/vector/src/main/res/layout/view_read_receipts.xml b/vector/src/main/res/layout/view_read_receipts.xml index 907f1ec0e3..e8101ec28d 100644 --- a/vector/src/main/res/layout/view_read_receipts.xml +++ b/vector/src/main/res/layout/view_read_receipts.xml @@ -16,6 +16,8 @@ android:paddingStart="4dp" android:paddingEnd="4dp" android:textColor="?vctr_content_primary" + android:textSize="12dp" + tools:ignore="SpUsage" tools:text="999+" /> Date: Wed, 27 Apr 2022 20:34:03 +0200 Subject: [PATCH 012/457] Add changelog --- changelog.d/5856.bugfix | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/5856.bugfix diff --git a/changelog.d/5856.bugfix b/changelog.d/5856.bugfix new file mode 100644 index 0000000000..87f10ac9b2 --- /dev/null +++ b/changelog.d/5856.bugfix @@ -0,0 +1 @@ +Use fixed text size in read receipt counter From 9e53e6cc8f1ef6f0507d93c5961c342185d1a07e Mon Sep 17 00:00:00 2001 From: ericdecanini Date: Thu, 28 Apr 2022 10:41:40 +0200 Subject: [PATCH 013/457] Adds space name to rooms in filtered search --- .../relationship/RoomChildRelationInfo.kt | 16 ++-------- .../room/summary/RoomSummaryUpdater.kt | 29 ++++++++----------- .../list/CollapsableTypedEpoxyController.kt | 2 +- .../home/room/list/RoomListFragment.kt | 2 +- .../home/room/list/RoomSummaryItem.kt | 17 ++++++++++- .../home/room/list/RoomSummaryItemFactory.kt | 7 ++++- .../room/list/RoomSummaryListController.kt | 3 +- .../room/list/RoomSummaryPagedController.kt | 6 ++-- .../list/RoomSummaryPagedControllerFactory.kt | 5 ++-- .../features/share/IncomingShareController.kt | 3 +- vector/src/main/res/layout/item_room.xml | 3 +- 11 files changed, 52 insertions(+), 41 deletions(-) diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/relationship/RoomChildRelationInfo.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/relationship/RoomChildRelationInfo.kt index 5bad334afc..fffca96acf 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/relationship/RoomChildRelationInfo.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/relationship/RoomChildRelationInfo.kt @@ -43,7 +43,6 @@ internal class RoomChildRelationInfo( data class SpaceChildInfo( val roomId: String, val order: String?, -// val autoJoin: Boolean, val viaServers: List ) @@ -60,18 +59,13 @@ internal class RoomChildRelationInfo( fun getDirectChildrenDescriptions(): List { return CurrentStateEventEntity.whereType(realm, roomId, EventType.STATE_SPACE_CHILD) .findAll() -// .also { -// Timber.v("## Space: Found ${it.count()} m.space.child state events for $roomId") -// } .mapNotNull { ContentMapper.map(it.root?.content).toModel()?.let { scc -> -// Timber.v("## Space child desc state event $scc") // Children where via is not present are ignored. scc.via?.let { via -> SpaceChildInfo( roomId = it.stateKey, order = scc.validOrder(), -// autoJoin = scc.autoJoin ?: false, viaServers = via ) } @@ -83,17 +77,13 @@ internal class RoomChildRelationInfo( fun getParentDescriptions(): List { return CurrentStateEventEntity.whereType(realm, roomId, EventType.STATE_SPACE_PARENT) .findAll() -// .also { -// Timber.v("## Space: Found ${it.count()} m.space.parent state events for $roomId") -// } .mapNotNull { - ContentMapper.map(it.root?.content).toModel()?.let { scc -> -// Timber.v("## Space parent desc state event $scc") + ContentMapper.map(it.root?.content).toModel()?.let { spaceParentContent -> // Parent where via is not present are ignored. - scc.via?.let { via -> + spaceParentContent.via?.let { via -> SpaceParentInfo( roomId = it.stateKey, - canonical = scc.canonical ?: false, + canonical = spaceParentContent.canonical ?: false, viaServers = via, stateEventSender = it.root?.sender ?: "" ) 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 3af579d050..70c1453865 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 @@ -17,6 +17,7 @@ package org.matrix.android.sdk.internal.session.room.summary import io.realm.Realm +import io.realm.RealmList import io.realm.kotlin.createObject import kotlinx.coroutines.runBlocking import org.matrix.android.sdk.api.extensions.orFalse @@ -349,39 +350,34 @@ internal class RoomSummaryUpdater @Inject constructor( } val acyclicGraph = graph.withoutEdges(backEdges) -// Timber.v("## SPACES: acyclicGraph $acyclicGraph") val flattenSpaceParents = acyclicGraph.flattenDestination().map { it.key.name to it.value.map { it.name } }.toMap() -// Timber.v("## SPACES: flattenSpaceParents ${flattenSpaceParents.map { it.key.name to it.value.map { it.name } }.joinToString("\n") { -// it.first + ": [" + it.second.joinToString(",") + "]" -// }}") - -// Timber.v("## SPACES: lookup map ${lookupMap.map { it.key.name to it.value.map { it.name } }.toMap()}") lookupMap.entries .filter { it.key.roomType == RoomType.SPACE && it.key.membership == Membership.JOIN } .forEach { entry -> val parent = RoomSummaryEntity.where(realm, entry.key.roomId).findFirst() if (parent != null) { -// Timber.v("## SPACES: check hierarchy of ${parent.name} id ${parent.roomId}") -// Timber.v("## SPACES: flat known parents of ${parent.name} are ${flattenSpaceParents[parent.roomId]}") val flattenParentsIds = (flattenSpaceParents[parent.roomId] ?: emptyList()) + listOf(parent.roomId) -// Timber.v("## SPACES: flatten known parents of children of ${parent.name} are ${flattenParentsIds}") entry.value.forEach { child -> RoomSummaryEntity.where(realm, child.roomId).findFirst()?.let { childSum -> - -// Timber.w("## SPACES: ${childSum.name} is ${childSum.roomId} fc: ${childSum.flattenParentIds}") -// var allParents = childSum.flattenParentIds ?: "" + // TODO: Revisit + childSum.parents.add(SpaceParentSummaryEntity( + true, + parent.roomId, + parent, + RealmList() + )) if (childSum.flattenParentIds == null) childSum.flattenParentIds = "" flattenParentsIds.forEach { if (childSum.flattenParentIds?.contains(it) != true) { - childSum.flattenParentIds += "|$it" + if (childSum.flattenParentIds?.isEmpty() == false) { + childSum.flattenParentIds += "|" + } + childSum.flattenParentIds += it } } -// childSum.flattenParentIds = "$allParents|" - -// Timber.v("## SPACES: flatten of ${childSum.name} is ${childSum.flattenParentIds}") } } } @@ -411,7 +407,6 @@ internal class RoomSummaryUpdater @Inject constructor( // we keep real m.child/m.parent relations and add the one for common memberships dmRoom.flattenParentIds += "|${flattenRelated.joinToString("|")}|" } -// Timber.v("## SPACES: flatten of ${dmRoom.otherMemberIds.joinToString(",")} is ${dmRoom.flattenParentIds}") } // Maybe a good place to count the number of notifications for spaces? diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/CollapsableTypedEpoxyController.kt b/vector/src/main/java/im/vector/app/features/home/room/list/CollapsableTypedEpoxyController.kt index 8cf7e6bcab..35396d52d5 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/CollapsableTypedEpoxyController.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/CollapsableTypedEpoxyController.kt @@ -68,7 +68,7 @@ abstract class CollapsableTypedEpoxyController : } override fun buildModels() { - check(isBuildingModels()) { + check(isBuildingModels) { ("You cannot call `buildModels` directly. Call `setData` instead to trigger a model " + "refresh with new data.") } diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/RoomListFragment.kt b/vector/src/main/java/im/vector/app/features/home/room/list/RoomListFragment.kt index ef7a1012df..cabaf11b75 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/RoomListFragment.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/RoomListFragment.kt @@ -287,7 +287,7 @@ class RoomListFragment @Inject constructor( val contentAdapter = when { section.livePages != null -> { - pagedControllerFactory.createRoomSummaryPagedController() + pagedControllerFactory.createRoomSummaryPagedController(roomListParams.displayMode) .also { controller -> section.livePages.observe(viewLifecycleOwner) { pl -> controller.submitList(pl) diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryItem.kt b/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryItem.kt index e5a4e374c9..a869041aa8 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryItem.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryItem.kt @@ -36,6 +36,7 @@ import im.vector.app.core.ui.views.PresenceStateImageView import im.vector.app.core.ui.views.ShieldImageView import im.vector.app.features.displayname.getBestName import im.vector.app.features.home.AvatarRenderer +import im.vector.app.features.home.RoomListDisplayMode import im.vector.app.features.themes.ThemeUtils import im.vector.lib.core.utils.epoxy.charsequence.EpoxyCharSequence import org.matrix.android.sdk.api.session.crypto.model.RoomEncryptionTrustLevel @@ -54,6 +55,12 @@ abstract class RoomSummaryItem : VectorEpoxyModel() { @EpoxyAttribute lateinit var matrixItem: MatrixItem + @EpoxyAttribute + var displayMode: RoomListDisplayMode = RoomListDisplayMode.PEOPLE + + @EpoxyAttribute + var spaceName: String? = null + @EpoxyAttribute lateinit var lastFormattedEvent: EpoxyCharSequence @@ -105,7 +112,7 @@ abstract class RoomSummaryItem : VectorEpoxyModel() { } holder.titleView.text = matrixItem.getBestName() holder.lastEventTimeView.text = lastEventTime - holder.lastEventView.text = lastFormattedEvent.charSequence + holder.lastEventView.text = getTextForLastEventView() holder.unreadCounterBadgeView.render(UnreadCounterBadgeView.State(unreadNotificationCount, showHighlighted)) holder.unreadIndentIndicator.isVisible = hasUnreadMessage holder.draftView.isVisible = hasDraft @@ -119,6 +126,14 @@ abstract class RoomSummaryItem : VectorEpoxyModel() { holder.roomAvatarPresenceImageView.render(showPresence, userPresence) } + private fun getTextForLastEventView(): CharSequence { + return if (displayMode == RoomListDisplayMode.FILTERED) { + spaceName.orEmpty() // TODO: handle other cases + } else { + lastFormattedEvent.charSequence + } + } + override fun unbind(holder: Holder) { holder.rootView.setOnClickListener(null) holder.rootView.setOnLongClickListener(null) diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryItemFactory.kt b/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryItemFactory.kt index cd3a8b0890..f11f39e402 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryItemFactory.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryItemFactory.kt @@ -26,6 +26,7 @@ import im.vector.app.core.epoxy.VectorEpoxyModel import im.vector.app.core.error.ErrorFormatter import im.vector.app.core.resources.StringProvider import im.vector.app.features.home.AvatarRenderer +import im.vector.app.features.home.RoomListDisplayMode import im.vector.app.features.home.room.detail.timeline.format.DisplayableEventFormatter import im.vector.app.features.home.room.typing.TypingHelper import im.vector.lib.core.utils.epoxy.charsequence.toEpoxyCharSequence @@ -46,13 +47,14 @@ class RoomSummaryItemFactory @Inject constructor(private val displayableEventFor fun create(roomSummary: RoomSummary, roomChangeMembershipStates: Map, selectedRoomIds: Set, + displayMode: RoomListDisplayMode, listener: RoomListListener?): VectorEpoxyModel<*> { return when (roomSummary.membership) { Membership.INVITE -> { val changeMembershipState = roomChangeMembershipStates[roomSummary.roomId] ?: ChangeMembershipState.Unknown createInvitationItem(roomSummary, changeMembershipState, listener) } - else -> createRoomItem(roomSummary, selectedRoomIds, listener?.let { it::onRoomClicked }, listener?.let { it::onRoomLongClicked }) + else -> createRoomItem(roomSummary, selectedRoomIds, displayMode, listener?.let { it::onRoomClicked }, listener?.let { it::onRoomLongClicked }) } } @@ -105,6 +107,7 @@ class RoomSummaryItemFactory @Inject constructor(private val displayableEventFor fun createRoomItem( roomSummary: RoomSummary, selectedRoomIds: Set, + displayMode: RoomListDisplayMode, onClick: ((RoomSummary) -> Unit)?, onLongClick: ((RoomSummary) -> Boolean)? ): VectorEpoxyModel<*> { @@ -124,6 +127,8 @@ class RoomSummaryItemFactory @Inject constructor(private val displayableEventFor .avatarRenderer(avatarRenderer) // We do not display shield in the room list anymore // .encryptionTrustLevel(roomSummary.roomEncryptionTrustLevel) + .displayMode(displayMode) + .spaceName(roomSummary.spaceParents?.firstOrNull()?.roomSummary?.name.orEmpty()) .isPublic(roomSummary.isPublic) .showPresence(roomSummary.isDirect) .userPresence(roomSummary.directUserPresence) diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryListController.kt b/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryListController.kt index 75aaee45cb..683263dbbc 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryListController.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryListController.kt @@ -16,6 +16,7 @@ package im.vector.app.features.home.room.list +import im.vector.app.features.home.RoomListDisplayMode import org.matrix.android.sdk.api.session.room.model.RoomSummary class RoomSummaryListController( @@ -26,7 +27,7 @@ class RoomSummaryListController( override fun buildModels(data: List?) { data?.forEach { - add(roomSummaryItemFactory.create(it, emptyMap(), emptySet(), listener)) + add(roomSummaryItemFactory.create(it, emptyMap(), emptySet(), RoomListDisplayMode.ROOMS /* TODO: change */, listener)) } } } diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryPagedController.kt b/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryPagedController.kt index e9cbc69215..445438eec9 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryPagedController.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryPagedController.kt @@ -19,11 +19,13 @@ package im.vector.app.features.home.room.list import com.airbnb.epoxy.EpoxyModel import com.airbnb.epoxy.paging.PagedListEpoxyController import im.vector.app.core.utils.createUIHandler +import im.vector.app.features.home.RoomListDisplayMode import org.matrix.android.sdk.api.session.room.members.ChangeMembershipState import org.matrix.android.sdk.api.session.room.model.RoomSummary class RoomSummaryPagedController( - private val roomSummaryItemFactory: RoomSummaryItemFactory + private val roomSummaryItemFactory: RoomSummaryItemFactory, + private val displayMode: RoomListDisplayMode ) : PagedListEpoxyController( // Important it must match the PageList builder notify Looper modelBuildingHandler = createUIHandler() @@ -57,6 +59,6 @@ class RoomSummaryPagedController( override fun buildItemModel(currentPosition: Int, item: RoomSummary?): EpoxyModel<*> { // for place holder if enabled item ?: return RoomSummaryItemPlaceHolder_().apply { id(currentPosition) } - return roomSummaryItemFactory.create(item, roomChangeMembershipStates.orEmpty(), emptySet(), listener) + return roomSummaryItemFactory.create(item, roomChangeMembershipStates.orEmpty(), emptySet(), displayMode, listener) } } diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryPagedControllerFactory.kt b/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryPagedControllerFactory.kt index c86d8ab243..36f1b5ac90 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryPagedControllerFactory.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryPagedControllerFactory.kt @@ -16,14 +16,15 @@ package im.vector.app.features.home.room.list +import im.vector.app.features.home.RoomListDisplayMode import javax.inject.Inject class RoomSummaryPagedControllerFactory @Inject constructor( private val roomSummaryItemFactory: RoomSummaryItemFactory ) { - fun createRoomSummaryPagedController(): RoomSummaryPagedController { - return RoomSummaryPagedController(roomSummaryItemFactory) + fun createRoomSummaryPagedController(displayMode: RoomListDisplayMode): RoomSummaryPagedController { + return RoomSummaryPagedController(roomSummaryItemFactory, displayMode) } fun createRoomSummaryListController(): RoomSummaryListController { diff --git a/vector/src/main/java/im/vector/app/features/share/IncomingShareController.kt b/vector/src/main/java/im/vector/app/features/share/IncomingShareController.kt index fd35bf11a4..7c82b7aea0 100644 --- a/vector/src/main/java/im/vector/app/features/share/IncomingShareController.kt +++ b/vector/src/main/java/im/vector/app/features/share/IncomingShareController.kt @@ -22,6 +22,7 @@ import im.vector.app.R import im.vector.app.core.epoxy.loadingItem import im.vector.app.core.epoxy.noResultItem import im.vector.app.core.resources.StringProvider +import im.vector.app.features.home.RoomListDisplayMode import im.vector.app.features.home.room.list.RoomSummaryItemFactory import org.matrix.android.sdk.api.session.room.model.RoomSummary import javax.inject.Inject @@ -53,7 +54,7 @@ class IncomingShareController @Inject constructor(private val roomSummaryItemFac } else { roomSummaries.forEach { roomSummary -> roomSummaryItemFactory - .createRoomItem(roomSummary, data.selectedRoomIds, callback?.let { it::onRoomClicked }, callback?.let { it::onRoomLongClicked }) + .createRoomItem(roomSummary, data.selectedRoomIds, RoomListDisplayMode.ROOMS /* TODO: Change */, callback?.let { it::onRoomClicked }, callback?.let { it::onRoomLongClicked }) .addTo(this) } } diff --git a/vector/src/main/res/layout/item_room.xml b/vector/src/main/res/layout/item_room.xml index 2b27cb8efe..3911e8df34 100644 --- a/vector/src/main/res/layout/item_room.xml +++ b/vector/src/main/res/layout/item_room.xml @@ -213,7 +213,8 @@ app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="@id/roomNameView" app:layout_constraintTop_toBottomOf="@id/roomNameView" - tools:text="Alice is typing…" /> + tools:text="Alice is typing…" + tools:visibility="gone" /> Date: Thu, 28 Apr 2022 11:12:47 +0200 Subject: [PATCH 014/457] Adds user id and canonical alias to search result subtitles --- .../app/features/home/room/list/RoomSummaryItem.kt | 10 +++++----- .../home/room/list/RoomSummaryItemFactory.kt | 12 +++++++++++- vector/src/main/res/layout/item_room.xml | 4 ++-- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryItem.kt b/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryItem.kt index a869041aa8..3c091d0e05 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryItem.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryItem.kt @@ -59,7 +59,7 @@ abstract class RoomSummaryItem : VectorEpoxyModel() { var displayMode: RoomListDisplayMode = RoomListDisplayMode.PEOPLE @EpoxyAttribute - var spaceName: String? = null + lateinit var subtitle: String @EpoxyAttribute lateinit var lastFormattedEvent: EpoxyCharSequence @@ -112,7 +112,7 @@ abstract class RoomSummaryItem : VectorEpoxyModel() { } holder.titleView.text = matrixItem.getBestName() holder.lastEventTimeView.text = lastEventTime - holder.lastEventView.text = getTextForLastEventView() + holder.subtitleView.text = getTextForLastEventView() holder.unreadCounterBadgeView.render(UnreadCounterBadgeView.State(unreadNotificationCount, showHighlighted)) holder.unreadIndentIndicator.isVisible = hasUnreadMessage holder.draftView.isVisible = hasDraft @@ -122,13 +122,13 @@ abstract class RoomSummaryItem : VectorEpoxyModel() { holder.roomAvatarFailSendingImageView.isVisible = hasFailedSending renderSelection(holder, showSelected) holder.typingView.setTextOrHide(typingMessage) - holder.lastEventView.isInvisible = holder.typingView.isVisible + holder.subtitleView.isInvisible = holder.typingView.isVisible holder.roomAvatarPresenceImageView.render(showPresence, userPresence) } private fun getTextForLastEventView(): CharSequence { return if (displayMode == RoomListDisplayMode.FILTERED) { - spaceName.orEmpty() // TODO: handle other cases + subtitle } else { lastFormattedEvent.charSequence } @@ -157,7 +157,7 @@ abstract class RoomSummaryItem : VectorEpoxyModel() { val titleView by bind(R.id.roomNameView) val unreadCounterBadgeView by bind(R.id.roomUnreadCounterBadgeView) val unreadIndentIndicator by bind(R.id.roomUnreadIndicator) - val lastEventView by bind(R.id.roomLastEventView) + val subtitleView by bind(R.id.subtitleView) val typingView by bind(R.id.roomTypingView) val draftView by bind(R.id.roomDraftBadge) val lastEventTimeView by bind(R.id.roomLastEventTimeView) diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryItemFactory.kt b/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryItemFactory.kt index f11f39e402..cc99c0eb6e 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryItemFactory.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryItemFactory.kt @@ -111,6 +111,7 @@ class RoomSummaryItemFactory @Inject constructor(private val displayableEventFor onClick: ((RoomSummary) -> Unit)?, onLongClick: ((RoomSummary) -> Boolean)? ): VectorEpoxyModel<*> { + val subtitle = getSearchResultSubtitle(roomSummary) val unreadCount = roomSummary.notificationCount val showHighlighted = roomSummary.highlightCount > 0 val showSelected = selectedRoomIds.contains(roomSummary.roomId) @@ -121,6 +122,7 @@ class RoomSummaryItemFactory @Inject constructor(private val displayableEventFor latestFormattedEvent = displayableEventFormatter.format(latestEvent, roomSummary.isDirect, roomSummary.isDirect.not()) latestEventTime = dateFormatter.format(latestEvent.root.originServerTs, DateFormatKind.ROOM_LIST) } + val typingMessage = typingHelper.getTypingMessage(roomSummary.typingUsers) return RoomSummaryItem_() .id(roomSummary.roomId) @@ -128,7 +130,7 @@ class RoomSummaryItemFactory @Inject constructor(private val displayableEventFor // We do not display shield in the room list anymore // .encryptionTrustLevel(roomSummary.roomEncryptionTrustLevel) .displayMode(displayMode) - .spaceName(roomSummary.spaceParents?.firstOrNull()?.roomSummary?.name.orEmpty()) + .subtitle(subtitle) .isPublic(roomSummary.isPublic) .showPresence(roomSummary.isDirect) .userPresence(roomSummary.directUserPresence) @@ -147,4 +149,12 @@ class RoomSummaryItemFactory @Inject constructor(private val displayableEventFor } .itemClickListener { onClick?.invoke(roomSummary) } } + + private fun getSearchResultSubtitle(roomSummary: RoomSummary): String { + val spaceName = roomSummary.spaceParents?.firstOrNull()?.roomSummary?.name + val userId = roomSummary.directUserId + val canonicalAlias = roomSummary.canonicalAlias + + return (spaceName ?: userId ?: canonicalAlias).orEmpty() + } } diff --git a/vector/src/main/res/layout/item_room.xml b/vector/src/main/res/layout/item_room.xml index 3911e8df34..ab0af18acb 100644 --- a/vector/src/main/res/layout/item_room.xml +++ b/vector/src/main/res/layout/item_room.xml @@ -183,7 +183,7 @@ tools:text="@tools:sample/date/hhmm" /> Date: Thu, 28 Apr 2022 11:46:02 +0200 Subject: [PATCH 015/457] Disables typing indicator in filtered search --- .../app/features/home/room/list/RoomSummaryItem.kt | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryItem.kt b/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryItem.kt index 3c091d0e05..e0547b87b1 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryItem.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryItem.kt @@ -121,9 +121,16 @@ abstract class RoomSummaryItem : VectorEpoxyModel() { holder.roomAvatarPublicDecorationImageView.isVisible = isPublic holder.roomAvatarFailSendingImageView.isVisible = hasFailedSending renderSelection(holder, showSelected) - holder.typingView.setTextOrHide(typingMessage) - holder.subtitleView.isInvisible = holder.typingView.isVisible holder.roomAvatarPresenceImageView.render(showPresence, userPresence) + showTypingViewIfNecessary(holder) + + } + + private fun showTypingViewIfNecessary(holder: Holder) { + if (displayMode != RoomListDisplayMode.FILTERED) { + holder.typingView.setTextOrHide(typingMessage) + holder.subtitleView.isInvisible = holder.typingView.isVisible + } } private fun getTextForLastEventView(): CharSequence { From 33475602f865d339c3119cb7e137c5c02aa4e9c5 Mon Sep 17 00:00:00 2001 From: ericdecanini Date: Thu, 28 Apr 2022 11:54:51 +0200 Subject: [PATCH 016/457] Adds canonical named argument to RoomSummaryUpdater --- .../sdk/internal/session/room/summary/RoomSummaryUpdater.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 70c1453865..1c1963bfd4 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 @@ -364,7 +364,7 @@ internal class RoomSummaryUpdater @Inject constructor( RoomSummaryEntity.where(realm, child.roomId).findFirst()?.let { childSum -> // TODO: Revisit childSum.parents.add(SpaceParentSummaryEntity( - true, + canonical = true, parent.roomId, parent, RealmList() From b28035807788e1ac40a1586a24b2a9b79046c4c7 Mon Sep 17 00:00:00 2001 From: ericdecanini Date: Thu, 28 Apr 2022 11:55:44 +0200 Subject: [PATCH 017/457] Adds more named arguments to RoomSummaryUpdater --- .../sdk/internal/session/room/summary/RoomSummaryUpdater.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 1c1963bfd4..81979c6926 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 @@ -365,9 +365,9 @@ internal class RoomSummaryUpdater @Inject constructor( // TODO: Revisit childSum.parents.add(SpaceParentSummaryEntity( canonical = true, - parent.roomId, - parent, - RealmList() + parentRoomId = parent.roomId, + parentSummaryEntity = parent, + viaServers = RealmList() )) if (childSum.flattenParentIds == null) childSum.flattenParentIds = "" flattenParentsIds.forEach { From 4784717b0cecab67d03731daaa4dc32f58ef8e1d Mon Sep 17 00:00:00 2001 From: ericdecanini Date: Thu, 28 Apr 2022 12:02:04 +0200 Subject: [PATCH 018/457] Fixes lint error --- .../im/vector/app/features/home/room/list/RoomSummaryItem.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryItem.kt b/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryItem.kt index e0547b87b1..aa459afd3b 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryItem.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryItem.kt @@ -123,7 +123,6 @@ abstract class RoomSummaryItem : VectorEpoxyModel() { renderSelection(holder, showSelected) holder.roomAvatarPresenceImageView.render(showPresence, userPresence) showTypingViewIfNecessary(holder) - } private fun showTypingViewIfNecessary(holder: Holder) { From 962e9abc6bea1bfd0efa9105fd0db072b6f48a67 Mon Sep 17 00:00:00 2001 From: ericdecanini Date: Thu, 28 Apr 2022 12:04:54 +0200 Subject: [PATCH 019/457] Fixes lint error --- .../app/features/home/room/list/RoomSummaryItemFactory.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryItemFactory.kt b/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryItemFactory.kt index cc99c0eb6e..f9f61f730b 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryItemFactory.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryItemFactory.kt @@ -54,7 +54,9 @@ class RoomSummaryItemFactory @Inject constructor(private val displayableEventFor val changeMembershipState = roomChangeMembershipStates[roomSummary.roomId] ?: ChangeMembershipState.Unknown createInvitationItem(roomSummary, changeMembershipState, listener) } - else -> createRoomItem(roomSummary, selectedRoomIds, displayMode, listener?.let { it::onRoomClicked }, listener?.let { it::onRoomLongClicked }) + else -> createRoomItem( + roomSummary, selectedRoomIds, displayMode, listener?.let { it::onRoomClicked }, listener?.let { it::onRoomLongClicked } + ) } } From 7e415e82b099dcb5111caffb05d1577f843fc3f8 Mon Sep 17 00:00:00 2001 From: ericdecanini Date: Thu, 28 Apr 2022 12:37:54 +0200 Subject: [PATCH 020/457] Fixes lint error --- .../vector/app/features/share/IncomingShareController.kt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/vector/src/main/java/im/vector/app/features/share/IncomingShareController.kt b/vector/src/main/java/im/vector/app/features/share/IncomingShareController.kt index 7c82b7aea0..6926a54cc4 100644 --- a/vector/src/main/java/im/vector/app/features/share/IncomingShareController.kt +++ b/vector/src/main/java/im/vector/app/features/share/IncomingShareController.kt @@ -54,7 +54,13 @@ class IncomingShareController @Inject constructor(private val roomSummaryItemFac } else { roomSummaries.forEach { roomSummary -> roomSummaryItemFactory - .createRoomItem(roomSummary, data.selectedRoomIds, RoomListDisplayMode.ROOMS /* TODO: Change */, callback?.let { it::onRoomClicked }, callback?.let { it::onRoomLongClicked }) + .createRoomItem( + roomSummary, + data.selectedRoomIds, + RoomListDisplayMode.ROOMS /* TODO: Change */, + callback?.let { it::onRoomClicked }, + callback?.let { it::onRoomLongClicked } + ) .addTo(this) } } From 042ec3628fc7caed9c15a936036f36a2ef64f79a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olive=CC=81r=20Falvai?= Date: Thu, 28 Apr 2022 19:02:48 +0200 Subject: [PATCH 021/457] Extract text size to style --- library/ui-styles/src/main/res/values/styles_timeline.xml | 7 +++++-- vector/src/main/res/layout/view_read_receipts.xml | 4 +--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/library/ui-styles/src/main/res/values/styles_timeline.xml b/library/ui-styles/src/main/res/values/styles_timeline.xml index c86eeb8efb..20c375c2d6 100644 --- a/library/ui-styles/src/main/res/values/styles_timeline.xml +++ b/library/ui-styles/src/main/res/values/styles_timeline.xml @@ -1,5 +1,5 @@ - + + - \ No newline at end of file + diff --git a/vector/src/main/res/layout/view_read_receipts.xml b/vector/src/main/res/layout/view_read_receipts.xml index e8101ec28d..11fdeb74d5 100644 --- a/vector/src/main/res/layout/view_read_receipts.xml +++ b/vector/src/main/res/layout/view_read_receipts.xml @@ -7,7 +7,7 @@ Date: Fri, 29 Apr 2022 12:37:19 +0200 Subject: [PATCH 022/457] Refactors RoomSummaryItem --- .../home/room/list/RoomSummaryItem.kt | 30 ++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryItem.kt b/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryItem.kt index aa459afd3b..4cea812775 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryItem.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryItem.kt @@ -105,14 +105,14 @@ abstract class RoomSummaryItem : VectorEpoxyModel() { override fun bind(holder: Holder) { super.bind(holder) + + renderDisplayMode(holder) holder.rootView.onClick(itemClickListener) holder.rootView.setOnLongClickListener { it.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS) itemLongClickListener?.onLongClick(it) ?: false } holder.titleView.text = matrixItem.getBestName() - holder.lastEventTimeView.text = lastEventTime - holder.subtitleView.text = getTextForLastEventView() holder.unreadCounterBadgeView.render(UnreadCounterBadgeView.State(unreadNotificationCount, showHighlighted)) holder.unreadIndentIndicator.isVisible = hasUnreadMessage holder.draftView.isVisible = hasDraft @@ -122,22 +122,24 @@ abstract class RoomSummaryItem : VectorEpoxyModel() { holder.roomAvatarFailSendingImageView.isVisible = hasFailedSending renderSelection(holder, showSelected) holder.roomAvatarPresenceImageView.render(showPresence, userPresence) - showTypingViewIfNecessary(holder) } - private fun showTypingViewIfNecessary(holder: Holder) { - if (displayMode != RoomListDisplayMode.FILTERED) { - holder.typingView.setTextOrHide(typingMessage) - holder.subtitleView.isInvisible = holder.typingView.isVisible - } + private fun renderDisplayMode(holder: Holder) = when (displayMode) { + RoomListDisplayMode.ROOMS, + RoomListDisplayMode.PEOPLE, + RoomListDisplayMode.NOTIFICATIONS -> renderForDefaultDisplayMode(holder) + RoomListDisplayMode.FILTERED -> renderForFilteredDisplayMode(holder) } - private fun getTextForLastEventView(): CharSequence { - return if (displayMode == RoomListDisplayMode.FILTERED) { - subtitle - } else { - lastFormattedEvent.charSequence - } + private fun renderForDefaultDisplayMode(holder: Holder) { + holder.subtitleView.text = lastFormattedEvent.charSequence + holder.lastEventTimeView.text = lastEventTime + } + + private fun renderForFilteredDisplayMode(holder: Holder) { + holder.subtitleView.text = subtitle + holder.typingView.setTextOrHide(typingMessage) + holder.subtitleView.isInvisible = holder.typingView.isVisible } override fun unbind(holder: Holder) { From a355b625e9dd671af000970963eb4406f270faa0 Mon Sep 17 00:00:00 2001 From: ericdecanini Date: Fri, 29 Apr 2022 13:05:08 +0200 Subject: [PATCH 023/457] Adds displayMode to RoomSummaryListController --- .../vector/app/features/home/room/list/RoomListFragment.kt | 2 +- .../app/features/home/room/list/RoomSummaryListController.kt | 5 +++-- .../home/room/list/RoomSummaryPagedControllerFactory.kt | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/RoomListFragment.kt b/vector/src/main/java/im/vector/app/features/home/room/list/RoomListFragment.kt index cabaf11b75..65055346e6 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/RoomListFragment.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/RoomListFragment.kt @@ -337,7 +337,7 @@ class RoomListFragment @Inject constructor( } } else -> { - pagedControllerFactory.createRoomSummaryListController() + pagedControllerFactory.createRoomSummaryListController(roomListParams.displayMode) .also { controller -> section.liveList?.observe(viewLifecycleOwner) { list -> controller.setData(list) diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryListController.kt b/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryListController.kt index 683263dbbc..2eb8921fd5 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryListController.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryListController.kt @@ -20,14 +20,15 @@ import im.vector.app.features.home.RoomListDisplayMode import org.matrix.android.sdk.api.session.room.model.RoomSummary class RoomSummaryListController( - private val roomSummaryItemFactory: RoomSummaryItemFactory + private val roomSummaryItemFactory: RoomSummaryItemFactory, + private val displayMode: RoomListDisplayMode ) : CollapsableTypedEpoxyController>() { var listener: RoomListListener? = null override fun buildModels(data: List?) { data?.forEach { - add(roomSummaryItemFactory.create(it, emptyMap(), emptySet(), RoomListDisplayMode.ROOMS /* TODO: change */, listener)) + add(roomSummaryItemFactory.create(it, emptyMap(), emptySet(), displayMode, listener)) } } } diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryPagedControllerFactory.kt b/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryPagedControllerFactory.kt index 36f1b5ac90..f72698048d 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryPagedControllerFactory.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryPagedControllerFactory.kt @@ -27,8 +27,8 @@ class RoomSummaryPagedControllerFactory @Inject constructor( return RoomSummaryPagedController(roomSummaryItemFactory, displayMode) } - fun createRoomSummaryListController(): RoomSummaryListController { - return RoomSummaryListController(roomSummaryItemFactory) + fun createRoomSummaryListController(displayMode: RoomListDisplayMode): RoomSummaryListController { + return RoomSummaryListController(roomSummaryItemFactory, displayMode) } fun createSuggestedRoomListController(): SuggestedRoomListController { From f70a24d257f6e28c9c6c3cd5216b52293d1af410 Mon Sep 17 00:00:00 2001 From: ericdecanini Date: Fri, 29 Apr 2022 13:18:46 +0200 Subject: [PATCH 024/457] Changes IncomingShareController display mode to FILTERED --- .../im/vector/app/features/share/IncomingShareController.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vector/src/main/java/im/vector/app/features/share/IncomingShareController.kt b/vector/src/main/java/im/vector/app/features/share/IncomingShareController.kt index 6926a54cc4..bf5cedd5da 100644 --- a/vector/src/main/java/im/vector/app/features/share/IncomingShareController.kt +++ b/vector/src/main/java/im/vector/app/features/share/IncomingShareController.kt @@ -57,7 +57,7 @@ class IncomingShareController @Inject constructor(private val roomSummaryItemFac .createRoomItem( roomSummary, data.selectedRoomIds, - RoomListDisplayMode.ROOMS /* TODO: Change */, + RoomListDisplayMode.FILTERED, callback?.let { it::onRoomClicked }, callback?.let { it::onRoomLongClicked } ) From 47493fcfa135ab6464fda974a45d9bd164ee5222 Mon Sep 17 00:00:00 2001 From: ericdecanini Date: Mon, 2 May 2022 14:11:17 +0200 Subject: [PATCH 025/457] Replaces method for getting the space parents of rooms --- .../session/room/summary/RoomSummaryDataSource.kt | 13 +++++++++++++ .../session/room/summary/RoomSummaryUpdater.kt | 8 -------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/summary/RoomSummaryDataSource.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/summary/RoomSummaryDataSource.kt index 18a4f80547..a84f9aa7d6 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/summary/RoomSummaryDataSource.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/summary/RoomSummaryDataSource.kt @@ -37,6 +37,7 @@ import org.matrix.android.sdk.api.session.room.UpdatableLivePageResult import org.matrix.android.sdk.api.session.room.model.Membership 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.SpaceParentInfo import org.matrix.android.sdk.api.session.room.roomSummaryQueryParams import org.matrix.android.sdk.api.session.room.spaceSummaryQueryParams import org.matrix.android.sdk.api.session.room.summary.RoomAggregateNotificationCount @@ -197,6 +198,18 @@ internal class RoomSummaryDataSource @Inject constructor( } val dataSourceFactory = realmDataSourceFactory.map { roomSummaryMapper.map(it) + }.map { roomSummary -> + val parents = roomSummary.flattenParentIds.mapNotNull { parentId -> + getRoomSummary(parentId)?.let { parentSummary -> + SpaceParentInfo( + parentId = parentSummary.flattenParentIds.firstOrNull(), + roomSummary = parentSummary, + canonical = true, + viaServers = emptyList() + ) + } + } + roomSummary.copy(spaceParents = parents) } val boundaries = MutableLiveData(ResultBoundaries()) 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 81979c6926..4a9f6c44c9 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 @@ -17,7 +17,6 @@ package org.matrix.android.sdk.internal.session.room.summary import io.realm.Realm -import io.realm.RealmList import io.realm.kotlin.createObject import kotlinx.coroutines.runBlocking import org.matrix.android.sdk.api.extensions.orFalse @@ -362,13 +361,6 @@ internal class RoomSummaryUpdater @Inject constructor( val flattenParentsIds = (flattenSpaceParents[parent.roomId] ?: emptyList()) + listOf(parent.roomId) entry.value.forEach { child -> RoomSummaryEntity.where(realm, child.roomId).findFirst()?.let { childSum -> - // TODO: Revisit - childSum.parents.add(SpaceParentSummaryEntity( - canonical = true, - parentRoomId = parent.roomId, - parentSummaryEntity = parent, - viaServers = RealmList() - )) if (childSum.flattenParentIds == null) childSum.flattenParentIds = "" flattenParentsIds.forEach { if (childSum.flattenParentIds?.contains(it) != true) { From c9b32fec44515b26f4815f41a10dafc738e3c7d6 Mon Sep 17 00:00:00 2001 From: ericdecanini Date: Mon, 2 May 2022 14:42:56 +0200 Subject: [PATCH 026/457] Changes ordering of room subtitles used --- .../room/summary/RoomSummaryUpdater.kt | 21 +++++++++++++++---- .../home/room/list/RoomSummaryItemFactory.kt | 4 ++-- 2 files changed, 19 insertions(+), 6 deletions(-) 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 4a9f6c44c9..3af579d050 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 @@ -349,27 +349,39 @@ internal class RoomSummaryUpdater @Inject constructor( } val acyclicGraph = graph.withoutEdges(backEdges) +// Timber.v("## SPACES: acyclicGraph $acyclicGraph") val flattenSpaceParents = acyclicGraph.flattenDestination().map { it.key.name to it.value.map { it.name } }.toMap() +// Timber.v("## SPACES: flattenSpaceParents ${flattenSpaceParents.map { it.key.name to it.value.map { it.name } }.joinToString("\n") { +// it.first + ": [" + it.second.joinToString(",") + "]" +// }}") + +// Timber.v("## SPACES: lookup map ${lookupMap.map { it.key.name to it.value.map { it.name } }.toMap()}") lookupMap.entries .filter { it.key.roomType == RoomType.SPACE && it.key.membership == Membership.JOIN } .forEach { entry -> val parent = RoomSummaryEntity.where(realm, entry.key.roomId).findFirst() if (parent != null) { +// Timber.v("## SPACES: check hierarchy of ${parent.name} id ${parent.roomId}") +// Timber.v("## SPACES: flat known parents of ${parent.name} are ${flattenSpaceParents[parent.roomId]}") val flattenParentsIds = (flattenSpaceParents[parent.roomId] ?: emptyList()) + listOf(parent.roomId) +// Timber.v("## SPACES: flatten known parents of children of ${parent.name} are ${flattenParentsIds}") entry.value.forEach { child -> RoomSummaryEntity.where(realm, child.roomId).findFirst()?.let { childSum -> + +// Timber.w("## SPACES: ${childSum.name} is ${childSum.roomId} fc: ${childSum.flattenParentIds}") +// var allParents = childSum.flattenParentIds ?: "" if (childSum.flattenParentIds == null) childSum.flattenParentIds = "" flattenParentsIds.forEach { if (childSum.flattenParentIds?.contains(it) != true) { - if (childSum.flattenParentIds?.isEmpty() == false) { - childSum.flattenParentIds += "|" - } - childSum.flattenParentIds += it + childSum.flattenParentIds += "|$it" } } +// childSum.flattenParentIds = "$allParents|" + +// Timber.v("## SPACES: flatten of ${childSum.name} is ${childSum.flattenParentIds}") } } } @@ -399,6 +411,7 @@ internal class RoomSummaryUpdater @Inject constructor( // we keep real m.child/m.parent relations and add the one for common memberships dmRoom.flattenParentIds += "|${flattenRelated.joinToString("|")}|" } +// Timber.v("## SPACES: flatten of ${dmRoom.otherMemberIds.joinToString(",")} is ${dmRoom.flattenParentIds}") } // Maybe a good place to count the number of notifications for spaces? diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryItemFactory.kt b/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryItemFactory.kt index f9f61f730b..05701b908f 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryItemFactory.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryItemFactory.kt @@ -153,10 +153,10 @@ class RoomSummaryItemFactory @Inject constructor(private val displayableEventFor } private fun getSearchResultSubtitle(roomSummary: RoomSummary): String { - val spaceName = roomSummary.spaceParents?.firstOrNull()?.roomSummary?.name val userId = roomSummary.directUserId + val spaceName = roomSummary.spaceParents?.firstOrNull()?.roomSummary?.name val canonicalAlias = roomSummary.canonicalAlias - return (spaceName ?: userId ?: canonicalAlias).orEmpty() + return (userId ?: spaceName ?: canonicalAlias).orEmpty() } } From b46794d4df2e863ef1799da1c1ae3e154ce49751 Mon Sep 17 00:00:00 2001 From: ericdecanini Date: Mon, 2 May 2022 14:44:23 +0200 Subject: [PATCH 027/457] Adds changelog file --- changelog.d/5860.feature | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/5860.feature diff --git a/changelog.d/5860.feature b/changelog.d/5860.feature new file mode 100644 index 0000000000..6c34fa0905 --- /dev/null +++ b/changelog.d/5860.feature @@ -0,0 +1 @@ +Adds space or user id as a subtitle under rooms in search From 133d1972a370939438c9011d294b97f4801674b9 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Thu, 17 Feb 2022 21:21:30 +0100 Subject: [PATCH 028/457] Check more modules --- tools/check/check_code_quality.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/check/check_code_quality.sh b/tools/check/check_code_quality.sh index e40d3635e8..910616176c 100755 --- a/tools/check/check_code_quality.sh +++ b/tools/check/check_code_quality.sh @@ -67,6 +67,9 @@ echo "Search for forbidden patterns in code..." ${searchForbiddenStringsScript} ./tools/check/forbidden_strings_in_code.txt \ ./matrix-sdk-android/src/main/java \ ./matrix-sdk-android-flow/src/main/java \ + ./library/core-utils/src/main/java \ + ./library/jsonviewer/src/main/java \ + ./library/ui-styles/src/main/java \ ./vector/src/main/java \ ./vector/src/debug/java \ ./vector/src/release/java \ @@ -100,6 +103,7 @@ echo echo "Search for forbidden patterns in resources..." ${searchForbiddenStringsScript} ./tools/check/forbidden_strings_in_resources.txt \ + ./library/ui-styles/src/main/res/values \ ./vector/src/main/res/color \ ./vector/src/main/res/layout \ ./vector/src/main/res/values \ From 26edf79aa2fbc824c3537ab1dbacc0999021967f Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Thu, 17 Feb 2022 21:25:09 +0100 Subject: [PATCH 029/457] Fix detected issues --- .../src/main/java/org/billcarsonfr/jsonviewer/ValueItem.kt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/library/jsonviewer/src/main/java/org/billcarsonfr/jsonviewer/ValueItem.kt b/library/jsonviewer/src/main/java/org/billcarsonfr/jsonviewer/ValueItem.kt index fac7099b37..66dfcc5dc3 100644 --- a/library/jsonviewer/src/main/java/org/billcarsonfr/jsonviewer/ValueItem.kt +++ b/library/jsonviewer/src/main/java/org/billcarsonfr/jsonviewer/ValueItem.kt @@ -18,11 +18,11 @@ package org.billcarsonfr.jsonviewer import android.content.ClipData import android.content.ClipboardManager -import android.content.Context import android.view.ContextMenu import android.view.View import android.widget.LinearLayout import android.widget.TextView +import androidx.core.content.getSystemService import com.airbnb.epoxy.EpoxyAttribute import com.airbnb.epoxy.EpoxyHolder import com.airbnb.epoxy.EpoxyModelClass @@ -77,8 +77,7 @@ internal abstract class ValueItem : EpoxyModelWithHolder() { ) { if (copyValue != null) { val menuItem = menu?.add(R.string.copy_value) - val clipService = - v?.context?.getSystemService(Context.CLIPBOARD_SERVICE) as? ClipboardManager + val clipService = v?.context?.getSystemService() menuItem?.setOnMenuItemClickListener { clipService?.setPrimaryClip(ClipData.newPlainText("", copyValue)) true From e45c79378f04639ba19380f6068381ff04b8045b Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Thu, 17 Feb 2022 21:39:49 +0100 Subject: [PATCH 030/457] Use fatalError and add missing `return` statement --- .../java/im/vector/app/core/platform/VectorBaseActivity.kt | 7 ++----- .../im/vector/app/features/navigation/DefaultNavigator.kt | 1 + 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/vector/src/main/java/im/vector/app/core/platform/VectorBaseActivity.kt b/vector/src/main/java/im/vector/app/core/platform/VectorBaseActivity.kt index febcfc5ef2..e90c1954c4 100644 --- a/vector/src/main/java/im/vector/app/core/platform/VectorBaseActivity.kt +++ b/vector/src/main/java/im/vector/app/core/platform/VectorBaseActivity.kt @@ -55,6 +55,7 @@ import im.vector.app.core.di.ActiveSessionHolder import im.vector.app.core.di.ActivityEntryPoint import im.vector.app.core.dialogs.DialogLocker import im.vector.app.core.dialogs.UnrecognizedCertificateDialog +import im.vector.app.core.error.fatalError import im.vector.app.core.extensions.observeEvent import im.vector.app.core.extensions.observeNotNull import im.vector.app.core.extensions.registerStartForActivityResult @@ -608,11 +609,7 @@ abstract class VectorBaseActivity : AppCompatActivity(), Maver } }.show() } else { - if (vectorPreferences.failFast()) { - error("No CoordinatorLayout to display this snackbar!") - } else { - Timber.w("No CoordinatorLayout to display this snackbar!") - } + fatalError("No CoordinatorLayout to display this snackbar!", vectorPreferences.failFast()) } } diff --git a/vector/src/main/java/im/vector/app/features/navigation/DefaultNavigator.kt b/vector/src/main/java/im/vector/app/features/navigation/DefaultNavigator.kt index 94aee1ba1a..1e33f2224b 100644 --- a/vector/src/main/java/im/vector/app/features/navigation/DefaultNavigator.kt +++ b/vector/src/main/java/im/vector/app/features/navigation/DefaultNavigator.kt @@ -316,6 +316,7 @@ class DefaultNavigator @Inject constructor( if (context is AppCompatActivity) { if (context !is MatrixToBottomSheet.InteractionListener) { fatalError("Caller context should implement MatrixToBottomSheet.InteractionListener", vectorPreferences.failFast()) + return } // TODO check if there is already one?? MatrixToBottomSheet.withLink(link, origin) From 90aad44edfc6beafe151c66dbeb2ca2db1bcc5f6 Mon Sep 17 00:00:00 2001 From: Maxime NATUREL Date: Fri, 29 Apr 2022 16:28:34 +0200 Subject: [PATCH 031/457] Adding live location summary data into MessageInformationData --- .../helper/MessageInformationDataFactory.kt | 17 ++++++++++++++--- .../timeline/item/MessageInformationData.kt | 12 +++++++++++- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/helper/MessageInformationDataFactory.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/helper/MessageInformationDataFactory.kt index f882840eee..8fb7aea7e4 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/helper/MessageInformationDataFactory.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/helper/MessageInformationDataFactory.kt @@ -21,6 +21,7 @@ import im.vector.app.core.date.VectorDateFormatter import im.vector.app.core.extensions.localDateTime import im.vector.app.features.home.room.detail.timeline.factory.TimelineItemFactoryParams import im.vector.app.features.home.room.detail.timeline.item.E2EDecoration +import im.vector.app.features.home.room.detail.timeline.item.LiveLocationShareSummaryData import im.vector.app.features.home.room.detail.timeline.item.MessageInformationData import im.vector.app.features.home.room.detail.timeline.item.PollResponseData import im.vector.app.features.home.room.detail.timeline.item.PollVoteSummaryData @@ -44,8 +45,7 @@ import org.matrix.android.sdk.api.session.room.timeline.hasBeenEdited import javax.inject.Inject /** - * TODO Update this comment - * This class compute if data of an event (such has avatar, display name, ...) should be displayed, depending on the previous event in the timeline + * This class is responsible of building extra information data associated to a given event. */ class MessageInformationDataFactory @Inject constructor(private val session: Session, private val dateFormatter: VectorDateFormatter, @@ -119,7 +119,8 @@ class MessageInformationDataFactory @Inject constructor(private val session: Ses isFirstFromThisSender = isFirstFromThisSender, isLastFromThisSender = isLastFromThisSender, e2eDecoration = e2eDecoration, - sendStateDecoration = sendStateDecoration + sendStateDecoration = sendStateDecoration, + liveLocationShareSummaryData = getLiveLocationShareSummaryData(event) ) } @@ -188,6 +189,16 @@ class MessageInformationDataFactory @Inject constructor(private val session: Ses } } + private fun getLiveLocationShareSummaryData(event: TimelineEvent): LiveLocationShareSummaryData? { + return event.annotations?.liveLocationShareAggregatedSummary?.let { summary -> + LiveLocationShareSummaryData( + isActive = summary.isActive, + endOfLiveTimestampAsMilliseconds = summary.endOfLiveTimestampAsMilliseconds, + lastGeoUri = summary.lastLocationDataContent?.getBestLocationInfo()?.geoUri + ) + } + } + /** * Tiles type message never show the sender information (like verification request), so we should repeat it for next message * even if same sender diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/MessageInformationData.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/MessageInformationData.kt index 9620077fd8..8ad4034a32 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/MessageInformationData.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/MessageInformationData.kt @@ -20,6 +20,8 @@ import android.os.Parcelable import im.vector.app.features.home.room.detail.timeline.style.TimelineMessageLayout import kotlinx.parcelize.Parcelize import org.matrix.android.sdk.api.session.crypto.verification.VerificationState +import org.matrix.android.sdk.api.session.room.model.message.LocationInfo +import org.matrix.android.sdk.api.session.room.model.message.MessageBeaconLocationDataContent import org.matrix.android.sdk.api.session.room.send.SendState import org.matrix.android.sdk.api.util.MatrixItem @@ -42,7 +44,8 @@ data class MessageInformationData( val e2eDecoration: E2EDecoration = E2EDecoration.NONE, val sendStateDecoration: SendStateDecoration = SendStateDecoration.NONE, val isFirstFromThisSender: Boolean = false, - val isLastFromThisSender: Boolean = false + val isLastFromThisSender: Boolean = false, + val liveLocationShareSummaryData: LiveLocationShareSummaryData? = null, ) : Parcelable { val matrixItem: MatrixItem @@ -98,6 +101,13 @@ data class PollVoteSummaryData( val percentage: Double = 0.0 ) : Parcelable +@Parcelize +data class LiveLocationShareSummaryData( + val isActive: Boolean?, + val endOfLiveTimestampAsMilliseconds: Long?, + val lastGeoUri: String?, +) : Parcelable + enum class E2EDecoration { NONE, WARN_IN_CLEAR, From 0561fe5b08fd52baee71b3ad3fd3c81d1289cfd6 Mon Sep 17 00:00:00 2001 From: Maxime NATUREL Date: Fri, 29 Apr 2022 17:00:32 +0200 Subject: [PATCH 032/457] Using information data in message factory --- .../factory/LiveLocationMessageItemFactory.kt | 16 ++++++++++------ .../timeline/factory/MessageItemFactory.kt | 2 +- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/LiveLocationMessageItemFactory.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/LiveLocationMessageItemFactory.kt index d233deffb8..3656b86b79 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/LiveLocationMessageItemFactory.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/LiveLocationMessageItemFactory.kt @@ -21,9 +21,11 @@ import im.vector.app.core.utils.DimensionConverter import im.vector.app.features.home.room.detail.timeline.helper.AvatarSizeProvider import im.vector.app.features.home.room.detail.timeline.helper.TimelineMediaSizeProvider import im.vector.app.features.home.room.detail.timeline.item.AbsMessageItem +import im.vector.app.features.home.room.detail.timeline.item.LiveLocationShareSummaryData import im.vector.app.features.home.room.detail.timeline.item.MessageLiveLocationStartItem import im.vector.app.features.home.room.detail.timeline.item.MessageLiveLocationStartItem_ import org.matrix.android.sdk.api.extensions.orFalse +import org.matrix.android.sdk.api.extensions.orTrue import org.matrix.android.sdk.api.session.room.model.message.MessageBeaconInfoContent import javax.inject.Inject @@ -34,20 +36,22 @@ class LiveLocationMessageItemFactory @Inject constructor( ) { fun create( - beaconInfoContent: MessageBeaconInfoContent, + liveLocationShareSummaryData: LiveLocationShareSummaryData?, highlight: Boolean, attributes: AbsMessageItem.Attributes, ): VectorEpoxyModel<*>? { // TODO handle location received and stopped states + // TODO create a dedicated ViewState return when { - isLiveRunning(beaconInfoContent) -> buildStartLiveItem(highlight, attributes) - else -> null + liveLocationShareSummaryData == null -> null + isLiveRunning(liveLocationShareSummaryData) -> buildStartLiveItem(highlight, attributes) + else -> null } } - private fun isLiveRunning(beaconInfoContent: MessageBeaconInfoContent): Boolean { - // TODO when we will use aggregatedSummary, check if the live has timed out as well - return beaconInfoContent.isLive.orFalse() + private fun isLiveRunning(liveLocationShareSummaryData: LiveLocationShareSummaryData): Boolean { + // TODO check if the live has timed out as well + return liveLocationShareSummaryData.isActive.orFalse() } private fun buildStartLiveItem( diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/MessageItemFactory.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/MessageItemFactory.kt index b960e2c6a9..953c45f07e 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/MessageItemFactory.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/MessageItemFactory.kt @@ -216,7 +216,7 @@ class MessageItemFactory @Inject constructor( buildMessageTextItem(messageContent.body, false, informationData, highlight, callback, attributes) } } - is MessageBeaconInfoContent -> liveLocationMessageItemFactory.create(messageContent, highlight, attributes) + is MessageBeaconInfoContent -> liveLocationMessageItemFactory.create(informationData.liveLocationShareSummaryData, highlight, attributes) else -> buildNotHandledMessageItem(messageContent, informationData, highlight, callback, attributes) } return messageItem?.apply { From d89d6bc1623f8df0d0f5943ec2bfd2c748d77997 Mon Sep 17 00:00:00 2001 From: Maxime NATUREL Date: Mon, 2 May 2022 09:13:05 +0200 Subject: [PATCH 033/457] Adding view state class --- .../factory/LiveLocationMessageItemFactory.kt | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/LiveLocationMessageItemFactory.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/LiveLocationMessageItemFactory.kt index 3656b86b79..86a5847605 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/LiveLocationMessageItemFactory.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/LiveLocationMessageItemFactory.kt @@ -25,8 +25,8 @@ import im.vector.app.features.home.room.detail.timeline.item.LiveLocationShareSu import im.vector.app.features.home.room.detail.timeline.item.MessageLiveLocationStartItem import im.vector.app.features.home.room.detail.timeline.item.MessageLiveLocationStartItem_ import org.matrix.android.sdk.api.extensions.orFalse -import org.matrix.android.sdk.api.extensions.orTrue -import org.matrix.android.sdk.api.session.room.model.message.MessageBeaconInfoContent +import org.matrix.android.sdk.api.session.room.model.message.LocationInfo +import java.time.LocalDateTime import javax.inject.Inject class LiveLocationMessageItemFactory @Inject constructor( @@ -68,4 +68,11 @@ class LiveLocationMessageItemFactory @Inject constructor( .highlighted(highlight) .leftGuideline(avatarSizeProvider.leftGuideline) } + + private sealed class LiveLocationShareViewState { + object Loading : LiveLocationShareViewState() + data class Running(val locationInfo: LocationInfo, val endOfLiveDateTime: LocalDateTime?) : LiveLocationShareViewState() + object Inactive : LiveLocationShareViewState() + object Unkwown : LiveLocationShareViewState() + } } From 68a44c4cc77e85bbfd983b4aee3043a2dd7fe40d Mon Sep 17 00:00:00 2001 From: Maxime NATUREL Date: Mon, 2 May 2022 09:13:59 +0200 Subject: [PATCH 034/457] Renaming message item factory --- ...eItemFactory.kt => LiveLocationShareMessageItemFactory.kt} | 2 +- .../home/room/detail/timeline/factory/MessageItemFactory.kt | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) rename vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/{LiveLocationMessageItemFactory.kt => LiveLocationShareMessageItemFactory.kt} (98%) diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/LiveLocationMessageItemFactory.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/LiveLocationShareMessageItemFactory.kt similarity index 98% rename from vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/LiveLocationMessageItemFactory.kt rename to vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/LiveLocationShareMessageItemFactory.kt index 86a5847605..f243da7c81 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/LiveLocationMessageItemFactory.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/LiveLocationShareMessageItemFactory.kt @@ -29,7 +29,7 @@ import org.matrix.android.sdk.api.session.room.model.message.LocationInfo import java.time.LocalDateTime import javax.inject.Inject -class LiveLocationMessageItemFactory @Inject constructor( +class LiveLocationShareMessageItemFactory @Inject constructor( private val dimensionConverter: DimensionConverter, private val timelineMediaSizeProvider: TimelineMediaSizeProvider, private val avatarSizeProvider: AvatarSizeProvider, diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/MessageItemFactory.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/MessageItemFactory.kt index 953c45f07e..6f22b3eff4 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/MessageItemFactory.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/MessageItemFactory.kt @@ -148,7 +148,7 @@ class MessageItemFactory @Inject constructor( private val locationPinProvider: LocationPinProvider, private val vectorPreferences: VectorPreferences, private val urlMapProvider: UrlMapProvider, - private val liveLocationMessageItemFactory: LiveLocationMessageItemFactory, + private val liveLocationShareMessageItemFactory: LiveLocationShareMessageItemFactory, ) { // TODO inject this properly? @@ -216,7 +216,7 @@ class MessageItemFactory @Inject constructor( buildMessageTextItem(messageContent.body, false, informationData, highlight, callback, attributes) } } - is MessageBeaconInfoContent -> liveLocationMessageItemFactory.create(informationData.liveLocationShareSummaryData, highlight, attributes) + is MessageBeaconInfoContent -> liveLocationShareMessageItemFactory.create(informationData.liveLocationShareSummaryData, highlight, attributes) else -> buildNotHandledMessageItem(messageContent, informationData, highlight, callback, attributes) } return messageItem?.apply { From d44a6c50f1f4b5623c4688103a8621eaf139150c Mon Sep 17 00:00:00 2001 From: Maxime NATUREL Date: Mon, 2 May 2022 09:47:07 +0200 Subject: [PATCH 035/457] Fixes in DateProvider --- .../vector/app/core/resources/DateProvider.kt | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/vector/src/main/java/im/vector/app/core/resources/DateProvider.kt b/vector/src/main/java/im/vector/app/core/resources/DateProvider.kt index 30cb1dcae4..6762bd68da 100644 --- a/vector/src/main/java/im/vector/app/core/resources/DateProvider.kt +++ b/vector/src/main/java/im/vector/app/core/resources/DateProvider.kt @@ -19,27 +19,30 @@ package im.vector.app.core.resources import org.threeten.bp.Instant import org.threeten.bp.LocalDateTime import org.threeten.bp.ZoneId +import org.threeten.bp.ZoneOffset object DateProvider { - private val zoneId = ZoneId.systemDefault() - private val zoneOffset by lazy { - val now = currentLocalDateTime() - zoneId.rules.getOffset(now) - } + // recompute the zoneId each time we access it to handle change of timezones + private val defaultZoneId: ZoneId + get() = ZoneId.systemDefault() + + // recompute the zoneOffset each time we access it to handle change of timezones + private val defaultZoneOffset: ZoneOffset + get() = defaultZoneId.rules.getOffset(currentLocalDateTime()) fun toLocalDateTime(timestamp: Long?): LocalDateTime { val instant = Instant.ofEpochMilli(timestamp ?: 0) - return LocalDateTime.ofInstant(instant, zoneId) + return LocalDateTime.ofInstant(instant, defaultZoneId) } fun currentLocalDateTime(): LocalDateTime { val instant = Instant.now() - return LocalDateTime.ofInstant(instant, zoneId) + return LocalDateTime.ofInstant(instant, defaultZoneId) } fun toTimestamp(localDateTime: LocalDateTime): Long { - return localDateTime.toInstant(zoneOffset).toEpochMilli() + return localDateTime.toInstant(defaultZoneOffset).toEpochMilli() } } From 431d86166ff0ffa93fbe73d645856fd098e7c185 Mon Sep 17 00:00:00 2001 From: Maxime NATUREL Date: Mon, 2 May 2022 09:47:48 +0200 Subject: [PATCH 036/457] Building correct item depending on the state of the live --- .../LiveLocationShareMessageItemFactory.kt | 56 ++++++++++++++----- 1 file changed, 41 insertions(+), 15 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/LiveLocationShareMessageItemFactory.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/LiveLocationShareMessageItemFactory.kt index f243da7c81..760ec92cd6 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/LiveLocationShareMessageItemFactory.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/LiveLocationShareMessageItemFactory.kt @@ -17,6 +17,7 @@ package im.vector.app.features.home.room.detail.timeline.factory import im.vector.app.core.epoxy.VectorEpoxyModel +import im.vector.app.core.resources.DateProvider import im.vector.app.core.utils.DimensionConverter import im.vector.app.features.home.room.detail.timeline.helper.AvatarSizeProvider import im.vector.app.features.home.room.detail.timeline.helper.TimelineMediaSizeProvider @@ -25,8 +26,8 @@ import im.vector.app.features.home.room.detail.timeline.item.LiveLocationShareSu import im.vector.app.features.home.room.detail.timeline.item.MessageLiveLocationStartItem import im.vector.app.features.home.room.detail.timeline.item.MessageLiveLocationStartItem_ import org.matrix.android.sdk.api.extensions.orFalse -import org.matrix.android.sdk.api.session.room.model.message.LocationInfo -import java.time.LocalDateTime +import org.threeten.bp.LocalDateTime +import timber.log.Timber import javax.inject.Inject class LiveLocationShareMessageItemFactory @Inject constructor( @@ -40,21 +41,15 @@ class LiveLocationShareMessageItemFactory @Inject constructor( highlight: Boolean, attributes: AbsMessageItem.Attributes, ): VectorEpoxyModel<*>? { - // TODO handle location received and stopped states - // TODO create a dedicated ViewState - return when { - liveLocationShareSummaryData == null -> null - isLiveRunning(liveLocationShareSummaryData) -> buildStartLiveItem(highlight, attributes) - else -> null + return when (getViewState(liveLocationShareSummaryData)) { + LiveLocationShareViewState.Loading -> buildLoadingItem(highlight, attributes) + LiveLocationShareViewState.Inactive -> buildInactiveItem() + is LiveLocationShareViewState.Running -> buildRunningItem() + LiveLocationShareViewState.Unkwown -> null } } - private fun isLiveRunning(liveLocationShareSummaryData: LiveLocationShareSummaryData): Boolean { - // TODO check if the live has timed out as well - return liveLocationShareSummaryData.isActive.orFalse() - } - - private fun buildStartLiveItem( + private fun buildLoadingItem( highlight: Boolean, attributes: AbsMessageItem.Attributes, ): MessageLiveLocationStartItem { @@ -69,9 +64,40 @@ class LiveLocationShareMessageItemFactory @Inject constructor( .leftGuideline(avatarSizeProvider.leftGuideline) } + private fun buildRunningItem() = null + + private fun buildInactiveItem() = null + + private fun getViewState(liveLocationShareSummaryData: LiveLocationShareSummaryData?): LiveLocationShareViewState { + return when { + liveLocationShareSummaryData?.isActive == null -> LiveLocationShareViewState.Unkwown + liveLocationShareSummaryData.isActive && liveLocationShareSummaryData.lastGeoUri.isNullOrEmpty() -> LiveLocationShareViewState.Loading + liveLocationShareSummaryData.isActive.not() || isLiveTimedOut(liveLocationShareSummaryData) -> LiveLocationShareViewState.Inactive + else -> + LiveLocationShareViewState.Running( + liveLocationShareSummaryData.lastGeoUri.orEmpty(), + getEndOfLiveDateTime(liveLocationShareSummaryData) + ) + }.also { viewState -> Timber.d("computed viewState: $viewState") } + } + + private fun isLiveTimedOut(liveLocationShareSummaryData: LiveLocationShareSummaryData): Boolean { + return getEndOfLiveDateTime(liveLocationShareSummaryData) + ?.let { endOfLive -> + // this will only cover users with different timezones but not users with manually time set + val now = LocalDateTime.now() + now.isAfter(endOfLive) + } + .orFalse() + } + + private fun getEndOfLiveDateTime(liveLocationShareSummaryData: LiveLocationShareSummaryData): LocalDateTime? { + return liveLocationShareSummaryData.endOfLiveTimestampAsMilliseconds?.let { DateProvider.toLocalDateTime(timestamp = it) } + } + private sealed class LiveLocationShareViewState { object Loading : LiveLocationShareViewState() - data class Running(val locationInfo: LocationInfo, val endOfLiveDateTime: LocalDateTime?) : LiveLocationShareViewState() + data class Running(val lastGeoUri: String, val endOfLiveDateTime: LocalDateTime?) : LiveLocationShareViewState() object Inactive : LiveLocationShareViewState() object Unkwown : LiveLocationShareViewState() } From df1ba8ec88f6295b6df663071a113ccf8ee52a10 Mon Sep 17 00:00:00 2001 From: Maxime NATUREL Date: Mon, 4 Apr 2022 18:14:51 +0200 Subject: [PATCH 037/457] Custom view for the banner --- .../src/main/res/values/styles_location.xml | 8 +++ .../live/LocationLiveMessageBannerView.kt | 40 +++++++++++ .../view_location_live_message_banner.xml | 67 +++++++++++++++++++ vector/src/main/res/values/strings.xml | 1 + 4 files changed, 116 insertions(+) create mode 100644 vector/src/main/java/im/vector/app/features/location/live/LocationLiveMessageBannerView.kt create mode 100644 vector/src/main/res/layout/view_location_live_message_banner.xml diff --git a/library/ui-styles/src/main/res/values/styles_location.xml b/library/ui-styles/src/main/res/values/styles_location.xml index 5563d28342..8f76ed469e 100644 --- a/library/ui-styles/src/main/res/values/styles_location.xml +++ b/library/ui-styles/src/main/res/values/styles_location.xml @@ -8,4 +8,12 @@ center + + diff --git a/vector/src/main/java/im/vector/app/features/location/live/LocationLiveMessageBannerView.kt b/vector/src/main/java/im/vector/app/features/location/live/LocationLiveMessageBannerView.kt new file mode 100644 index 0000000000..95805d5b7d --- /dev/null +++ b/vector/src/main/java/im/vector/app/features/location/live/LocationLiveMessageBannerView.kt @@ -0,0 +1,40 @@ +/* + * 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.features.location.live + +import android.content.Context +import android.util.AttributeSet +import android.view.LayoutInflater +import android.widget.Button +import androidx.constraintlayout.widget.ConstraintLayout +import im.vector.app.databinding.ViewLocationLiveMessageBannerBinding +import im.vector.app.databinding.ViewLocationLiveStatusBinding + +class LocationLiveMessageBannerView @JvmOverloads constructor( + context: Context, + attrs: AttributeSet? = null, + defStyleAttr: Int = 0 +) : ConstraintLayout(context, attrs, defStyleAttr) { + + private val binding = ViewLocationLiveMessageBannerBinding.inflate( + LayoutInflater.from(context), + this + ) + + val stopButton: Button + get() = binding.locationLiveMessageBannerStop +} diff --git a/vector/src/main/res/layout/view_location_live_message_banner.xml b/vector/src/main/res/layout/view_location_live_message_banner.xml new file mode 100644 index 0000000000..f3345bac05 --- /dev/null +++ b/vector/src/main/res/layout/view_location_live_message_banner.xml @@ -0,0 +1,67 @@ + + + + + + + + + + + +