You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
iceraven-browser/app/src/main/java/org/mozilla/fenix/library/historymetadata/view/HistoryMetadataGroupItemVie...

73 lines
2.5 KiB
Kotlin

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.fenix.library.historymetadata.view
import android.view.View
import androidx.core.view.isVisible
import androidx.recyclerview.widget.RecyclerView
import org.mozilla.fenix.R
import org.mozilla.fenix.databinding.HistoryMetadataGroupListItemBinding
import org.mozilla.fenix.ext.hideAndDisable
import org.mozilla.fenix.ext.showAndEnable
import org.mozilla.fenix.library.history.History
import org.mozilla.fenix.library.historymetadata.interactor.HistoryMetadataGroupInteractor
import org.mozilla.fenix.selection.SelectionHolder
/**
* View holder for a history metadata list item.
*/
class HistoryMetadataGroupItemViewHolder(
view: View,
private val interactor: HistoryMetadataGroupInteractor,
private val selectionHolder: SelectionHolder<History.Metadata>,
) : RecyclerView.ViewHolder(view) {
private val binding = HistoryMetadataGroupListItemBinding.bind(view)
private var item: History.Metadata? = null
init {
binding.historyLayout.overflowView.apply {
[fenix] For https://github.com/mozilla-mobile/fenix/issues/23350 - Revert changes from removing duplicate icons that already exists in ui-icons (https://github.com/mozilla-mobile/fenix/pull/23527) * Revert "For https://github.com/mozilla-mobile/fenix/issues/23121 - Override @color/mozac_ui_icons_fill with ?primaryText attribute" This reverts commit 4c630eba96182254daa4cdd2bbfeac23ab04690d. * Revert "For https://github.com/mozilla-mobile/fenix/issues/23121 - Replace @drawble/ic_share with @drawable/mozac_ic_share" This reverts commit 072d3a3c9f87b77ed6381c36af7d9c812b8b371d. * Revert "For https://github.com/mozilla-mobile/fenix/issues/23121 - Replace @drawble/ic_storage_enabled with @drawable/mozac_ic_storage" This reverts commit 10dde2baa6fd320443690a49dd6551938a2d83db. * Revert "For https://github.com/mozilla-mobile/fenix/issues/23121 - Replace @drawble/ic_notifications_enabled with @drawable/mozac_ic_notification" This reverts commit 90943cfda427fd06d5e77b1e4fd0463bbe21e449. * Revert "For https://github.com/mozilla-mobile/fenix/issues/23121 - Replace @drawble/ic_microphone_enabled with @drawable/mozac_ic_microphone" This reverts commit 200fd14d288b4b21c1711995f63d548f58fb1dc8. * Revert "For https://github.com/mozilla-mobile/fenix/issues/23121 - Replace @drawble/ic_location_enabled with @drawable/mozac_ic_location" This reverts commit e85998bdc24dcdd17585581bd99aab35d5147f93. * Revert "For https://github.com/mozilla-mobile/fenix/issues/23121 - Replace @drawble/ic_autoplay_disabled with @drawable/mozac_ic_autoplay_blocked" This reverts commit 0e408dc26e069719c895ae5279d3c11df6677699. * Revert "For https://github.com/mozilla-mobile/fenix/issues/23121 - Replace @drawble/ic_camera_enabled with @drawable/mozac_ic_video" This reverts commit ceab2d77490b9b9b545ebbc14ee2a7b3811d3064. * Revert "For https://github.com/mozilla-mobile/fenix/issues/23121 - Replace @drawble/mozac_ic_extensions_black with @drawable/mozac_ic_extensions" This reverts commit 7bc005927acee0481c8936d000737ba7f738e2ba. * Revert "For https://github.com/mozilla-mobile/fenix/issues/23121 - Replace @drawble/ic_top_sites with @drawable/mozac_ic_pin" This reverts commit f4d58ff722baa5dc9f7f811a758de75699bb8ccb. * Revert "For https://github.com/mozilla-mobile/fenix/issues/23121 - Replace @drawble/ic_search with @drawable/mozac_ic_search" This reverts commit ac8f8632557ac07c32d040fbb0ddfa3cf1a0e5f6. * Revert "For https://github.com/mozilla-mobile/fenix/issues/23121 - Replace @drawble/ic_readermode with @drawable/mozac_ic_reader_mode" This reverts commit d1953045b062a5b6fbedd990252834e9e1a6ca4f. * Revert "For https://github.com/mozilla-mobile/fenix/issues/23121 - Replace @drawble/ic_menu with @drawable/mozac_ic_menu" This reverts commit 682b02101aa7e5ce82868de81d9b034701629976. * Revert "For https://github.com/mozilla-mobile/fenix/issues/23121 - Replace @drawble/ic_login with @drawable/mozac_ic_login" This reverts commit 982c695260aaa10fc1f0ee7e6d2e271e9a214ce3. * Revert "For https://github.com/mozilla-mobile/fenix/issues/23121 - Replace @drawble/ic_internet with @drawable/mozac_ic_globe" This reverts commit d248bfc21fff644bdc2141c4e24ae5bc125a41d2. * Revert "For https://github.com/mozilla-mobile/fenix/issues/23121 - Replace @drawble/ic_download with @drawable/mozac_ic_download" This reverts commit 4cdceb393ac411a7b59d9c0e1164fddfb62bc494. * Revert "For https://github.com/mozilla-mobile/fenix/issues/23121 - Replace @drawble/ic_lock with @drawable/mozac_ic_lock" This reverts commit 3878a83e30f318293b099bc49c690f953c2f3def. * Revert "For https://github.com/mozilla-mobile/fenix/issues/23121 - Replace @drawble/ic_desktop with @drawable/mozac_ic_device_desktop" This reverts commit 8c4e6e23e0bf1ed762d9c3ab8566aff4df0a8eb1. * Revert "For https://github.com/mozilla-mobile/fenix/issues/23121 - Replace @drawble/ic_close with @drawable/mozac_ic_close" This reverts commit 7f61c95923600eeabb8046380a31c1eaa4968525. * Revert "For https://github.com/mozilla-mobile/fenix/issues/23121 - Replace @drawble/ic_delete with @drawable/mozac_ic_delete" This reverts commit b8814f62bffde0c192f078f8cd5e808d0f07af9d. * Revert "For https://github.com/mozilla-mobile/fenix/issues/23121 - Replace @drawble/ic_chevron_up with @drawable/mozac_ic_arrowhead_up" This reverts commit 265b0a47cae6bed39ce9e8cc9af465705d1a2363. * Revert "For https://github.com/mozilla-mobile/fenix/issues/23121 - Replace @drawble/ic_chevron_down with @drawable/mozac_ic_arrowhead_down" This reverts commit fe8a0b604941bbbb9dacff176cd17ce0485431ed. * Revert "For https://github.com/mozilla-mobile/fenix/issues/23121 - Replace @drawble/ic_back_button with @drawable/mozac_ic_back" This reverts commit fb236b1c6175c1f8b5e6b1bf6d9f02c6a7fff9b9. * Revert "For https://github.com/mozilla-mobile/fenix/issues/23121 - Replace @drawable/ic_arrowhead_right with @drawable/mozac_ic_arrowhead_right" This reverts commit ae2f768ac02aa6b161b0bcbba7922f5f12e31e80. * Revert "For https://github.com/mozilla-mobile/fenix/issues/23121 - Replace @drawable/ic_new with @drawable/mozac_ic_new" This reverts commit ce5bb35a7cdbd189bb177900ec19bc6cb5a9bfa7. * Revert "For https://github.com/mozilla-mobile/fenix/issues/23121 - Replace @drawable/ic_addons_extensions with @drawable/mozac_ic_extensions" This reverts commit 1006637673965ebf70ad5e18e9a3598cf736347b.
2 years ago
setImageResource(R.drawable.ic_close)
contentDescription = view.context.getString(R.string.history_delete_item)
setOnClickListener {
val item = item ?: return@setOnClickListener
interactor.onDelete(setOf(item))
}
}
}
/**
* Displays the data of the given history record.
*
* @param item The [History.Metadata] to display.
* @param isPendingDeletion Whether or not the [item] is pending deletion.
*/
fun bind(item: History.Metadata, isPendingDeletion: Boolean) {
binding.historyLayout.isVisible = !isPendingDeletion
binding.historyLayout.titleView.text = item.title
binding.historyLayout.urlView.text = item.url
binding.historyLayout.setSelectionInteractor(item, selectionHolder, interactor)
binding.historyLayout.changeSelected(item in selectionHolder.selectedItems)
if (this.item?.url != item.url) {
binding.historyLayout.loadFavicon(item.url)
}
if (selectionHolder.selectedItems.isEmpty()) {
binding.historyLayout.overflowView.showAndEnable()
} else {
binding.historyLayout.overflowView.hideAndDisable()
}
this.item = item
}
companion object {
const val LAYOUT_ID = R.layout.history_metadata_group_list_item
}
}