From 51532687b9ebd5c9274ec448e699443c8aaa8aaa Mon Sep 17 00:00:00 2001 From: Maxime NATUREL Date: Mon, 12 Sep 2022 17:47:29 +0200 Subject: [PATCH] Learn more in session overview screen --- .../v2/VectorSettingsDevicesFragment.kt | 2 +- .../v2/overview/SessionOverviewFragment.kt | 24 ++++++++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/v2/VectorSettingsDevicesFragment.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/VectorSettingsDevicesFragment.kt index 885a91b9d7..2a90cf6c19 100644 --- a/vector/src/main/java/im/vector/app/features/settings/devices/v2/VectorSettingsDevicesFragment.kt +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/VectorSettingsDevicesFragment.kt @@ -168,7 +168,7 @@ class VectorSettingsDevicesFragment : append(getString(R.string.device_manager_learn_more_sessions_unverified)) append("\n\n") append(getString(R.string.device_manager_learn_more_sessions_inactive)) - } + }, ) SessionLearnMoreBottomSheet.show(childFragmentManager, args) } diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/v2/overview/SessionOverviewFragment.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/overview/SessionOverviewFragment.kt index 4af4913183..46121340b5 100644 --- a/vector/src/main/java/im/vector/app/features/settings/devices/v2/overview/SessionOverviewFragment.kt +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/overview/SessionOverviewFragment.kt @@ -22,7 +22,6 @@ import android.view.LayoutInflater import android.view.MenuItem import android.view.View import android.view.ViewGroup -import android.widget.Toast import androidx.appcompat.app.AppCompatActivity import androidx.core.view.isVisible import com.airbnb.mvrx.Success @@ -44,6 +43,8 @@ import im.vector.app.features.settings.devices.v2.list.SessionInfoViewState import im.vector.app.features.workers.signout.SignOutUiWorker import org.matrix.android.sdk.api.auth.data.LoginFlowTypes import org.matrix.android.sdk.api.extensions.orFalse +import im.vector.app.features.settings.devices.v2.more.SessionLearnMoreBottomSheet +import org.matrix.android.sdk.api.session.crypto.model.RoomEncryptionTrustLevel import javax.inject.Inject /** @@ -204,6 +205,9 @@ class SessionOverviewFragment : isLastSeenDetailsVisible = true, ) views.sessionOverviewInfo.render(infoViewState, dateFormatter, drawableProvider, colorProvider) + views.sessionOverviewInfo.onLearnMoreClickListener = { + showLearnMoreInfoVerificationStatus(viewState.deviceFullInfo.roomEncryptionTrustLevel == RoomEncryptionTrustLevel.Trusted) + } } else { views.sessionOverviewInfo.isVisible = false } @@ -249,4 +253,22 @@ class SessionOverviewFragment : reAuthActivityResultLauncher.launch(intent) } } + + private fun showLearnMoreInfoVerificationStatus(isVerified: Boolean) { + val titleResId = if (isVerified) { + R.string.device_manager_verification_status_verified + } else { + R.string.device_manager_verification_status_unverified + } + val descriptionResId = if (isVerified) { + R.string.device_manager_learn_more_session_verified + } else { + R.string.device_manager_learn_more_sessions_unverified + } + val args = SessionLearnMoreBottomSheet.Args( + title = getString(titleResId), + description = getString(descriptionResId), + ) + SessionLearnMoreBottomSheet.show(childFragmentManager, args) + } }