From 637c54073ac52f0ae5286fc2d322699af1c18b19 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Thu, 26 Nov 2020 20:49:23 +0100 Subject: [PATCH] Room history visibility: Use correct wording for the setting. --- .../bottomsheet/BottomSheetActionItem.kt | 11 ++++++++- .../bottomsheet/BottomSheetGenericAction.kt | 7 +++--- .../timeline/format/NoticeEventFormatter.kt | 6 ++--- .../format/RoomHistoryVisibilityFormatter.kt | 24 ++++++++++--------- .../settings/RoomSettingsController.kt | 5 +--- .../BottomSheetRoomHistoryVisibilityAction.kt | 5 ++-- .../RoomHistoryVisibilityController.kt | 2 +- 7 files changed, 33 insertions(+), 27 deletions(-) diff --git a/vector/src/main/java/im/vector/app/core/epoxy/bottomsheet/BottomSheetActionItem.kt b/vector/src/main/java/im/vector/app/core/epoxy/bottomsheet/BottomSheetActionItem.kt index e28bec6874..3666cabce3 100644 --- a/vector/src/main/java/im/vector/app/core/epoxy/bottomsheet/BottomSheetActionItem.kt +++ b/vector/src/main/java/im/vector/app/core/epoxy/bottomsheet/BottomSheetActionItem.kt @@ -21,6 +21,7 @@ import android.view.View import android.widget.ImageView import android.widget.TextView import androidx.annotation.DrawableRes +import androidx.annotation.StringRes import androidx.core.content.ContextCompat import androidx.core.graphics.drawable.DrawableCompat import androidx.core.view.isInvisible @@ -43,6 +44,10 @@ abstract class BottomSheetActionItem : VectorEpoxyModel()?.historyVisibility ?: return null - val formattedVisibility = roomHistoryVisibilityFormatter.format(historyVisibility) + val historyVisibilitySuffix = roomHistoryVisibilityFormatter.getNoticeSuffix(historyVisibility) return if (event.isSentByCurrentUser()) { sp.getString(if (rs.isDm()) R.string.notice_made_future_direct_room_visibility_by_you else R.string.notice_made_future_room_visibility_by_you, - formattedVisibility) + historyVisibilitySuffix) } else { sp.getString(if (rs.isDm()) R.string.notice_made_future_direct_room_visibility else R.string.notice_made_future_room_visibility, - senderName, formattedVisibility) + senderName, historyVisibilitySuffix) } } diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/format/RoomHistoryVisibilityFormatter.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/format/RoomHistoryVisibilityFormatter.kt index e2dc3932b2..14769bc95b 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/format/RoomHistoryVisibilityFormatter.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/format/RoomHistoryVisibilityFormatter.kt @@ -16,7 +16,6 @@ package im.vector.app.features.home.room.detail.timeline.format -import androidx.annotation.StringRes import im.vector.app.R import im.vector.app.core.resources.StringProvider import org.matrix.android.sdk.api.session.room.model.RoomHistoryVisibility @@ -25,18 +24,21 @@ import javax.inject.Inject class RoomHistoryVisibilityFormatter @Inject constructor( private val stringProvider: StringProvider ) { - - fun format(roomHistoryVisibility: RoomHistoryVisibility): String { - return stringProvider.getString(getStringResId(roomHistoryVisibility)) - } - - @StringRes - fun getStringResId(roomHistoryVisibility: RoomHistoryVisibility): Int { - return when (roomHistoryVisibility) { + fun getNoticeSuffix(roomHistoryVisibility: RoomHistoryVisibility): String { + return stringProvider.getString(when (roomHistoryVisibility) { + RoomHistoryVisibility.WORLD_READABLE -> R.string.notice_room_visibility_world_readable RoomHistoryVisibility.SHARED -> R.string.notice_room_visibility_shared RoomHistoryVisibility.INVITED -> R.string.notice_room_visibility_invited RoomHistoryVisibility.JOINED -> R.string.notice_room_visibility_joined - RoomHistoryVisibility.WORLD_READABLE -> R.string.notice_room_visibility_world_readable - } + }) + } + + fun getSetting(roomHistoryVisibility: RoomHistoryVisibility): String { + return stringProvider.getString(when (roomHistoryVisibility) { + RoomHistoryVisibility.WORLD_READABLE -> R.string.room_settings_read_history_entry_anyone + RoomHistoryVisibility.SHARED -> R.string.room_settings_read_history_entry_members_only_option_time_shared + RoomHistoryVisibility.INVITED -> R.string.room_settings_read_history_entry_members_only_invited + RoomHistoryVisibility.JOINED -> R.string.room_settings_read_history_entry_members_only_joined + }) } } diff --git a/vector/src/main/java/im/vector/app/features/roomprofile/settings/RoomSettingsController.kt b/vector/src/main/java/im/vector/app/features/roomprofile/settings/RoomSettingsController.kt index c3c74f0d7c..96ae07e0e9 100644 --- a/vector/src/main/java/im/vector/app/features/roomprofile/settings/RoomSettingsController.kt +++ b/vector/src/main/java/im/vector/app/features/roomprofile/settings/RoomSettingsController.kt @@ -112,13 +112,10 @@ class RoomSettingsController @Inject constructor( action = { callback?.onRoomAliasesClicked() } ) - val historyVisibility = roomHistoryVisibilityFormatter.format(data.currentHistoryVisibility) - val newHistoryVisibility = data.newHistoryVisibility?.let { roomHistoryVisibilityFormatter.format(it) } - buildProfileAction( id = "historyReadability", title = stringProvider.getString(R.string.room_settings_room_read_history_rules_pref_title), - subtitle = newHistoryVisibility ?: historyVisibility, + subtitle = roomHistoryVisibilityFormatter.getSetting(data.newHistoryVisibility ?: data.currentHistoryVisibility), dividerColor = dividerColor, divider = false, editable = data.actionPermissions.canChangeHistoryVisibility, diff --git a/vector/src/main/java/im/vector/app/features/roomprofile/settings/historyvisibility/BottomSheetRoomHistoryVisibilityAction.kt b/vector/src/main/java/im/vector/app/features/roomprofile/settings/historyvisibility/BottomSheetRoomHistoryVisibilityAction.kt index 45e7188952..9fc27070b3 100644 --- a/vector/src/main/java/im/vector/app/features/roomprofile/settings/historyvisibility/BottomSheetRoomHistoryVisibilityAction.kt +++ b/vector/src/main/java/im/vector/app/features/roomprofile/settings/historyvisibility/BottomSheetRoomHistoryVisibilityAction.kt @@ -17,18 +17,17 @@ package im.vector.app.features.roomprofile.settings.historyvisibility import androidx.annotation.DrawableRes -import androidx.annotation.StringRes import im.vector.app.core.ui.bottomsheet.BottomSheetGenericAction import org.matrix.android.sdk.api.session.room.model.RoomHistoryVisibility class BottomSheetRoomHistoryVisibilityAction( val roomHistoryVisibility: RoomHistoryVisibility, - @StringRes titleRes: Int, + title: String, @DrawableRes iconResId: Int, isSelected: Boolean, destructive: Boolean ) : BottomSheetGenericAction( - titleRes = titleRes, + title = title, iconResId = iconResId, isSelected = isSelected, destructive = destructive diff --git a/vector/src/main/java/im/vector/app/features/roomprofile/settings/historyvisibility/RoomHistoryVisibilityController.kt b/vector/src/main/java/im/vector/app/features/roomprofile/settings/historyvisibility/RoomHistoryVisibilityController.kt index bdb5f80198..34b9f8571c 100644 --- a/vector/src/main/java/im/vector/app/features/roomprofile/settings/historyvisibility/RoomHistoryVisibilityController.kt +++ b/vector/src/main/java/im/vector/app/features/roomprofile/settings/historyvisibility/RoomHistoryVisibilityController.kt @@ -35,7 +35,7 @@ class RoomHistoryVisibilityController @Inject constructor( .map { roomHistoryVisibility -> BottomSheetRoomHistoryVisibilityAction( roomHistoryVisibility = roomHistoryVisibility, - titleRes = historyVisibilityFormatter.getStringResId(roomHistoryVisibility), + title = historyVisibilityFormatter.getSetting(roomHistoryVisibility), iconResId = 0, isSelected = roomHistoryVisibility == state.currentRoomHistoryVisibility, destructive = false