From 5791a4d3cdcc7ca096f5ccdc4e2d650027919c31 Mon Sep 17 00:00:00 2001 From: Maxime NATUREL Date: Fri, 2 Sep 2022 15:00:53 +0200 Subject: [PATCH] Using plurals when needed --- library/ui-strings/src/main/res/values/strings.xml | 11 +++++++++-- .../devices/v2/VectorSettingsDevicesFragment.kt | 6 +++++- .../devices/v2/list/OtherSessionsController.kt | 5 +++-- .../src/main/res/layout/fragment_settings_devices.xml | 2 +- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/library/ui-strings/src/main/res/values/strings.xml b/library/ui-strings/src/main/res/values/strings.xml index 8cf89196e1..df0e10627a 100644 --- a/library/ui-strings/src/main/res/values/strings.xml +++ b/library/ui-strings/src/main/res/values/strings.xml @@ -3225,12 +3225,19 @@ View All (%1$d) Verified · Last activity %1$s Unverified · Last activity %1$s - Inactive for %1$d+ days (%2$s) + + + Inactive for %1$d+ day (%2$s) + Inactive for %1$d+ days (%2$s) + Security recommendations Improve your account security by following these recommendations. Unverified sessions Verify or sign out from unverified sessions. Inactive sessions - Consider signing out from old sessions (%1$d days or more) that you don’t use anymore. + + Consider signing out from old sessions (%1$d day or more) that you don’t use anymore. + Consider signing out from old sessions (%1$d days or more) that you don’t use anymore. + 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 ef42a6e5a7..1850f2d847 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 @@ -155,7 +155,11 @@ class VectorSettingsDevicesFragment : views.deviceListUnverifiedSessionsRecommendation.setCount(unverifiedSessionsCount) views.deviceListInactiveSessionsRecommendation.setCount(inactiveSessionsCount) views.deviceListInactiveSessionsRecommendation.setDescription( - getString(R.string.device_manager_inactive_sessions_description, SESSION_IS_MARKED_AS_INACTIVE_AFTER_DAYS) + resources.getQuantityString( + R.plurals.device_manager_inactive_sessions_description, + SESSION_IS_MARKED_AS_INACTIVE_AFTER_DAYS, + SESSION_IS_MARKED_AS_INACTIVE_AFTER_DAYS + ) ) } } diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/v2/list/OtherSessionsController.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/list/OtherSessionsController.kt index 04427d4cb6..817878cf0f 100644 --- a/vector/src/main/java/im/vector/app/features/settings/devices/v2/list/OtherSessionsController.kt +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/list/OtherSessionsController.kt @@ -45,8 +45,9 @@ class OtherSessionsController @Inject constructor( data.take(NUMBER_OF_OTHER_DEVICES_TO_RENDER).forEach { device -> val formattedLastActivityDate = host.dateFormatter.format(device.deviceInfo.lastSeenTs, DateFormatKind.DEFAULT_DATE_AND_TIME) val description = if (device.isInactive) { - stringProvider.getString( - R.string.device_manager_other_sessions_description_inactive, + stringProvider.getQuantityString( + R.plurals.device_manager_other_sessions_description_inactive, + SESSION_IS_MARKED_AS_INACTIVE_AFTER_DAYS, SESSION_IS_MARKED_AS_INACTIVE_AFTER_DAYS, formattedLastActivityDate ) diff --git a/vector/src/main/res/layout/fragment_settings_devices.xml b/vector/src/main/res/layout/fragment_settings_devices.xml index 220e49f28f..6710f345ce 100644 --- a/vector/src/main/res/layout/fragment_settings_devices.xml +++ b/vector/src/main/res/layout/fragment_settings_devices.xml @@ -39,7 +39,7 @@ android:layout_marginHorizontal="16dp" android:layout_marginVertical="16dp" app:recommendationTitle="@string/device_manager_inactive_sessions_title" - app:recommendationDescription="@string/device_manager_inactive_sessions_description" + app:recommendationDescription="@plurals/device_manager_inactive_sessions_description" app:recommendationImageResource="@drawable/ic_inactive_sessions" app:recommendationImageBackgroundTint="?vctr_system" app:layout_constraintEnd_toEndOf="parent"