Skip to content
This repository has been archived by the owner on Feb 20, 2023. It is now read-only.

For #21035 - Refactor HistoryViewInteractor from HistoryView into HistoryInteractor #21036

Merged
merged 1 commit into from
Aug 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class HistoryFragment : LibraryPageFragment<HistoryItem>(), UserInteractionHandl
syncHistory = ::syncHistory,
metrics = requireComponents.analytics.metrics
)
historyInteractor = HistoryInteractor(
historyInteractor = DefaultHistoryInteractor(
historyController
)
_historyView = HistoryView(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down