You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
iceraven-browser/app/src/main/java/org/mozilla/fenix/components/toolbar/DefaultToolbarMenu.kt

467 lines
19 KiB
Kotlin

/* 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/. */
package org.mozilla.fenix.components.toolbar
import android.content.Context
import androidx.annotation.ColorRes
import androidx.annotation.VisibleForTesting
import androidx.annotation.VisibleForTesting.PRIVATE
import androidx.core.content.ContextCompat.getColor
4281 remove qab (#6310) * For #4281: small ToolbarMenu refactor This makes it easier to see how items are ordered in the menuItems list * For 4281: add QAB buttons to menu * For 4281: removed menu back button per mocks I double checked with UX, and we'll be relying on the hardware back button for its functionality * For 4281: add content descriptions for bookmarking * For 4281: updated BrowserToolbarController for new functionality * For 4281: provided simple dependencies to browser controller More complex changes will be in a following commit, for review readability * For 4281: move toolbar controller dependencies up to BaseBrowserFragment The functionality they control is being moved into the toolbar menu, which is shared by both normal tabs and custom ones * For 4281: removed (now unused) code related to QAB * For 4281: fix test compilation after QAB removal Tests still need to be expanded to include added functionality * For 4281: updated menu to show if url is bookmarked This sloppy workaround is required because TwoStateButton requires that `isInPrimaryState` be a synchronous call, and checking whether or not the current site is bookmarked is quite slow (10-50 MS, in my tests). After days of work and many attempted solutions, this was the least abhorrent among them. https://github.com/mozilla-mobile/android-components/issues/4915 was opened against AC to evaluate potentially supporting async `isInPrimaryState` functions. https://github.com/mozilla-mobile/fenix/issues/6370 was opened against Fenix to investigate the unexpectedly slow call to `BookmarkStorage`. * For 4281: update reader mode switch * For 4281: selectively show/hide menu items * For 4281: add reader mode appearance * For 4281: update bookmark button when it is clicked * For 4281: removed unused QAB code * For 4281: removed QAB robot, updated UI tests * For 4281: removed QuickActionSheet metrics Since this behavior now lives in the toolbar, it is tracked via Event.BrowserMenuItemTapped * For 4281: fixed lint errors * For 4281: add new strings for buttons added to menu This is necessary because the location change (from QAB to toolbar menu) could affect the grammar in some languages * For 4281: remove outdated TODOs * For 4281: removed QAB container * For 4281: removed back button reference from UI test This button no longer exists * For 4821: Fixes a visual defect (extra padding on top of toolbar) * For 4281: update copy on reader mode * For 4281: fixed review nits
5 years ago
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.lifecycleScope
import kotlinx.coroutines.Job
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.flow.mapNotNull
4281 remove qab (#6310) * For #4281: small ToolbarMenu refactor This makes it easier to see how items are ordered in the menuItems list * For 4281: add QAB buttons to menu * For 4281: removed menu back button per mocks I double checked with UX, and we'll be relying on the hardware back button for its functionality * For 4281: add content descriptions for bookmarking * For 4281: updated BrowserToolbarController for new functionality * For 4281: provided simple dependencies to browser controller More complex changes will be in a following commit, for review readability * For 4281: move toolbar controller dependencies up to BaseBrowserFragment The functionality they control is being moved into the toolbar menu, which is shared by both normal tabs and custom ones * For 4281: removed (now unused) code related to QAB * For 4281: fix test compilation after QAB removal Tests still need to be expanded to include added functionality * For 4281: updated menu to show if url is bookmarked This sloppy workaround is required because TwoStateButton requires that `isInPrimaryState` be a synchronous call, and checking whether or not the current site is bookmarked is quite slow (10-50 MS, in my tests). After days of work and many attempted solutions, this was the least abhorrent among them. https://github.com/mozilla-mobile/android-components/issues/4915 was opened against AC to evaluate potentially supporting async `isInPrimaryState` functions. https://github.com/mozilla-mobile/fenix/issues/6370 was opened against Fenix to investigate the unexpectedly slow call to `BookmarkStorage`. * For 4281: update reader mode switch * For 4281: selectively show/hide menu items * For 4281: add reader mode appearance * For 4281: update bookmark button when it is clicked * For 4281: removed unused QAB code * For 4281: removed QAB robot, updated UI tests * For 4281: removed QuickActionSheet metrics Since this behavior now lives in the toolbar, it is tracked via Event.BrowserMenuItemTapped * For 4281: fixed lint errors * For 4281: add new strings for buttons added to menu This is necessary because the location change (from QAB to toolbar menu) could affect the grammar in some languages * For 4281: remove outdated TODOs * For 4281: removed QAB container * For 4281: removed back button reference from UI test This button no longer exists * For 4821: Fixes a visual defect (extra padding on top of toolbar) * For 4281: update copy on reader mode * For 4281: fixed review nits
5 years ago
import kotlinx.coroutines.launch
import mozilla.components.browser.menu.BrowserMenuHighlight
import mozilla.components.browser.menu.WebExtensionBrowserMenuBuilder
import mozilla.components.browser.menu.item.BrowserMenuDivider
import mozilla.components.browser.menu.item.BrowserMenuHighlightableItem
import mozilla.components.browser.menu.item.BrowserMenuImageSwitch
import mozilla.components.browser.menu.item.BrowserMenuImageText
import mozilla.components.browser.menu.item.BrowserMenuImageTextCheckboxButton
import mozilla.components.browser.menu.item.BrowserMenuItemToolbar
import mozilla.components.browser.menu.item.TwoStateBrowserMenuImageText
import mozilla.components.browser.menu.item.WebExtensionPlaceholderMenuItem
import mozilla.components.browser.state.selector.findTab
import mozilla.components.browser.state.selector.selectedTab
import mozilla.components.browser.state.state.TabSessionState
import mozilla.components.browser.state.store.BrowserStore
4281 remove qab (#6310) * For #4281: small ToolbarMenu refactor This makes it easier to see how items are ordered in the menuItems list * For 4281: add QAB buttons to menu * For 4281: removed menu back button per mocks I double checked with UX, and we'll be relying on the hardware back button for its functionality * For 4281: add content descriptions for bookmarking * For 4281: updated BrowserToolbarController for new functionality * For 4281: provided simple dependencies to browser controller More complex changes will be in a following commit, for review readability * For 4281: move toolbar controller dependencies up to BaseBrowserFragment The functionality they control is being moved into the toolbar menu, which is shared by both normal tabs and custom ones * For 4281: removed (now unused) code related to QAB * For 4281: fix test compilation after QAB removal Tests still need to be expanded to include added functionality * For 4281: updated menu to show if url is bookmarked This sloppy workaround is required because TwoStateButton requires that `isInPrimaryState` be a synchronous call, and checking whether or not the current site is bookmarked is quite slow (10-50 MS, in my tests). After days of work and many attempted solutions, this was the least abhorrent among them. https://github.com/mozilla-mobile/android-components/issues/4915 was opened against AC to evaluate potentially supporting async `isInPrimaryState` functions. https://github.com/mozilla-mobile/fenix/issues/6370 was opened against Fenix to investigate the unexpectedly slow call to `BookmarkStorage`. * For 4281: update reader mode switch * For 4281: selectively show/hide menu items * For 4281: add reader mode appearance * For 4281: update bookmark button when it is clicked * For 4281: removed unused QAB code * For 4281: removed QAB robot, updated UI tests * For 4281: removed QuickActionSheet metrics Since this behavior now lives in the toolbar, it is tracked via Event.BrowserMenuItemTapped * For 4281: fixed lint errors * For 4281: add new strings for buttons added to menu This is necessary because the location change (from QAB to toolbar menu) could affect the grammar in some languages * For 4281: remove outdated TODOs * For 4281: removed QAB container * For 4281: removed back button reference from UI test This button no longer exists * For 4821: Fixes a visual defect (extra padding on top of toolbar) * For 4281: update copy on reader mode * For 4281: fixed review nits
5 years ago
import mozilla.components.concept.storage.BookmarksStorage
import mozilla.components.feature.top.sites.PinnedSiteStorage
import mozilla.components.feature.webcompat.reporter.WebCompatReporterFeature
import mozilla.components.lib.state.ext.flowScoped
import mozilla.components.support.ktx.android.content.getColorFromAttr
import mozilla.components.support.ktx.kotlinx.coroutines.flow.ifAnyChanged
import org.mozilla.fenix.R
import org.mozilla.fenix.components.accounts.FenixAccountManager
import org.mozilla.fenix.ext.components
import org.mozilla.fenix.ext.settings
import org.mozilla.fenix.nimbus.MessageSurfaceId
import org.mozilla.fenix.theme.ThemeManager
/**
* Builds the toolbar object used with the 3-dot menu in the browser fragment.
* @param store reference to the application's [BrowserStore].
* @param hasAccountProblem If true, there was a problem signing into the Firefox account.
* @param shouldReverseItems If true, reverse the menu items.
* @param pinnedSiteStorage Used to check if the current url is a pinned site.
* @param onItemTapped Called when a menu item is tapped.
* @param lifecycleOwner View lifecycle owner used to determine when to cancel UI jobs.
* @param bookmarksStorage Used to check if a page is bookmarked.
*/
@Suppress("LargeClass", "LongParameterList", "TooManyFunctions")
open class DefaultToolbarMenu(
private val context: Context,
private val store: BrowserStore,
hasAccountProblem: Boolean = false,
4281 remove qab (#6310) * For #4281: small ToolbarMenu refactor This makes it easier to see how items are ordered in the menuItems list * For 4281: add QAB buttons to menu * For 4281: removed menu back button per mocks I double checked with UX, and we'll be relying on the hardware back button for its functionality * For 4281: add content descriptions for bookmarking * For 4281: updated BrowserToolbarController for new functionality * For 4281: provided simple dependencies to browser controller More complex changes will be in a following commit, for review readability * For 4281: move toolbar controller dependencies up to BaseBrowserFragment The functionality they control is being moved into the toolbar menu, which is shared by both normal tabs and custom ones * For 4281: removed (now unused) code related to QAB * For 4281: fix test compilation after QAB removal Tests still need to be expanded to include added functionality * For 4281: updated menu to show if url is bookmarked This sloppy workaround is required because TwoStateButton requires that `isInPrimaryState` be a synchronous call, and checking whether or not the current site is bookmarked is quite slow (10-50 MS, in my tests). After days of work and many attempted solutions, this was the least abhorrent among them. https://github.com/mozilla-mobile/android-components/issues/4915 was opened against AC to evaluate potentially supporting async `isInPrimaryState` functions. https://github.com/mozilla-mobile/fenix/issues/6370 was opened against Fenix to investigate the unexpectedly slow call to `BookmarkStorage`. * For 4281: update reader mode switch * For 4281: selectively show/hide menu items * For 4281: add reader mode appearance * For 4281: update bookmark button when it is clicked * For 4281: removed unused QAB code * For 4281: removed QAB robot, updated UI tests * For 4281: removed QuickActionSheet metrics Since this behavior now lives in the toolbar, it is tracked via Event.BrowserMenuItemTapped * For 4281: fixed lint errors * For 4281: add new strings for buttons added to menu This is necessary because the location change (from QAB to toolbar menu) could affect the grammar in some languages * For 4281: remove outdated TODOs * For 4281: removed QAB container * For 4281: removed back button reference from UI test This button no longer exists * For 4821: Fixes a visual defect (extra padding on top of toolbar) * For 4281: update copy on reader mode * For 4281: fixed review nits
5 years ago
private val onItemTapped: (ToolbarMenu.Item) -> Unit = {},
private val lifecycleOwner: LifecycleOwner,
private val bookmarksStorage: BookmarksStorage,
private val pinnedSiteStorage: PinnedSiteStorage,
val isPinningSupported: Boolean
) : ToolbarMenu {
private var isCurrentUrlPinned = false
private var isCurrentUrlBookmarked = false
4281 remove qab (#6310) * For #4281: small ToolbarMenu refactor This makes it easier to see how items are ordered in the menuItems list * For 4281: add QAB buttons to menu * For 4281: removed menu back button per mocks I double checked with UX, and we'll be relying on the hardware back button for its functionality * For 4281: add content descriptions for bookmarking * For 4281: updated BrowserToolbarController for new functionality * For 4281: provided simple dependencies to browser controller More complex changes will be in a following commit, for review readability * For 4281: move toolbar controller dependencies up to BaseBrowserFragment The functionality they control is being moved into the toolbar menu, which is shared by both normal tabs and custom ones * For 4281: removed (now unused) code related to QAB * For 4281: fix test compilation after QAB removal Tests still need to be expanded to include added functionality * For 4281: updated menu to show if url is bookmarked This sloppy workaround is required because TwoStateButton requires that `isInPrimaryState` be a synchronous call, and checking whether or not the current site is bookmarked is quite slow (10-50 MS, in my tests). After days of work and many attempted solutions, this was the least abhorrent among them. https://github.com/mozilla-mobile/android-components/issues/4915 was opened against AC to evaluate potentially supporting async `isInPrimaryState` functions. https://github.com/mozilla-mobile/fenix/issues/6370 was opened against Fenix to investigate the unexpectedly slow call to `BookmarkStorage`. * For 4281: update reader mode switch * For 4281: selectively show/hide menu items * For 4281: add reader mode appearance * For 4281: update bookmark button when it is clicked * For 4281: removed unused QAB code * For 4281: removed QAB robot, updated UI tests * For 4281: removed QuickActionSheet metrics Since this behavior now lives in the toolbar, it is tracked via Event.BrowserMenuItemTapped * For 4281: fixed lint errors * For 4281: add new strings for buttons added to menu This is necessary because the location change (from QAB to toolbar menu) could affect the grammar in some languages * For 4281: remove outdated TODOs * For 4281: removed QAB container * For 4281: removed back button reference from UI test This button no longer exists * For 4821: Fixes a visual defect (extra padding on top of toolbar) * For 4281: update copy on reader mode * For 4281: fixed review nits
5 years ago
private var isBookmarkedJob: Job? = null
private val shouldDeleteDataOnQuit = context.settings().shouldDeleteBrowsingDataOnQuit
private val shouldUseBottomToolbar = context.settings().shouldUseBottomToolbar
private val accountManager = FenixAccountManager(context)
private val selectedSession: TabSessionState?
get() = store.state.selectedTab
override val menuBuilder by lazy {
WebExtensionBrowserMenuBuilder(
items = coreMenuItems,
endOfMenuAlwaysVisible = shouldUseBottomToolbar,
store = store,
style = WebExtensionBrowserMenuBuilder.Style(
webExtIconTintColorResource = primaryTextColor(),
For #23350 - Revert changes from removing duplicate icons that already exists in ui-icons (#23527) * Revert "For #23121 - Override @color/mozac_ui_icons_fill with ?primaryText attribute" This reverts commit 12347c99999c340e7f7072ab2749cb13c5fd86c9. * Revert "For #23121 - Replace @drawble/ic_share with @drawable/mozac_ic_share" This reverts commit bbf6ce3f0c52e58493423ce2e2c62e3fb08f21b2. * Revert "For #23121 - Replace @drawble/ic_storage_enabled with @drawable/mozac_ic_storage" This reverts commit 930c7bf3b3076cf6b56be85fd733dd9f5cf2d1bb. * Revert "For #23121 - Replace @drawble/ic_notifications_enabled with @drawable/mozac_ic_notification" This reverts commit 9069b57c2440b517357a180e7c74b70ab86501a8. * Revert "For #23121 - Replace @drawble/ic_microphone_enabled with @drawable/mozac_ic_microphone" This reverts commit 53216f3f4a1fc6982aee8ab111cb6e92ef54f92a. * Revert "For #23121 - Replace @drawble/ic_location_enabled with @drawable/mozac_ic_location" This reverts commit 9ee9aafd879a884814f1d4b826db75f24ebdacec. * Revert "For #23121 - Replace @drawble/ic_autoplay_disabled with @drawable/mozac_ic_autoplay_blocked" This reverts commit b045a5e20317516bac422ed44549d5871a2cb96a. * Revert "For #23121 - Replace @drawble/ic_camera_enabled with @drawable/mozac_ic_video" This reverts commit 62842db131fee3aa0646c586f075f85105d32cb7. * Revert "For #23121 - Replace @drawble/mozac_ic_extensions_black with @drawable/mozac_ic_extensions" This reverts commit c020a9da10e6a49ce097b48fe2d40b7b21c578fe. * Revert "For #23121 - Replace @drawble/ic_top_sites with @drawable/mozac_ic_pin" This reverts commit ca67b0a752f9582a85ef5d22ff9cfba5f95fd1a0. * Revert "For #23121 - Replace @drawble/ic_search with @drawable/mozac_ic_search" This reverts commit 02d9197945ca9305cf3d2017954a48dd762a8a09. * Revert "For #23121 - Replace @drawble/ic_readermode with @drawable/mozac_ic_reader_mode" This reverts commit cf8592c709d26cf34a187175a2a0b4275a53a576. * Revert "For #23121 - Replace @drawble/ic_menu with @drawable/mozac_ic_menu" This reverts commit a1ac0190242ae416472442e3838318d210a6e419. * Revert "For #23121 - Replace @drawble/ic_login with @drawable/mozac_ic_login" This reverts commit 541c56b5894436c4384c7fdcb6ad3a57a566833a. * Revert "For #23121 - Replace @drawble/ic_internet with @drawable/mozac_ic_globe" This reverts commit 4d8adce85e07edce1969bd188698963c7452cac7. * Revert "For #23121 - Replace @drawble/ic_download with @drawable/mozac_ic_download" This reverts commit ef026d3ec290614053001a0709b800480ac59bf5. * Revert "For #23121 - Replace @drawble/ic_lock with @drawable/mozac_ic_lock" This reverts commit 18591d5dd848af6a11f1ebf4d37efc602a0f36e7. * Revert "For #23121 - Replace @drawble/ic_desktop with @drawable/mozac_ic_device_desktop" This reverts commit ad33e3c1e148bf20264a4cc08c524814da15409a. * Revert "For #23121 - Replace @drawble/ic_close with @drawable/mozac_ic_close" This reverts commit a9f0fefac21e63260a7e8547431a9a5af780faf1. * Revert "For #23121 - Replace @drawble/ic_delete with @drawable/mozac_ic_delete" This reverts commit 33dc752ef2864e8662eebe63756ea37360c4cf61. * Revert "For #23121 - Replace @drawble/ic_chevron_up with @drawable/mozac_ic_arrowhead_up" This reverts commit 5bf937cfd37e2fec2258d8e03e3f31d35952d9cc. * Revert "For #23121 - Replace @drawble/ic_chevron_down with @drawable/mozac_ic_arrowhead_down" This reverts commit 0fadd68112fc313f20be14c13ee75bb9ce67c472. * Revert "For #23121 - Replace @drawble/ic_back_button with @drawable/mozac_ic_back" This reverts commit bea766e7858e6a0bf38a8d1a74d79c8da68d204a. * Revert "For #23121 - Replace @drawable/ic_arrowhead_right with @drawable/mozac_ic_arrowhead_right" This reverts commit 5a6f349ea857cd2a5fdeb3b6001dcf52e8463025. * Revert "For #23121 - Replace @drawable/ic_new with @drawable/mozac_ic_new" This reverts commit ae38410106d7ed0eb65f3eda43ef45ecb7fecc73. * Revert "For #23121 - Replace @drawable/ic_addons_extensions with @drawable/mozac_ic_extensions" This reverts commit 9352946afce4d7be135bfe9b1ffc83895eb20b40.
2 years ago
addonsManagerMenuItemDrawableRes = R.drawable.ic_addons_extensions
),
onAddonsManagerTapped = {
onItemTapped.invoke(ToolbarMenu.Item.AddonsManager)
},
appendExtensionSubMenuAtStart = shouldUseBottomToolbar
)
}
override val menuToolbar by lazy {
val back = BrowserMenuItemToolbar.TwoStateButton(
primaryImageResource = mozilla.components.ui.icons.R.drawable.mozac_ic_back,
primaryContentDescription = context.getString(R.string.browser_menu_back),
primaryImageTintResource = primaryTextColor(),
isInPrimaryState = {
selectedSession?.content?.canGoBack ?: true
},
secondaryImageTintResource = ThemeManager.resolveAttribute(R.attr.textDisabled, context),
disableInSecondaryState = true,
longClickListener = { onItemTapped.invoke(ToolbarMenu.Item.Back(viewHistory = true)) }
) {
onItemTapped.invoke(ToolbarMenu.Item.Back(viewHistory = false))
}
val forward = BrowserMenuItemToolbar.TwoStateButton(
primaryImageResource = mozilla.components.ui.icons.R.drawable.mozac_ic_forward,
primaryContentDescription = context.getString(R.string.browser_menu_forward),
primaryImageTintResource = primaryTextColor(),
isInPrimaryState = {
selectedSession?.content?.canGoForward ?: true
},
secondaryImageTintResource = ThemeManager.resolveAttribute(R.attr.textDisabled, context),
disableInSecondaryState = true,
longClickListener = { onItemTapped.invoke(ToolbarMenu.Item.Forward(viewHistory = true)) }
) {
onItemTapped.invoke(ToolbarMenu.Item.Forward(viewHistory = false))
}
val refresh = BrowserMenuItemToolbar.TwoStateButton(
primaryImageResource = mozilla.components.ui.icons.R.drawable.mozac_ic_refresh,
primaryContentDescription = context.getString(R.string.browser_menu_refresh),
primaryImageTintResource = primaryTextColor(),
isInPrimaryState = {
selectedSession?.content?.loading == false
},
secondaryImageResource = mozilla.components.ui.icons.R.drawable.mozac_ic_stop,
secondaryContentDescription = context.getString(R.string.browser_menu_stop),
secondaryImageTintResource = primaryTextColor(),
disableInSecondaryState = false,
longClickListener = { onItemTapped.invoke(ToolbarMenu.Item.Reload(bypassCache = true)) }
) {
if (selectedSession?.content?.loading == true) {
onItemTapped.invoke(ToolbarMenu.Item.Stop)
} else {
onItemTapped.invoke(ToolbarMenu.Item.Reload(bypassCache = false))
}
}
4281 remove qab (#6310) * For #4281: small ToolbarMenu refactor This makes it easier to see how items are ordered in the menuItems list * For 4281: add QAB buttons to menu * For 4281: removed menu back button per mocks I double checked with UX, and we'll be relying on the hardware back button for its functionality * For 4281: add content descriptions for bookmarking * For 4281: updated BrowserToolbarController for new functionality * For 4281: provided simple dependencies to browser controller More complex changes will be in a following commit, for review readability * For 4281: move toolbar controller dependencies up to BaseBrowserFragment The functionality they control is being moved into the toolbar menu, which is shared by both normal tabs and custom ones * For 4281: removed (now unused) code related to QAB * For 4281: fix test compilation after QAB removal Tests still need to be expanded to include added functionality * For 4281: updated menu to show if url is bookmarked This sloppy workaround is required because TwoStateButton requires that `isInPrimaryState` be a synchronous call, and checking whether or not the current site is bookmarked is quite slow (10-50 MS, in my tests). After days of work and many attempted solutions, this was the least abhorrent among them. https://github.com/mozilla-mobile/android-components/issues/4915 was opened against AC to evaluate potentially supporting async `isInPrimaryState` functions. https://github.com/mozilla-mobile/fenix/issues/6370 was opened against Fenix to investigate the unexpectedly slow call to `BookmarkStorage`. * For 4281: update reader mode switch * For 4281: selectively show/hide menu items * For 4281: add reader mode appearance * For 4281: update bookmark button when it is clicked * For 4281: removed unused QAB code * For 4281: removed QAB robot, updated UI tests * For 4281: removed QuickActionSheet metrics Since this behavior now lives in the toolbar, it is tracked via Event.BrowserMenuItemTapped * For 4281: fixed lint errors * For 4281: add new strings for buttons added to menu This is necessary because the location change (from QAB to toolbar menu) could affect the grammar in some languages * For 4281: remove outdated TODOs * For 4281: removed QAB container * For 4281: removed back button reference from UI test This button no longer exists * For 4821: Fixes a visual defect (extra padding on top of toolbar) * For 4281: update copy on reader mode * For 4281: fixed review nits
5 years ago
val share = BrowserMenuItemToolbar.Button(
For #23350 - Revert changes from removing duplicate icons that already exists in ui-icons (#23527) * Revert "For #23121 - Override @color/mozac_ui_icons_fill with ?primaryText attribute" This reverts commit 12347c99999c340e7f7072ab2749cb13c5fd86c9. * Revert "For #23121 - Replace @drawble/ic_share with @drawable/mozac_ic_share" This reverts commit bbf6ce3f0c52e58493423ce2e2c62e3fb08f21b2. * Revert "For #23121 - Replace @drawble/ic_storage_enabled with @drawable/mozac_ic_storage" This reverts commit 930c7bf3b3076cf6b56be85fd733dd9f5cf2d1bb. * Revert "For #23121 - Replace @drawble/ic_notifications_enabled with @drawable/mozac_ic_notification" This reverts commit 9069b57c2440b517357a180e7c74b70ab86501a8. * Revert "For #23121 - Replace @drawble/ic_microphone_enabled with @drawable/mozac_ic_microphone" This reverts commit 53216f3f4a1fc6982aee8ab111cb6e92ef54f92a. * Revert "For #23121 - Replace @drawble/ic_location_enabled with @drawable/mozac_ic_location" This reverts commit 9ee9aafd879a884814f1d4b826db75f24ebdacec. * Revert "For #23121 - Replace @drawble/ic_autoplay_disabled with @drawable/mozac_ic_autoplay_blocked" This reverts commit b045a5e20317516bac422ed44549d5871a2cb96a. * Revert "For #23121 - Replace @drawble/ic_camera_enabled with @drawable/mozac_ic_video" This reverts commit 62842db131fee3aa0646c586f075f85105d32cb7. * Revert "For #23121 - Replace @drawble/mozac_ic_extensions_black with @drawable/mozac_ic_extensions" This reverts commit c020a9da10e6a49ce097b48fe2d40b7b21c578fe. * Revert "For #23121 - Replace @drawble/ic_top_sites with @drawable/mozac_ic_pin" This reverts commit ca67b0a752f9582a85ef5d22ff9cfba5f95fd1a0. * Revert "For #23121 - Replace @drawble/ic_search with @drawable/mozac_ic_search" This reverts commit 02d9197945ca9305cf3d2017954a48dd762a8a09. * Revert "For #23121 - Replace @drawble/ic_readermode with @drawable/mozac_ic_reader_mode" This reverts commit cf8592c709d26cf34a187175a2a0b4275a53a576. * Revert "For #23121 - Replace @drawble/ic_menu with @drawable/mozac_ic_menu" This reverts commit a1ac0190242ae416472442e3838318d210a6e419. * Revert "For #23121 - Replace @drawble/ic_login with @drawable/mozac_ic_login" This reverts commit 541c56b5894436c4384c7fdcb6ad3a57a566833a. * Revert "For #23121 - Replace @drawble/ic_internet with @drawable/mozac_ic_globe" This reverts commit 4d8adce85e07edce1969bd188698963c7452cac7. * Revert "For #23121 - Replace @drawble/ic_download with @drawable/mozac_ic_download" This reverts commit ef026d3ec290614053001a0709b800480ac59bf5. * Revert "For #23121 - Replace @drawble/ic_lock with @drawable/mozac_ic_lock" This reverts commit 18591d5dd848af6a11f1ebf4d37efc602a0f36e7. * Revert "For #23121 - Replace @drawble/ic_desktop with @drawable/mozac_ic_device_desktop" This reverts commit ad33e3c1e148bf20264a4cc08c524814da15409a. * Revert "For #23121 - Replace @drawble/ic_close with @drawable/mozac_ic_close" This reverts commit a9f0fefac21e63260a7e8547431a9a5af780faf1. * Revert "For #23121 - Replace @drawble/ic_delete with @drawable/mozac_ic_delete" This reverts commit 33dc752ef2864e8662eebe63756ea37360c4cf61. * Revert "For #23121 - Replace @drawble/ic_chevron_up with @drawable/mozac_ic_arrowhead_up" This reverts commit 5bf937cfd37e2fec2258d8e03e3f31d35952d9cc. * Revert "For #23121 - Replace @drawble/ic_chevron_down with @drawable/mozac_ic_arrowhead_down" This reverts commit 0fadd68112fc313f20be14c13ee75bb9ce67c472. * Revert "For #23121 - Replace @drawble/ic_back_button with @drawable/mozac_ic_back" This reverts commit bea766e7858e6a0bf38a8d1a74d79c8da68d204a. * Revert "For #23121 - Replace @drawable/ic_arrowhead_right with @drawable/mozac_ic_arrowhead_right" This reverts commit 5a6f349ea857cd2a5fdeb3b6001dcf52e8463025. * Revert "For #23121 - Replace @drawable/ic_new with @drawable/mozac_ic_new" This reverts commit ae38410106d7ed0eb65f3eda43ef45ecb7fecc73. * Revert "For #23121 - Replace @drawable/ic_addons_extensions with @drawable/mozac_ic_extensions" This reverts commit 9352946afce4d7be135bfe9b1ffc83895eb20b40.
2 years ago
imageResource = R.drawable.ic_share,
4281 remove qab (#6310) * For #4281: small ToolbarMenu refactor This makes it easier to see how items are ordered in the menuItems list * For 4281: add QAB buttons to menu * For 4281: removed menu back button per mocks I double checked with UX, and we'll be relying on the hardware back button for its functionality * For 4281: add content descriptions for bookmarking * For 4281: updated BrowserToolbarController for new functionality * For 4281: provided simple dependencies to browser controller More complex changes will be in a following commit, for review readability * For 4281: move toolbar controller dependencies up to BaseBrowserFragment The functionality they control is being moved into the toolbar menu, which is shared by both normal tabs and custom ones * For 4281: removed (now unused) code related to QAB * For 4281: fix test compilation after QAB removal Tests still need to be expanded to include added functionality * For 4281: updated menu to show if url is bookmarked This sloppy workaround is required because TwoStateButton requires that `isInPrimaryState` be a synchronous call, and checking whether or not the current site is bookmarked is quite slow (10-50 MS, in my tests). After days of work and many attempted solutions, this was the least abhorrent among them. https://github.com/mozilla-mobile/android-components/issues/4915 was opened against AC to evaluate potentially supporting async `isInPrimaryState` functions. https://github.com/mozilla-mobile/fenix/issues/6370 was opened against Fenix to investigate the unexpectedly slow call to `BookmarkStorage`. * For 4281: update reader mode switch * For 4281: selectively show/hide menu items * For 4281: add reader mode appearance * For 4281: update bookmark button when it is clicked * For 4281: removed unused QAB code * For 4281: removed QAB robot, updated UI tests * For 4281: removed QuickActionSheet metrics Since this behavior now lives in the toolbar, it is tracked via Event.BrowserMenuItemTapped * For 4281: fixed lint errors * For 4281: add new strings for buttons added to menu This is necessary because the location change (from QAB to toolbar menu) could affect the grammar in some languages * For 4281: remove outdated TODOs * For 4281: removed QAB container * For 4281: removed back button reference from UI test This button no longer exists * For 4821: Fixes a visual defect (extra padding on top of toolbar) * For 4281: update copy on reader mode * For 4281: fixed review nits
5 years ago
contentDescription = context.getString(R.string.browser_menu_share),
iconTintColorResource = primaryTextColor(),
4281 remove qab (#6310) * For #4281: small ToolbarMenu refactor This makes it easier to see how items are ordered in the menuItems list * For 4281: add QAB buttons to menu * For 4281: removed menu back button per mocks I double checked with UX, and we'll be relying on the hardware back button for its functionality * For 4281: add content descriptions for bookmarking * For 4281: updated BrowserToolbarController for new functionality * For 4281: provided simple dependencies to browser controller More complex changes will be in a following commit, for review readability * For 4281: move toolbar controller dependencies up to BaseBrowserFragment The functionality they control is being moved into the toolbar menu, which is shared by both normal tabs and custom ones * For 4281: removed (now unused) code related to QAB * For 4281: fix test compilation after QAB removal Tests still need to be expanded to include added functionality * For 4281: updated menu to show if url is bookmarked This sloppy workaround is required because TwoStateButton requires that `isInPrimaryState` be a synchronous call, and checking whether or not the current site is bookmarked is quite slow (10-50 MS, in my tests). After days of work and many attempted solutions, this was the least abhorrent among them. https://github.com/mozilla-mobile/android-components/issues/4915 was opened against AC to evaluate potentially supporting async `isInPrimaryState` functions. https://github.com/mozilla-mobile/fenix/issues/6370 was opened against Fenix to investigate the unexpectedly slow call to `BookmarkStorage`. * For 4281: update reader mode switch * For 4281: selectively show/hide menu items * For 4281: add reader mode appearance * For 4281: update bookmark button when it is clicked * For 4281: removed unused QAB code * For 4281: removed QAB robot, updated UI tests * For 4281: removed QuickActionSheet metrics Since this behavior now lives in the toolbar, it is tracked via Event.BrowserMenuItemTapped * For 4281: fixed lint errors * For 4281: add new strings for buttons added to menu This is necessary because the location change (from QAB to toolbar menu) could affect the grammar in some languages * For 4281: remove outdated TODOs * For 4281: removed QAB container * For 4281: removed back button reference from UI test This button no longer exists * For 4821: Fixes a visual defect (extra padding on top of toolbar) * For 4281: update copy on reader mode * For 4281: fixed review nits
5 years ago
listener = {
onItemTapped.invoke(ToolbarMenu.Item.Share)
}
)
registerForIsBookmarkedUpdates()
BrowserMenuItemToolbar(listOf(back, forward, share, refresh), isSticky = true)
}
// Predicates that need to be repeatedly called as the session changes
@VisibleForTesting(otherwise = PRIVATE)
fun canAddToHomescreen(): Boolean =
selectedSession != null && isPinningSupported &&
!context.components.useCases.webAppUseCases.isInstallable()
@VisibleForTesting(otherwise = PRIVATE)
fun canInstall(): Boolean =
selectedSession != null && isPinningSupported &&
context.components.useCases.webAppUseCases.isInstallable()
@VisibleForTesting(otherwise = PRIVATE)
fun shouldShowOpenInApp(): Boolean = selectedSession?.let { session ->
val appLink = context.components.useCases.appLinksUseCases.appLinkRedirect
appLink(session.content.url).hasExternalApp()
} ?: false
@VisibleForTesting(otherwise = PRIVATE)
fun shouldShowReaderViewCustomization(): Boolean = selectedSession?.let {
store.state.findTab(it.id)?.readerState?.active
} ?: false
// End of predicates //
val installToHomescreen = BrowserMenuHighlightableItem(
label = context.getString(R.string.browser_menu_install_on_homescreen),
startImageResource = R.drawable.mozac_ic_add_to_home_screen,
iconTintColorResource = primaryTextColor(),
highlight = BrowserMenuHighlight.LowPriority(
label = context.getString(R.string.browser_menu_install_on_homescreen),
notificationTint = getColor(context, R.color.fx_mobile_icon_color_information)
),
isHighlighted = {
!context.settings().installPwaOpened
}
) {
onItemTapped.invoke(ToolbarMenu.Item.InstallPwaToHomeScreen)
}
val newTabItem = BrowserMenuImageText(
context.getString(R.string.library_new_tab),
For #23350 - Revert changes from removing duplicate icons that already exists in ui-icons (#23527) * Revert "For #23121 - Override @color/mozac_ui_icons_fill with ?primaryText attribute" This reverts commit 12347c99999c340e7f7072ab2749cb13c5fd86c9. * Revert "For #23121 - Replace @drawble/ic_share with @drawable/mozac_ic_share" This reverts commit bbf6ce3f0c52e58493423ce2e2c62e3fb08f21b2. * Revert "For #23121 - Replace @drawble/ic_storage_enabled with @drawable/mozac_ic_storage" This reverts commit 930c7bf3b3076cf6b56be85fd733dd9f5cf2d1bb. * Revert "For #23121 - Replace @drawble/ic_notifications_enabled with @drawable/mozac_ic_notification" This reverts commit 9069b57c2440b517357a180e7c74b70ab86501a8. * Revert "For #23121 - Replace @drawble/ic_microphone_enabled with @drawable/mozac_ic_microphone" This reverts commit 53216f3f4a1fc6982aee8ab111cb6e92ef54f92a. * Revert "For #23121 - Replace @drawble/ic_location_enabled with @drawable/mozac_ic_location" This reverts commit 9ee9aafd879a884814f1d4b826db75f24ebdacec. * Revert "For #23121 - Replace @drawble/ic_autoplay_disabled with @drawable/mozac_ic_autoplay_blocked" This reverts commit b045a5e20317516bac422ed44549d5871a2cb96a. * Revert "For #23121 - Replace @drawble/ic_camera_enabled with @drawable/mozac_ic_video" This reverts commit 62842db131fee3aa0646c586f075f85105d32cb7. * Revert "For #23121 - Replace @drawble/mozac_ic_extensions_black with @drawable/mozac_ic_extensions" This reverts commit c020a9da10e6a49ce097b48fe2d40b7b21c578fe. * Revert "For #23121 - Replace @drawble/ic_top_sites with @drawable/mozac_ic_pin" This reverts commit ca67b0a752f9582a85ef5d22ff9cfba5f95fd1a0. * Revert "For #23121 - Replace @drawble/ic_search with @drawable/mozac_ic_search" This reverts commit 02d9197945ca9305cf3d2017954a48dd762a8a09. * Revert "For #23121 - Replace @drawble/ic_readermode with @drawable/mozac_ic_reader_mode" This reverts commit cf8592c709d26cf34a187175a2a0b4275a53a576. * Revert "For #23121 - Replace @drawble/ic_menu with @drawable/mozac_ic_menu" This reverts commit a1ac0190242ae416472442e3838318d210a6e419. * Revert "For #23121 - Replace @drawble/ic_login with @drawable/mozac_ic_login" This reverts commit 541c56b5894436c4384c7fdcb6ad3a57a566833a. * Revert "For #23121 - Replace @drawble/ic_internet with @drawable/mozac_ic_globe" This reverts commit 4d8adce85e07edce1969bd188698963c7452cac7. * Revert "For #23121 - Replace @drawble/ic_download with @drawable/mozac_ic_download" This reverts commit ef026d3ec290614053001a0709b800480ac59bf5. * Revert "For #23121 - Replace @drawble/ic_lock with @drawable/mozac_ic_lock" This reverts commit 18591d5dd848af6a11f1ebf4d37efc602a0f36e7. * Revert "For #23121 - Replace @drawble/ic_desktop with @drawable/mozac_ic_device_desktop" This reverts commit ad33e3c1e148bf20264a4cc08c524814da15409a. * Revert "For #23121 - Replace @drawble/ic_close with @drawable/mozac_ic_close" This reverts commit a9f0fefac21e63260a7e8547431a9a5af780faf1. * Revert "For #23121 - Replace @drawble/ic_delete with @drawable/mozac_ic_delete" This reverts commit 33dc752ef2864e8662eebe63756ea37360c4cf61. * Revert "For #23121 - Replace @drawble/ic_chevron_up with @drawable/mozac_ic_arrowhead_up" This reverts commit 5bf937cfd37e2fec2258d8e03e3f31d35952d9cc. * Revert "For #23121 - Replace @drawble/ic_chevron_down with @drawable/mozac_ic_arrowhead_down" This reverts commit 0fadd68112fc313f20be14c13ee75bb9ce67c472. * Revert "For #23121 - Replace @drawble/ic_back_button with @drawable/mozac_ic_back" This reverts commit bea766e7858e6a0bf38a8d1a74d79c8da68d204a. * Revert "For #23121 - Replace @drawable/ic_arrowhead_right with @drawable/mozac_ic_arrowhead_right" This reverts commit 5a6f349ea857cd2a5fdeb3b6001dcf52e8463025. * Revert "For #23121 - Replace @drawable/ic_new with @drawable/mozac_ic_new" This reverts commit ae38410106d7ed0eb65f3eda43ef45ecb7fecc73. * Revert "For #23121 - Replace @drawable/ic_addons_extensions with @drawable/mozac_ic_extensions" This reverts commit 9352946afce4d7be135bfe9b1ffc83895eb20b40.
2 years ago
R.drawable.ic_new,
primaryTextColor()
) {
onItemTapped.invoke(ToolbarMenu.Item.NewTab)
}
val historyItem = BrowserMenuImageText(
context.getString(R.string.library_history),
R.drawable.ic_history,
primaryTextColor()
) {
onItemTapped.invoke(ToolbarMenu.Item.History)
}
val downloadsItem = BrowserMenuImageText(
context.getString(R.string.library_downloads),
For #23350 - Revert changes from removing duplicate icons that already exists in ui-icons (#23527) * Revert "For #23121 - Override @color/mozac_ui_icons_fill with ?primaryText attribute" This reverts commit 12347c99999c340e7f7072ab2749cb13c5fd86c9. * Revert "For #23121 - Replace @drawble/ic_share with @drawable/mozac_ic_share" This reverts commit bbf6ce3f0c52e58493423ce2e2c62e3fb08f21b2. * Revert "For #23121 - Replace @drawble/ic_storage_enabled with @drawable/mozac_ic_storage" This reverts commit 930c7bf3b3076cf6b56be85fd733dd9f5cf2d1bb. * Revert "For #23121 - Replace @drawble/ic_notifications_enabled with @drawable/mozac_ic_notification" This reverts commit 9069b57c2440b517357a180e7c74b70ab86501a8. * Revert "For #23121 - Replace @drawble/ic_microphone_enabled with @drawable/mozac_ic_microphone" This reverts commit 53216f3f4a1fc6982aee8ab111cb6e92ef54f92a. * Revert "For #23121 - Replace @drawble/ic_location_enabled with @drawable/mozac_ic_location" This reverts commit 9ee9aafd879a884814f1d4b826db75f24ebdacec. * Revert "For #23121 - Replace @drawble/ic_autoplay_disabled with @drawable/mozac_ic_autoplay_blocked" This reverts commit b045a5e20317516bac422ed44549d5871a2cb96a. * Revert "For #23121 - Replace @drawble/ic_camera_enabled with @drawable/mozac_ic_video" This reverts commit 62842db131fee3aa0646c586f075f85105d32cb7. * Revert "For #23121 - Replace @drawble/mozac_ic_extensions_black with @drawable/mozac_ic_extensions" This reverts commit c020a9da10e6a49ce097b48fe2d40b7b21c578fe. * Revert "For #23121 - Replace @drawble/ic_top_sites with @drawable/mozac_ic_pin" This reverts commit ca67b0a752f9582a85ef5d22ff9cfba5f95fd1a0. * Revert "For #23121 - Replace @drawble/ic_search with @drawable/mozac_ic_search" This reverts commit 02d9197945ca9305cf3d2017954a48dd762a8a09. * Revert "For #23121 - Replace @drawble/ic_readermode with @drawable/mozac_ic_reader_mode" This reverts commit cf8592c709d26cf34a187175a2a0b4275a53a576. * Revert "For #23121 - Replace @drawble/ic_menu with @drawable/mozac_ic_menu" This reverts commit a1ac0190242ae416472442e3838318d210a6e419. * Revert "For #23121 - Replace @drawble/ic_login with @drawable/mozac_ic_login" This reverts commit 541c56b5894436c4384c7fdcb6ad3a57a566833a. * Revert "For #23121 - Replace @drawble/ic_internet with @drawable/mozac_ic_globe" This reverts commit 4d8adce85e07edce1969bd188698963c7452cac7. * Revert "For #23121 - Replace @drawble/ic_download with @drawable/mozac_ic_download" This reverts commit ef026d3ec290614053001a0709b800480ac59bf5. * Revert "For #23121 - Replace @drawble/ic_lock with @drawable/mozac_ic_lock" This reverts commit 18591d5dd848af6a11f1ebf4d37efc602a0f36e7. * Revert "For #23121 - Replace @drawble/ic_desktop with @drawable/mozac_ic_device_desktop" This reverts commit ad33e3c1e148bf20264a4cc08c524814da15409a. * Revert "For #23121 - Replace @drawble/ic_close with @drawable/mozac_ic_close" This reverts commit a9f0fefac21e63260a7e8547431a9a5af780faf1. * Revert "For #23121 - Replace @drawble/ic_delete with @drawable/mozac_ic_delete" This reverts commit 33dc752ef2864e8662eebe63756ea37360c4cf61. * Revert "For #23121 - Replace @drawble/ic_chevron_up with @drawable/mozac_ic_arrowhead_up" This reverts commit 5bf937cfd37e2fec2258d8e03e3f31d35952d9cc. * Revert "For #23121 - Replace @drawble/ic_chevron_down with @drawable/mozac_ic_arrowhead_down" This reverts commit 0fadd68112fc313f20be14c13ee75bb9ce67c472. * Revert "For #23121 - Replace @drawble/ic_back_button with @drawable/mozac_ic_back" This reverts commit bea766e7858e6a0bf38a8d1a74d79c8da68d204a. * Revert "For #23121 - Replace @drawable/ic_arrowhead_right with @drawable/mozac_ic_arrowhead_right" This reverts commit 5a6f349ea857cd2a5fdeb3b6001dcf52e8463025. * Revert "For #23121 - Replace @drawable/ic_new with @drawable/mozac_ic_new" This reverts commit ae38410106d7ed0eb65f3eda43ef45ecb7fecc73. * Revert "For #23121 - Replace @drawable/ic_addons_extensions with @drawable/mozac_ic_extensions" This reverts commit 9352946afce4d7be135bfe9b1ffc83895eb20b40.
2 years ago
R.drawable.ic_download,
primaryTextColor()
) {
onItemTapped.invoke(ToolbarMenu.Item.Downloads)
}
val extensionsItem = WebExtensionPlaceholderMenuItem(
id = WebExtensionPlaceholderMenuItem.MAIN_EXTENSIONS_MENU_ID
)
val findInPageItem = BrowserMenuImageText(
label = context.getString(R.string.browser_menu_find_in_page),
imageResource = R.drawable.mozac_ic_search,
iconTintColorResource = primaryTextColor()
) {
onItemTapped.invoke(ToolbarMenu.Item.FindInPage)
}
val desktopSiteItem = BrowserMenuImageSwitch(
For #23350 - Revert changes from removing duplicate icons that already exists in ui-icons (#23527) * Revert "For #23121 - Override @color/mozac_ui_icons_fill with ?primaryText attribute" This reverts commit 12347c99999c340e7f7072ab2749cb13c5fd86c9. * Revert "For #23121 - Replace @drawble/ic_share with @drawable/mozac_ic_share" This reverts commit bbf6ce3f0c52e58493423ce2e2c62e3fb08f21b2. * Revert "For #23121 - Replace @drawble/ic_storage_enabled with @drawable/mozac_ic_storage" This reverts commit 930c7bf3b3076cf6b56be85fd733dd9f5cf2d1bb. * Revert "For #23121 - Replace @drawble/ic_notifications_enabled with @drawable/mozac_ic_notification" This reverts commit 9069b57c2440b517357a180e7c74b70ab86501a8. * Revert "For #23121 - Replace @drawble/ic_microphone_enabled with @drawable/mozac_ic_microphone" This reverts commit 53216f3f4a1fc6982aee8ab111cb6e92ef54f92a. * Revert "For #23121 - Replace @drawble/ic_location_enabled with @drawable/mozac_ic_location" This reverts commit 9ee9aafd879a884814f1d4b826db75f24ebdacec. * Revert "For #23121 - Replace @drawble/ic_autoplay_disabled with @drawable/mozac_ic_autoplay_blocked" This reverts commit b045a5e20317516bac422ed44549d5871a2cb96a. * Revert "For #23121 - Replace @drawble/ic_camera_enabled with @drawable/mozac_ic_video" This reverts commit 62842db131fee3aa0646c586f075f85105d32cb7. * Revert "For #23121 - Replace @drawble/mozac_ic_extensions_black with @drawable/mozac_ic_extensions" This reverts commit c020a9da10e6a49ce097b48fe2d40b7b21c578fe. * Revert "For #23121 - Replace @drawble/ic_top_sites with @drawable/mozac_ic_pin" This reverts commit ca67b0a752f9582a85ef5d22ff9cfba5f95fd1a0. * Revert "For #23121 - Replace @drawble/ic_search with @drawable/mozac_ic_search" This reverts commit 02d9197945ca9305cf3d2017954a48dd762a8a09. * Revert "For #23121 - Replace @drawble/ic_readermode with @drawable/mozac_ic_reader_mode" This reverts commit cf8592c709d26cf34a187175a2a0b4275a53a576. * Revert "For #23121 - Replace @drawble/ic_menu with @drawable/mozac_ic_menu" This reverts commit a1ac0190242ae416472442e3838318d210a6e419. * Revert "For #23121 - Replace @drawble/ic_login with @drawable/mozac_ic_login" This reverts commit 541c56b5894436c4384c7fdcb6ad3a57a566833a. * Revert "For #23121 - Replace @drawble/ic_internet with @drawable/mozac_ic_globe" This reverts commit 4d8adce85e07edce1969bd188698963c7452cac7. * Revert "For #23121 - Replace @drawble/ic_download with @drawable/mozac_ic_download" This reverts commit ef026d3ec290614053001a0709b800480ac59bf5. * Revert "For #23121 - Replace @drawble/ic_lock with @drawable/mozac_ic_lock" This reverts commit 18591d5dd848af6a11f1ebf4d37efc602a0f36e7. * Revert "For #23121 - Replace @drawble/ic_desktop with @drawable/mozac_ic_device_desktop" This reverts commit ad33e3c1e148bf20264a4cc08c524814da15409a. * Revert "For #23121 - Replace @drawble/ic_close with @drawable/mozac_ic_close" This reverts commit a9f0fefac21e63260a7e8547431a9a5af780faf1. * Revert "For #23121 - Replace @drawble/ic_delete with @drawable/mozac_ic_delete" This reverts commit 33dc752ef2864e8662eebe63756ea37360c4cf61. * Revert "For #23121 - Replace @drawble/ic_chevron_up with @drawable/mozac_ic_arrowhead_up" This reverts commit 5bf937cfd37e2fec2258d8e03e3f31d35952d9cc. * Revert "For #23121 - Replace @drawble/ic_chevron_down with @drawable/mozac_ic_arrowhead_down" This reverts commit 0fadd68112fc313f20be14c13ee75bb9ce67c472. * Revert "For #23121 - Replace @drawble/ic_back_button with @drawable/mozac_ic_back" This reverts commit bea766e7858e6a0bf38a8d1a74d79c8da68d204a. * Revert "For #23121 - Replace @drawable/ic_arrowhead_right with @drawable/mozac_ic_arrowhead_right" This reverts commit 5a6f349ea857cd2a5fdeb3b6001dcf52e8463025. * Revert "For #23121 - Replace @drawable/ic_new with @drawable/mozac_ic_new" This reverts commit ae38410106d7ed0eb65f3eda43ef45ecb7fecc73. * Revert "For #23121 - Replace @drawable/ic_addons_extensions with @drawable/mozac_ic_extensions" This reverts commit 9352946afce4d7be135bfe9b1ffc83895eb20b40.
2 years ago
imageResource = R.drawable.ic_desktop,
label = context.getString(R.string.browser_menu_desktop_site),
initialState = {
selectedSession?.content?.desktopMode ?: false
}
) { checked ->
onItemTapped.invoke(ToolbarMenu.Item.RequestDesktop(checked))
}
val customizeReaderView = BrowserMenuImageText(
label = context.getString(R.string.browser_menu_customize_reader_view),
imageResource = R.drawable.ic_readermode_appearance,
iconTintColorResource = primaryTextColor()
) {
onItemTapped.invoke(ToolbarMenu.Item.CustomizeReaderView)
}
val openInApp = BrowserMenuHighlightableItem(
label = context.getString(R.string.browser_menu_open_app_link),
startImageResource = R.drawable.ic_open_in_app,
iconTintColorResource = primaryTextColor(),
highlight = BrowserMenuHighlight.LowPriority(
label = context.getString(R.string.browser_menu_open_app_link),
notificationTint = getColor(context, R.color.fx_mobile_icon_color_information)
),
isHighlighted = { !context.settings().openInAppOpened }
) {
onItemTapped.invoke(ToolbarMenu.Item.OpenInApp)
}
val reportSiteIssuePlaceholder = WebExtensionPlaceholderMenuItem(
id = WebCompatReporterFeature.WEBCOMPAT_REPORTER_EXTENSION_ID,
iconTintColorResource = primaryTextColor()
)
val addToHomeScreenItem = BrowserMenuImageText(
label = context.getString(R.string.browser_menu_add_to_homescreen),
imageResource = R.drawable.mozac_ic_add_to_home_screen,
iconTintColorResource = primaryTextColor(),
isCollapsingMenuLimit = true
) {
onItemTapped.invoke(ToolbarMenu.Item.AddToHomeScreen)
}
val addRemoveTopSitesItem = TwoStateBrowserMenuImageText(
primaryLabel = context.getString(R.string.browser_menu_add_to_top_sites),
secondaryLabel = context.getString(R.string.browser_menu_remove_from_top_sites),
For #23350 - Revert changes from removing duplicate icons that already exists in ui-icons (#23527) * Revert "For #23121 - Override @color/mozac_ui_icons_fill with ?primaryText attribute" This reverts commit 12347c99999c340e7f7072ab2749cb13c5fd86c9. * Revert "For #23121 - Replace @drawble/ic_share with @drawable/mozac_ic_share" This reverts commit bbf6ce3f0c52e58493423ce2e2c62e3fb08f21b2. * Revert "For #23121 - Replace @drawble/ic_storage_enabled with @drawable/mozac_ic_storage" This reverts commit 930c7bf3b3076cf6b56be85fd733dd9f5cf2d1bb. * Revert "For #23121 - Replace @drawble/ic_notifications_enabled with @drawable/mozac_ic_notification" This reverts commit 9069b57c2440b517357a180e7c74b70ab86501a8. * Revert "For #23121 - Replace @drawble/ic_microphone_enabled with @drawable/mozac_ic_microphone" This reverts commit 53216f3f4a1fc6982aee8ab111cb6e92ef54f92a. * Revert "For #23121 - Replace @drawble/ic_location_enabled with @drawable/mozac_ic_location" This reverts commit 9ee9aafd879a884814f1d4b826db75f24ebdacec. * Revert "For #23121 - Replace @drawble/ic_autoplay_disabled with @drawable/mozac_ic_autoplay_blocked" This reverts commit b045a5e20317516bac422ed44549d5871a2cb96a. * Revert "For #23121 - Replace @drawble/ic_camera_enabled with @drawable/mozac_ic_video" This reverts commit 62842db131fee3aa0646c586f075f85105d32cb7. * Revert "For #23121 - Replace @drawble/mozac_ic_extensions_black with @drawable/mozac_ic_extensions" This reverts commit c020a9da10e6a49ce097b48fe2d40b7b21c578fe. * Revert "For #23121 - Replace @drawble/ic_top_sites with @drawable/mozac_ic_pin" This reverts commit ca67b0a752f9582a85ef5d22ff9cfba5f95fd1a0. * Revert "For #23121 - Replace @drawble/ic_search with @drawable/mozac_ic_search" This reverts commit 02d9197945ca9305cf3d2017954a48dd762a8a09. * Revert "For #23121 - Replace @drawble/ic_readermode with @drawable/mozac_ic_reader_mode" This reverts commit cf8592c709d26cf34a187175a2a0b4275a53a576. * Revert "For #23121 - Replace @drawble/ic_menu with @drawable/mozac_ic_menu" This reverts commit a1ac0190242ae416472442e3838318d210a6e419. * Revert "For #23121 - Replace @drawble/ic_login with @drawable/mozac_ic_login" This reverts commit 541c56b5894436c4384c7fdcb6ad3a57a566833a. * Revert "For #23121 - Replace @drawble/ic_internet with @drawable/mozac_ic_globe" This reverts commit 4d8adce85e07edce1969bd188698963c7452cac7. * Revert "For #23121 - Replace @drawble/ic_download with @drawable/mozac_ic_download" This reverts commit ef026d3ec290614053001a0709b800480ac59bf5. * Revert "For #23121 - Replace @drawble/ic_lock with @drawable/mozac_ic_lock" This reverts commit 18591d5dd848af6a11f1ebf4d37efc602a0f36e7. * Revert "For #23121 - Replace @drawble/ic_desktop with @drawable/mozac_ic_device_desktop" This reverts commit ad33e3c1e148bf20264a4cc08c524814da15409a. * Revert "For #23121 - Replace @drawble/ic_close with @drawable/mozac_ic_close" This reverts commit a9f0fefac21e63260a7e8547431a9a5af780faf1. * Revert "For #23121 - Replace @drawble/ic_delete with @drawable/mozac_ic_delete" This reverts commit 33dc752ef2864e8662eebe63756ea37360c4cf61. * Revert "For #23121 - Replace @drawble/ic_chevron_up with @drawable/mozac_ic_arrowhead_up" This reverts commit 5bf937cfd37e2fec2258d8e03e3f31d35952d9cc. * Revert "For #23121 - Replace @drawble/ic_chevron_down with @drawable/mozac_ic_arrowhead_down" This reverts commit 0fadd68112fc313f20be14c13ee75bb9ce67c472. * Revert "For #23121 - Replace @drawble/ic_back_button with @drawable/mozac_ic_back" This reverts commit bea766e7858e6a0bf38a8d1a74d79c8da68d204a. * Revert "For #23121 - Replace @drawable/ic_arrowhead_right with @drawable/mozac_ic_arrowhead_right" This reverts commit 5a6f349ea857cd2a5fdeb3b6001dcf52e8463025. * Revert "For #23121 - Replace @drawable/ic_new with @drawable/mozac_ic_new" This reverts commit ae38410106d7ed0eb65f3eda43ef45ecb7fecc73. * Revert "For #23121 - Replace @drawable/ic_addons_extensions with @drawable/mozac_ic_extensions" This reverts commit 9352946afce4d7be135bfe9b1ffc83895eb20b40.
2 years ago
primaryStateIconResource = R.drawable.ic_top_sites,
secondaryStateIconResource = R.drawable.ic_top_sites,
iconTintColorResource = primaryTextColor(),
isInPrimaryState = { !isCurrentUrlPinned },
isInSecondaryState = { isCurrentUrlPinned },
primaryStateAction = {
isCurrentUrlPinned = true
onItemTapped.invoke(ToolbarMenu.Item.AddToTopSites)
},
secondaryStateAction = {
isCurrentUrlPinned = false
onItemTapped.invoke(ToolbarMenu.Item.RemoveFromTopSites)
}
)
val saveToCollectionItem = BrowserMenuImageText(
label = context.getString(R.string.browser_menu_save_to_collection_2),
imageResource = R.drawable.ic_tab_collection,
iconTintColorResource = primaryTextColor()
) {
onItemTapped.invoke(ToolbarMenu.Item.SaveToCollection)
}
4281 remove qab (#6310) * For #4281: small ToolbarMenu refactor This makes it easier to see how items are ordered in the menuItems list * For 4281: add QAB buttons to menu * For 4281: removed menu back button per mocks I double checked with UX, and we'll be relying on the hardware back button for its functionality * For 4281: add content descriptions for bookmarking * For 4281: updated BrowserToolbarController for new functionality * For 4281: provided simple dependencies to browser controller More complex changes will be in a following commit, for review readability * For 4281: move toolbar controller dependencies up to BaseBrowserFragment The functionality they control is being moved into the toolbar menu, which is shared by both normal tabs and custom ones * For 4281: removed (now unused) code related to QAB * For 4281: fix test compilation after QAB removal Tests still need to be expanded to include added functionality * For 4281: updated menu to show if url is bookmarked This sloppy workaround is required because TwoStateButton requires that `isInPrimaryState` be a synchronous call, and checking whether or not the current site is bookmarked is quite slow (10-50 MS, in my tests). After days of work and many attempted solutions, this was the least abhorrent among them. https://github.com/mozilla-mobile/android-components/issues/4915 was opened against AC to evaluate potentially supporting async `isInPrimaryState` functions. https://github.com/mozilla-mobile/fenix/issues/6370 was opened against Fenix to investigate the unexpectedly slow call to `BookmarkStorage`. * For 4281: update reader mode switch * For 4281: selectively show/hide menu items * For 4281: add reader mode appearance * For 4281: update bookmark button when it is clicked * For 4281: removed unused QAB code * For 4281: removed QAB robot, updated UI tests * For 4281: removed QuickActionSheet metrics Since this behavior now lives in the toolbar, it is tracked via Event.BrowserMenuItemTapped * For 4281: fixed lint errors * For 4281: add new strings for buttons added to menu This is necessary because the location change (from QAB to toolbar menu) could affect the grammar in some languages * For 4281: remove outdated TODOs * For 4281: removed QAB container * For 4281: removed back button reference from UI test This button no longer exists * For 4821: Fixes a visual defect (extra padding on top of toolbar) * For 4281: update copy on reader mode * For 4281: fixed review nits
5 years ago
val settingsItem = BrowserMenuHighlightableItem(
label = context.getString(R.string.browser_menu_settings),
startImageResource = R.drawable.mozac_ic_settings,
iconTintColorResource = if (hasAccountProblem) {
ThemeManager.resolveAttribute(R.attr.syncDisconnected, context)
} else {
primaryTextColor()
},
textColorResource = if (hasAccountProblem) {
ThemeManager.resolveAttribute(R.attr.textPrimary, context)
} else {
primaryTextColor()
},
highlight = BrowserMenuHighlight.HighPriority(
endImageResource = R.drawable.ic_sync_disconnected,
backgroundTint = context.getColorFromAttr(R.attr.syncDisconnectedBackground),
canPropagate = false
),
isHighlighted = { hasAccountProblem }
) {
onItemTapped.invoke(ToolbarMenu.Item.Settings)
}
4281 remove qab (#6310) * For #4281: small ToolbarMenu refactor This makes it easier to see how items are ordered in the menuItems list * For 4281: add QAB buttons to menu * For 4281: removed menu back button per mocks I double checked with UX, and we'll be relying on the hardware back button for its functionality * For 4281: add content descriptions for bookmarking * For 4281: updated BrowserToolbarController for new functionality * For 4281: provided simple dependencies to browser controller More complex changes will be in a following commit, for review readability * For 4281: move toolbar controller dependencies up to BaseBrowserFragment The functionality they control is being moved into the toolbar menu, which is shared by both normal tabs and custom ones * For 4281: removed (now unused) code related to QAB * For 4281: fix test compilation after QAB removal Tests still need to be expanded to include added functionality * For 4281: updated menu to show if url is bookmarked This sloppy workaround is required because TwoStateButton requires that `isInPrimaryState` be a synchronous call, and checking whether or not the current site is bookmarked is quite slow (10-50 MS, in my tests). After days of work and many attempted solutions, this was the least abhorrent among them. https://github.com/mozilla-mobile/android-components/issues/4915 was opened against AC to evaluate potentially supporting async `isInPrimaryState` functions. https://github.com/mozilla-mobile/fenix/issues/6370 was opened against Fenix to investigate the unexpectedly slow call to `BookmarkStorage`. * For 4281: update reader mode switch * For 4281: selectively show/hide menu items * For 4281: add reader mode appearance * For 4281: update bookmark button when it is clicked * For 4281: removed unused QAB code * For 4281: removed QAB robot, updated UI tests * For 4281: removed QuickActionSheet metrics Since this behavior now lives in the toolbar, it is tracked via Event.BrowserMenuItemTapped * For 4281: fixed lint errors * For 4281: add new strings for buttons added to menu This is necessary because the location change (from QAB to toolbar menu) could affect the grammar in some languages * For 4281: remove outdated TODOs * For 4281: removed QAB container * For 4281: removed back button reference from UI test This button no longer exists * For 4821: Fixes a visual defect (extra padding on top of toolbar) * For 4281: update copy on reader mode * For 4281: fixed review nits
5 years ago
val bookmarksItem = BrowserMenuImageTextCheckboxButton(
imageResource = R.drawable.ic_bookmarks_menu,
iconTintColorResource = primaryTextColor(),
label = context.getString(R.string.library_bookmarks),
labelListener = {
onItemTapped.invoke(ToolbarMenu.Item.Bookmarks)
},
primaryStateIconResource = R.drawable.ic_bookmark_outline,
secondaryStateIconResource = R.drawable.ic_bookmark_filled,
tintColorResource = menuItemButtonTintColor(),
primaryLabel = context.getString(R.string.browser_menu_add),
secondaryLabel = context.getString(R.string.browser_menu_edit),
isInPrimaryState = { !isCurrentUrlBookmarked }
) {
handleBookmarkItemTapped()
}
val deleteDataOnQuit = BrowserMenuImageText(
label = context.getString(R.string.delete_browsing_data_on_quit_action),
imageResource = R.drawable.mozac_ic_quit,
iconTintColorResource = primaryTextColor()
) {
onItemTapped.invoke(ToolbarMenu.Item.Quit)
}
private fun getSyncItemTitle() =
accountManager.accountProfileEmail ?: context.getString(R.string.sync_menu_sign_in)
val syncMenuItem = BrowserMenuImageText(
getSyncItemTitle(),
R.drawable.ic_signed_out,
primaryTextColor()
) {
onItemTapped.invoke(
ToolbarMenu.Item.SyncAccount(accountManager.accountState)
)
}
@VisibleForTesting(otherwise = PRIVATE)
val coreMenuItems by lazy {
val defaultBrowserItem = getSetDefaultBrowserItem()
val menuItems =
listOfNotNull(
if (shouldUseBottomToolbar) null else menuToolbar,
newTabItem,
BrowserMenuDivider(),
bookmarksItem,
historyItem,
downloadsItem,
extensionsItem,
syncMenuItem,
BrowserMenuDivider(),
defaultBrowserItem,
defaultBrowserItem?.let { BrowserMenuDivider() },
findInPageItem,
desktopSiteItem,
customizeReaderView.apply { visible = ::shouldShowReaderViewCustomization },
openInApp.apply { visible = ::shouldShowOpenInApp },
reportSiteIssuePlaceholder,
BrowserMenuDivider(),
addToHomeScreenItem.apply { visible = ::canAddToHomescreen },
installToHomescreen.apply { visible = ::canInstall },
addRemoveTopSitesItem,
saveToCollectionItem,
BrowserMenuDivider(),
settingsItem,
if (shouldDeleteDataOnQuit) deleteDataOnQuit else null,
if (shouldUseBottomToolbar) BrowserMenuDivider() else null,
if (shouldUseBottomToolbar) menuToolbar else null
)
menuItems
}
private fun handleBookmarkItemTapped() {
if (!isCurrentUrlBookmarked) isCurrentUrlBookmarked = true
onItemTapped.invoke(ToolbarMenu.Item.Bookmark)
}
@ColorRes
@VisibleForTesting
internal fun primaryTextColor() = ThemeManager.resolveAttribute(R.attr.textPrimary, context)
@ColorRes
@VisibleForTesting
internal fun menuItemButtonTintColor() = ThemeManager.resolveAttribute(R.attr.menuItemButtonTintColor, context)
@VisibleForTesting
internal fun updateIsCurrentUrlPinned(currentUrl: String) {
lifecycleOwner.lifecycleScope.launch {
isCurrentUrlPinned = pinnedSiteStorage
.getPinnedSites()
.find { it.url == currentUrl } != null
}
}
@VisibleForTesting
internal fun registerForIsBookmarkedUpdates() {
store.flowScoped(lifecycleOwner) { flow ->
flow.mapNotNull { state -> state.selectedTab }
.ifAnyChanged { tab ->
arrayOf(
tab.id,
tab.content.url
)
}
.collect {
isCurrentUrlPinned = false
updateIsCurrentUrlPinned(it.content.url)
isCurrentUrlBookmarked = false
updateCurrentUrlIsBookmarked(it.content.url)
}
4281 remove qab (#6310) * For #4281: small ToolbarMenu refactor This makes it easier to see how items are ordered in the menuItems list * For 4281: add QAB buttons to menu * For 4281: removed menu back button per mocks I double checked with UX, and we'll be relying on the hardware back button for its functionality * For 4281: add content descriptions for bookmarking * For 4281: updated BrowserToolbarController for new functionality * For 4281: provided simple dependencies to browser controller More complex changes will be in a following commit, for review readability * For 4281: move toolbar controller dependencies up to BaseBrowserFragment The functionality they control is being moved into the toolbar menu, which is shared by both normal tabs and custom ones * For 4281: removed (now unused) code related to QAB * For 4281: fix test compilation after QAB removal Tests still need to be expanded to include added functionality * For 4281: updated menu to show if url is bookmarked This sloppy workaround is required because TwoStateButton requires that `isInPrimaryState` be a synchronous call, and checking whether or not the current site is bookmarked is quite slow (10-50 MS, in my tests). After days of work and many attempted solutions, this was the least abhorrent among them. https://github.com/mozilla-mobile/android-components/issues/4915 was opened against AC to evaluate potentially supporting async `isInPrimaryState` functions. https://github.com/mozilla-mobile/fenix/issues/6370 was opened against Fenix to investigate the unexpectedly slow call to `BookmarkStorage`. * For 4281: update reader mode switch * For 4281: selectively show/hide menu items * For 4281: add reader mode appearance * For 4281: update bookmark button when it is clicked * For 4281: removed unused QAB code * For 4281: removed QAB robot, updated UI tests * For 4281: removed QuickActionSheet metrics Since this behavior now lives in the toolbar, it is tracked via Event.BrowserMenuItemTapped * For 4281: fixed lint errors * For 4281: add new strings for buttons added to menu This is necessary because the location change (from QAB to toolbar menu) could affect the grammar in some languages * For 4281: remove outdated TODOs * For 4281: removed QAB container * For 4281: removed back button reference from UI test This button no longer exists * For 4821: Fixes a visual defect (extra padding on top of toolbar) * For 4281: update copy on reader mode * For 4281: fixed review nits
5 years ago
}
}
@VisibleForTesting
internal fun updateCurrentUrlIsBookmarked(newUrl: String) {
4281 remove qab (#6310) * For #4281: small ToolbarMenu refactor This makes it easier to see how items are ordered in the menuItems list * For 4281: add QAB buttons to menu * For 4281: removed menu back button per mocks I double checked with UX, and we'll be relying on the hardware back button for its functionality * For 4281: add content descriptions for bookmarking * For 4281: updated BrowserToolbarController for new functionality * For 4281: provided simple dependencies to browser controller More complex changes will be in a following commit, for review readability * For 4281: move toolbar controller dependencies up to BaseBrowserFragment The functionality they control is being moved into the toolbar menu, which is shared by both normal tabs and custom ones * For 4281: removed (now unused) code related to QAB * For 4281: fix test compilation after QAB removal Tests still need to be expanded to include added functionality * For 4281: updated menu to show if url is bookmarked This sloppy workaround is required because TwoStateButton requires that `isInPrimaryState` be a synchronous call, and checking whether or not the current site is bookmarked is quite slow (10-50 MS, in my tests). After days of work and many attempted solutions, this was the least abhorrent among them. https://github.com/mozilla-mobile/android-components/issues/4915 was opened against AC to evaluate potentially supporting async `isInPrimaryState` functions. https://github.com/mozilla-mobile/fenix/issues/6370 was opened against Fenix to investigate the unexpectedly slow call to `BookmarkStorage`. * For 4281: update reader mode switch * For 4281: selectively show/hide menu items * For 4281: add reader mode appearance * For 4281: update bookmark button when it is clicked * For 4281: removed unused QAB code * For 4281: removed QAB robot, updated UI tests * For 4281: removed QuickActionSheet metrics Since this behavior now lives in the toolbar, it is tracked via Event.BrowserMenuItemTapped * For 4281: fixed lint errors * For 4281: add new strings for buttons added to menu This is necessary because the location change (from QAB to toolbar menu) could affect the grammar in some languages * For 4281: remove outdated TODOs * For 4281: removed QAB container * For 4281: removed back button reference from UI test This button no longer exists * For 4821: Fixes a visual defect (extra padding on top of toolbar) * For 4281: update copy on reader mode * For 4281: fixed review nits
5 years ago
isBookmarkedJob?.cancel()
isBookmarkedJob = lifecycleOwner.lifecycleScope.launch {
isCurrentUrlBookmarked = bookmarksStorage
4281 remove qab (#6310) * For #4281: small ToolbarMenu refactor This makes it easier to see how items are ordered in the menuItems list * For 4281: add QAB buttons to menu * For 4281: removed menu back button per mocks I double checked with UX, and we'll be relying on the hardware back button for its functionality * For 4281: add content descriptions for bookmarking * For 4281: updated BrowserToolbarController for new functionality * For 4281: provided simple dependencies to browser controller More complex changes will be in a following commit, for review readability * For 4281: move toolbar controller dependencies up to BaseBrowserFragment The functionality they control is being moved into the toolbar menu, which is shared by both normal tabs and custom ones * For 4281: removed (now unused) code related to QAB * For 4281: fix test compilation after QAB removal Tests still need to be expanded to include added functionality * For 4281: updated menu to show if url is bookmarked This sloppy workaround is required because TwoStateButton requires that `isInPrimaryState` be a synchronous call, and checking whether or not the current site is bookmarked is quite slow (10-50 MS, in my tests). After days of work and many attempted solutions, this was the least abhorrent among them. https://github.com/mozilla-mobile/android-components/issues/4915 was opened against AC to evaluate potentially supporting async `isInPrimaryState` functions. https://github.com/mozilla-mobile/fenix/issues/6370 was opened against Fenix to investigate the unexpectedly slow call to `BookmarkStorage`. * For 4281: update reader mode switch * For 4281: selectively show/hide menu items * For 4281: add reader mode appearance * For 4281: update bookmark button when it is clicked * For 4281: removed unused QAB code * For 4281: removed QAB robot, updated UI tests * For 4281: removed QuickActionSheet metrics Since this behavior now lives in the toolbar, it is tracked via Event.BrowserMenuItemTapped * For 4281: fixed lint errors * For 4281: add new strings for buttons added to menu This is necessary because the location change (from QAB to toolbar menu) could affect the grammar in some languages * For 4281: remove outdated TODOs * For 4281: removed QAB container * For 4281: removed back button reference from UI test This button no longer exists * For 4821: Fixes a visual defect (extra padding on top of toolbar) * For 4281: update copy on reader mode * For 4281: fixed review nits
5 years ago
.getBookmarksWithUrl(newUrl)
.any { it.url == newUrl }
}
}
private fun getSetDefaultBrowserItem(): BrowserMenuImageText? {
val settings = context.components.settings
return if (
settings.isDefaultBrowserMessageLocation(MessageSurfaceId.APP_MENU_ITEM)
) {
BrowserMenuImageText(
label = context.getString(R.string.preferences_set_as_default_browser),
imageResource = R.mipmap.ic_launcher
) {
onItemTapped.invoke(ToolbarMenu.Item.SetDefaultBrowser)
}
} else {
null
}
}
}