mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-19 09:25:34 +00:00
[fenix] Update to latest feature-intent and feature-recentlyclosed APIs (and update Android Components).
This commit is contained in:
parent
ecdf3415d2
commit
21e848692d
@ -45,14 +45,14 @@ class IntentProcessors(
|
|||||||
* Provides intent processing functionality for ACTION_VIEW and ACTION_SEND intents.
|
* Provides intent processing functionality for ACTION_VIEW and ACTION_SEND intents.
|
||||||
*/
|
*/
|
||||||
val intentProcessor by lazyMonitored {
|
val intentProcessor by lazyMonitored {
|
||||||
TabIntentProcessor(sessionManager, sessionUseCases.loadUrl, searchUseCases.newTabSearch, isPrivate = false)
|
TabIntentProcessor(tabsUseCases, sessionUseCases.loadUrl, searchUseCases.newTabSearch, isPrivate = false)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides intent processing functionality for ACTION_VIEW and ACTION_SEND intents in private tabs.
|
* Provides intent processing functionality for ACTION_VIEW and ACTION_SEND intents in private tabs.
|
||||||
*/
|
*/
|
||||||
val privateIntentProcessor by lazyMonitored {
|
val privateIntentProcessor by lazyMonitored {
|
||||||
TabIntentProcessor(sessionManager, sessionUseCases.loadUrl, searchUseCases.newTabSearch, isPrivate = true)
|
TabIntentProcessor(tabsUseCases, sessionUseCases.loadUrl, searchUseCases.newTabSearch, isPrivate = true)
|
||||||
}
|
}
|
||||||
|
|
||||||
val customTabIntentProcessor by lazyMonitored {
|
val customTabIntentProcessor by lazyMonitored {
|
||||||
|
@ -8,11 +8,11 @@ import android.view.LayoutInflater
|
|||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.recyclerview.widget.DiffUtil
|
import androidx.recyclerview.widget.DiffUtil
|
||||||
import androidx.recyclerview.widget.ListAdapter
|
import androidx.recyclerview.widget.ListAdapter
|
||||||
import mozilla.components.browser.state.state.ClosedTab
|
import mozilla.components.browser.state.state.recover.RecoverableTab
|
||||||
|
|
||||||
class RecentlyClosedAdapter(
|
class RecentlyClosedAdapter(
|
||||||
private val interactor: RecentlyClosedFragmentInteractor
|
private val interactor: RecentlyClosedFragmentInteractor
|
||||||
) : ListAdapter<ClosedTab, RecentlyClosedItemViewHolder>(DiffCallback) {
|
) : ListAdapter<RecoverableTab, RecentlyClosedItemViewHolder>(DiffCallback) {
|
||||||
override fun onCreateViewHolder(
|
override fun onCreateViewHolder(
|
||||||
parent: ViewGroup,
|
parent: ViewGroup,
|
||||||
viewType: Int
|
viewType: Int
|
||||||
@ -26,11 +26,11 @@ class RecentlyClosedAdapter(
|
|||||||
holder.bind(getItem(position))
|
holder.bind(getItem(position))
|
||||||
}
|
}
|
||||||
|
|
||||||
private object DiffCallback : DiffUtil.ItemCallback<ClosedTab>() {
|
private object DiffCallback : DiffUtil.ItemCallback<RecoverableTab>() {
|
||||||
override fun areItemsTheSame(oldItem: ClosedTab, newItem: ClosedTab) =
|
override fun areItemsTheSame(oldItem: RecoverableTab, newItem: RecoverableTab) =
|
||||||
oldItem.id == newItem.id
|
oldItem.id == newItem.id
|
||||||
|
|
||||||
override fun areContentsTheSame(oldItem: ClosedTab, newItem: ClosedTab) =
|
override fun areContentsTheSame(oldItem: RecoverableTab, newItem: RecoverableTab) =
|
||||||
oldItem.id == newItem.id
|
oldItem.id == newItem.id
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,10 +11,10 @@ import androidx.navigation.NavController
|
|||||||
import androidx.navigation.NavOptions
|
import androidx.navigation.NavOptions
|
||||||
import mozilla.components.browser.session.SessionManager
|
import mozilla.components.browser.session.SessionManager
|
||||||
import mozilla.components.browser.state.action.RecentlyClosedAction
|
import mozilla.components.browser.state.action.RecentlyClosedAction
|
||||||
import mozilla.components.browser.state.state.ClosedTab
|
import mozilla.components.browser.state.state.recover.RecoverableTab
|
||||||
import mozilla.components.browser.state.store.BrowserStore
|
import mozilla.components.browser.state.store.BrowserStore
|
||||||
import mozilla.components.concept.engine.prompt.ShareData
|
import mozilla.components.concept.engine.prompt.ShareData
|
||||||
import mozilla.components.feature.recentlyclosed.ext.restoreTab
|
import mozilla.components.feature.tabs.TabsUseCases
|
||||||
import org.mozilla.fenix.BrowserDirection
|
import org.mozilla.fenix.BrowserDirection
|
||||||
import org.mozilla.fenix.HomeActivity
|
import org.mozilla.fenix.HomeActivity
|
||||||
import org.mozilla.fenix.R
|
import org.mozilla.fenix.R
|
||||||
@ -22,29 +22,30 @@ import org.mozilla.fenix.browser.browsingmode.BrowsingMode
|
|||||||
import org.mozilla.fenix.components.FenixSnackbar
|
import org.mozilla.fenix.components.FenixSnackbar
|
||||||
|
|
||||||
interface RecentlyClosedController {
|
interface RecentlyClosedController {
|
||||||
fun handleOpen(item: ClosedTab, mode: BrowsingMode? = null)
|
fun handleOpen(item: RecoverableTab, mode: BrowsingMode? = null)
|
||||||
fun handleDeleteOne(tab: ClosedTab)
|
fun handleDeleteOne(tab: RecoverableTab)
|
||||||
fun handleCopyUrl(item: ClosedTab)
|
fun handleCopyUrl(item: RecoverableTab)
|
||||||
fun handleShare(item: ClosedTab)
|
fun handleShare(item: RecoverableTab)
|
||||||
fun handleNavigateToHistory()
|
fun handleNavigateToHistory()
|
||||||
fun handleRestore(item: ClosedTab)
|
fun handleRestore(item: RecoverableTab)
|
||||||
}
|
}
|
||||||
|
|
||||||
class DefaultRecentlyClosedController(
|
class DefaultRecentlyClosedController(
|
||||||
private val navController: NavController,
|
private val navController: NavController,
|
||||||
private val store: BrowserStore,
|
private val store: BrowserStore,
|
||||||
private val sessionManager: SessionManager,
|
private val sessionManager: SessionManager,
|
||||||
|
private val tabsUseCases: TabsUseCases,
|
||||||
private val resources: Resources,
|
private val resources: Resources,
|
||||||
private val snackbar: FenixSnackbar,
|
private val snackbar: FenixSnackbar,
|
||||||
private val clipboardManager: ClipboardManager,
|
private val clipboardManager: ClipboardManager,
|
||||||
private val activity: HomeActivity,
|
private val activity: HomeActivity,
|
||||||
private val openToBrowser: (item: ClosedTab, mode: BrowsingMode?) -> Unit
|
private val openToBrowser: (item: RecoverableTab, mode: BrowsingMode?) -> Unit
|
||||||
) : RecentlyClosedController {
|
) : RecentlyClosedController {
|
||||||
override fun handleOpen(item: ClosedTab, mode: BrowsingMode?) {
|
override fun handleOpen(item: RecoverableTab, mode: BrowsingMode?) {
|
||||||
openToBrowser(item, mode)
|
openToBrowser(item, mode)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun handleDeleteOne(tab: ClosedTab) {
|
override fun handleDeleteOne(tab: RecoverableTab) {
|
||||||
store.dispatch(RecentlyClosedAction.RemoveClosedTabAction(tab))
|
store.dispatch(RecentlyClosedAction.RemoveClosedTabAction(tab))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,7 +56,7 @@ class DefaultRecentlyClosedController(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun handleCopyUrl(item: ClosedTab) {
|
override fun handleCopyUrl(item: RecoverableTab) {
|
||||||
val urlClipData = ClipData.newPlainText(item.url, item.url)
|
val urlClipData = ClipData.newPlainText(item.url, item.url)
|
||||||
clipboardManager.setPrimaryClip(urlClipData)
|
clipboardManager.setPrimaryClip(urlClipData)
|
||||||
with(snackbar) {
|
with(snackbar) {
|
||||||
@ -64,7 +65,7 @@ class DefaultRecentlyClosedController(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun handleShare(item: ClosedTab) {
|
override fun handleShare(item: RecoverableTab) {
|
||||||
navController.navigate(
|
navController.navigate(
|
||||||
RecentlyClosedFragmentDirections.actionGlobalShareFragment(
|
RecentlyClosedFragmentDirections.actionGlobalShareFragment(
|
||||||
data = arrayOf(ShareData(url = item.url, title = item.title))
|
data = arrayOf(ShareData(url = item.url, title = item.title))
|
||||||
@ -72,15 +73,15 @@ class DefaultRecentlyClosedController(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun handleRestore(item: ClosedTab) {
|
override fun handleRestore(item: RecoverableTab) {
|
||||||
item.restoreTab(
|
tabsUseCases.restore(item)
|
||||||
store,
|
|
||||||
sessionManager,
|
store.dispatch(
|
||||||
onTabRestored = {
|
RecentlyClosedAction.RemoveClosedTabAction(item)
|
||||||
|
)
|
||||||
|
|
||||||
activity.openToBrowser(
|
activity.openToBrowser(
|
||||||
from = BrowserDirection.FromRecentlyClosed
|
from = BrowserDirection.FromRecentlyClosed
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ import kotlinx.android.synthetic.main.fragment_recently_closed_tabs.view.*
|
|||||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||||
import kotlinx.coroutines.flow.collect
|
import kotlinx.coroutines.flow.collect
|
||||||
import kotlinx.coroutines.flow.map
|
import kotlinx.coroutines.flow.map
|
||||||
import mozilla.components.browser.state.state.ClosedTab
|
import mozilla.components.browser.state.state.recover.RecoverableTab
|
||||||
import mozilla.components.lib.state.ext.consumeFrom
|
import mozilla.components.lib.state.ext.consumeFrom
|
||||||
import mozilla.components.lib.state.ext.flowScoped
|
import mozilla.components.lib.state.ext.flowScoped
|
||||||
import mozilla.components.support.ktx.kotlinx.coroutines.flow.ifChanged
|
import mozilla.components.support.ktx.kotlinx.coroutines.flow.ifChanged
|
||||||
@ -34,7 +34,7 @@ import org.mozilla.fenix.ext.showToolbar
|
|||||||
import org.mozilla.fenix.library.LibraryPageFragment
|
import org.mozilla.fenix.library.LibraryPageFragment
|
||||||
|
|
||||||
@Suppress("TooManyFunctions")
|
@Suppress("TooManyFunctions")
|
||||||
class RecentlyClosedFragment : LibraryPageFragment<ClosedTab>() {
|
class RecentlyClosedFragment : LibraryPageFragment<RecoverableTab>() {
|
||||||
private lateinit var recentlyClosedFragmentStore: RecentlyClosedFragmentStore
|
private lateinit var recentlyClosedFragmentStore: RecentlyClosedFragmentStore
|
||||||
private var _recentlyClosedFragmentView: RecentlyClosedFragmentView? = null
|
private var _recentlyClosedFragmentView: RecentlyClosedFragmentView? = null
|
||||||
protected val recentlyClosedFragmentView: RecentlyClosedFragmentView
|
protected val recentlyClosedFragmentView: RecentlyClosedFragmentView
|
||||||
@ -82,6 +82,7 @@ class RecentlyClosedFragment : LibraryPageFragment<ClosedTab>() {
|
|||||||
navController = findNavController(),
|
navController = findNavController(),
|
||||||
store = requireComponents.core.store,
|
store = requireComponents.core.store,
|
||||||
activity = activity as HomeActivity,
|
activity = activity as HomeActivity,
|
||||||
|
tabsUseCases = requireComponents.useCases.tabsUseCases,
|
||||||
sessionManager = requireComponents.core.sessionManager,
|
sessionManager = requireComponents.core.sessionManager,
|
||||||
resources = requireContext().resources,
|
resources = requireContext().resources,
|
||||||
snackbar = FenixSnackbar.make(
|
snackbar = FenixSnackbar.make(
|
||||||
@ -104,7 +105,7 @@ class RecentlyClosedFragment : LibraryPageFragment<ClosedTab>() {
|
|||||||
_recentlyClosedFragmentView = null
|
_recentlyClosedFragmentView = null
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun openItem(tab: ClosedTab, mode: BrowsingMode? = null) {
|
private fun openItem(tab: RecoverableTab, mode: BrowsingMode? = null) {
|
||||||
mode?.let { (activity as HomeActivity).browsingModeManager.mode = it }
|
mode?.let { (activity as HomeActivity).browsingModeManager.mode = it }
|
||||||
|
|
||||||
(activity as HomeActivity).openToBrowserAndLoad(
|
(activity as HomeActivity).openToBrowserAndLoad(
|
||||||
@ -131,5 +132,5 @@ class RecentlyClosedFragment : LibraryPageFragment<ClosedTab>() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override val selectedItems: Set<ClosedTab> = setOf()
|
override val selectedItems: Set<RecoverableTab> = setOf()
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
package org.mozilla.fenix.library.recentlyclosed
|
package org.mozilla.fenix.library.recentlyclosed
|
||||||
|
|
||||||
import mozilla.components.browser.state.state.ClosedTab
|
import mozilla.components.browser.state.state.recover.RecoverableTab
|
||||||
import org.mozilla.fenix.browser.browsingmode.BrowsingMode
|
import org.mozilla.fenix.browser.browsingmode.BrowsingMode
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -14,27 +14,27 @@ import org.mozilla.fenix.browser.browsingmode.BrowsingMode
|
|||||||
class RecentlyClosedFragmentInteractor(
|
class RecentlyClosedFragmentInteractor(
|
||||||
private val recentlyClosedController: RecentlyClosedController
|
private val recentlyClosedController: RecentlyClosedController
|
||||||
) : RecentlyClosedInteractor {
|
) : RecentlyClosedInteractor {
|
||||||
override fun restore(item: ClosedTab) {
|
override fun restore(item: RecoverableTab) {
|
||||||
recentlyClosedController.handleRestore(item)
|
recentlyClosedController.handleRestore(item)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCopyPressed(item: ClosedTab) {
|
override fun onCopyPressed(item: RecoverableTab) {
|
||||||
recentlyClosedController.handleCopyUrl(item)
|
recentlyClosedController.handleCopyUrl(item)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onSharePressed(item: ClosedTab) {
|
override fun onSharePressed(item: RecoverableTab) {
|
||||||
recentlyClosedController.handleShare(item)
|
recentlyClosedController.handleShare(item)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onOpenInNormalTab(item: ClosedTab) {
|
override fun onOpenInNormalTab(item: RecoverableTab) {
|
||||||
recentlyClosedController.handleOpen(item, BrowsingMode.Normal)
|
recentlyClosedController.handleOpen(item, BrowsingMode.Normal)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onOpenInPrivateTab(item: ClosedTab) {
|
override fun onOpenInPrivateTab(item: RecoverableTab) {
|
||||||
recentlyClosedController.handleOpen(item, BrowsingMode.Private)
|
recentlyClosedController.handleOpen(item, BrowsingMode.Private)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDeleteOne(tab: ClosedTab) {
|
override fun onDeleteOne(tab: RecoverableTab) {
|
||||||
recentlyClosedController.handleDeleteOne(tab)
|
recentlyClosedController.handleDeleteOne(tab)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
package org.mozilla.fenix.library.recentlyclosed
|
package org.mozilla.fenix.library.recentlyclosed
|
||||||
|
|
||||||
import mozilla.components.browser.state.state.ClosedTab
|
import mozilla.components.browser.state.state.recover.RecoverableTab
|
||||||
import mozilla.components.lib.state.Action
|
import mozilla.components.lib.state.Action
|
||||||
import mozilla.components.lib.state.State
|
import mozilla.components.lib.state.State
|
||||||
import mozilla.components.lib.state.Store
|
import mozilla.components.lib.state.Store
|
||||||
@ -23,14 +23,14 @@ class RecentlyClosedFragmentStore(initialState: RecentlyClosedFragmentState) :
|
|||||||
* `RecentlyClosedFragmentState` through the reducer.
|
* `RecentlyClosedFragmentState` through the reducer.
|
||||||
*/
|
*/
|
||||||
sealed class RecentlyClosedFragmentAction : Action {
|
sealed class RecentlyClosedFragmentAction : Action {
|
||||||
data class Change(val list: List<ClosedTab>) : RecentlyClosedFragmentAction()
|
data class Change(val list: List<RecoverableTab>) : RecentlyClosedFragmentAction()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The state for the Recently Closed Screen
|
* The state for the Recently Closed Screen
|
||||||
* @property items List of recently closed tabs to display
|
* @property items List of recently closed tabs to display
|
||||||
*/
|
*/
|
||||||
data class RecentlyClosedFragmentState(val items: List<ClosedTab> = emptyList()) : State
|
data class RecentlyClosedFragmentState(val items: List<RecoverableTab> = emptyList()) : State
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The RecentlyClosedFragmentState Reducer.
|
* The RecentlyClosedFragmentState Reducer.
|
||||||
|
@ -12,7 +12,7 @@ import androidx.core.view.isVisible
|
|||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import kotlinx.android.extensions.LayoutContainer
|
import kotlinx.android.extensions.LayoutContainer
|
||||||
import kotlinx.android.synthetic.main.component_recently_closed.*
|
import kotlinx.android.synthetic.main.component_recently_closed.*
|
||||||
import mozilla.components.browser.state.state.ClosedTab
|
import mozilla.components.browser.state.state.recover.RecoverableTab
|
||||||
import org.mozilla.fenix.R
|
import org.mozilla.fenix.R
|
||||||
|
|
||||||
interface RecentlyClosedInteractor {
|
interface RecentlyClosedInteractor {
|
||||||
@ -21,7 +21,7 @@ interface RecentlyClosedInteractor {
|
|||||||
*
|
*
|
||||||
* @param item the tapped item to restore.
|
* @param item the tapped item to restore.
|
||||||
*/
|
*/
|
||||||
fun restore(item: ClosedTab)
|
fun restore(item: RecoverableTab)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the view more history option is tapped.
|
* Called when the view more history option is tapped.
|
||||||
@ -33,35 +33,35 @@ interface RecentlyClosedInteractor {
|
|||||||
*
|
*
|
||||||
* @param item the recently closed tab item to copy the URL from
|
* @param item the recently closed tab item to copy the URL from
|
||||||
*/
|
*/
|
||||||
fun onCopyPressed(item: ClosedTab)
|
fun onCopyPressed(item: RecoverableTab)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Opens the share sheet for a recently closed tab item.
|
* Opens the share sheet for a recently closed tab item.
|
||||||
*
|
*
|
||||||
* @param item the recently closed tab item to share
|
* @param item the recently closed tab item to share
|
||||||
*/
|
*/
|
||||||
fun onSharePressed(item: ClosedTab)
|
fun onSharePressed(item: RecoverableTab)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Opens a recently closed tab item in a new tab.
|
* Opens a recently closed tab item in a new tab.
|
||||||
*
|
*
|
||||||
* @param item the recently closed tab item to open in a new tab
|
* @param item the recently closed tab item to open in a new tab
|
||||||
*/
|
*/
|
||||||
fun onOpenInNormalTab(item: ClosedTab)
|
fun onOpenInNormalTab(item: RecoverableTab)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Opens a recently closed tab item in a private tab.
|
* Opens a recently closed tab item in a private tab.
|
||||||
*
|
*
|
||||||
* @param item the recently closed tab item to open in a private tab
|
* @param item the recently closed tab item to open in a private tab
|
||||||
*/
|
*/
|
||||||
fun onOpenInPrivateTab(item: ClosedTab)
|
fun onOpenInPrivateTab(item: RecoverableTab)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes one recently closed tab item.
|
* Deletes one recently closed tab item.
|
||||||
*
|
*
|
||||||
* @param item the recently closed tab item to delete.
|
* @param tab the recently closed tab item to delete.
|
||||||
*/
|
*/
|
||||||
fun onDeleteOne(tab: ClosedTab)
|
fun onDeleteOne(tab: RecoverableTab)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -102,7 +102,7 @@ class RecentlyClosedFragmentView(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun update(items: List<ClosedTab>) {
|
fun update(items: List<RecoverableTab>) {
|
||||||
recently_closed_empty_view.isVisible = items.isEmpty()
|
recently_closed_empty_view.isVisible = items.isEmpty()
|
||||||
recently_closed_list.isVisible = items.isNotEmpty()
|
recently_closed_list.isVisible = items.isNotEmpty()
|
||||||
recentlyClosedAdapter.submitList(items)
|
recentlyClosedAdapter.submitList(items)
|
||||||
|
@ -7,7 +7,7 @@ package org.mozilla.fenix.library.recentlyclosed
|
|||||||
import android.view.View
|
import android.view.View
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import kotlinx.android.synthetic.main.history_list_item.view.*
|
import kotlinx.android.synthetic.main.history_list_item.view.*
|
||||||
import mozilla.components.browser.state.state.ClosedTab
|
import mozilla.components.browser.state.state.recover.RecoverableTab
|
||||||
import org.mozilla.fenix.R
|
import org.mozilla.fenix.R
|
||||||
import org.mozilla.fenix.library.history.HistoryItemMenu
|
import org.mozilla.fenix.library.history.HistoryItemMenu
|
||||||
import org.mozilla.fenix.utils.Do
|
import org.mozilla.fenix.utils.Do
|
||||||
@ -17,14 +17,14 @@ class RecentlyClosedItemViewHolder(
|
|||||||
private val recentlyClosedFragmentInteractor: RecentlyClosedFragmentInteractor
|
private val recentlyClosedFragmentInteractor: RecentlyClosedFragmentInteractor
|
||||||
) : RecyclerView.ViewHolder(view) {
|
) : RecyclerView.ViewHolder(view) {
|
||||||
|
|
||||||
private var item: ClosedTab? = null
|
private var item: RecoverableTab? = null
|
||||||
|
|
||||||
init {
|
init {
|
||||||
setupMenu()
|
setupMenu()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun bind(
|
fun bind(
|
||||||
item: ClosedTab
|
item: RecoverableTab
|
||||||
) {
|
) {
|
||||||
itemView.history_layout.titleView.text =
|
itemView.history_layout.titleView.text =
|
||||||
if (item.title.isNotEmpty()) item.title else item.url
|
if (item.title.isNotEmpty()) item.title else item.url
|
||||||
|
@ -13,18 +13,16 @@ import io.mockk.Runs
|
|||||||
import io.mockk.every
|
import io.mockk.every
|
||||||
import io.mockk.just
|
import io.mockk.just
|
||||||
import io.mockk.mockk
|
import io.mockk.mockk
|
||||||
import io.mockk.mockkStatic
|
|
||||||
import io.mockk.slot
|
import io.mockk.slot
|
||||||
import io.mockk.unmockkStatic
|
|
||||||
import io.mockk.verify
|
import io.mockk.verify
|
||||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||||
import kotlinx.coroutines.test.TestCoroutineDispatcher
|
import kotlinx.coroutines.test.TestCoroutineDispatcher
|
||||||
import mozilla.components.browser.session.SessionManager
|
import mozilla.components.browser.session.SessionManager
|
||||||
import mozilla.components.browser.state.action.RecentlyClosedAction
|
import mozilla.components.browser.state.action.RecentlyClosedAction
|
||||||
import mozilla.components.browser.state.state.ClosedTab
|
import mozilla.components.browser.state.state.recover.RecoverableTab
|
||||||
import mozilla.components.browser.state.store.BrowserStore
|
import mozilla.components.browser.state.store.BrowserStore
|
||||||
import mozilla.components.concept.engine.prompt.ShareData
|
import mozilla.components.concept.engine.prompt.ShareData
|
||||||
import mozilla.components.feature.recentlyclosed.ext.restoreTab
|
import mozilla.components.feature.tabs.TabsUseCases
|
||||||
import org.junit.After
|
import org.junit.After
|
||||||
import org.junit.Assert.assertEquals
|
import org.junit.Assert.assertEquals
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
@ -47,16 +45,18 @@ class DefaultRecentlyClosedControllerTest {
|
|||||||
private val resources: Resources = mockk(relaxed = true)
|
private val resources: Resources = mockk(relaxed = true)
|
||||||
private val snackbar: FenixSnackbar = mockk(relaxed = true)
|
private val snackbar: FenixSnackbar = mockk(relaxed = true)
|
||||||
private val clipboardManager: ClipboardManager = mockk(relaxed = true)
|
private val clipboardManager: ClipboardManager = mockk(relaxed = true)
|
||||||
private val openToBrowser: (ClosedTab, BrowsingMode?) -> Unit = mockk(relaxed = true)
|
private val openToBrowser: (RecoverableTab, BrowsingMode?) -> Unit = mockk(relaxed = true)
|
||||||
private val sessionManager: SessionManager = mockk(relaxed = true)
|
private val sessionManager: SessionManager = mockk(relaxed = true)
|
||||||
private val activity: HomeActivity = mockk(relaxed = true)
|
private val activity: HomeActivity = mockk(relaxed = true)
|
||||||
private val store: BrowserStore = mockk(relaxed = true)
|
private val store: BrowserStore = mockk(relaxed = true)
|
||||||
val mockedTab: ClosedTab = mockk(relaxed = true)
|
private val tabsUseCases: TabsUseCases = mockk(relaxed = true)
|
||||||
|
val mockedTab: RecoverableTab = mockk(relaxed = true)
|
||||||
|
|
||||||
private val controller = DefaultRecentlyClosedController(
|
private val controller = DefaultRecentlyClosedController(
|
||||||
navController,
|
navController,
|
||||||
store,
|
store,
|
||||||
sessionManager,
|
sessionManager,
|
||||||
|
tabsUseCases,
|
||||||
resources,
|
resources,
|
||||||
snackbar,
|
snackbar,
|
||||||
clipboardManager,
|
clipboardManager,
|
||||||
@ -66,19 +66,17 @@ class DefaultRecentlyClosedControllerTest {
|
|||||||
|
|
||||||
@Before
|
@Before
|
||||||
fun setUp() {
|
fun setUp() {
|
||||||
mockkStatic("mozilla.components.feature.recentlyclosed.ext.ClosedTabKt")
|
every { tabsUseCases.restore.invoke(any(), true) } just Runs
|
||||||
every { mockedTab.restoreTab(any(), any(), any()) } just Runs
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
fun tearDown() {
|
fun tearDown() {
|
||||||
dispatcher.cleanupTestCoroutines()
|
dispatcher.cleanupTestCoroutines()
|
||||||
unmockkStatic("mozilla.components.feature.recentlyclosed.ext.ClosedTabKt")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun handleOpen() {
|
fun handleOpen() {
|
||||||
val item: ClosedTab = mockk(relaxed = true)
|
val item: RecoverableTab = mockk(relaxed = true)
|
||||||
|
|
||||||
controller.handleOpen(item, BrowsingMode.Private)
|
controller.handleOpen(item, BrowsingMode.Private)
|
||||||
|
|
||||||
@ -95,7 +93,7 @@ class DefaultRecentlyClosedControllerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun handleDeleteOne() {
|
fun handleDeleteOne() {
|
||||||
val item: ClosedTab = mockk(relaxed = true)
|
val item: RecoverableTab = mockk(relaxed = true)
|
||||||
|
|
||||||
controller.handleDeleteOne(item)
|
controller.handleDeleteOne(item)
|
||||||
|
|
||||||
@ -120,7 +118,7 @@ class DefaultRecentlyClosedControllerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun handleCopyUrl() {
|
fun handleCopyUrl() {
|
||||||
val item = ClosedTab(id = "tab-id", title = "Mozilla", url = "mozilla.org", createdAt = 1L)
|
val item = RecoverableTab(id = "tab-id", title = "Mozilla", url = "mozilla.org", lastAccess = 1L)
|
||||||
|
|
||||||
val clipdata = slot<ClipData>()
|
val clipdata = slot<ClipData>()
|
||||||
|
|
||||||
@ -139,7 +137,7 @@ class DefaultRecentlyClosedControllerTest {
|
|||||||
@Test
|
@Test
|
||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
fun handleShare() {
|
fun handleShare() {
|
||||||
val item = ClosedTab(id = "tab-id", title = "Mozilla", url = "mozilla.org", createdAt = 1L)
|
val item = RecoverableTab(id = "tab-id", title = "Mozilla", url = "mozilla.org", lastAccess = 1L)
|
||||||
|
|
||||||
controller.handleShare(item)
|
controller.handleShare(item)
|
||||||
|
|
||||||
@ -160,12 +158,6 @@ class DefaultRecentlyClosedControllerTest {
|
|||||||
|
|
||||||
dispatcher.advanceUntilIdle()
|
dispatcher.advanceUntilIdle()
|
||||||
|
|
||||||
verify {
|
verify { tabsUseCases.restore.invoke(mockedTab, true) }
|
||||||
mockedTab.restoreTab(
|
|
||||||
store,
|
|
||||||
sessionManager,
|
|
||||||
onTabRestored = any()
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ package org.mozilla.fenix.library.recentlyclosed
|
|||||||
|
|
||||||
import io.mockk.mockk
|
import io.mockk.mockk
|
||||||
import io.mockk.verify
|
import io.mockk.verify
|
||||||
import mozilla.components.browser.state.state.ClosedTab
|
import mozilla.components.browser.state.state.recover.RecoverableTab
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.mozilla.fenix.browser.browsingmode.BrowsingMode
|
import org.mozilla.fenix.browser.browsingmode.BrowsingMode
|
||||||
@ -27,7 +27,7 @@ class RecentlyClosedFragmentInteractorTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun open() {
|
fun open() {
|
||||||
val tab = ClosedTab(id = "tab-id", title = "Mozilla", url = "mozilla.org", createdAt = 1L)
|
val tab = RecoverableTab(id = "tab-id", title = "Mozilla", url = "mozilla.org", lastAccess = 1L)
|
||||||
interactor.restore(tab)
|
interactor.restore(tab)
|
||||||
|
|
||||||
verify {
|
verify {
|
||||||
@ -37,7 +37,7 @@ class RecentlyClosedFragmentInteractorTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun onCopyPressed() {
|
fun onCopyPressed() {
|
||||||
val tab = ClosedTab(id = "tab-id", title = "Mozilla", url = "mozilla.org", createdAt = 1L)
|
val tab = RecoverableTab(id = "tab-id", title = "Mozilla", url = "mozilla.org", lastAccess = 1L)
|
||||||
interactor.onCopyPressed(tab)
|
interactor.onCopyPressed(tab)
|
||||||
|
|
||||||
verify {
|
verify {
|
||||||
@ -47,7 +47,7 @@ class RecentlyClosedFragmentInteractorTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun onSharePressed() {
|
fun onSharePressed() {
|
||||||
val tab = ClosedTab(id = "tab-id", title = "Mozilla", url = "mozilla.org", createdAt = 1L)
|
val tab = RecoverableTab(id = "tab-id", title = "Mozilla", url = "mozilla.org", lastAccess = 1L)
|
||||||
interactor.onSharePressed(tab)
|
interactor.onSharePressed(tab)
|
||||||
|
|
||||||
verify {
|
verify {
|
||||||
@ -57,7 +57,7 @@ class RecentlyClosedFragmentInteractorTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun onOpenInNormalTab() {
|
fun onOpenInNormalTab() {
|
||||||
val tab = ClosedTab(id = "tab-id", title = "Mozilla", url = "mozilla.org", createdAt = 1L)
|
val tab = RecoverableTab(id = "tab-id", title = "Mozilla", url = "mozilla.org", lastAccess = 1L)
|
||||||
interactor.onOpenInNormalTab(tab)
|
interactor.onOpenInNormalTab(tab)
|
||||||
|
|
||||||
verify {
|
verify {
|
||||||
@ -67,7 +67,7 @@ class RecentlyClosedFragmentInteractorTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun onOpenInPrivateTab() {
|
fun onOpenInPrivateTab() {
|
||||||
val tab = ClosedTab(id = "tab-id", title = "Mozilla", url = "mozilla.org", createdAt = 1L)
|
val tab = RecoverableTab(id = "tab-id", title = "Mozilla", url = "mozilla.org", lastAccess = 1L)
|
||||||
interactor.onOpenInPrivateTab(tab)
|
interactor.onOpenInPrivateTab(tab)
|
||||||
|
|
||||||
verify {
|
verify {
|
||||||
@ -77,7 +77,7 @@ class RecentlyClosedFragmentInteractorTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun onDeleteOne() {
|
fun onDeleteOne() {
|
||||||
val tab = ClosedTab(id = "tab-id", title = "Mozilla", url = "mozilla.org", createdAt = 1L)
|
val tab = RecoverableTab(id = "tab-id", title = "Mozilla", url = "mozilla.org", lastAccess = 1L)
|
||||||
interactor.onDeleteOne(tab)
|
interactor.onDeleteOne(tab)
|
||||||
|
|
||||||
verify {
|
verify {
|
||||||
|
@ -3,5 +3,5 @@
|
|||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
object AndroidComponents {
|
object AndroidComponents {
|
||||||
const val VERSION = "71.0.20210110143120"
|
const val VERSION = "71.0.20210111162202"
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user