Using plurals when needed

This commit is contained in:
Maxime NATUREL 2022-09-02 15:00:53 +02:00
parent 2b50208a23
commit 5791a4d3cd
4 changed files with 18 additions and 6 deletions

View File

@ -3225,12 +3225,19 @@
<string name="device_manager_other_sessions_view_all">View All (%1$d)</string>
<string name="device_manager_other_sessions_description_verified">Verified · Last activity %1$s</string>
<string name="device_manager_other_sessions_description_unverified">Unverified · Last activity %1$s</string>
<string name="device_manager_other_sessions_description_inactive">Inactive for %1$d+ days (%2$s)</string>
<!-- Example: Inactive for 90+ days (Dec 25, 2021) -->
<plurals name="device_manager_other_sessions_description_inactive">
<item quantity="one">Inactive for %1$d+ day (%2$s)</item>
<item quantity="other">Inactive for %1$d+ days (%2$s)</item>
</plurals>
<string name="device_manager_header_section_security_recommendations_title">Security recommendations</string>
<string name="device_manager_header_section_security_recommendations_description">Improve your account security by following these recommendations.</string>
<string name="device_manager_unverified_sessions_title">Unverified sessions</string>
<string name="device_manager_unverified_sessions_description">Verify or sign out from unverified sessions.</string>
<string name="device_manager_inactive_sessions_title">Inactive sessions</string>
<string name="device_manager_inactive_sessions_description">Consider signing out from old sessions (%1$d days or more) that you dont use anymore.</string>
<plurals name="device_manager_inactive_sessions_description">
<item quantity="one">Consider signing out from old sessions (%1$d day or more) that you dont use anymore.</item>
<item quantity="other">Consider signing out from old sessions (%1$d days or more) that you dont use anymore.</item>
</plurals>
</resources>

View File

@ -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
)
)
}
}

View File

@ -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
)

View File

@ -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"