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/4134 Add Forward Back Reload to Toolbar on Tablets
This commit is contained in:
parent
4082b5eb90
commit
982dc4410f
@ -33,6 +33,7 @@ import org.mozilla.fenix.FeatureFlags
|
||||
import org.mozilla.fenix.R
|
||||
import org.mozilla.fenix.components.FenixSnackbar
|
||||
import org.mozilla.fenix.components.TabCollectionStorage
|
||||
import org.mozilla.fenix.components.toolbar.ToolbarMenu
|
||||
import org.mozilla.fenix.components.metrics.Event
|
||||
import org.mozilla.fenix.ext.components
|
||||
import org.mozilla.fenix.ext.nav
|
||||
@ -82,10 +83,10 @@ class BrowserFragment : BaseBrowserFragment(), UserInteractionHandler {
|
||||
if (FeatureFlags.showHomeButtonFeature) {
|
||||
val homeAction = BrowserToolbar.Button(
|
||||
imageDrawable = AppCompatResources.getDrawable(
|
||||
requireContext(),
|
||||
context,
|
||||
R.drawable.mozac_ic_home
|
||||
)!!,
|
||||
contentDescription = requireContext().getString(R.string.browser_toolbar_home),
|
||||
contentDescription = context.getString(R.string.browser_toolbar_home),
|
||||
iconTintColorResource = ThemeManager.resolveAttribute(R.attr.primaryText, context),
|
||||
listener = browserToolbarInteractor::onHomeButtonClicked
|
||||
)
|
||||
@ -93,19 +94,100 @@ class BrowserFragment : BaseBrowserFragment(), UserInteractionHandler {
|
||||
browserToolbarView.view.addNavigationAction(homeAction)
|
||||
}
|
||||
|
||||
if (resources.getBoolean(R.bool.tablet)) {
|
||||
val enableTint = ThemeManager.resolveAttribute(R.attr.primaryText, context)
|
||||
val disableTint = ThemeManager.resolveAttribute(R.attr.disabled, context)
|
||||
val backAction = BrowserToolbar.TwoStateButton(
|
||||
primaryImage = AppCompatResources.getDrawable(
|
||||
context,
|
||||
R.drawable.mozac_ic_back
|
||||
)!!,
|
||||
primaryContentDescription = context.getString(R.string.browser_menu_back),
|
||||
primaryImageTintResource = enableTint,
|
||||
isInPrimaryState = { getCurrentTab()?.content?.canGoBack ?: false },
|
||||
secondaryImageTintResource = disableTint,
|
||||
disableInSecondaryState = true,
|
||||
longClickListener = {
|
||||
browserToolbarInteractor.onBrowserToolbarMenuItemTapped(
|
||||
ToolbarMenu.Item.Back(viewHistory = true)
|
||||
)
|
||||
},
|
||||
listener = {
|
||||
browserToolbarInteractor.onBrowserToolbarMenuItemTapped(
|
||||
ToolbarMenu.Item.Back(viewHistory = false)
|
||||
)
|
||||
}
|
||||
)
|
||||
browserToolbarView.view.addNavigationAction(backAction)
|
||||
val forwardAction = BrowserToolbar.TwoStateButton(
|
||||
primaryImage = AppCompatResources.getDrawable(
|
||||
context,
|
||||
R.drawable.mozac_ic_forward
|
||||
)!!,
|
||||
primaryContentDescription = context.getString(R.string.browser_menu_forward),
|
||||
primaryImageTintResource = enableTint,
|
||||
isInPrimaryState = { getCurrentTab()?.content?.canGoForward ?: false },
|
||||
secondaryImageTintResource = disableTint,
|
||||
disableInSecondaryState = true,
|
||||
longClickListener = {
|
||||
browserToolbarInteractor.onBrowserToolbarMenuItemTapped(
|
||||
ToolbarMenu.Item.Forward(viewHistory = true)
|
||||
)
|
||||
},
|
||||
listener = {
|
||||
browserToolbarInteractor.onBrowserToolbarMenuItemTapped(
|
||||
ToolbarMenu.Item.Forward(viewHistory = false)
|
||||
)
|
||||
}
|
||||
)
|
||||
browserToolbarView.view.addNavigationAction(forwardAction)
|
||||
val refreshAction = BrowserToolbar.TwoStateButton(
|
||||
primaryImage = AppCompatResources.getDrawable(
|
||||
context,
|
||||
R.drawable.mozac_ic_refresh
|
||||
)!!,
|
||||
primaryContentDescription = context.getString(R.string.browser_menu_refresh),
|
||||
primaryImageTintResource = enableTint,
|
||||
isInPrimaryState = {
|
||||
getCurrentTab()?.content?.loading == false
|
||||
},
|
||||
secondaryImage = AppCompatResources.getDrawable(
|
||||
context,
|
||||
R.drawable.mozac_ic_stop
|
||||
)!!,
|
||||
secondaryContentDescription = context.getString(R.string.browser_menu_stop),
|
||||
disableInSecondaryState = false,
|
||||
longClickListener = {
|
||||
browserToolbarInteractor.onBrowserToolbarMenuItemTapped(
|
||||
ToolbarMenu.Item.Reload(bypassCache = true)
|
||||
)
|
||||
},
|
||||
listener = {
|
||||
if (getCurrentTab()?.content?.loading == true) {
|
||||
browserToolbarInteractor.onBrowserToolbarMenuItemTapped(ToolbarMenu.Item.Stop)
|
||||
} else {
|
||||
browserToolbarInteractor.onBrowserToolbarMenuItemTapped(
|
||||
ToolbarMenu.Item.Reload(bypassCache = false)
|
||||
)
|
||||
}
|
||||
}
|
||||
)
|
||||
browserToolbarView.view.addNavigationAction(refreshAction)
|
||||
}
|
||||
|
||||
val readerModeAction =
|
||||
BrowserToolbar.ToggleButton(
|
||||
image = AppCompatResources.getDrawable(
|
||||
requireContext(),
|
||||
context,
|
||||
R.drawable.ic_readermode
|
||||
)!!,
|
||||
imageSelected =
|
||||
AppCompatResources.getDrawable(
|
||||
requireContext(),
|
||||
context,
|
||||
R.drawable.ic_readermode_selected
|
||||
)!!,
|
||||
contentDescription = requireContext().getString(R.string.browser_menu_read),
|
||||
contentDescriptionSelected = requireContext().getString(R.string.browser_menu_read_close),
|
||||
contentDescription = context.getString(R.string.browser_menu_read),
|
||||
contentDescriptionSelected = context.getString(R.string.browser_menu_read_close),
|
||||
visible = {
|
||||
readerModeAvailable
|
||||
},
|
||||
|
7
app/src/main/res/values-sw600dp/bools.xml
Normal file
7
app/src/main/res/values-sw600dp/bools.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- This Source Code Form is subject to the terms of the Mozilla Public
|
||||
- License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
||||
<resources>
|
||||
<bool name="tablet">true</bool>
|
||||
</resources>
|
@ -6,4 +6,5 @@
|
||||
<bool name="theme_is_light">true</bool>
|
||||
<bool name="API28">false</bool>
|
||||
<bool name="underAPI28">true</bool>
|
||||
<bool name="tablet">false</bool>
|
||||
</resources>
|
||||
|
Loading…
Reference in New Issue
Block a user