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

For #203 - Adds find in page and request desktop site to custom tab menu (#3835)

This commit is contained in:
Emily Kager 2019-07-02 14:41:29 -07:00 committed by Sawyer Blatz
parent eedb0fa3b2
commit ce2d597af3
3 changed files with 30 additions and 4 deletions

View File

@ -726,7 +726,9 @@ class BrowserFragment : Fragment(), BackHandler {
R.id.browserFragment,
BrowserFragmentDirections.actionBrowserFragmentToLibraryFragment()
)
is ToolbarMenu.Item.RequestDesktop -> sessionUseCases.requestDesktopSite.invoke(action.item.isChecked)
is ToolbarMenu.Item.RequestDesktop -> getSessionById()?.let { session ->
sessionUseCases.requestDesktopSite.invoke(action.item.isChecked, session)
}
ToolbarMenu.Item.Share -> getSessionById()?.let { session ->
session.url.apply {
shareUrl(this)

View File

@ -52,7 +52,9 @@ class FindInPageIntegration(
private fun launch() {
sessionManager.runWithSessionIdOrSelected(sessionId) {
if (!it.isCustomTabSession()) {
toolbar.visibility = View.GONE
}
view.asView().visibility = View.VISIBLE
feature.bind(it)
}
@ -77,7 +79,11 @@ class FindInPageBarBehavior(
context: Context,
attrs: AttributeSet
) : CoordinatorLayout.Behavior<FindInPageBar>(context, attrs) {
override fun layoutDependsOn(parent: CoordinatorLayout, child: FindInPageBar, dependency: View): Boolean {
override fun layoutDependsOn(
parent: CoordinatorLayout,
child: FindInPageBar,
dependency: View
): Boolean {
if (dependency is BrowserToolbar) {
return true
}
@ -85,7 +91,11 @@ class FindInPageBarBehavior(
return super.layoutDependsOn(parent, child, dependency)
}
override fun onDependentViewChanged(parent: CoordinatorLayout, child: FindInPageBar, dependency: View): Boolean {
override fun onDependentViewChanged(
parent: CoordinatorLayout,
child: FindInPageBar,
dependency: View
): Boolean {
return if (dependency is BrowserToolbar) {
repositionFindInPageBar(child, dependency)
true

View File

@ -9,6 +9,7 @@ import mozilla.components.browser.menu.BrowserMenuBuilder
import mozilla.components.browser.menu.item.BrowserMenuDivider
import mozilla.components.browser.menu.item.BrowserMenuImageText
import mozilla.components.browser.menu.item.BrowserMenuItemToolbar
import mozilla.components.browser.menu.item.BrowserMenuSwitch
import mozilla.components.browser.menu.item.SimpleBrowserMenuItem
import mozilla.components.browser.session.Session
import mozilla.components.browser.session.SessionManager
@ -116,6 +117,19 @@ class CustomTabToolbarMenu(
onItemTapped.invoke(ToolbarMenu.Item.Share)
},
BrowserMenuSwitch(context.getString(R.string.browser_menu_desktop_site),
{ session?.desktopMode ?: false }, { checked ->
onItemTapped.invoke(ToolbarMenu.Item.RequestDesktop(checked))
}),
BrowserMenuImageText(
context.getString(R.string.browser_menu_find_in_page),
R.drawable.mozac_ic_search,
ThemeManager.resolveAttribute(R.attr.primaryText, context)
) {
onItemTapped.invoke(ToolbarMenu.Item.FindInPage)
},
SimpleBrowserMenuItem(
{
val appName = context.getString(R.string.app_name)