Refacto: let's matrixItem be part of the constructor

This commit is contained in:
Benoit Marty 2020-09-04 20:42:35 +02:00
parent 254eb26211
commit ac4c111ad3
4 changed files with 18 additions and 19 deletions

View File

@ -76,10 +76,10 @@ class IncomingVerificationRequestHandler @Inject constructor(
}
} ?: true
} else true
})
},
matrixItem = session?.getUser(tx.otherUserId)?.toMatrixItem()
)
.apply {
matrixItem = session?.getUser(tx.otherUserId)?.toMatrixItem()
contentAction = Runnable {
(weakCurrentActivity?.get() as? VectorBaseActivity)?.let {
it.navigator.performDeviceVerification(it, tx.otherUserId, tx.transactionId)
@ -132,10 +132,10 @@ class IncomingVerificationRequestHandler @Inject constructor(
it.roomId != pr.roomId
} ?: true
} else true
})
},
matrixItem = session?.getUser(pr.otherUserId)?.toMatrixItem()
)
.apply {
matrixItem = session?.getUser(pr.otherUserId)?.toMatrixItem()
contentAction = Runnable {
(weakCurrentActivity?.get() as? VectorBaseActivity)?.let {
val roomId = pr.roomId

View File

@ -50,11 +50,11 @@ import im.vector.app.features.themes.ThemeUtils
import im.vector.app.features.workers.signout.ServerBackupStatusViewModel
import im.vector.app.features.workers.signout.ServerBackupStatusViewState
import im.vector.app.push.fcm.FcmHelper
import org.matrix.android.sdk.api.session.InitialSyncProgressService
import org.matrix.android.sdk.api.util.MatrixItem
import kotlinx.android.parcel.Parcelize
import kotlinx.android.synthetic.main.activity_home.*
import kotlinx.android.synthetic.main.merge_overlay_waiting_view.*
import org.matrix.android.sdk.api.session.InitialSyncProgressService
import org.matrix.android.sdk.api.util.MatrixItem
import timber.log.Timber
import javax.inject.Inject
@ -239,9 +239,9 @@ class HomeActivity : VectorBaseActivity(), ToolbarConfigurable, UnknownDeviceDet
uid = "upgradeSecurity",
title = getString(titleRes),
description = getString(descRes),
iconId = R.drawable.ic_shield_warning
iconId = R.drawable.ic_shield_warning,
matrixItem = userItem
).apply {
matrixItem = userItem
colorInt = ContextCompat.getColor(this@HomeActivity, R.color.riotx_positive_accent)
contentAction = Runnable {
(weakCurrentActivity?.get() as? VectorBaseActivity)?.let {

View File

@ -46,10 +46,10 @@ import im.vector.app.features.themes.ThemeUtils
import im.vector.app.features.workers.signout.BannerState
import im.vector.app.features.workers.signout.ServerBackupStatusViewModel
import im.vector.app.features.workers.signout.ServerBackupStatusViewState
import kotlinx.android.synthetic.main.fragment_home_detail.*
import org.matrix.android.sdk.api.session.group.model.GroupSummary
import org.matrix.android.sdk.api.util.toMatrixItem
import org.matrix.android.sdk.internal.crypto.model.rest.DeviceInfo
import kotlinx.android.synthetic.main.fragment_home_detail.*
import timber.log.Timber
import javax.inject.Inject
@ -151,9 +151,9 @@ class HomeDetailFragment @Inject constructor(
uid = uid,
title = getString(R.string.new_session),
description = getString(R.string.verify_this_session, newest.displayName ?: newest.deviceId ?: ""),
iconId = R.drawable.ic_shield_warning
iconId = R.drawable.ic_shield_warning,
matrixItem = user
).apply {
matrixItem = user
colorInt = ContextCompat.getColor(requireActivity(), R.color.riotx_accent)
contentAction = Runnable {
(weakCurrentActivity?.get() as? VectorBaseActivity)
@ -179,9 +179,9 @@ class HomeDetailFragment @Inject constructor(
uid = uid,
title = getString(R.string.review_logins),
description = getString(R.string.verify_other_sessions),
iconId = R.drawable.ic_shield_warning
iconId = R.drawable.ic_shield_warning,
matrixItem = user
).apply {
matrixItem = user
colorInt = ContextCompat.getColor(requireActivity(), R.color.riotx_accent)
contentAction = Runnable {
(weakCurrentActivity?.get() as? VectorBaseActivity)?.let {

View File

@ -94,9 +94,8 @@ class VerificationVectorAlert(uid: String,
/**
* Alert are displayed by default, but let this lambda return false to prevent displaying
*/
override val shouldBeDisplayedIn: ((Activity) -> Boolean) = { true }
override val shouldBeDisplayedIn: ((Activity) -> Boolean) = { true },
val matrixItem: MatrixItem?
) : DefaultVectorAlert(
uid, title, description, iconId, shouldBeDisplayedIn
) {
var matrixItem: MatrixItem? = null
}
)