From ac4c111ad39d35f1563ea36cd1901f56af89325d Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Fri, 4 Sep 2020 20:42:35 +0200 Subject: [PATCH] Refacto: let's matrixItem be part of the constructor --- .../IncomingVerificationRequestHandler.kt | 12 ++++++------ .../java/im/vector/app/features/home/HomeActivity.kt | 8 ++++---- .../vector/app/features/home/HomeDetailFragment.kt | 10 +++++----- .../java/im/vector/app/features/popup/VectorAlert.kt | 7 +++---- 4 files changed, 18 insertions(+), 19 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/crypto/verification/IncomingVerificationRequestHandler.kt b/vector/src/main/java/im/vector/app/features/crypto/verification/IncomingVerificationRequestHandler.kt index fb8ef1f114..f662755e2c 100644 --- a/vector/src/main/java/im/vector/app/features/crypto/verification/IncomingVerificationRequestHandler.kt +++ b/vector/src/main/java/im/vector/app/features/crypto/verification/IncomingVerificationRequestHandler.kt @@ -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 diff --git a/vector/src/main/java/im/vector/app/features/home/HomeActivity.kt b/vector/src/main/java/im/vector/app/features/home/HomeActivity.kt index 62ae0bfc2c..76de2daf54 100644 --- a/vector/src/main/java/im/vector/app/features/home/HomeActivity.kt +++ b/vector/src/main/java/im/vector/app/features/home/HomeActivity.kt @@ -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 { diff --git a/vector/src/main/java/im/vector/app/features/home/HomeDetailFragment.kt b/vector/src/main/java/im/vector/app/features/home/HomeDetailFragment.kt index 7b8f1148c9..1c63d63ae0 100644 --- a/vector/src/main/java/im/vector/app/features/home/HomeDetailFragment.kt +++ b/vector/src/main/java/im/vector/app/features/home/HomeDetailFragment.kt @@ -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 { diff --git a/vector/src/main/java/im/vector/app/features/popup/VectorAlert.kt b/vector/src/main/java/im/vector/app/features/popup/VectorAlert.kt index 0b4fc1ce19..00f80240c5 100644 --- a/vector/src/main/java/im/vector/app/features/popup/VectorAlert.kt +++ b/vector/src/main/java/im/vector/app/features/popup/VectorAlert.kt @@ -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 -} +)