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 } ?: true
} else true } else true
}) },
.apply {
matrixItem = session?.getUser(tx.otherUserId)?.toMatrixItem() matrixItem = session?.getUser(tx.otherUserId)?.toMatrixItem()
)
.apply {
contentAction = Runnable { contentAction = Runnable {
(weakCurrentActivity?.get() as? VectorBaseActivity)?.let { (weakCurrentActivity?.get() as? VectorBaseActivity)?.let {
it.navigator.performDeviceVerification(it, tx.otherUserId, tx.transactionId) it.navigator.performDeviceVerification(it, tx.otherUserId, tx.transactionId)
@ -132,10 +132,10 @@ class IncomingVerificationRequestHandler @Inject constructor(
it.roomId != pr.roomId it.roomId != pr.roomId
} ?: true } ?: true
} else true } else true
}) },
.apply {
matrixItem = session?.getUser(pr.otherUserId)?.toMatrixItem() matrixItem = session?.getUser(pr.otherUserId)?.toMatrixItem()
)
.apply {
contentAction = Runnable { contentAction = Runnable {
(weakCurrentActivity?.get() as? VectorBaseActivity)?.let { (weakCurrentActivity?.get() as? VectorBaseActivity)?.let {
val roomId = pr.roomId 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.ServerBackupStatusViewModel
import im.vector.app.features.workers.signout.ServerBackupStatusViewState import im.vector.app.features.workers.signout.ServerBackupStatusViewState
import im.vector.app.push.fcm.FcmHelper 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.parcel.Parcelize
import kotlinx.android.synthetic.main.activity_home.* import kotlinx.android.synthetic.main.activity_home.*
import kotlinx.android.synthetic.main.merge_overlay_waiting_view.* 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 timber.log.Timber
import javax.inject.Inject import javax.inject.Inject
@ -239,9 +239,9 @@ class HomeActivity : VectorBaseActivity(), ToolbarConfigurable, UnknownDeviceDet
uid = "upgradeSecurity", uid = "upgradeSecurity",
title = getString(titleRes), title = getString(titleRes),
description = getString(descRes), description = getString(descRes),
iconId = R.drawable.ic_shield_warning iconId = R.drawable.ic_shield_warning,
).apply {
matrixItem = userItem matrixItem = userItem
).apply {
colorInt = ContextCompat.getColor(this@HomeActivity, R.color.riotx_positive_accent) colorInt = ContextCompat.getColor(this@HomeActivity, R.color.riotx_positive_accent)
contentAction = Runnable { contentAction = Runnable {
(weakCurrentActivity?.get() as? VectorBaseActivity)?.let { (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.BannerState
import im.vector.app.features.workers.signout.ServerBackupStatusViewModel import im.vector.app.features.workers.signout.ServerBackupStatusViewModel
import im.vector.app.features.workers.signout.ServerBackupStatusViewState 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.session.group.model.GroupSummary
import org.matrix.android.sdk.api.util.toMatrixItem import org.matrix.android.sdk.api.util.toMatrixItem
import org.matrix.android.sdk.internal.crypto.model.rest.DeviceInfo import org.matrix.android.sdk.internal.crypto.model.rest.DeviceInfo
import kotlinx.android.synthetic.main.fragment_home_detail.*
import timber.log.Timber import timber.log.Timber
import javax.inject.Inject import javax.inject.Inject
@ -151,9 +151,9 @@ class HomeDetailFragment @Inject constructor(
uid = uid, uid = uid,
title = getString(R.string.new_session), title = getString(R.string.new_session),
description = getString(R.string.verify_this_session, newest.displayName ?: newest.deviceId ?: ""), description = getString(R.string.verify_this_session, newest.displayName ?: newest.deviceId ?: ""),
iconId = R.drawable.ic_shield_warning iconId = R.drawable.ic_shield_warning,
).apply {
matrixItem = user matrixItem = user
).apply {
colorInt = ContextCompat.getColor(requireActivity(), R.color.riotx_accent) colorInt = ContextCompat.getColor(requireActivity(), R.color.riotx_accent)
contentAction = Runnable { contentAction = Runnable {
(weakCurrentActivity?.get() as? VectorBaseActivity) (weakCurrentActivity?.get() as? VectorBaseActivity)
@ -179,9 +179,9 @@ class HomeDetailFragment @Inject constructor(
uid = uid, uid = uid,
title = getString(R.string.review_logins), title = getString(R.string.review_logins),
description = getString(R.string.verify_other_sessions), description = getString(R.string.verify_other_sessions),
iconId = R.drawable.ic_shield_warning iconId = R.drawable.ic_shield_warning,
).apply {
matrixItem = user matrixItem = user
).apply {
colorInt = ContextCompat.getColor(requireActivity(), R.color.riotx_accent) colorInt = ContextCompat.getColor(requireActivity(), R.color.riotx_accent)
contentAction = Runnable { contentAction = Runnable {
(weakCurrentActivity?.get() as? VectorBaseActivity)?.let { (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 * 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( ) : DefaultVectorAlert(
uid, title, description, iconId, shouldBeDisplayedIn uid, title, description, iconId, shouldBeDisplayedIn
) { )
var matrixItem: MatrixItem? = null
}