2
0
mirror of https://github.com/fork-maintainers/iceraven-browser synced 2024-11-03 23:15:31 +00:00

For #4155: Handle custom tabs & fix test

This commit is contained in:
Sawyer Blatz 2019-09-11 08:32:38 -07:00
parent 53b3f105ca
commit 5586b18c3e
4 changed files with 29 additions and 25 deletions

View File

@ -57,7 +57,8 @@ class DefaultBrowserToolbarController(
navController.nav(
R.id.browserFragment,
BrowserFragmentDirections.actionBrowserFragmentToSearchFragment(
sessionId = customTabSession?.id ?: context.components.core.sessionManager.selectedSession?.id
sessionId = customTabSession?.id ?: context.components.core.sessionManager.selectedSession?.id,
pastedText = text
)
)
}

View File

@ -51,6 +51,8 @@ class BrowserToolbarView(
val toolbarIntegration: ToolbarIntegration
init {
val isCustomTabSession = customTabSession != null
view.setOnUrlLongClickListener {
val clipboard = view.context.getSystemService(CLIPBOARD_SERVICE) as ClipboardManager
val customView = LayoutInflater.from(view.context).inflate(R.layout.browser_toolbar_popup_window, null)
@ -62,8 +64,8 @@ class BrowserToolbarView(
popupWindow.showAsDropDown(view, view.context.dimen(R.dimen.context_menu_x_offset), 0, Gravity.START)
customView.paste.isVisible = clipboard.containsText()
customView.paste_and_go.isVisible = clipboard.containsText()
customView.paste.isVisible = clipboard.containsText() && !isCustomTabSession
customView.paste_and_go.isVisible = clipboard.containsText() && !isCustomTabSession
customView.copy.setOnClickListener {
popupWindow.dismiss()
@ -85,7 +87,6 @@ class BrowserToolbarView(
with(container.context) {
val sessionManager = components.core.sessionManager
val isCustomTabSession = customTabSession != null
view.apply {
elevation = TOOLBAR_ELEVATION.dpToFloat(resources.displayMetrics)

View File

@ -96,9 +96,4 @@ class ExternalAppBrowserFragment : BaseBrowserFragment(), BackHandler {
}
override fun getAppropriateLayoutGravity() = Gravity.TOP
companion object {
private const val SHARED_TRANSITION_MS = 200L
private const val TAB_ITEM_TRANSITION_NAME = "tab_item"
}
}

View File

@ -19,25 +19,32 @@ import org.mozilla.fenix.quickactionsheet.QuickActionSheetController
class BrowserInteractorTest {
val metrics: MetricController = mockk()
val context: Context = mockk()
val browserStore: BrowserFragmentStore = mockk(relaxed = true)
val browserToolbarController: BrowserToolbarController = mockk(relaxed = true)
val quickActionSheetController: QuickActionSheetController = mockk(relaxed = true)
val readerModeController: ReaderModeController = mockk(relaxed = true)
val session: Session = mockk()
val interactor = BrowserInteractor(
context,
browserStore,
browserToolbarController,
quickActionSheetController,
readerModeController,
session
)
lateinit var metrics: MetricController
lateinit var context: Context
lateinit var browserStore: BrowserFragmentStore
lateinit var browserToolbarController: BrowserToolbarController
lateinit var quickActionSheetController: QuickActionSheetController
lateinit var readerModeController: ReaderModeController
lateinit var session: Session
lateinit var interactor: BrowserInteractor
@Before
fun setup() {
metrics = mockk()
context = mockk()
browserStore = mockk(relaxed = true)
browserToolbarController = mockk(relaxed = true)
quickActionSheetController = mockk(relaxed = true)
readerModeController = mockk(relaxed = true)
session = mockk()
interactor = BrowserInteractor(
context,
browserStore,
browserToolbarController,
quickActionSheetController,
readerModeController,
session
)
every { context.metrics } returns metrics
every { context.components.core.sessionManager.selectedSession } returns session
}