Merge branch 'develop' into feature/bca/rust_flavor

This commit is contained in:
valere 2023-01-10 08:55:04 +01:00
commit 13d3f4f1a7
23 changed files with 214 additions and 22 deletions

View File

@ -29,7 +29,7 @@ buildscript {
classpath 'org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:3.5.0.2730'
classpath 'com.google.android.gms:oss-licenses-plugin:0.10.5'
classpath "com.likethesalad.android:stem-plugin:2.2.3"
classpath 'org.owasp:dependency-check-gradle:7.4.3'
classpath 'org.owasp:dependency-check-gradle:7.4.4'
classpath "org.jetbrains.dokka:dokka-gradle-plugin:1.7.20"
classpath "org.jetbrains.kotlinx:kotlinx-knit:0.4.0"
classpath 'com.jakewharton:butterknife-gradle-plugin:10.2.3'

1
changelog.d/7913.bugfix Normal file
View File

@ -0,0 +1 @@
Handle network error on API `rooms/{roomId}/threads`

View File

@ -101,7 +101,7 @@ ext.libs = [
],
element : [
'opusencoder' : "io.element.android:opusencoder:1.1.0",
'wysiwyg' : "io.element.android:wysiwyg:0.13.0"
'wysiwyg' : "io.element.android:wysiwyg:0.14.0"
],
squareup : [
'moshi' : "com.squareup.moshi:moshi:$moshi",

View File

@ -0,0 +1,2 @@
Modifiche principali in questa versione: i messaggi in conversazioni sono attivi in modo predefinito.
Cronologia completa: https://github.com/vector-im/element-android/releases

View File

@ -0,0 +1,2 @@
Modifiche principali in questa versione: i messaggi in conversazioni sono attivi in modo predefinito.
Cronologia completa: https://github.com/vector-im/element-android/releases

View File

@ -2889,4 +2889,13 @@
<string name="set_link_create">Link erstellen</string>
<string name="set_link_link">Link</string>
<string name="set_link_text">Text</string>
<string name="settings_access_token_summary">Dein Zugriffstoken gewährt vollen Zugriff auf dein Konto. Teile ihn mit niemandem.</string>
<string name="settings_access_token">Zugriffstoken</string>
<string name="rich_text_editor_bullet_list">Unsortierte Liste umschalten</string>
<string name="rich_text_editor_numbered_list">Nummerierte Liste umschalten</string>
<string name="room_polls_ended_no_item">In diesem Raum gibt es noch keine abgeschlossenen Umfragen</string>
<string name="room_polls_ended">Vergangene Umfragen</string>
<string name="room_polls_active_no_item">In diesem Raum gibt es keine aktiven Umfragen</string>
<string name="room_polls_active">Aktive Umfragen</string>
<string name="room_profile_section_more_polls">Umfrageverlauf</string>
</resources>

View File

@ -2881,4 +2881,13 @@
<string name="set_link_link">Link</string>
<string name="set_link_create">Loo link</string>
<string name="set_link_edit">Muuda linki</string>
<string name="room_profile_section_more_polls">Küsitluste ajalugu</string>
<string name="room_polls_active">Käimasolevad küsitlused</string>
<string name="room_polls_active_no_item">Selles jututoas pole käimasolevaid küsitlusi</string>
<string name="room_polls_ended">Varasemad küsitlused</string>
<string name="room_polls_ended_no_item">Selles jututoas pole varasemaid küsitlusi</string>
<string name="rich_text_editor_numbered_list">Lülita nummerdatud loend sisse/välja</string>
<string name="rich_text_editor_bullet_list">Lülita täpploend sisse/välja</string>
<string name="settings_access_token">Pääsuluba</string>
<string name="settings_access_token_summary">Sinu pääsuluba annab täismahulise ligipääsu sinu kasutajakontole. Palun ära jaga seda teistega.</string>
</resources>

View File

@ -2890,4 +2890,13 @@
<string name="set_link_link">پیوند</string>
<string name="set_link_text">متن</string>
<string name="rich_text_editor_link">تنظیم پیوند</string>
<string name="settings_access_token_summary">ژتون دسترسیتان، دسترسی کامل به حسابتان را می‌دهد. با هیچ‌کس هم‌رسانیش نکنید.</string>
<string name="settings_access_token">ژتون دسترسی</string>
<string name="rich_text_editor_bullet_list">تغییر وضعیت سیاههٔ گلوله‌ای</string>
<string name="rich_text_editor_numbered_list">تغییر وضعیت سیاههٔ شماره‌دار</string>
<string name="room_polls_ended_no_item">هیچ‌ نظرسنجی قدیمی‌ای در این اتاق وجود ندارد</string>
<string name="room_polls_ended">نظرسنجی‌های گذشته</string>
<string name="room_polls_active_no_item">هیچ نظرسنجی فعّالی در این اتاق وجود ندارد</string>
<string name="room_polls_active">نظرسنجی‌های فعّال</string>
<string name="room_profile_section_more_polls">تاریخچهٔ نظرسنجی‌ها</string>
</resources>

View File

@ -2890,4 +2890,13 @@
<string name="set_link_link">Lien</string>
<string name="set_link_text">Texte</string>
<string name="rich_text_editor_link">Définir un lien</string>
<string name="settings_access_token_summary">Votre jeton daccès donne un accès intégral à votre compte. Ne le partagez avec personne.</string>
<string name="settings_access_token">Jeton daccès</string>
<string name="rich_text_editor_bullet_list">(Dés)activer la liste à puce</string>
<string name="rich_text_editor_numbered_list">(Dés)activer la liste numérotée</string>
<string name="room_polls_ended_no_item">Il ny a aucun ancien sondage dans ce salon</string>
<string name="room_polls_ended">Anciens sondages</string>
<string name="room_polls_active_no_item">Il ny a aucun sondage en cours dans ce salon</string>
<string name="room_polls_active">Sondages actifs</string>
<string name="room_profile_section_more_polls">Historique des sondages</string>
</resources>

View File

@ -2836,4 +2836,13 @@ Di masa mendatang proses verifikasi ini akan dimutakhirkan.</string>
<string name="set_link_link">Tautan</string>
<string name="set_link_text">Teks</string>
<string name="rich_text_editor_link">Atur tautan</string>
<string name="settings_access_token_summary">Token akses Anda memberikan akses penuh ke akun Anda. Jangan bagikan dengan siapa pun.</string>
<string name="settings_access_token">Token Akses</string>
<string name="rich_text_editor_bullet_list">Saklar daftar bulat</string>
<string name="rich_text_editor_numbered_list">Saklar daftar bernomor</string>
<string name="room_polls_ended_no_item">Tidak ada pemungutan suara sebelumnya di ruangan ini</string>
<string name="room_polls_ended">Pemungutan suara sebelumnya</string>
<string name="room_polls_active_no_item">Tidak ada pemungutan suara yang aktif di ruangan ini</string>
<string name="room_polls_active">Pemungutan suara aktif</string>
<string name="room_profile_section_more_polls">Riwayat pemungutan suara</string>
</resources>

View File

@ -2881,4 +2881,13 @@
<string name="set_link_link">Collegamento</string>
<string name="set_link_text">Testo</string>
<string name="rich_text_editor_link">Imposta collegamento</string>
<string name="settings_access_token_summary">Il tuo token di accesso ti dà l\'accesso al tuo account. Non condividerlo con nessuno.</string>
<string name="settings_access_token">Token di accesso</string>
<string name="rich_text_editor_numbered_list">Attiva/disattiva elenco numerato</string>
<string name="rich_text_editor_bullet_list">Attiva/disattiva elenco puntato</string>
<string name="room_polls_ended_no_item">In questa stanza non ci sono sondaggi passati</string>
<string name="room_polls_ended">Sondaggi passati</string>
<string name="room_polls_active_no_item">In questa stanza non ci sono sondaggi attivi</string>
<string name="room_polls_active">Sondaggi attivi</string>
<string name="room_profile_section_more_polls">Cronologia sondaggi</string>
</resources>

View File

@ -2946,4 +2946,13 @@
<string name="set_link_link">Odkaz</string>
<string name="set_link_text">Text</string>
<string name="rich_text_editor_link">Nastaviť odkaz</string>
<string name="settings_access_token_summary">Váš prístupový token poskytuje úplný prístup k vášmu účtu. S nikým ho nezdieľajte.</string>
<string name="settings_access_token">Prístupový token</string>
<string name="rich_text_editor_numbered_list">Prepnúť na číslovaný zoznam</string>
<string name="rich_text_editor_bullet_list">Prepnúť zoznam s odrážkami</string>
<string name="room_polls_ended_no_item">V tejto miestnosti nie sú žiadne predchádzajúce ankety</string>
<string name="room_polls_ended">Predchádzajúce ankety</string>
<string name="room_polls_active_no_item">V tejto miestnosti nie sú žiadne aktívne ankety</string>
<string name="room_polls_active">Aktívne ankety</string>
<string name="room_profile_section_more_polls">História ankety</string>
</resources>

View File

@ -2504,7 +2504,7 @@
<string name="home_empty_space_no_rooms_title">%s
\nduket paksa si i zbrazët.</string>
<string name="labs_enable_voice_broadcast_summary">Jini në gjendje të incizoni dhe dërgoni transmetim zanor në rrjedhën kohore të dhomës.</string>
<string name="labs_enable_voice_broadcast_title">Aktivizoni transmetim zanor (nën zhvillim aktiv)</string>
<string name="labs_enable_voice_broadcast_title">Aktivizoni transmetim zanor</string>
<string name="labs_enable_client_info_recording_title">Aktivizo regjistrim hollësish klienti</string>
<string name="labs_enable_session_manager_summary">Shihini më qartë dhe kontrolloni më mirë krejt sesionet tuaj.</string>
<string name="labs_enable_session_manager_title">Aktivizo përgjegjës të ri sesionesh</string>
@ -2874,4 +2874,12 @@
<string name="set_link_create">Krijoni një lidhje</string>
<string name="set_link_link">Lidhje</string>
<string name="set_link_text">Tekst</string>
<string name="settings_access_token_summary">Tokeni juaj i hyrjeve jep hyrje të plotë në llogarinë tuaj. Mos ia jepni kujt.</string>
<string name="settings_access_token">Token Hyrjesh</string>
<string name="room_polls_ended_no_item">Ska pyetësorë të kaluar në këtë dhomë</string>
<string name="room_polls_ended">Pyetësorë të kaluar</string>
<string name="room_polls_active_no_item">Ska pyetësorë aktivë në këtë dhomë</string>
<string name="room_polls_active">Pyetësorë aktivë</string>
<string name="a11y_poll_winner_option">mundësia fituese</string>
<string name="room_profile_section_more_polls">Historik pyetësorësh</string>
</resources>

View File

@ -3002,4 +3002,13 @@
<string name="set_link_link">Посилання</string>
<string name="set_link_text">Текст</string>
<string name="rich_text_editor_link">Налаштувати посилання</string>
<string name="settings_access_token_summary">Ваш токен доступу надає повний доступ до вашого облікового запису. Не передавайте його нікому.</string>
<string name="settings_access_token">Токен доступу</string>
<string name="rich_text_editor_bullet_list">Перемкнути на маркований список</string>
<string name="rich_text_editor_numbered_list">Перемкнути на нумерований список</string>
<string name="room_polls_ended_no_item">У цій кімнаті ще не проводилися опитування</string>
<string name="room_polls_ended">Минулі опитування</string>
<string name="room_polls_active_no_item">У цій кімнаті немає активних опитувань</string>
<string name="room_polls_active">Активні опитування</string>
<string name="room_profile_section_more_polls">Історія опитувань</string>
</resources>

View File

@ -2834,4 +2834,13 @@
<string name="set_link_link">連結</string>
<string name="set_link_text">文字</string>
<string name="rich_text_editor_link">設定連結</string>
<string name="settings_access_token_summary">您的存取權杖可以完整存取您的帳號。不要將其與其他人分享。</string>
<string name="settings_access_token">存取權杖</string>
<string name="rich_text_editor_bullet_list">切換項目符號清單</string>
<string name="rich_text_editor_numbered_list">切換編號清單</string>
<string name="room_polls_ended_no_item">此聊天室沒有過去的投票</string>
<string name="room_polls_ended">過去的投票</string>
<string name="room_polls_active_no_item">此聊天室沒有正在進行的投票</string>
<string name="room_polls_active">進行中的投票</string>
<string name="room_profile_section_more_polls">投票歷史紀錄</string>
</resources>

View File

@ -795,6 +795,7 @@
<string name="thread_list_modal_my_threads_subtitle">Shows all threads youve participated in</string>
<string name="thread_list_empty_title">Keep discussions organized with threads</string>
<string name="thread_list_empty_subtitle">Threads help keep your conversations on-topic and easy to track.</string>
<string name="thread_list_not_available">You\'re homeserver does not support listing threads yet.</string>
<!-- Parameter %s will be replaced by the value of string reply_in_thread -->
<string name="thread_list_empty_notice">Tip: Long tap a message and use “%s”.</string>
<string name="search_thread_from_a_thread">From a Thread</string>

View File

@ -25,6 +25,9 @@ import java.io.IOException
import java.net.UnknownHostException
import javax.net.ssl.HttpsURLConnection
fun Throwable.is400() = this is Failure.ServerError &&
httpCode == HttpsURLConnection.HTTP_BAD_REQUEST
fun Throwable.is401() = this is Failure.ServerError &&
httpCode == HttpsURLConnection.HTTP_UNAUTHORIZED && /* 401 */
error.code == MatrixError.M_UNAUTHORIZED

View File

@ -19,5 +19,4 @@ package org.matrix.android.sdk.api.session.room.threads
sealed class FetchThreadsResult {
data class ShouldFetchMore(val nextBatch: String) : FetchThreadsResult()
object ReachedEnd : FetchThreadsResult()
object Failed : FetchThreadsResult()
}

View File

@ -23,7 +23,7 @@ import org.matrix.android.sdk.api.session.room.threads.model.ThreadSummary
* This interface defines methods to interact with thread related features.
* It's the dynamic threads implementation and the homeserver must return
* a capability entry for threads. If the server do not support m.thread
* then [ThreadsLocalService] should be used instead
* then [org.matrix.android.sdk.api.session.room.threads.local.ThreadsLocalService] should be used instead
*/
interface ThreadsService {

View File

@ -0,0 +1,23 @@
/*
* Copyright (c) 2023 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.home.room.threads.list.viewmodel
import im.vector.app.core.platform.VectorViewModelAction
sealed interface ThreadListViewActions : VectorViewModelAction {
object TryAgain : ThreadListViewActions
}

View File

@ -0,0 +1,23 @@
/*
* Copyright (c) 2023 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.home.room.threads.list.viewmodel
import im.vector.app.core.platform.VectorViewEvents
sealed interface ThreadListViewEvents : VectorViewEvents {
data class ShowError(val throwable: Throwable) : ThreadListViewEvents
}

View File

@ -27,8 +27,6 @@ import com.airbnb.mvrx.ViewModelContext
import dagger.assisted.Assisted
import dagger.assisted.AssistedFactory
import dagger.assisted.AssistedInject
import im.vector.app.core.platform.EmptyAction
import im.vector.app.core.platform.EmptyViewEvents
import im.vector.app.core.platform.VectorViewModel
import im.vector.app.features.analytics.AnalyticsTracker
import im.vector.app.features.analytics.extensions.toAnalyticsInteraction
@ -52,7 +50,7 @@ class ThreadListViewModel @AssistedInject constructor(
@Assisted val initialState: ThreadListViewState,
private val analyticsTracker: AnalyticsTracker,
private val session: Session,
) : VectorViewModel<ThreadListViewState, EmptyAction, EmptyViewEvents>(initialState) {
) : VectorViewModel<ThreadListViewState, ThreadListViewActions, ThreadListViewEvents>(initialState) {
private val room = session.getRoom(initialState.roomId)
@ -93,7 +91,17 @@ class ThreadListViewModel @AssistedInject constructor(
fetchAndObserveThreads()
}
override fun handle(action: EmptyAction) {}
override fun handle(action: ThreadListViewActions) {
when (action) {
ThreadListViewActions.TryAgain -> handleTryAgain()
}
}
private fun handleTryAgain() {
viewModelScope.launch {
fetchNextPage()
}
}
/**
* Observing thread list with respect to homeserver capabilities.
@ -181,11 +189,12 @@ class ThreadListViewModel @AssistedInject constructor(
true -> ThreadFilter.PARTICIPATED
false -> ThreadFilter.ALL
}
try {
room?.threadsService()?.fetchThreadList(
nextBatchId = nextBatchId,
limit = defaultPagedListConfig.pageSize,
filter = filter,
).let { result ->
)?.let { result ->
when (result) {
is FetchThreadsResult.ReachedEnd -> {
hasReachedEnd = true
@ -193,9 +202,10 @@ class ThreadListViewModel @AssistedInject constructor(
is FetchThreadsResult.ShouldFetchMore -> {
nextBatchId = result.nextBatch
}
else -> {
}
}
} catch (throwable: Throwable) {
_viewEvents.post(ThreadListViewEvents.ShowError(throwable))
}
}
}

View File

@ -26,6 +26,7 @@ import androidx.core.view.isVisible
import com.airbnb.mvrx.args
import com.airbnb.mvrx.fragmentViewModel
import com.airbnb.mvrx.withState
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import dagger.hilt.android.AndroidEntryPoint
import im.vector.app.R
import im.vector.app.core.extensions.cleanup
@ -41,10 +42,14 @@ import im.vector.app.features.home.room.threads.arguments.ThreadListArgs
import im.vector.app.features.home.room.threads.arguments.ThreadTimelineArgs
import im.vector.app.features.home.room.threads.list.viewmodel.ThreadListController
import im.vector.app.features.home.room.threads.list.viewmodel.ThreadListPagedController
import im.vector.app.features.home.room.threads.list.viewmodel.ThreadListViewActions
import im.vector.app.features.home.room.threads.list.viewmodel.ThreadListViewEvents
import im.vector.app.features.home.room.threads.list.viewmodel.ThreadListViewModel
import im.vector.app.features.home.room.threads.list.viewmodel.ThreadListViewState
import im.vector.app.features.rageshake.BugReporter
import im.vector.app.features.rageshake.ReportType
import org.matrix.android.sdk.api.failure.is400
import org.matrix.android.sdk.api.failure.is404
import org.matrix.android.sdk.api.session.room.threads.model.ThreadSummary
import org.matrix.android.sdk.api.session.room.timeline.TimelineEvent
import org.matrix.android.sdk.api.util.MatrixItem
@ -126,11 +131,45 @@ class ThreadListFragment :
views.threadListRecyclerView.configureWith(legacyThreadListController, TimelineItemAnimator(), hasFixedSize = false)
legacyThreadListController.listener = this
}
observeViewEvents()
}
private fun observeViewEvents() {
threadListViewModel.observeViewEvents {
when (it) {
is ThreadListViewEvents.ShowError -> handleShowError(it)
}
}
}
private fun handleShowError(event: ThreadListViewEvents.ShowError) {
val error = event.throwable
MaterialAlertDialogBuilder(requireActivity())
.setTitle(R.string.dialog_title_error)
.also {
if (error.is400() || error.is404()) {
// Outdated Homeserver
it.setMessage(R.string.thread_list_not_available)
it.setPositiveButton(R.string.ok) { _, _ ->
requireActivity().finish()
}
} else {
// Other error, can retry
// (Can happen on first request or on pagination request)
it.setMessage(errorFormatter.toHumanReadable(error))
it.setPositiveButton(R.string.ok, null)
it.setNegativeButton(R.string.global_retry) { _, _ ->
threadListViewModel.handle(ThreadListViewActions.TryAgain)
}
}
}
.show()
}
override fun onDestroyView() {
views.threadListRecyclerView.cleanup()
threadListController.listener = null
legacyThreadListController.listener = null
super.onDestroyView()
}