From 6eb5d9818094a81aae7d2ec7ae5721a58fe17b4b Mon Sep 17 00:00:00 2001 From: Maxime NATUREL Date: Mon, 12 Sep 2022 14:14:45 +0200 Subject: [PATCH 01/17] Add changelog entry --- changelog.d/7100.wip | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/7100.wip diff --git a/changelog.d/7100.wip b/changelog.d/7100.wip new file mode 100644 index 0000000000..47e7a6f810 --- /dev/null +++ b/changelog.d/7100.wip @@ -0,0 +1 @@ +[Device Management] Learn more bottom sheets From 70a5093e3d82eae12af70bdeb7378c31efcb209a Mon Sep 17 00:00:00 2001 From: Maxime NATUREL Date: Mon, 12 Sep 2022 14:37:38 +0200 Subject: [PATCH 02/17] Adding string resources --- library/ui-strings/src/main/res/values/strings.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/library/ui-strings/src/main/res/values/strings.xml b/library/ui-strings/src/main/res/values/strings.xml index 4ff7aae750..2170ec6c5b 100644 --- a/library/ui-strings/src/main/res/values/strings.xml +++ b/library/ui-strings/src/main/res/values/strings.xml @@ -3302,6 +3302,10 @@ Session name Custom session names can help you recognize your devices more easily. Please be aware that session names are also visible to people you communicate with. + Inactive sessions are sessions you have not used in some time. Removing inactive sessions can improve performance, and make it easier for you to identify if a new session is suspicious. In addition, inactive sessions continue to receive encryption keys and so may pose a security or privacy risk if an unauthorised person is able to access the session. + Unverified sessions are sessions that have logged in with your credentials but not been verified via cross-verification from a verified session, or using your passphrase. You should make especially certain that you recognise these sessions as they could represent an unauthorised use of your account. If you do recognise them, you should verify them as this allows your contacts to see that the new login is really you. + This session has logged in with your credentials and then been verified, either using your secure passphrase or by cross-verifying from another verified session. This means it holds encryption keys for your previous messages, and confirms to other users you are communicating with that the session is really you. + Other users in direct messages and rooms that you join are able to view a full list of your sessions, including which are verified and unverified. This provides them with confidence that they are really speaking to you, but it also means they can see the session name you enter here. %s\nis looking a little empty. From 1d11eae0cc69a98594fdbc9d96ae1177f547fa14 Mon Sep 17 00:00:00 2001 From: Maxime NATUREL Date: Mon, 12 Sep 2022 14:54:26 +0200 Subject: [PATCH 03/17] Removing learn more link from security header --- .../values/stylable_sessions_list_header_view.xml | 1 + .../devices/v2/list/SessionsListHeaderView.kt | 13 +++++++++++-- .../main/res/layout/fragment_settings_devices.xml | 3 +++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/library/ui-styles/src/main/res/values/stylable_sessions_list_header_view.xml b/library/ui-styles/src/main/res/values/stylable_sessions_list_header_view.xml index d3b931e44a..098ec263fc 100644 --- a/library/ui-styles/src/main/res/values/stylable_sessions_list_header_view.xml +++ b/library/ui-styles/src/main/res/values/stylable_sessions_list_header_view.xml @@ -4,6 +4,7 @@ + diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/v2/list/SessionsListHeaderView.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/list/SessionsListHeaderView.kt index ef8682df01..0264db08e1 100644 --- a/vector/src/main/java/im/vector/app/features/settings/devices/v2/list/SessionsListHeaderView.kt +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/list/SessionsListHeaderView.kt @@ -65,14 +65,23 @@ class SessionsListHeaderView @JvmOverloads constructor( return } + val hasLearnMoreLink = typedArray.getBoolean(R.styleable.SessionsListHeaderView_sessionsListHeaderHasLearnMoreLink, true) + if(hasLearnMoreLink) { + setDescriptionWithLearnMore(description) + } else { + binding.sessionsListHeaderDescription.text = description + } + + binding.sessionsListHeaderDescription.isVisible = true + } + + private fun setDescriptionWithLearnMore(description: String) { val learnMore = context.getString(R.string.action_learn_more) val fullDescription = buildString { append(description) append(" ") append(learnMore) } - - binding.sessionsListHeaderDescription.isVisible = true binding.sessionsListHeaderDescription.setTextWithColoredPart( fullText = fullDescription, coloredPart = learnMore, diff --git a/vector/src/main/res/layout/fragment_settings_devices.xml b/vector/src/main/res/layout/fragment_settings_devices.xml index 8e2daa2239..4f4e14eaad 100644 --- a/vector/src/main/res/layout/fragment_settings_devices.xml +++ b/vector/src/main/res/layout/fragment_settings_devices.xml @@ -14,6 +14,7 @@ android:layout_height="wrap_content" app:sessionsListHeaderDescription="@string/device_manager_header_section_security_recommendations_description" app:sessionsListHeaderTitle="@string/device_manager_header_section_security_recommendations_title" + app:sessionsListHeaderHasLearnMoreLink="false" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> @@ -62,6 +63,7 @@ android:layout_height="wrap_content" app:sessionsListHeaderDescription="" app:sessionsListHeaderTitle="@string/device_manager_current_session_title" + app:sessionsListHeaderHasLearnMoreLink="false" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/deviceListSecurityRecommendationsDivider" /> @@ -92,6 +94,7 @@ android:layout_height="wrap_content" app:sessionsListHeaderDescription="@string/device_manager_sessions_other_description" app:sessionsListHeaderTitle="@string/device_manager_sessions_other_title" + app:sessionsListHeaderHasLearnMoreLink="true" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/deviceListDividerCurrentSession" /> From 648311e2b10b7fb3528053394e915d95a3e11c46 Mon Sep 17 00:00:00 2001 From: Maxime NATUREL Date: Mon, 12 Sep 2022 15:54:15 +0200 Subject: [PATCH 04/17] Show basic bottom sheet when pressing learn more link from other sessions section --- .../src/main/res/values-ca/strings.xml | 4 +- .../src/main/res/values-cs/strings.xml | 2 +- .../src/main/res/values-de/strings.xml | 2 +- .../src/main/res/values-et/strings.xml | 2 +- .../src/main/res/values-fa/strings.xml | 4 +- .../src/main/res/values-fr/strings.xml | 2 +- .../src/main/res/values-hu/strings.xml | 2 +- .../src/main/res/values-in/strings.xml | 2 +- .../src/main/res/values-it/strings.xml | 2 +- .../src/main/res/values-nl/strings.xml | 2 +- .../src/main/res/values-pl/strings.xml | 2 +- .../src/main/res/values-pt-rBR/strings.xml | 2 +- .../src/main/res/values-ru/strings.xml | 2 +- .../src/main/res/values-sk/strings.xml | 2 +- .../src/main/res/values-uk/strings.xml | 2 +- .../src/main/res/values-zh-rCN/strings.xml | 2 +- .../src/main/res/values-zh-rTW/strings.xml | 2 +- .../src/main/res/values/strings.xml | 6 +- .../app/core/di/MavericksViewModelModule.kt | 6 ++ .../v2/VectorSettingsDevicesFragment.kt | 18 +++++- .../v2/more/SessionLearnMoreBottomSheet.kt | 62 +++++++++++++++++++ .../v2/more/SessionLearnMoreViewModel.kt | 43 +++++++++++++ .../v2/more/SessionLearnMoreViewState.kt | 29 +++++++++ .../bottom_sheet_session_learn_more.xml | 45 ++++++++++++++ 24 files changed, 222 insertions(+), 25 deletions(-) create mode 100644 vector/src/main/java/im/vector/app/features/settings/devices/v2/more/SessionLearnMoreBottomSheet.kt create mode 100644 vector/src/main/java/im/vector/app/features/settings/devices/v2/more/SessionLearnMoreViewModel.kt create mode 100644 vector/src/main/java/im/vector/app/features/settings/devices/v2/more/SessionLearnMoreViewState.kt create mode 100644 vector/src/main/res/layout/bottom_sheet_session_learn_more.xml diff --git a/library/ui-strings/src/main/res/values-ca/strings.xml b/library/ui-strings/src/main/res/values-ca/strings.xml index 863fa13fbb..daeebf6b30 100644 --- a/library/ui-strings/src/main/res/values-ca/strings.xml +++ b/library/ui-strings/src/main/res/values-ca/strings.xml @@ -2604,7 +2604,7 @@ Explora sales Per estar més segur, verifica les teves sessions i tanca qualsevol sessió que no reconeguis o ja no utilitzis. Altres sessions - Sessions + Sessions Obre la llista d\'espais Crea un nou xat o sala Gent @@ -2674,4 +2674,4 @@ Aquesta sessió està llesta per a missatges segurs. La teva sessió actual està llesta per a missatges segurs. Verifica la teva sessió actual obtenir missatges segurs millorats. - \ No newline at end of file + diff --git a/library/ui-strings/src/main/res/values-cs/strings.xml b/library/ui-strings/src/main/res/values-cs/strings.xml index 79f8311159..7e6a012c65 100644 --- a/library/ui-strings/src/main/res/values-cs/strings.xml +++ b/library/ui-strings/src/main/res/values-cs/strings.xml @@ -2653,7 +2653,7 @@ Zobrazit všechny relace (V2, WIP) V zájmu co nejlepšího zabezpečení ověřujte své relace a odhlašujte se ze všech relací, které již nepoznáváte nebo nepoužíváte. Ostatní relace - Relace + Relace Seznam otevřených prostorů Vytvořit novou konverzaci nebo místnost Lidé diff --git a/library/ui-strings/src/main/res/values-de/strings.xml b/library/ui-strings/src/main/res/values-de/strings.xml index e01fc898a3..0b6d8b9666 100644 --- a/library/ui-strings/src/main/res/values-de/strings.xml +++ b/library/ui-strings/src/main/res/values-de/strings.xml @@ -2589,7 +2589,7 @@ Alle Sitzungen anzeigen (V2, in Arbeit) Für bestmögliche Sicherheit verifiziere deine Sitzungen und melde dich von allen ab, die du nicht erkennst oder nutzt. Andere Sitzungen - Sitzungen + Sitzungen Space-Liste öffnen Beginne ein Gespräch oder erstelle einen Raum Favoriten diff --git a/library/ui-strings/src/main/res/values-et/strings.xml b/library/ui-strings/src/main/res/values-et/strings.xml index 9bd1dd23b7..51882a505a 100644 --- a/library/ui-strings/src/main/res/values-et/strings.xml +++ b/library/ui-strings/src/main/res/values-et/strings.xml @@ -2594,7 +2594,7 @@ Näita kõiki sessioone (V2, WIP) Parima turvalisuse nimel verifitseeri kõik oma sessioonid ning logi välja neist, mida sa enam ei kasuta. Muud sessioonid - Sessionid + Sessionid Ava kogukondade loend Alusta uut vestlust või loo uus jututuba Inimesed diff --git a/library/ui-strings/src/main/res/values-fa/strings.xml b/library/ui-strings/src/main/res/values-fa/strings.xml index 400a8121f9..1b8d3a4fb3 100644 --- a/library/ui-strings/src/main/res/values-fa/strings.xml +++ b/library/ui-strings/src/main/res/values-fa/strings.xml @@ -2603,7 +2603,7 @@ نمایش تمامی نشست‌ها (ن۲، دح‌ت) برای امنیت بیش‌تر، نشست‌هایتان را تأیید و از هر نشستی که تشخیصش نمی‌دهید یا دیگر استفاده نمی‌کنید خارج شوید. دیگر نشست‌ها - نشست‌ها + نشست‌ها گشودن سیاههٔ فضاها ایجاد اتاق یا گفت‌وگویی جدید افراد @@ -2700,4 +2700,4 @@ ایجاد پیام خصوصی فقط در نخستین پیام المنتی ساده شده با زبانه‌های انتخابی به کار انداختن چینش جدید - \ No newline at end of file + diff --git a/library/ui-strings/src/main/res/values-fr/strings.xml b/library/ui-strings/src/main/res/values-fr/strings.xml index 5a19ccf2da..bbd82dd596 100644 --- a/library/ui-strings/src/main/res/values-fr/strings.xml +++ b/library/ui-strings/src/main/res/values-fr/strings.xml @@ -2603,7 +2603,7 @@ Afficher toutes les sessions (V2, en cours) Pour une meilleure sécurité, vérifiez vos sessions et déconnectez toutes les sessions que vous ne connaissez pas ou que vous n’utilisez plus. Autres sessions - Sessions + Sessions Ouvrir la liste des espaces Créer une nouvelle conversation ou salon Personnes diff --git a/library/ui-strings/src/main/res/values-hu/strings.xml b/library/ui-strings/src/main/res/values-hu/strings.xml index 3068556fe4..397c2d4662 100644 --- a/library/ui-strings/src/main/res/values-hu/strings.xml +++ b/library/ui-strings/src/main/res/values-hu/strings.xml @@ -2614,7 +2614,7 @@ A Visszaállítási Kulcsot tartsd biztonságos helyen, mint pl. egy jelszókeze Minden munkamenet megjelenítése (V2, WIP) A legjobb biztonság érdekében ellenőrizd a munkameneteket, és jelentkezz ki minden olyan munkamenetből, melyet már nem ismersz fel vagy nem használsz. Más munkamenetek - Munkamenetek + Munkamenetek Nyitott területek listája Új beszélgetés vagy szoba létrehozása Emberek diff --git a/library/ui-strings/src/main/res/values-in/strings.xml b/library/ui-strings/src/main/res/values-in/strings.xml index 3b30950bd1..18dbbff4ad 100644 --- a/library/ui-strings/src/main/res/values-in/strings.xml +++ b/library/ui-strings/src/main/res/values-in/strings.xml @@ -2555,7 +2555,7 @@ Di masa mendatang proses verifikasi ini akan dimutakhirkan. Tampilkan Semua Sesi (V2, Dalam Pengembangan) Untuk keamanan terbaik, verifikasi sesi Anda dan keluarkan sesi apa pun yang Anda tidak kenal atau Anda tidak gunakan lagi. Sesi lainnya - Sesi + Sesi Buka daftar space Buat percakapan atau ruangan baru Orang diff --git a/library/ui-strings/src/main/res/values-it/strings.xml b/library/ui-strings/src/main/res/values-it/strings.xml index b7b0fe91af..8ad2e62821 100644 --- a/library/ui-strings/src/main/res/values-it/strings.xml +++ b/library/ui-strings/src/main/res/values-it/strings.xml @@ -2594,7 +2594,7 @@ Mostra tutte le sessioni (V2, WIP) Per una maggiore sicurezza, verifica le tue sessioni e disconnetti quelle che non riconosci o che non usi più. Altre sessioni - Sessioni + Sessioni Apri elenco spazi Crea una nuova conversazione o stanza Persone diff --git a/library/ui-strings/src/main/res/values-nl/strings.xml b/library/ui-strings/src/main/res/values-nl/strings.xml index ce122b0646..c5de4ae5f7 100644 --- a/library/ui-strings/src/main/res/values-nl/strings.xml +++ b/library/ui-strings/src/main/res/values-nl/strings.xml @@ -2602,7 +2602,7 @@ Open instellingen Voor de beste beveiliging verifieert u uw sessies en meldt u zich af bij elke sessie die u niet meer herkent of gebruikt. Andere sessies - Sessies + Sessies Lijst met publieke spaces Nieuw gesprek of nieuwe kamer aanmaken Personen diff --git a/library/ui-strings/src/main/res/values-pl/strings.xml b/library/ui-strings/src/main/res/values-pl/strings.xml index b7b73eb9e6..6deb3dd2e7 100644 --- a/library/ui-strings/src/main/res/values-pl/strings.xml +++ b/library/ui-strings/src/main/res/values-pl/strings.xml @@ -2699,7 +2699,7 @@ Otwórz ustawienia Aby zapewnić najlepsze bezpieczeństwo, zweryfikuj swoje sesje i wyloguj się z każdej sesji, której już nie rozpoznajesz lub której już nie używasz. Inne sesje - Sesje + Sesje Lista otwartych przestrzeni Utwórz nową rozmowę lub pokój Ludzie diff --git a/library/ui-strings/src/main/res/values-pt-rBR/strings.xml b/library/ui-strings/src/main/res/values-pt-rBR/strings.xml index 817c7646df..1c5291d6f3 100644 --- a/library/ui-strings/src/main/res/values-pt-rBR/strings.xml +++ b/library/ui-strings/src/main/res/values-pt-rBR/strings.xml @@ -2603,7 +2603,7 @@ Mostrar Todas Sessões (V2, WIP) Para a melhor segurança, verifique suas sessões e faça signout de qualquer sessão que você não reconhece ou usa mais. Outras sessões - Sessões + Sessões Abrir lista de espaços Criar uma nova conversa ou sala Todas diff --git a/library/ui-strings/src/main/res/values-ru/strings.xml b/library/ui-strings/src/main/res/values-ru/strings.xml index 7c9d073035..718e4cd125 100644 --- a/library/ui-strings/src/main/res/values-ru/strings.xml +++ b/library/ui-strings/src/main/res/values-ru/strings.xml @@ -2662,7 +2662,7 @@ Все беседы Для лучшей безопасности заверьте свои сессии и выйдите из тех, которые более не признаёте или не используете. Другие сессии - Сессии + Сессии Создать беседу или комнату Показать все сессии (V2, в разработке) Люди diff --git a/library/ui-strings/src/main/res/values-sk/strings.xml b/library/ui-strings/src/main/res/values-sk/strings.xml index 9eb22e3ae3..b100db2717 100644 --- a/library/ui-strings/src/main/res/values-sk/strings.xml +++ b/library/ui-strings/src/main/res/values-sk/strings.xml @@ -2653,7 +2653,7 @@ Zobraziť všetky relácie (V2, WIP) V záujme čo najlepšieho zabezpečenia overte svoje relácie a odhláste sa z každej relácie, ktorú už nepoznáte alebo nepoužívate. Iné relácie - Relácie + Relácie Otvoriť zoznam priestorov Vytvoriť novú konverzáciu alebo miestnosť Ľudia diff --git a/library/ui-strings/src/main/res/values-uk/strings.xml b/library/ui-strings/src/main/res/values-uk/strings.xml index 3e511f8459..0de8e7191e 100644 --- a/library/ui-strings/src/main/res/values-uk/strings.xml +++ b/library/ui-strings/src/main/res/values-uk/strings.xml @@ -2703,7 +2703,7 @@ Показати всі сеанси (V2, WIP) Для найкращої безпеки перевірте свої сеанси та вийдіть з усіх сеансів, які ви більше не розпізнаєте або не використовуєте. Інші сеанси - Сеанси + Сеанси Відкрити список кімнат Створити нову розмову або кімнату Люди diff --git a/library/ui-strings/src/main/res/values-zh-rCN/strings.xml b/library/ui-strings/src/main/res/values-zh-rCN/strings.xml index db1dab92e2..56a399482c 100644 --- a/library/ui-strings/src/main/res/values-zh-rCN/strings.xml +++ b/library/ui-strings/src/main/res/values-zh-rCN/strings.xml @@ -2553,7 +2553,7 @@ 显示全部会话(V2, WIP) 为获得最佳安全性,请验证你的会话,并从任何你不认识或不再使用的会话登出。 其他会话 - 会话 + 会话 打开空间列表 创建新对话或房间 diff --git a/library/ui-strings/src/main/res/values-zh-rTW/strings.xml b/library/ui-strings/src/main/res/values-zh-rTW/strings.xml index 78caa2cc2e..cfeb6ca915 100644 --- a/library/ui-strings/src/main/res/values-zh-rTW/strings.xml +++ b/library/ui-strings/src/main/res/values-zh-rTW/strings.xml @@ -2553,7 +2553,7 @@ 顯示所有工作階段 (V2, WIP) 為了取得最佳安全性,請驗證您的工作階段並登出任何您無法識別或不再使用的工作階段。 其他工作階段 - 工作階段 + 工作階段 開啟空間清單 建立新的對話或聊天室 聯絡人 diff --git a/library/ui-strings/src/main/res/values/strings.xml b/library/ui-strings/src/main/res/values/strings.xml index 2170ec6c5b..40653db278 100644 --- a/library/ui-strings/src/main/res/values/strings.xml +++ b/library/ui-strings/src/main/res/values/strings.xml @@ -2365,9 +2365,6 @@ Show All Sessions Manage Sessions Sign out of this session - Sessions - Other sessions - For best security, verify your sessions and sign out from any session that you don’t recognize or use anymore. Server name Server version @@ -3229,6 +3226,9 @@ Show All Sessions (V2, WIP) + Sessions + Other sessions + For best security, verify your sessions and sign out from any session that you don’t recognize or use anymore. Mobile Web Desktop diff --git a/vector/src/main/java/im/vector/app/core/di/MavericksViewModelModule.kt b/vector/src/main/java/im/vector/app/core/di/MavericksViewModelModule.kt index 62e7140742..7a5b95f88e 100644 --- a/vector/src/main/java/im/vector/app/core/di/MavericksViewModelModule.kt +++ b/vector/src/main/java/im/vector/app/core/di/MavericksViewModelModule.kt @@ -90,6 +90,7 @@ import im.vector.app.features.settings.devices.DeviceVerificationInfoBottomSheet import im.vector.app.features.settings.devices.DevicesViewModel import im.vector.app.features.settings.devices.v2.details.SessionDetailsViewModel import im.vector.app.features.settings.devices.v2.othersessions.OtherSessionsViewModel +import im.vector.app.features.settings.devices.v2.more.SessionLearnMoreViewModel import im.vector.app.features.settings.devices.v2.overview.SessionOverviewViewModel import im.vector.app.features.settings.devices.v2.rename.RenameSessionViewModel import im.vector.app.features.settings.devtools.AccountDataViewModel @@ -659,4 +660,9 @@ interface MavericksViewModelModule { @IntoMap @MavericksViewModelKey(RenameSessionViewModel::class) fun renameSessionViewModelFactory(factory: RenameSessionViewModel.Factory): MavericksAssistedViewModelFactory<*, *> + + @Binds + @IntoMap + @MavericksViewModelKey(SessionLearnMoreViewModel::class) + fun sessionLearnMoreViewModelFactory(factory: SessionLearnMoreViewModel.Factory): MavericksAssistedViewModelFactory<*, *> } 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 1e5c4d88e0..885a91b9d7 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 @@ -21,7 +21,6 @@ import android.os.Bundle import android.view.LayoutInflater 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,7 @@ import im.vector.app.features.settings.devices.v2.list.SESSION_IS_MARKED_AS_INAC import im.vector.app.features.settings.devices.v2.list.SecurityRecommendationView import im.vector.app.features.settings.devices.v2.list.SecurityRecommendationViewState import im.vector.app.features.settings.devices.v2.list.SessionInfoViewState +import im.vector.app.features.settings.devices.v2.more.SessionLearnMoreBottomSheet import javax.inject.Inject /** @@ -76,7 +76,7 @@ class VectorSettingsDevicesFragment : private fun initToolbar() { (activity as? AppCompatActivity) ?.supportActionBar - ?.setTitle(R.string.settings_sessions_list) + ?.setTitle(R.string.device_manager_sessions_list_title) } override fun onViewCreated(view: View, savedInstanceState: Bundle?) { @@ -157,10 +157,22 @@ class VectorSettingsDevicesFragment : private fun initLearnMoreButtons() { views.deviceListHeaderOtherSessions.onLearnMoreClickListener = { - Toast.makeText(context, "Learn more other", Toast.LENGTH_LONG).show() + showLearnMoreInfoOtherSessions() } } + private fun showLearnMoreInfoOtherSessions() { + val args = SessionLearnMoreBottomSheet.Args( + title = getString(R.string.device_manager_sessions_other_title), + description = buildString { + 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) + } + private fun cleanUpLearnMoreButtonsListeners() { views.deviceListHeaderOtherSessions.onLearnMoreClickListener = null } diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/v2/more/SessionLearnMoreBottomSheet.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/more/SessionLearnMoreBottomSheet.kt new file mode 100644 index 0000000000..5846c8aa0b --- /dev/null +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/more/SessionLearnMoreBottomSheet.kt @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2022 New Vector Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package im.vector.app.features.settings.devices.v2.more + +import android.os.Parcelable +import android.view.LayoutInflater +import android.view.ViewGroup +import androidx.fragment.app.FragmentManager +import com.airbnb.mvrx.fragmentViewModel +import com.airbnb.mvrx.withState +import dagger.hilt.android.AndroidEntryPoint +import im.vector.app.core.platform.VectorBaseBottomSheetDialogFragment +import im.vector.app.databinding.BottomSheetSessionLearnMoreBinding +import kotlinx.parcelize.Parcelize + +@AndroidEntryPoint +class SessionLearnMoreBottomSheet : VectorBaseBottomSheetDialogFragment() { + + @Parcelize + data class Args( + val title: String, + val description: String, + ) : Parcelable + + private val viewModel: SessionLearnMoreViewModel by fragmentViewModel() + + override val showExpanded = true + + override fun getBinding(inflater: LayoutInflater, container: ViewGroup?): BottomSheetSessionLearnMoreBinding { + return BottomSheetSessionLearnMoreBinding.inflate(inflater, container, false) + } + + override fun invalidate() = withState(viewModel) { viewState -> + super.invalidate() + views.bottomSheetSessionLearnMoreTitle.text = viewState.title + views.bottomSheetSessionLearnMoreDescription.text = viewState.description + } + + companion object { + + fun show(fragmentManager: FragmentManager, args: Args) { + val bottomSheet = SessionLearnMoreBottomSheet() + bottomSheet.isCancelable = true + bottomSheet.setArguments(args) + bottomSheet.show(fragmentManager, "SessionLearnMoreBottomSheet") + } + } +} diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/v2/more/SessionLearnMoreViewModel.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/more/SessionLearnMoreViewModel.kt new file mode 100644 index 0000000000..09ca2df15d --- /dev/null +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/more/SessionLearnMoreViewModel.kt @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2022 New Vector Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package im.vector.app.features.settings.devices.v2.more + +import com.airbnb.mvrx.MavericksViewModelFactory +import dagger.assisted.Assisted +import dagger.assisted.AssistedFactory +import dagger.assisted.AssistedInject +import im.vector.app.core.di.MavericksAssistedViewModelFactory +import im.vector.app.core.di.hiltMavericksViewModelFactory +import im.vector.app.core.platform.EmptyAction +import im.vector.app.core.platform.EmptyViewEvents +import im.vector.app.core.platform.VectorViewModel + +class SessionLearnMoreViewModel @AssistedInject constructor( + @Assisted initialState: SessionLearnMoreViewState, +) : VectorViewModel(initialState) { + + @AssistedFactory + interface Factory : MavericksAssistedViewModelFactory { + override fun create(initialState: SessionLearnMoreViewState): SessionLearnMoreViewModel + } + + companion object : MavericksViewModelFactory by hiltMavericksViewModelFactory() + + override fun handle(action: EmptyAction) { + // do nothing + } +} diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/v2/more/SessionLearnMoreViewState.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/more/SessionLearnMoreViewState.kt new file mode 100644 index 0000000000..cade2ce861 --- /dev/null +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/more/SessionLearnMoreViewState.kt @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2022 New Vector Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package im.vector.app.features.settings.devices.v2.more + +import com.airbnb.mvrx.MavericksState + +data class SessionLearnMoreViewState( + val title: String, + val description: String, +) : MavericksState { + constructor(args: SessionLearnMoreBottomSheet.Args) : this( + title = args.title, + description = args.description, + ) +} diff --git a/vector/src/main/res/layout/bottom_sheet_session_learn_more.xml b/vector/src/main/res/layout/bottom_sheet_session_learn_more.xml new file mode 100644 index 0000000000..bdfa4b3c1a --- /dev/null +++ b/vector/src/main/res/layout/bottom_sheet_session_learn_more.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + + From 97cdda45d6692a6f0841f2bdcab18ab7ca8b918e Mon Sep 17 00:00:00 2001 From: Maxime NATUREL Date: Mon, 12 Sep 2022 17:14:31 +0200 Subject: [PATCH 05/17] Adding close button --- library/ui-strings/src/main/res/values/strings.xml | 1 + .../devices/v2/more/SessionLearnMoreBottomSheet.kt | 13 +++++++++++++ .../res/layout/bottom_sheet_session_learn_more.xml | 14 +++++++++++++- 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/library/ui-strings/src/main/res/values/strings.xml b/library/ui-strings/src/main/res/values/strings.xml index 40653db278..8ae869639a 100644 --- a/library/ui-strings/src/main/res/values/strings.xml +++ b/library/ui-strings/src/main/res/values/strings.xml @@ -406,6 +406,7 @@ Reset Learn more Next + Got it Copied to clipboard diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/v2/more/SessionLearnMoreBottomSheet.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/more/SessionLearnMoreBottomSheet.kt index 5846c8aa0b..22ca06eb1e 100644 --- a/vector/src/main/java/im/vector/app/features/settings/devices/v2/more/SessionLearnMoreBottomSheet.kt +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/more/SessionLearnMoreBottomSheet.kt @@ -16,8 +16,10 @@ package im.vector.app.features.settings.devices.v2.more +import android.os.Bundle import android.os.Parcelable import android.view.LayoutInflater +import android.view.View import android.view.ViewGroup import androidx.fragment.app.FragmentManager import com.airbnb.mvrx.fragmentViewModel @@ -44,6 +46,17 @@ class SessionLearnMoreBottomSheet : VectorBaseBottomSheetDialogFragment super.invalidate() views.bottomSheetSessionLearnMoreTitle.text = viewState.title diff --git a/vector/src/main/res/layout/bottom_sheet_session_learn_more.xml b/vector/src/main/res/layout/bottom_sheet_session_learn_more.xml index bdfa4b3c1a..72e1bbdf23 100644 --- a/vector/src/main/res/layout/bottom_sheet_session_learn_more.xml +++ b/vector/src/main/res/layout/bottom_sheet_session_learn_more.xml @@ -34,12 +34,24 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="16dp" - app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintBottom_toTopOf="@id/bottomSheetSessionLearnMoreCloseButton" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/bottomSheetSessionLearnMoreTitle" tools:text="Further context on verified sessions. What do those mean, and how do they differ from unverified ones." /> +