1
0
Fork 0

For #357 - Changes delete text depending on the number of items selected

master
Jeff Boek 2019-02-15 13:57:26 -08:00
parent 1f276ec9fc
commit a65bd9b245
3 changed files with 13 additions and 6 deletions

View File

@ -125,12 +125,14 @@ class HistoryAdapter(
}
fun bind(mode: HistoryState.Mode) {
when(mode) {
is HistoryState.Mode.Normal ->
text.text = text.context.resources.getText(R.string.delete_history)
is HistoryState.Mode.Editing ->
text.text = text.context.resources.getString(R.string.delete_history_items, mode.selectedItems.size)
val text = if (mode is HistoryState.Mode.Editing && mode.selectedItems.isNotEmpty()) {
text.context.resources.getString(R.string.delete_history_items, mode.selectedItems.size)
} else {
text.context.resources.getString(R.string.delete_history)
}
button.contentDescription = text
this.text.text = text
}
companion object {

View File

@ -4,9 +4,12 @@
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/delete_history_button"
android:foreground="?android:attr/selectableItemBackground"
android:background="@drawable/delete_history_background"
android:layout_margin="16dp"
android:padding="6dp"
android:clickable="true"
android:focusable="true"
android:layout_width="match_parent"
android:layout_height="wrap_content">
@ -19,5 +22,7 @@
android:drawablePadding="8dp"
android:textSize="16sp"
android:gravity="center"
android:clickable="false"
android:focusable="false"
android:layout_gravity="center" />
</FrameLayout>

View File

@ -152,5 +152,5 @@
<!-- Text for the button to clear selected history items. The first parameter
is the number of items you have selected -->
<string name="delete_history_items">Delete %1$s Items</string>
<string name="delete_history_items">Delete %1$d Items</string>
</resources>