diff --git a/app/src/main/java/org/mozilla/fenix/library/history/HistoryAdapter.kt b/app/src/main/java/org/mozilla/fenix/library/history/HistoryAdapter.kt index 8109b1e1b4..ce9eb1c98e 100644 --- a/app/src/main/java/org/mozilla/fenix/library/history/HistoryAdapter.kt +++ b/app/src/main/java/org/mozilla/fenix/library/history/HistoryAdapter.kt @@ -113,7 +113,8 @@ class HistoryAdapter( } class HistoryDeleteViewHolder( - view: View + view: View, + private val actionEmitter: Observer ) : RecyclerView.ViewHolder(view) { private val button = view.findViewById(R.id.delete_history_button) private val text = view.findViewById(R.id.delete_history_button_text).apply { @@ -123,7 +124,14 @@ class HistoryAdapter( this.setCompoundDrawablesWithIntrinsicBounds(drawable, null, null, null) } - fun bind() { } + 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) + } + } companion object { const val LAYOUT_ID = R.layout.history_delete @@ -143,7 +151,7 @@ class HistoryAdapter( val view = LayoutInflater.from(parent.context).inflate(viewType, parent, false) return when (viewType) { - HistoryDeleteViewHolder.LAYOUT_ID -> HistoryDeleteViewHolder(view) + HistoryDeleteViewHolder.LAYOUT_ID -> HistoryDeleteViewHolder(view, actionEmitter) HistoryHeaderViewHolder.LAYOUT_ID -> HistoryHeaderViewHolder(view) HistoryListItemViewHolder.LAYOUT_ID -> HistoryListItemViewHolder(view, actionEmitter) else -> throw IllegalStateException("viewType $viewType does not match to a ViewHolder") @@ -162,6 +170,7 @@ class HistoryAdapter( override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) { when (holder) { + is HistoryDeleteViewHolder -> holder.bind(mode) is HistoryHeaderViewHolder -> holder.bind("Today") is HistoryListItemViewHolder -> holder.bind(items[position - NUMBER_OF_SECTIONS], mode) } diff --git a/app/src/main/res/layout/history_delete.xml b/app/src/main/res/layout/history_delete.xml index 715fdc2a35..8255aa218e 100644 --- a/app/src/main/res/layout/history_delete.xml +++ b/app/src/main/res/layout/history_delete.xml @@ -14,7 +14,7 @@ android:id="@+id/delete_history_button_text" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:text="Delete History" + android:text="@string/delete_history" android:textColor="@color/photonRed60" android:drawablePadding="8dp" android:textSize="16sp" diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 04afe5dc3e..ef6520013e 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -146,4 +146,11 @@ Archive Send and Share Current session image + + + Delete History + + + Delete %1$s Items