Update actionbar strings to allow for pluralization.

This commit is contained in:
Greyson Parrelli
2021-10-22 11:49:14 -04:00
parent ec2e3e29c3
commit acebf5964c
6 changed files with 84 additions and 48 deletions

View File

@@ -8,6 +8,6 @@ import androidx.annotation.StringRes
*/
data class ActionItem(
@DrawableRes val iconRes: Int,
@StringRes val titleRes: Int,
val title: CharSequence,
val action: Runnable
)

View File

@@ -69,7 +69,7 @@ class SignalBottomActionBar(context: Context, attributeSet: AttributeSet) : Line
view,
ActionItem(
iconRes = R.drawable.ic_more_horiz_24,
titleRes = R.string.SignalBottomActionBar_more,
title = context.getString(R.string.SignalBottomActionBar_more),
action = {
SignalContextMenu.Builder(view, parent as ViewGroup)
.preferredHorizontalPosition(SignalContextMenu.HorizontalPosition.END)
@@ -86,7 +86,7 @@ class SignalBottomActionBar(context: Context, attributeSet: AttributeSet) : Line
val title: TextView = view.findViewById(R.id.signal_bottom_action_bar_item_title)
icon.setImageResource(item.iconRes)
title.setText(item.titleRes)
title.text = item.title
view.setOnClickListener { item.action.run() }
}
}

View File

@@ -157,7 +157,7 @@ class SignalContextMenu private constructor(
override fun bind(model: DisplayItem) {
icon.setImageResource(model.item.iconRes)
title.setText(model.item.titleRes)
title.text = model.item.title
itemView.setOnClickListener {
model.item.action.run()
dismiss()