Merge branch 'develop' into feature/ons/device_manager_filter

This commit is contained in:
Onuray Sahin 2022-09-19 12:02:22 +03:00
commit 32d7516dcb
34 changed files with 605 additions and 272 deletions

View File

@ -29,7 +29,7 @@ buildscript {
classpath 'org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:3.4.0.2513'
classpath 'com.google.android.gms:oss-licenses-plugin:0.10.5'
classpath "com.likethesalad.android:stem-plugin:2.2.2"
classpath 'org.owasp:dependency-check-gradle:7.1.2'
classpath 'org.owasp:dependency-check-gradle:7.2.0'
classpath "org.jetbrains.dokka:dokka-gradle-plugin:1.7.10"
classpath "org.jetbrains.kotlinx:kotlinx-knit:0.4.0"
classpath 'com.jakewharton:butterknife-gradle-plugin:10.2.3'

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

@ -0,0 +1 @@
Fix empty verification bottom sheet.

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

@ -0,0 +1 @@
[New Layout] Fixes new chat dialog not getting dismissed after selecting its actions

1
changelog.d/7140.misc Normal file
View File

@ -0,0 +1 @@
Exclude legacy android support annotation library

1
changelog.d/7157.misc Normal file
View File

@ -0,0 +1 @@
Fixing build cache misses when compiling the vector module

View File

@ -69,8 +69,6 @@ ext.groups = [
'com.gabrielittner.threetenbp',
'com.getkeepsafe.relinker',
'com.github.bumptech.glide',
'com.github.filippudak',
'com.github.filippudak.progresspieview',
'com.github.javaparser',
'com.github.piasy',
'com.github.shyiko.klob',

View File

@ -55,8 +55,9 @@ dependencies {
implementation libs.airbnb.mavericks
// Span utils
implementation 'me.gujun.android:span:1.7'
implementation('me.gujun.android:span:1.7') {
exclude group: 'com.android.support', module: 'support-annotations'
}
implementation libs.jetbrains.coroutinesCore
implementation libs.jetbrains.coroutinesAndroid

View File

@ -20,3 +20,7 @@ android {
jvmTarget = "11"
}
}
tasks.withType( com.likethesalad.android.templates.common.tasks.BaseTask) {
it.outputs.cacheIf { true }
}

View File

@ -32,5 +32,13 @@ fun Session.getRoomSummary(roomIdOrAlias: String): RoomSummary? = roomService().
/**
* Get a user using the UserService of a Session.
* @param userId the userId to look for.
* @return a user with userId or null if the User is not known yet by the SDK.
* See [org.matrix.android.sdk.api.session.user.UserService.resolveUser] to ensure that a User is retrieved.
*/
fun Session.getUser(userId: String): User? = userService().getUser(userId)
/**
* Similar to [getUser], but fallback to a User without details if the User is not known by the SDK, or if Session is null.
*/
fun Session?.getUserOrDefault(userId: String): User = this?.userService()?.getUser(userId) ?: User(userId)

View File

@ -29,7 +29,7 @@ interface UserService {
/**
* Get a user from a userId.
* @param userId the userId to look for.
* @return a user with userId or null
* @return a user with userId or null if the User is not known yet by the SDK. See [resolveUser] to ensure that a User is retrieved.
*/
fun getUser(userId: String): User?

File diff suppressed because it is too large Load Diff

View File

@ -370,7 +370,7 @@ dependencies {
debugImplementation 'com.facebook.soloader:soloader:0.10.4'
debugImplementation "com.kgurgul.flipper:flipper-realm-android:2.2.0"
gplayImplementation "com.google.android.gms:play-services-location:16.0.0"
gplayImplementation "com.google.android.gms:play-services-location:20.0.0"
// UnifiedPush gplay flavor only
gplayImplementation('com.github.UnifiedPush:android-embedded_fcm_distributor:2.1.2') {
exclude group: 'com.google.firebase', module: 'firebase-core'

View File

@ -100,7 +100,6 @@ android {
viewBinding true
}
}
dependencies {
implementation project(":vector-config")
api project(":matrix-sdk-android")
@ -177,7 +176,9 @@ dependencies {
// UI
implementation 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
implementation libs.google.material
api 'me.gujun.android:span:1.7'
api('me.gujun.android:span:1.7') {
exclude group: 'com.android.support', module: 'support-annotations'
}
implementation libs.markwon.core
implementation libs.markwon.extLatex
implementation libs.markwon.inlineParser
@ -206,7 +207,6 @@ dependencies {
// Image Loading
implementation libs.github.bigImageViewer
implementation libs.github.glideImageLoader
implementation libs.github.progressPieIndicator
implementation libs.github.glideImageViewFactory
// implementation 'com.github.MikeOrtiz:TouchImageView:3.0.2'
@ -225,7 +225,9 @@ dependencies {
kapt libs.dagger.hiltCompiler
// Analytics
implementation 'com.posthog.android:posthog:1.1.2'
implementation('com.posthog.android:posthog:1.1.2') {
exclude group: 'com.android.support', module: 'support-annotations'
}
// UnifiedPush
implementation 'com.github.UnifiedPush:android-connector:2.0.1'
@ -242,12 +244,22 @@ dependencies {
exclude group: 'com.google.firebase'
exclude group: 'com.google.android.gms'
exclude group: 'com.android.installreferrer'
// Exclude jitsi's android-scalablevideoview fork's support library
// The library exports a jetified artifact but doesn't remove the support library dependency
// https://github.com/MatrixFrog/Android-ScalableVideoView/blob/master/gradle.properties#L1
exclude group: 'com.android.support', module: 'appcompat-v7'
}
// QR-code
// Stick to 3.3.3 because of https://github.com/zxing/zxing/issues/1170
implementation 'com.google.zxing:core:3.3.3'
implementation 'me.dm7.barcodescanner:zxing:1.9.13'
// Excludes the legacy support library annotation usages
// https://github.com/dm77/barcodescanner/blob/d036996c8a6f36a68843ffe539c834c28944b2d5/core/src/main/java/me/dm7/barcodescanner/core/CameraWrapper.java#L4
implementation ('me.dm7.barcodescanner:zxing:1.9.13') {
exclude group: 'com.android.support', module: 'support-v4'
}
// Emoji Keyboard
api libs.vanniktech.emojiMaterial

View File

@ -37,11 +37,10 @@ import kotlinx.coroutines.launch
import org.matrix.android.sdk.api.extensions.orFalse
import org.matrix.android.sdk.api.raw.RawService
import org.matrix.android.sdk.api.session.Session
import org.matrix.android.sdk.api.session.getUser
import org.matrix.android.sdk.api.session.getUserOrDefault
import org.matrix.android.sdk.api.session.permalinks.PermalinkData
import org.matrix.android.sdk.api.session.permalinks.PermalinkParser
import org.matrix.android.sdk.api.session.room.model.create.CreateRoomParams
import org.matrix.android.sdk.api.session.user.model.User
class CreateDirectRoomViewModel @AssistedInject constructor(
@Assisted initialState: CreateDirectRoomViewState,
@ -78,11 +77,7 @@ class CreateDirectRoomViewModel @AssistedInject constructor(
_viewEvents.post(CreateDirectRoomViewEvents.DmSelf)
} else {
// Try to get user from known users and fall back to creating a User object from MXID
val qrInvitee = if (session.getUser(mxid) != null) {
session.getUser(mxid)!!
} else {
User(mxid, null, null)
}
val qrInvitee = session.getUserOrDefault(mxid)
onSubmitInvitees(setOf(PendingSelection.UserPendingSelection(qrInvitee)))
}
}

View File

@ -31,6 +31,7 @@ import org.matrix.android.sdk.api.session.crypto.verification.PendingVerificatio
import org.matrix.android.sdk.api.session.crypto.verification.VerificationService
import org.matrix.android.sdk.api.session.crypto.verification.VerificationTransaction
import org.matrix.android.sdk.api.session.crypto.verification.VerificationTxState
import org.matrix.android.sdk.api.session.getUserOrDefault
import org.matrix.android.sdk.api.util.toMatrixItem
import timber.log.Timber
import javax.inject.Inject
@ -67,8 +68,8 @@ class IncomingVerificationRequestHandler @Inject constructor(
when (tx.state) {
is VerificationTxState.OnStarted -> {
// Add a notification for every incoming request
val user = session?.userService()?.getUser(tx.otherUserId)
val name = user?.toMatrixItem()?.getBestName() ?: tx.otherUserId
val user = session.getUserOrDefault(tx.otherUserId).toMatrixItem()
val name = user.getBestName()
val alert = VerificationVectorAlert(
uid,
context.getString(R.string.sas_incoming_request_notif_title),
@ -86,7 +87,7 @@ class IncomingVerificationRequestHandler @Inject constructor(
}
)
.apply {
viewBinder = VerificationVectorAlert.ViewBinder(user?.toMatrixItem(), avatarRenderer.get())
viewBinder = VerificationVectorAlert.ViewBinder(user, avatarRenderer.get())
contentAction = Runnable {
(weakCurrentActivity?.get() as? VectorBaseActivity<*>)?.let {
it.navigator.performDeviceVerification(it, tx.otherUserId, tx.transactionId)
@ -131,8 +132,8 @@ class IncomingVerificationRequestHandler @Inject constructor(
// XXX this is a bit hard coded :/
popupAlertManager.cancelAlert("review_login")
}
val user = session?.userService()?.getUser(pr.otherUserId)?.toMatrixItem()
val name = user?.getBestName() ?: pr.otherUserId
val user = session.getUserOrDefault(pr.otherUserId).toMatrixItem()
val name = user.getBestName()
val description = if (name == pr.otherUserId) {
name
} else {

View File

@ -152,29 +152,25 @@ class VerificationBottomSheet : VectorBaseBottomSheetDialogFragment<BottomSheetV
}
override fun invalidate() = withState(viewModel) { state ->
state.otherUserMxItem?.let { matrixItem ->
if (state.isMe) {
avatarRenderer.render(matrixItem, views.otherUserAvatarImageView)
if (state.sasTransactionState == VerificationTxState.Verified ||
state.qrTransactionState == VerificationTxState.Verified ||
state.verifiedFromPrivateKeys) {
views.otherUserShield.render(RoomEncryptionTrustLevel.Trusted)
} else {
views.otherUserShield.render(RoomEncryptionTrustLevel.Warning)
}
views.otherUserNameText.text = getString(
if (state.selfVerificationMode) R.string.crosssigning_verify_this_session else R.string.crosssigning_verify_session
)
avatarRenderer.render(state.otherUserMxItem, views.otherUserAvatarImageView)
if (state.isMe) {
if (state.sasTransactionState == VerificationTxState.Verified ||
state.qrTransactionState == VerificationTxState.Verified ||
state.verifiedFromPrivateKeys) {
views.otherUserShield.render(RoomEncryptionTrustLevel.Trusted)
} else {
avatarRenderer.render(matrixItem, views.otherUserAvatarImageView)
if (state.sasTransactionState == VerificationTxState.Verified || state.qrTransactionState == VerificationTxState.Verified) {
views.otherUserNameText.text = getString(R.string.verification_verified_user, matrixItem.getBestName())
views.otherUserShield.render(RoomEncryptionTrustLevel.Trusted)
} else {
views.otherUserNameText.text = getString(R.string.verification_verify_user, matrixItem.getBestName())
views.otherUserShield.render(null)
}
views.otherUserShield.render(RoomEncryptionTrustLevel.Warning)
}
views.otherUserNameText.text = getString(
if (state.selfVerificationMode) R.string.crosssigning_verify_this_session else R.string.crosssigning_verify_session
)
} else {
if (state.sasTransactionState == VerificationTxState.Verified || state.qrTransactionState == VerificationTxState.Verified) {
views.otherUserNameText.text = getString(R.string.verification_verified_user, state.otherUserMxItem.getBestName())
views.otherUserShield.render(RoomEncryptionTrustLevel.Trusted)
} else {
views.otherUserNameText.text = getString(R.string.verification_verify_user, state.otherUserMxItem.getBestName())
views.otherUserShield.render(null)
}
}
@ -235,7 +231,7 @@ class VerificationBottomSheet : VectorBaseBottomSheetDialogFragment<BottomSheetV
showFragment(
VerificationEmojiCodeFragment::class,
VerificationArgs(
state.otherUserMxItem?.id ?: "",
state.otherUserId,
// If it was outgoing it.transaction id would be null, but the pending request
// would be updated (from localId to txId)
state.pendingRequest.invoke()?.transactionId ?: state.transactionId
@ -271,7 +267,7 @@ class VerificationBottomSheet : VectorBaseBottomSheetDialogFragment<BottomSheetV
VerificationQRWaitingFragment::class,
VerificationQRWaitingFragment.Args(
isMe = state.isMe,
otherUserName = state.otherUserMxItem?.getBestName() ?: ""
otherUserName = state.otherUserMxItem.getBestName()
)
)
return@withState
@ -319,7 +315,7 @@ class VerificationBottomSheet : VectorBaseBottomSheetDialogFragment<BottomSheetV
showFragment(
VerificationChooseMethodFragment::class,
VerificationArgs(
otherUserId = state.otherUserMxItem?.id ?: "",
otherUserId = state.otherUserId,
verificationId = state.pendingRequest.invoke()?.transactionId
)
)
@ -328,7 +324,7 @@ class VerificationBottomSheet : VectorBaseBottomSheetDialogFragment<BottomSheetV
showFragment(
VerificationRequestFragment::class,
VerificationArgs(
otherUserId = state.otherUserMxItem?.id ?: "",
otherUserId = state.otherUserId,
verificationId = state.pendingRequest.invoke()?.transactionId,
verificationLocalId = state.roomId
)
@ -340,7 +336,7 @@ class VerificationBottomSheet : VectorBaseBottomSheetDialogFragment<BottomSheetV
showFragment(
VerificationChooseMethodFragment::class,
VerificationArgs(
otherUserId = state.otherUserMxItem?.id ?: "",
otherUserId = state.otherUserId,
verificationId = state.pendingRequest.invoke()?.transactionId
)
)

View File

@ -37,6 +37,7 @@ import kotlinx.coroutines.launch
import org.matrix.android.sdk.api.Matrix
import org.matrix.android.sdk.api.MatrixCallback
import org.matrix.android.sdk.api.extensions.orFalse
import org.matrix.android.sdk.api.extensions.tryOrNull
import org.matrix.android.sdk.api.raw.RawService
import org.matrix.android.sdk.api.session.Session
import org.matrix.android.sdk.api.session.crypto.crosssigning.KEYBACKUP_SECRET_SSSS_NAME
@ -70,7 +71,7 @@ data class VerificationBottomSheetViewState(
val roomId: String?,
// true when we display the loading and we wait for the other (incoming request)
val selfVerificationMode: Boolean,
val otherUserMxItem: MatrixItem? = null,
val otherUserMxItem: MatrixItem,
val pendingRequest: Async<PendingVerificationRequest> = Uninitialized,
val pendingLocalId: String? = null,
val sasTransactionState: VerificationTxState? = null,
@ -92,7 +93,8 @@ data class VerificationBottomSheetViewState(
otherUserId = args.otherUserId,
verificationId = args.verificationId,
roomId = args.roomId,
selfVerificationMode = args.selfVerificationMode
selfVerificationMode = args.selfVerificationMode,
otherUserMxItem = MatrixItem.UserItem(args.otherUserId),
)
}
@ -126,7 +128,7 @@ class VerificationBottomSheetViewModel @AssistedInject constructor(
}
}
val userItem = session.getUser(initialState.otherUserId)
fetchOtherUserProfile(initialState.otherUserId)
var autoReady = false
val pr = if (initialState.selfVerificationMode) {
@ -160,7 +162,6 @@ class VerificationBottomSheetViewModel @AssistedInject constructor(
setState {
copy(
otherUserMxItem = userItem?.toMatrixItem(),
sasTransactionState = sasTx?.state,
qrTransactionState = qrTx?.state,
transactionId = pr?.transactionId ?: initialState.verificationId,
@ -183,6 +184,28 @@ class VerificationBottomSheetViewModel @AssistedInject constructor(
}
}
private fun fetchOtherUserProfile(otherUserId: String) {
session.getUser(otherUserId)?.toMatrixItem()?.let {
setState {
copy(
otherUserMxItem = it
)
}
}
// Always fetch the latest User data
viewModelScope.launch {
tryOrNull { session.userService().resolveUser(otherUserId) }
?.toMatrixItem()
?.let {
setState {
copy(
otherUserMxItem = it
)
}
}
}
}
override fun onCleared() {
session.cryptoService().verificationService().removeListener(this)
super.onCleared()
@ -216,12 +239,12 @@ class VerificationBottomSheetViewModel @AssistedInject constructor(
private fun cancelAllPendingVerifications(state: VerificationBottomSheetViewState) {
session.cryptoService()
.verificationService().getExistingVerificationRequest(state.otherUserMxItem?.id ?: "", state.transactionId)?.let {
.verificationService().getExistingVerificationRequest(state.otherUserId, state.transactionId)?.let {
session.cryptoService().verificationService().cancelVerificationRequest(it)
}
session.cryptoService()
.verificationService()
.getExistingTransaction(state.otherUserMxItem?.id ?: "", state.transactionId ?: "")
.getExistingTransaction(state.otherUserId, state.transactionId ?: "")
?.cancel(CancelCode.User)
}
@ -249,7 +272,7 @@ class VerificationBottomSheetViewModel @AssistedInject constructor(
}
override fun handle(action: VerificationAction) = withState { state ->
val otherUserId = state.otherUserMxItem?.id ?: return@withState
val otherUserId = state.otherUserId
val roomId = state.roomId
?: session.roomService().getExistingDirectRoomWithUser(otherUserId)
@ -514,7 +537,7 @@ class VerificationBottomSheetViewModel @AssistedInject constructor(
override fun transactionUpdated(tx: VerificationTransaction) = withState { state ->
if (state.selfVerificationMode && state.transactionId == null) {
// is this an incoming with that user
if (tx.isIncoming && tx.otherUserId == state.otherUserMxItem?.id) {
if (tx.isIncoming && tx.otherUserId == state.otherUserId) {
// Also auto accept incoming if needed!
if (tx is IncomingSasVerificationTransaction) {
if (tx.uxState == IncomingSasVerificationTransaction.UxState.SHOW_ACCEPT) {
@ -564,7 +587,7 @@ class VerificationBottomSheetViewModel @AssistedInject constructor(
if (state.selfVerificationMode && state.pendingRequest.invoke() == null && state.transactionId == null) {
// is this an incoming with that user
if (pr.isIncoming && pr.otherUserId == state.otherUserMxItem?.id) {
if (pr.isIncoming && pr.otherUserId == state.otherUserId) {
if (!pr.isReady) {
// auto ready in this case, as we are waiting
// TODO, can I be here in DM mode? in this case should test if roomID is null?

View File

@ -26,6 +26,7 @@ import im.vector.app.core.utils.colorizeMatchingText
import im.vector.app.features.crypto.verification.VerificationBottomSheetViewState
import im.vector.app.features.crypto.verification.epoxy.bottomSheetVerificationActionItem
import im.vector.app.features.crypto.verification.epoxy.bottomSheetVerificationNoticeItem
import im.vector.app.features.displayname.getBestName
import im.vector.lib.core.utils.epoxy.charsequence.EpoxyCharSequence
import im.vector.lib.core.utils.epoxy.charsequence.toEpoxyCharSequence
import javax.inject.Inject
@ -60,8 +61,8 @@ class VerificationCancelController @Inject constructor(
}
}
} else {
val otherUserID = state.otherUserMxItem?.id ?: ""
val otherDisplayName = state.otherUserMxItem?.displayName ?: ""
val otherUserID = state.otherUserId
val otherDisplayName = state.otherUserMxItem.getBestName()
bottomSheetVerificationNoticeItem {
id("notice")
notice(

View File

@ -78,7 +78,7 @@ class VerificationChooseMethodFragment :
override fun doVerifyBySas() = withState(sharedViewModel) { state ->
sharedViewModel.handle(
VerificationAction.StartSASVerification(
state.otherUserMxItem?.id ?: "",
state.otherUserId,
state.pendingRequest.invoke()?.transactionId ?: ""
)
)
@ -130,7 +130,7 @@ class VerificationChooseMethodFragment :
private fun onRemoteQrCodeScanned(remoteQrCode: String) = withState(sharedViewModel) { state ->
sharedViewModel.handle(
VerificationAction.RemoteQrCodeScanned(
state.otherUserMxItem?.id ?: "",
state.otherUserId,
state.pendingRequest.invoke()?.transactionId ?: "",
remoteQrCode
)

View File

@ -136,7 +136,7 @@ class VerificationEmojiCodeController @Inject constructor(
if (state.isWaitingFromOther) {
bottomSheetVerificationWaitingItem {
id("waiting")
title(host.stringProvider.getString(R.string.verification_request_waiting_for, state.otherUser?.getBestName() ?: ""))
title(host.stringProvider.getString(R.string.verification_request_waiting_for, state.otherUser.getBestName()))
}
} else {
bottomSheetVerificationActionItem {

View File

@ -68,13 +68,13 @@ class VerificationEmojiCodeFragment :
}
override fun onMatchButtonTapped() = withState(viewModel) { state ->
val otherUserId = state.otherUser?.id ?: return@withState
val otherUserId = state.otherUser.id
val txId = state.transactionId ?: return@withState
sharedViewModel.handle(VerificationAction.SASMatchAction(otherUserId, txId))
}
override fun onDoNotMatchButtonTapped() = withState(viewModel) { state ->
val otherUserId = state.otherUser?.id ?: return@withState
val otherUserId = state.otherUser.id
val txId = state.transactionId ?: return@withState
sharedViewModel.handle(VerificationAction.SASDoNotMatchAction(otherUserId, txId))
}

View File

@ -40,13 +40,13 @@ import org.matrix.android.sdk.api.session.crypto.verification.SasVerificationTra
import org.matrix.android.sdk.api.session.crypto.verification.VerificationService
import org.matrix.android.sdk.api.session.crypto.verification.VerificationTransaction
import org.matrix.android.sdk.api.session.crypto.verification.VerificationTxState
import org.matrix.android.sdk.api.session.getUser
import org.matrix.android.sdk.api.session.getUserOrDefault
import org.matrix.android.sdk.api.util.MatrixItem
import org.matrix.android.sdk.api.util.toMatrixItem
data class VerificationEmojiCodeViewState(
val transactionId: String?,
val otherUser: MatrixItem? = null,
val otherUser: MatrixItem,
val supportsEmoji: Boolean = true,
val emojiDescription: Async<List<EmojiRepresentation>> = Uninitialized,
val decimalDescription: Async<String> = Uninitialized,
@ -59,15 +59,13 @@ class VerificationEmojiCodeViewModel @AssistedInject constructor(
) : VectorViewModel<VerificationEmojiCodeViewState, EmptyAction, EmptyViewEvents>(initialState), VerificationService.Listener {
init {
withState { state ->
refreshStateFromTx(
session.cryptoService().verificationService()
.getExistingTransaction(
state.otherUser?.id ?: "", state.transactionId
?: ""
) as? SasVerificationTransaction
)
}
refreshStateFromTx(
session.cryptoService().verificationService()
.getExistingTransaction(
otherUserId = initialState.otherUser.id,
tid = initialState.transactionId ?: ""
) as? SasVerificationTransaction
)
session.cryptoService().verificationService().addListener(this)
}
@ -165,10 +163,10 @@ class VerificationEmojiCodeViewModel @AssistedInject constructor(
companion object : MavericksViewModelFactory<VerificationEmojiCodeViewModel, VerificationEmojiCodeViewState> by hiltMavericksViewModelFactory() {
override fun initialState(viewModelContext: ViewModelContext): VerificationEmojiCodeViewState? {
override fun initialState(viewModelContext: ViewModelContext): VerificationEmojiCodeViewState {
val args = viewModelContext.args<VerificationBottomSheet.VerificationArgs>()
val session = EntryPoints.get(viewModelContext.app(), SingletonEntryPoint::class.java).activeSessionHolder().getActiveSession()
val matrixItem = session.getUser(args.otherUserId)?.toMatrixItem()
val matrixItem = session.getUserOrDefault(args.otherUserId).toMatrixItem()
return VerificationEmojiCodeViewState(
transactionId = args.verificationId,

View File

@ -54,7 +54,7 @@ class VerificationQrScannedByOtherController @Inject constructor(
if (state.isMe) {
notice(host.stringProvider.getString(R.string.qr_code_scanned_self_verif_notice).toEpoxyCharSequence())
} else {
val name = state.otherUserMxItem?.getBestName() ?: ""
val name = state.otherUserMxItem.getBestName()
notice(host.stringProvider.getString(R.string.qr_code_scanned_by_other_notice, name).toEpoxyCharSequence())
}
}

View File

@ -52,7 +52,6 @@ class VerificationRequestController @Inject constructor(
override fun buildModels() {
val state = viewState ?: return
val matrixItem = viewState?.otherUserMxItem ?: return
val host = this
if (state.selfVerificationMode) {
@ -107,11 +106,9 @@ class VerificationRequestController @Inject constructor(
if (state.isMe) {
stringProvider.getString(R.string.verify_new_session_notice)
} else {
matrixItem.let {
stringProvider.getString(R.string.verification_request_notice, it.id)
.toSpannable()
.colorizeMatchingText(it.id, colorProvider.getColorFromAttribute(R.attr.vctr_notice_text_color))
}
stringProvider.getString(R.string.verification_request_notice, state.otherUserId)
.toSpannable()
.colorizeMatchingText(state.otherUserId, colorProvider.getColorFromAttribute(R.attr.vctr_notice_text_color))
}
bottomSheetVerificationNoticeItem {
@ -138,7 +135,7 @@ class VerificationRequestController @Inject constructor(
is Loading -> {
bottomSheetVerificationWaitingItem {
id("waiting")
title(host.stringProvider.getString(R.string.verification_request_waiting_for, matrixItem.getBestName()))
title(host.stringProvider.getString(R.string.verification_request_waiting_for, state.otherUserMxItem.getBestName()))
}
}
is Success -> {
@ -151,7 +148,7 @@ class VerificationRequestController @Inject constructor(
} else {
bottomSheetVerificationWaitingItem {
id("waiting")
title(host.stringProvider.getString(R.string.verification_request_waiting_for, matrixItem.getBestName()))
title(host.stringProvider.getString(R.string.verification_request_waiting_for, state.otherUserMxItem.getBestName()))
}
}
}

View File

@ -64,9 +64,7 @@ class VerificationRequestFragment :
}
override fun onClickOnVerificationStart(): Unit = withState(viewModel) { state ->
state.otherUserMxItem?.id?.let { otherUserId ->
viewModel.handle(VerificationAction.RequestVerificationByDM(otherUserId, state.roomId))
}
viewModel.handle(VerificationAction.RequestVerificationByDM(state.otherUserId, state.roomId))
}
override fun onClickRecoverFromPassphrase() {

View File

@ -514,7 +514,7 @@ class HomeActivity :
)
}
private fun promptSecurityEvent(userItem: MatrixItem.UserItem?, titleRes: Int, descRes: Int, action: ((VectorBaseActivity<*>) -> Unit)) {
private fun promptSecurityEvent(userItem: MatrixItem.UserItem, titleRes: Int, descRes: Int, action: ((VectorBaseActivity<*>) -> Unit)) {
popupAlertManager.postVectorAlert(
VerificationVectorAlert(
uid = "upgradeSecurity",

View File

@ -20,13 +20,13 @@ import im.vector.app.core.platform.VectorViewEvents
import org.matrix.android.sdk.api.util.MatrixItem
sealed interface HomeActivityViewEvents : VectorViewEvents {
data class AskPasswordToInitCrossSigning(val userItem: MatrixItem.UserItem?) : HomeActivityViewEvents
data class AskPasswordToInitCrossSigning(val userItem: MatrixItem.UserItem) : HomeActivityViewEvents
data class CurrentSessionNotVerified(
val userItem: MatrixItem.UserItem?,
val userItem: MatrixItem.UserItem,
val waitForIncomingRequest: Boolean = true,
) : HomeActivityViewEvents
data class CurrentSessionCannotBeVerified(
val userItem: MatrixItem.UserItem?,
val userItem: MatrixItem.UserItem,
) : HomeActivityViewEvents
data class OnCrossSignedInvalidated(val userItem: MatrixItem.UserItem) : HomeActivityViewEvents
object PromptToEnableSessionPush : HomeActivityViewEvents

View File

@ -60,7 +60,7 @@ import org.matrix.android.sdk.api.raw.RawService
import org.matrix.android.sdk.api.session.crypto.crosssigning.CrossSigningService
import org.matrix.android.sdk.api.session.crypto.model.CryptoDeviceInfo
import org.matrix.android.sdk.api.session.crypto.model.MXUsersDevicesMap
import org.matrix.android.sdk.api.session.getUser
import org.matrix.android.sdk.api.session.getUserOrDefault
import org.matrix.android.sdk.api.session.pushrules.RuleIds
import org.matrix.android.sdk.api.session.room.model.Membership
import org.matrix.android.sdk.api.session.room.roomSummaryQueryParams
@ -312,10 +312,10 @@ class HomeActivityViewModel @AssistedInject constructor(
} else {
// cross signing keys have been reset
// Trigger a popup to re-verify
// Note: user can be null in case of logout
session.getUser(session.myUserId)
?.toMatrixItem()
?.let { user ->
// Note: user can be unknown in case of logout
session.getUserOrDefault(session.myUserId)
.toMatrixItem()
.let { user ->
_viewEvents.post(HomeActivityViewEvents.OnCrossSignedInvalidated(user))
}
}
@ -396,7 +396,7 @@ class HomeActivityViewModel @AssistedInject constructor(
// New session
_viewEvents.post(
HomeActivityViewEvents.CurrentSessionNotVerified(
session.getUser(session.myUserId)?.toMatrixItem(),
session.getUserOrDefault(session.myUserId).toMatrixItem(),
// Always send request instead of waiting for an incoming as per recent EW changes
false
)
@ -404,7 +404,7 @@ class HomeActivityViewModel @AssistedInject constructor(
} else {
_viewEvents.post(
HomeActivityViewEvents.CurrentSessionCannotBeVerified(
session.getUser(session.myUserId)?.toMatrixItem(),
session.getUserOrDefault(session.myUserId).toMatrixItem(),
)
)
}
@ -424,7 +424,7 @@ class HomeActivityViewModel @AssistedInject constructor(
// Check this is not an SSO account
if (session.homeServerCapabilitiesService().getHomeServerCapabilities().canChangePassword) {
// Ask password to the user: Upgrade security
_viewEvents.post(HomeActivityViewEvents.AskPasswordToInitCrossSigning(session.getUser(session.myUserId)?.toMatrixItem()))
_viewEvents.post(HomeActivityViewEvents.AskPasswordToInitCrossSigning(session.getUserOrDefault(session.myUserId).toMatrixItem()))
}
// Else (SSO) just ignore for the moment
} else {

View File

@ -21,10 +21,13 @@ import com.airbnb.mvrx.MavericksState
import com.airbnb.mvrx.MavericksViewModelFactory
import com.airbnb.mvrx.Success
import com.airbnb.mvrx.Uninitialized
import com.airbnb.mvrx.ViewModelContext
import dagger.assisted.Assisted
import dagger.assisted.AssistedFactory
import dagger.assisted.AssistedInject
import dagger.hilt.EntryPoints
import im.vector.app.core.di.MavericksAssistedViewModelFactory
import im.vector.app.core.di.SingletonEntryPoint
import im.vector.app.core.di.hiltMavericksViewModelFactory
import im.vector.app.core.platform.EmptyViewEvents
import im.vector.app.core.platform.VectorViewModel
@ -40,14 +43,14 @@ import org.matrix.android.sdk.api.NoOpMatrixCallback
import org.matrix.android.sdk.api.extensions.orFalse
import org.matrix.android.sdk.api.session.Session
import org.matrix.android.sdk.api.session.crypto.model.DeviceInfo
import org.matrix.android.sdk.api.session.getUser
import org.matrix.android.sdk.api.session.getUserOrDefault
import org.matrix.android.sdk.api.util.MatrixItem
import org.matrix.android.sdk.api.util.toMatrixItem
import org.matrix.android.sdk.flow.flow
import timber.log.Timber
data class UnknownDevicesState(
val myMatrixItem: MatrixItem.UserItem? = null,
val myMatrixItem: MatrixItem.UserItem,
val unknownSessions: Async<List<DeviceDetectionInfo>> = Uninitialized
) : MavericksState
@ -73,7 +76,15 @@ class UnknownDeviceDetectorSharedViewModel @AssistedInject constructor(
override fun create(initialState: UnknownDevicesState): UnknownDeviceDetectorSharedViewModel
}
companion object : MavericksViewModelFactory<UnknownDeviceDetectorSharedViewModel, UnknownDevicesState> by hiltMavericksViewModelFactory()
companion object : MavericksViewModelFactory<UnknownDeviceDetectorSharedViewModel, UnknownDevicesState> by hiltMavericksViewModelFactory() {
override fun initialState(viewModelContext: ViewModelContext): UnknownDevicesState {
val session = EntryPoints.get(viewModelContext.app(), SingletonEntryPoint::class.java).activeSessionHolder().getActiveSession()
return UnknownDevicesState(
myMatrixItem = session.getUserOrDefault(session.myUserId).toMatrixItem()
)
}
}
private val ignoredDeviceList = ArrayList<String>()
@ -118,7 +129,7 @@ class UnknownDeviceDetectorSharedViewModel @AssistedInject constructor(
.execute { async ->
// Timber.v("## Detector trigger passed distinct")
copy(
myMatrixItem = session.getUser(session.myUserId)?.toMatrixItem(),
myMatrixItem = session.getUserOrDefault(session.myUserId).toMatrixItem(),
unknownSessions = async
)
}

View File

@ -32,6 +32,7 @@ import im.vector.app.core.platform.StateView
import im.vector.app.core.platform.VectorViewModel
import im.vector.app.core.resources.DrawableProvider
import im.vector.app.core.resources.StringProvider
import im.vector.app.features.displayname.getBestName
import im.vector.app.features.home.room.list.home.header.HomeRoomFilter
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.Flow
@ -53,6 +54,7 @@ import org.matrix.android.sdk.api.query.RoomTagQueryFilter
import org.matrix.android.sdk.api.query.toActiveSpaceOrNoFilter
import org.matrix.android.sdk.api.session.Session
import org.matrix.android.sdk.api.session.getRoom
import org.matrix.android.sdk.api.session.getUserOrDefault
import org.matrix.android.sdk.api.session.room.RoomSortOrder
import org.matrix.android.sdk.api.session.room.RoomSummaryQueryParams
import org.matrix.android.sdk.api.session.room.UpdatableLivePageResult
@ -62,6 +64,7 @@ import org.matrix.android.sdk.api.session.room.model.tag.RoomTag
import org.matrix.android.sdk.api.session.room.roomSummaryQueryParams
import org.matrix.android.sdk.api.session.room.state.isPublic
import org.matrix.android.sdk.api.util.Optional
import org.matrix.android.sdk.api.util.toMatrixItem
import org.matrix.android.sdk.flow.flow
class HomeRoomListViewModel @AssistedInject constructor(
@ -298,7 +301,7 @@ class HomeRoomListViewModel @AssistedInject constructor(
isBigImage = true
)
} else {
val userName = session.userService().getUser(session.myUserId)?.displayName ?: ""
val userName = session.getUserOrDefault(session.myUserId).toMatrixItem().getBestName()
StateView.State.Empty(
title = stringProvider.getString(R.string.home_empty_no_rooms_title, userName),
message = stringProvider.getString(R.string.home_empty_no_rooms_message),

View File

@ -42,14 +42,17 @@ class NewChatBottomSheet : VectorBaseBottomSheetDialogFragment<FragmentNewChatBo
private fun initFABs() {
views.startChat.debouncedClicks {
dismiss()
navigator.openCreateDirectRoom(requireActivity())
}
views.createRoom.debouncedClicks {
dismiss()
navigator.openCreateRoom(requireActivity())
}
views.exploreRooms.debouncedClicks {
dismiss()
navigator.openRoomDirectory(requireContext())
}
}

View File

@ -38,13 +38,13 @@ class VerificationVectorAlert(
override val layoutRes = R.layout.alerter_verification_layout
class ViewBinder(
private val matrixItem: MatrixItem?,
private val matrixItem: MatrixItem,
private val avatarRenderer: AvatarRenderer
) : VectorAlert.ViewBinder {
override fun bind(view: View) {
val views = AlerterVerificationLayoutBinding.bind(view)
matrixItem?.let { avatarRenderer.render(it, views.ivUserAvatar, GlideApp.with(view.context.applicationContext)) }
avatarRenderer.render(matrixItem, views.ivUserAvatar, GlideApp.with(view.context.applicationContext))
}
}
}

View File

@ -47,6 +47,7 @@ import org.matrix.android.sdk.api.session.Session
import org.matrix.android.sdk.api.session.events.model.toContent
import org.matrix.android.sdk.api.session.events.model.toModel
import org.matrix.android.sdk.api.session.getRoom
import org.matrix.android.sdk.api.session.getUserOrDefault
import org.matrix.android.sdk.api.session.room.RoomSortOrder
import org.matrix.android.sdk.api.session.room.accountdata.RoomAccountDataTypes
import org.matrix.android.sdk.api.session.room.model.Membership
@ -272,7 +273,7 @@ class SpaceListViewModel @AssistedInject constructor(
?.safeOrder()
}
val inviterIds = spaces.mapNotNull { it.inviterId }
val inviters = inviterIds.mapNotNull { session.userService().getUser(it) }
val inviters = inviterIds.map { session.getUserOrDefault(it) }
copy(
asyncSpaces = asyncSpaces,
spaces = spaces,

File diff suppressed because one or more lines are too long