For #21035 - Refactor HistoryViewInteractor from HistoryView into HistoryInteractor

upstream-sync
Gabriel Luong 3 years ago committed by mergify[bot]
parent 46e87147ba
commit e4a25f4123

@ -101,7 +101,7 @@ class HistoryFragment : LibraryPageFragment<HistoryItem>(), UserInteractionHandl
syncHistory = ::syncHistory,
metrics = requireComponents.analytics.metrics
)
historyInteractor = HistoryInteractor(
historyInteractor = DefaultHistoryInteractor(
historyController
)
_historyView = HistoryView(

@ -5,15 +5,82 @@
package org.mozilla.fenix.library.history
import org.mozilla.fenix.browser.browsingmode.BrowsingMode
import org.mozilla.fenix.selection.SelectionInteractor
/**
* Interface for the HistoryInteractor. This interface is implemented by objects that want
* to respond to user interaction on the HistoryView
*/
interface HistoryInteractor : SelectionInteractor<HistoryItem> {
/**
* Called on backpressed to exit edit mode
*/
fun onBackPressed(): Boolean
/**
* Called when the mode is switched so we can invalidate the menu
*/
fun onModeSwitched()
/**
* Copies the URL of a history item to the copy-paste buffer.
*
* @param item the history item to copy the URL from
*/
fun onCopyPressed(item: HistoryItem)
/**
* Opens the share sheet for a history item.
*
* @param item the history item to share
*/
fun onSharePressed(item: HistoryItem)
/**
* Opens a history item in a new tab.
*
* @param item the history item to open in a new tab
*/
fun onOpenInNormalTab(item: HistoryItem)
/**
* Opens a history item in a private tab.
*
* @param item the history item to open in a private tab
*/
fun onOpenInPrivateTab(item: HistoryItem)
/**
* Called when delete all is tapped
*/
fun onDeleteAll()
/**
* Called when multiple history items are deleted
* @param items the history items to delete
*/
fun onDeleteSome(items: Set<HistoryItem>)
/**
* Called when the user requests a sync of the history
*/
fun onRequestSync()
/**
* Called when the user clicks on recently closed tab button.
*/
fun onRecentlyClosedClicked()
}
/**
* Interactor for the history screen
* Provides implementations for the HistoryViewInteractor
* Provides implementations for the HistoryInteractor
*/
@SuppressWarnings("TooManyFunctions")
class HistoryInteractor(
class DefaultHistoryInteractor(
private val historyController: HistoryController
) : HistoryViewInteractor {
) : HistoryInteractor {
override fun open(item: HistoryItem) {
historyController.handleOpen(item)
}

@ -14,75 +14,8 @@ import org.mozilla.fenix.R
import org.mozilla.fenix.databinding.ComponentHistoryBinding
import org.mozilla.fenix.ext.components
import org.mozilla.fenix.library.LibraryPageView
import org.mozilla.fenix.selection.SelectionInteractor
import org.mozilla.fenix.theme.ThemeManager
/**
* Interface for the HistoryViewInteractor. This interface is implemented by objects that want
* to respond to user interaction on the HistoryView
*/
interface HistoryViewInteractor : SelectionInteractor<HistoryItem> {
/**
* Called on backpressed to exit edit mode
*/
fun onBackPressed(): Boolean
/**
* Called when the mode is switched so we can invalidate the menu
*/
fun onModeSwitched()
/**
* Copies the URL of a history item to the copy-paste buffer.
*
* @param item the history item to copy the URL from
*/
fun onCopyPressed(item: HistoryItem)
/**
* Opens the share sheet for a history item.
*
* @param item the history item to share
*/
fun onSharePressed(item: HistoryItem)
/**
* Opens a history item in a new tab.
*
* @param item the history item to open in a new tab
*/
fun onOpenInNormalTab(item: HistoryItem)
/**
* Opens a history item in a private tab.
*
* @param item the history item to open in a private tab
*/
fun onOpenInPrivateTab(item: HistoryItem)
/**
* Called when delete all is tapped
*/
fun onDeleteAll()
/**
* Called when multiple history items are deleted
* @param items the history items to delete
*/
fun onDeleteSome(items: Set<HistoryItem>)
/**
* Called when the user requests a sync of the history
*/
fun onRequestSync()
/**
* Called when the user clicks on recently closed tab button.
*/
fun onRecentlyClosedClicked()
}
/**
* View that contains and configures the History List
*/

@ -14,7 +14,7 @@ import org.mozilla.fenix.browser.browsingmode.BrowsingMode
class HistoryInteractorTest {
private val historyItem = HistoryItem(0, "title", "url", 0.toLong())
val controller: HistoryController = mockk(relaxed = true)
val interactor = HistoryInteractor(controller)
val interactor = DefaultHistoryInteractor(controller)
@Test
fun onOpen() {

Loading…
Cancel
Save