For #21037 - Add a delete history menu item

This removes the existing "Delete history" button in the History in favour of a menu item
upstream-sync
Gabriel Luong 3 years ago committed by mergify[bot]
parent b5d907622b
commit 4080eba225

@ -72,7 +72,6 @@ class HistoryRobot {
}
fun clickDeleteHistoryButton() {
mDevice.waitNotNull(Until.findObject(By.text("Delete history")), waitingTime)
deleteAllHistoryButton().click()
}
@ -117,7 +116,7 @@ private fun threeDotMenu() = onView(withId(R.id.overflow_menu))
private fun snackBarText() = onView(withId(R.id.snackbar_text))
private fun deleteAllHistoryButton() = onView(withId(R.id.delete_button))
private fun deleteAllHistoryButton() = onView(withId(R.id.history_delete_all))
private fun assertHistoryMenuView() {
onView(

@ -138,7 +138,6 @@ class HistoryFragment : LibraryPageFragment<HistoryItem>(), UserInteractionHandl
}
private fun deleteHistoryItems(items: Set<HistoryItem>) {
updatePendingHistoryToDelete(items)
undoScope = CoroutineScope(IO)
undoScope?.allowUndo(
@ -182,6 +181,8 @@ class HistoryFragment : LibraryPageFragment<HistoryItem>(), UserInteractionHandl
SpannableString(getString(R.string.bookmark_menu_delete_button)).apply {
setTextColor(requireContext(), R.attr.destructive)
}
} else {
inflater.inflate(R.menu.history_menu, menu)
}
}
@ -220,6 +221,10 @@ class HistoryFragment : LibraryPageFragment<HistoryItem>(), UserInteractionHandl
showTabTray()
true
}
R.id.history_delete_all -> {
historyInteractor.onDeleteAll()
true
}
else -> super.onOptionsItemSelected(item)
}

@ -32,15 +32,6 @@ class HistoryListItemViewHolder(
init {
setupMenu()
binding.deleteButton.setOnClickListener {
val selected = selectionHolder.selectedItems
if (selected.isEmpty()) {
historyInteractor.onDeleteAll()
} else {
historyInteractor.onDeleteSome(selected)
}
}
binding.recentlyClosedNavEmpty.recentlyClosedNav.setOnClickListener {
historyInteractor.onRecentlyClosedClicked()
}
@ -49,7 +40,7 @@ class HistoryListItemViewHolder(
fun bind(
item: HistoryItem,
timeGroup: HistoryItemTimeGroup?,
showDeleteButton: Boolean,
showTopContent: Boolean,
mode: HistoryFragmentState.Mode,
isPendingDeletion: Boolean = false
) {
@ -62,7 +53,7 @@ class HistoryListItemViewHolder(
binding.historyLayout.titleView.text = item.title
binding.historyLayout.urlView.text = item.url
toggleTopContent(showDeleteButton, mode === HistoryFragmentState.Mode.Normal)
toggleTopContent(showTopContent, mode === HistoryFragmentState.Mode.Normal)
val headerText = timeGroup?.humanReadable(itemView.context)
toggleHeader(headerText)
@ -96,19 +87,9 @@ class HistoryListItemViewHolder(
showTopContent: Boolean,
isNormalMode: Boolean
) {
binding.deleteButton.isVisible = showTopContent
binding.recentlyClosedNavEmpty.recentlyClosedNav.isVisible = showTopContent
if (showTopContent) {
binding.deleteButton.run {
if (isNormalMode) {
isEnabled = true
alpha = 1f
} else {
isEnabled = false
alpha = DELETE_BUTTON_DISABLED_ALPHA
}
}
val numRecentTabs = itemView.context.components.core.store.state.closedTabs.size
binding.recentlyClosedNavEmpty.recentlyClosedTabsDescription.text = String.format(
itemView.context.getString(
@ -123,7 +104,7 @@ class HistoryListItemViewHolder(
alpha = 1f
} else {
isEnabled = false
alpha = DELETE_BUTTON_DISABLED_ALPHA
alpha = DISABLED_BUTTON_ALPHA
}
}
}
@ -145,7 +126,7 @@ class HistoryListItemViewHolder(
}
companion object {
const val DELETE_BUTTON_DISABLED_ALPHA = 0.7f
const val DISABLED_BUTTON_ALPHA = 0.7f
const val LAYOUT_ID = R.layout.history_list_item
}
}

@ -9,15 +9,6 @@
android:importantForAccessibility="no"
android:orientation="vertical">
<com.google.android.material.button.MaterialButton
android:id="@+id/delete_button"
style="@style/DestructiveButton"
android:layout_marginHorizontal="16dp"
android:layout_marginTop="8dp"
android:text="@string/history_delete_all"
android:visibility="gone"
tools:visibility="visible" />
<include
android:id="@+id/recently_closed_nav_empty"
layout="@layout/recently_closed_nav_item" />

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- 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/. -->
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/history_delete_all"
android:icon="@drawable/ic_delete"
android:title="@string/history_delete_all"
app:iconTint="?primaryText"
app:showAsAction="ifRoom" />
</menu>
Loading…
Cancel
Save