Room history visibility: Use correct wording for the setting.
This commit is contained in:
parent
4171311095
commit
637c54073a
|
@ -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<BottomSheetActionItem.Ho
|
|||
@DrawableRes
|
||||
var iconRes: Int = 0
|
||||
|
||||
@EpoxyAttribute
|
||||
var text: String? = null
|
||||
|
||||
@StringRes
|
||||
@EpoxyAttribute
|
||||
var textRes: Int = 0
|
||||
|
||||
|
@ -77,7 +82,11 @@ abstract class BottomSheetActionItem : VectorEpoxyModel<BottomSheetActionItem.Ho
|
|||
}
|
||||
holder.icon.setImageResource(iconRes)
|
||||
ImageViewCompat.setImageTintList(holder.icon, ColorStateList.valueOf(tintColor))
|
||||
holder.text.setText(textRes)
|
||||
if (text != null) {
|
||||
holder.text.text = text
|
||||
} else {
|
||||
holder.text.setText(textRes)
|
||||
}
|
||||
holder.text.setTextColor(tintColor)
|
||||
holder.selected.isInvisible = !selected
|
||||
if (showExpand) {
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
package im.vector.app.core.ui.bottomsheet
|
||||
|
||||
import androidx.annotation.DrawableRes
|
||||
import androidx.annotation.StringRes
|
||||
import im.vector.app.core.epoxy.bottomsheet.BottomSheetActionItem_
|
||||
import im.vector.app.core.platform.VectorSharedAction
|
||||
|
||||
|
@ -25,7 +24,7 @@ import im.vector.app.core.platform.VectorSharedAction
|
|||
* Parent class for a bottom sheet action
|
||||
*/
|
||||
open class BottomSheetGenericAction(
|
||||
@StringRes open val titleRes: Int,
|
||||
open val title: String,
|
||||
@DrawableRes open val iconResId: Int,
|
||||
open val isSelected: Boolean,
|
||||
open val destructive: Boolean
|
||||
|
@ -33,9 +32,9 @@ open class BottomSheetGenericAction(
|
|||
|
||||
fun toBottomSheetItem(): BottomSheetActionItem_ {
|
||||
return BottomSheetActionItem_().apply {
|
||||
id("action_$titleRes")
|
||||
id("action_$title")
|
||||
iconRes(iconResId)
|
||||
textRes(titleRes)
|
||||
text(title)
|
||||
selected(isSelected)
|
||||
destructive(destructive)
|
||||
}
|
||||
|
|
|
@ -260,13 +260,13 @@ class NoticeEventFormatter @Inject constructor(
|
|||
private fun formatRoomHistoryVisibilityEvent(event: Event, senderName: String?, rs: RoomSummary?): CharSequence? {
|
||||
val historyVisibility = event.getClearContent().toModel<RoomHistoryVisibilityContent>()?.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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue