mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-17 15:26:23 +00:00
[fenix] For https://github.com/mozilla-mobile/fenix/issues/7155 Align custom tabs overflow menu to original mocks
Reverse menu items order when toolbar position is top
This commit is contained in:
parent
cea6d9d394
commit
fd06352b8b
@ -178,6 +178,7 @@ class BrowserToolbarView(
|
|||||||
this,
|
this,
|
||||||
sessionManager,
|
sessionManager,
|
||||||
customTabSession?.id,
|
customTabSession?.id,
|
||||||
|
shouldReverseItems = !shouldUseBottomToolbar,
|
||||||
onItemTapped = {
|
onItemTapped = {
|
||||||
interactor.onBrowserToolbarMenuItemTapped(it)
|
interactor.onBrowserToolbarMenuItemTapped(it)
|
||||||
}
|
}
|
||||||
|
@ -5,12 +5,14 @@
|
|||||||
package org.mozilla.fenix.customtabs
|
package org.mozilla.fenix.customtabs
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.graphics.Typeface
|
||||||
import mozilla.components.browser.menu.BrowserMenuBuilder
|
import mozilla.components.browser.menu.BrowserMenuBuilder
|
||||||
import mozilla.components.browser.menu.item.BrowserMenuDivider
|
import mozilla.components.browser.menu.item.BrowserMenuDivider
|
||||||
import mozilla.components.browser.menu.item.BrowserMenuImageText
|
import mozilla.components.browser.menu.item.BrowserMenuImageText
|
||||||
import mozilla.components.browser.menu.item.BrowserMenuItemToolbar
|
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.menu.item.SimpleBrowserMenuItem
|
||||||
|
import mozilla.components.browser.menu.item.BrowserMenuImageSwitch
|
||||||
|
import mozilla.components.browser.menu.item.BrowserMenuCategory
|
||||||
import mozilla.components.browser.session.Session
|
import mozilla.components.browser.session.Session
|
||||||
import mozilla.components.browser.session.SessionManager
|
import mozilla.components.browser.session.SessionManager
|
||||||
import org.mozilla.fenix.R
|
import org.mozilla.fenix.R
|
||||||
@ -21,6 +23,7 @@ class CustomTabToolbarMenu(
|
|||||||
private val context: Context,
|
private val context: Context,
|
||||||
private val sessionManager: SessionManager,
|
private val sessionManager: SessionManager,
|
||||||
private val sessionId: String?,
|
private val sessionId: String?,
|
||||||
|
private val shouldReverseItems: Boolean,
|
||||||
private val onItemTapped: (ToolbarMenu.Item) -> Unit = {}
|
private val onItemTapped: (ToolbarMenu.Item) -> Unit = {}
|
||||||
) : ToolbarMenu {
|
) : ToolbarMenu {
|
||||||
override val menuBuilder by lazy { BrowserMenuBuilder(menuItems) }
|
override val menuBuilder by lazy { BrowserMenuBuilder(menuItems) }
|
||||||
@ -84,16 +87,17 @@ class CustomTabToolbarMenu(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private val menuItems by lazy {
|
private val menuItems by lazy {
|
||||||
listOf(
|
val menuItems = listOf(
|
||||||
menuToolbar,
|
poweredBy,
|
||||||
BrowserMenuDivider(),
|
BrowserMenuDivider(),
|
||||||
share,
|
share,
|
||||||
desktopMode,
|
desktopMode,
|
||||||
findInPage,
|
findInPage,
|
||||||
openInFenix,
|
openInFenix,
|
||||||
BrowserMenuDivider(),
|
BrowserMenuDivider(),
|
||||||
poweredBy
|
menuToolbar
|
||||||
)
|
)
|
||||||
|
if (shouldReverseItems) { menuItems.reversed() } else { menuItems }
|
||||||
}
|
}
|
||||||
|
|
||||||
private val share = BrowserMenuImageText(
|
private val share = BrowserMenuImageText(
|
||||||
@ -105,7 +109,8 @@ class CustomTabToolbarMenu(
|
|||||||
onItemTapped.invoke(ToolbarMenu.Item.Share)
|
onItemTapped.invoke(ToolbarMenu.Item.Share)
|
||||||
}
|
}
|
||||||
|
|
||||||
private val desktopMode = BrowserMenuSwitch(
|
private val desktopMode = BrowserMenuImageSwitch(
|
||||||
|
imageResource = R.drawable.ic_desktop,
|
||||||
label = context.getString(R.string.browser_menu_desktop_site),
|
label = context.getString(R.string.browser_menu_desktop_site),
|
||||||
initialState = { session?.desktopMode ?: false }
|
initialState = { session?.desktopMode ?: false }
|
||||||
) { checked ->
|
) { checked ->
|
||||||
@ -130,13 +135,14 @@ class CustomTabToolbarMenu(
|
|||||||
onItemTapped.invoke(ToolbarMenu.Item.OpenInFenix)
|
onItemTapped.invoke(ToolbarMenu.Item.OpenInFenix)
|
||||||
}
|
}
|
||||||
|
|
||||||
private val poweredBy = SimpleBrowserMenuItem(
|
private val poweredBy = BrowserMenuCategory(
|
||||||
label = {
|
label = {
|
||||||
val appName = context.getString(R.string.app_name)
|
val appName = context.getString(R.string.app_name)
|
||||||
context.getString(R.string.browser_menu_powered_by, appName).toUpperCase()
|
context.getString(R.string.browser_menu_powered_by, appName).toUpperCase()
|
||||||
}(),
|
}(),
|
||||||
textSize = ToolbarMenu.CAPTION_TEXT_SIZE,
|
textSize = ToolbarMenu.CAPTION_TEXT_SIZE,
|
||||||
textColorResource = primaryTextColor()
|
textColorResource = primaryTextColor(),
|
||||||
|
textStyle = Typeface.NORMAL
|
||||||
)
|
)
|
||||||
|
|
||||||
private fun primaryTextColor() = ThemeManager.resolveAttribute(R.attr.primaryText, context)
|
private fun primaryTextColor() = ThemeManager.resolveAttribute(R.attr.primaryText, context)
|
||||||
|
@ -25,6 +25,7 @@ class CustomTabsIntegration(
|
|||||||
activity: Activity,
|
activity: Activity,
|
||||||
engineLayout: View,
|
engineLayout: View,
|
||||||
onItemTapped: (ToolbarMenu.Item) -> Unit = {},
|
onItemTapped: (ToolbarMenu.Item) -> Unit = {},
|
||||||
|
shouldReverseItems: Boolean,
|
||||||
isPrivate: Boolean
|
isPrivate: Boolean
|
||||||
) : LifecycleAwareFeature, UserInteractionHandler {
|
) : LifecycleAwareFeature, UserInteractionHandler {
|
||||||
|
|
||||||
@ -86,6 +87,7 @@ class CustomTabsIntegration(
|
|||||||
activity,
|
activity,
|
||||||
sessionManager,
|
sessionManager,
|
||||||
sessionId,
|
sessionId,
|
||||||
|
shouldReverseItems,
|
||||||
onItemTapped = onItemTapped
|
onItemTapped = onItemTapped
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -35,6 +35,7 @@ import org.mozilla.fenix.browser.FenixSnackbarDelegate
|
|||||||
import org.mozilla.fenix.ext.components
|
import org.mozilla.fenix.ext.components
|
||||||
import org.mozilla.fenix.ext.nav
|
import org.mozilla.fenix.ext.nav
|
||||||
import org.mozilla.fenix.ext.requireComponents
|
import org.mozilla.fenix.ext.requireComponents
|
||||||
|
import org.mozilla.fenix.ext.settings
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fragment used for browsing the web within external apps.
|
* Fragment used for browsing the web within external apps.
|
||||||
@ -68,7 +69,8 @@ class ExternalAppBrowserFragment : BaseBrowserFragment(), UserInteractionHandler
|
|||||||
activity = activity,
|
activity = activity,
|
||||||
engineLayout = view.swipeRefresh,
|
engineLayout = view.swipeRefresh,
|
||||||
onItemTapped = { browserInteractor.onBrowserToolbarMenuItemTapped(it) },
|
onItemTapped = { browserInteractor.onBrowserToolbarMenuItemTapped(it) },
|
||||||
isPrivate = (activity as HomeActivity).browsingModeManager.mode.isPrivate
|
isPrivate = (activity as HomeActivity).browsingModeManager.mode.isPrivate,
|
||||||
|
shouldReverseItems = !activity.settings().shouldUseBottomToolbar
|
||||||
),
|
),
|
||||||
owner = this,
|
owner = this,
|
||||||
view = view
|
view = view
|
||||||
|
Loading…
Reference in New Issue
Block a user