mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-19 09:25:34 +00:00
[fenix] For https://github.com/mozilla-mobile/fenix/issues/357 - Display number of selected items in the delete button
This commit is contained in:
parent
a2fee5b715
commit
2431d61130
@ -113,7 +113,8 @@ class HistoryAdapter(
|
||||
}
|
||||
|
||||
class HistoryDeleteViewHolder(
|
||||
view: View
|
||||
view: View,
|
||||
private val actionEmitter: Observer<HistoryAction>
|
||||
) : RecyclerView.ViewHolder(view) {
|
||||
private val button = view.findViewById<View>(R.id.delete_history_button)
|
||||
private val text = view.findViewById<TextView>(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)
|
||||
}
|
||||
|
@ -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"
|
||||
|
@ -146,4 +146,11 @@
|
||||
<string name="current_session_archive">Archive</string>
|
||||
<string name="current_session_send_and_share">Send and Share</string>
|
||||
<string name="current_session_image">Current session image</string>
|
||||
|
||||
<!-- Text for the button to clear all history -->
|
||||
<string name="delete_history">Delete History</string>
|
||||
|
||||
<!-- 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>
|
||||
</resources>
|
||||
|
Loading…
Reference in New Issue
Block a user