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

Bug 1840578 - Add shopping experience entry point

This commit is contained in:
rahulsainani 2023-06-27 16:07:22 +02:00 committed by mergify[bot]
parent 3dd59019f7
commit d3e5c2a002
5 changed files with 104 additions and 1 deletions

View File

@ -50,6 +50,7 @@ import org.mozilla.fenix.ext.settings
import org.mozilla.fenix.nimbus.FxNimbus
import org.mozilla.fenix.settings.quicksettings.protections.cookiebanners.dialog.CookieBannerReEngagementDialogUtils
import org.mozilla.fenix.settings.quicksettings.protections.cookiebanners.getCookieBannerUIMode
import org.mozilla.fenix.shopping.ReviewQualityCheckFeature
import org.mozilla.fenix.shortcut.PwaOnboardingObserver
import org.mozilla.fenix.theme.ThemeManager
@ -61,8 +62,10 @@ class BrowserFragment : BaseBrowserFragment(), UserInteractionHandler {
private val windowFeature = ViewBoundFeatureWrapper<WindowFeature>()
private val openInAppOnboardingObserver = ViewBoundFeatureWrapper<OpenInAppOnboardingObserver>()
private val reviewQualityCheckFeature = ViewBoundFeatureWrapper<ReviewQualityCheckFeature>()
private var readerModeAvailable = false
private var reviewQualityCheckAvailable = false
private var pwaOnboardingObserver: PwaOnboardingObserver? = null
private var forwardAction: BrowserToolbar.TwoStateButton? = null
@ -118,7 +121,7 @@ class BrowserFragment : BaseBrowserFragment(), UserInteractionHandler {
contentDescription = context.getString(R.string.browser_menu_read),
contentDescriptionSelected = context.getString(R.string.browser_menu_read_close),
visible = {
readerModeAvailable
readerModeAvailable && !reviewQualityCheckAvailable
},
selected = getCurrentTab()?.let {
activity?.components?.core?.store?.state?.findTab(it.id)?.readerState?.active
@ -128,6 +131,8 @@ class BrowserFragment : BaseBrowserFragment(), UserInteractionHandler {
browserToolbarView.view.addPageAction(readerModeAction)
initReviewQualityCheck(context, view)
thumbnailsFeature.set(
feature = BrowserThumbnails(context, binding.engineView, components.core.store),
owner = this,
@ -185,6 +190,34 @@ class BrowserFragment : BaseBrowserFragment(), UserInteractionHandler {
}
}
private fun initReviewQualityCheck(context: Context, view: View) {
val reviewQualityCheck =
BrowserToolbar.ToggleButton(
image = AppCompatResources.getDrawable(
context,
R.drawable.ic_shopping_cart,
)!!,
imageSelected = AppCompatResources.getDrawable(
context,
R.drawable.ic_shopping_cart_selected,
)!!,
contentDescription = context.getString(R.string.browser_menu_review_quality_check),
contentDescriptionSelected = context.getString(R.string.browser_menu_review_quality_check_close),
visible = { reviewQualityCheckAvailable },
listener = {},
)
browserToolbarView.view.addPageAction(reviewQualityCheck)
reviewQualityCheckFeature.set(
feature = ReviewQualityCheckFeature(
onAvailabilityChange = { reviewQualityCheckAvailable = it },
),
owner = this,
view = view,
)
}
override fun onUpdateToolbarForConfigurationChange(toolbar: BrowserToolbarView) {
super.onUpdateToolbarForConfigurationChange(toolbar)

View File

@ -0,0 +1,28 @@
/* 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.shopping
import mozilla.components.support.base.feature.LifecycleAwareFeature
import org.mozilla.fenix.nimbus.FxNimbus
/**
* Feature implementation that provides review quality check information for supported product
* pages.
*/
class ReviewQualityCheckFeature(
private val onAvailabilityChange: (isAvailable: Boolean) -> Unit,
) : LifecycleAwareFeature {
override fun start() {
val isFeatureEnabled = FxNimbus.features.shoppingExperience.value().enabled
// Update to use product page detector api in Bug 1840580
val isSupportedProductPage = false
onAvailabilityChange(isFeatureEnabled && isSupportedProductPage)
}
override fun stop() {
// no-op
}
}

View File

@ -0,0 +1,13 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:autoMirrored="true"
android:viewportWidth="24"
android:viewportHeight="24">
<group>
<clip-path android:pathData="M4,4h16v16h-16z" />
<path
android:fillColor="?attr/textPrimary"
android:pathData="M19.775,8.509C19.83,8.308 19.788,8.094 19.662,7.929C19.536,7.764 19.341,7.667 19.133,7.667H7.698C7.618,7.668 7.549,7.612 7.533,7.533L7.152,5.72C6.938,4.72 6.056,4.005 5.034,4C4.574,4 4.201,4.373 4.201,4.833C4.201,5.294 4.574,5.667 5.034,5.667C5.271,5.668 5.475,5.835 5.523,6.067L7.633,16.113C7.743,16.628 8.036,17.085 8.458,17.4C8.499,17.43 8.523,17.477 8.525,17.528C8.526,17.578 8.505,17.626 8.467,17.659C7.943,18.113 7.853,18.892 8.261,19.452C8.669,20.013 9.438,20.167 10.03,19.808C10.623,19.449 10.842,18.695 10.533,18.075C10.507,18.023 10.51,17.962 10.541,17.913C10.571,17.864 10.625,17.834 10.683,17.834H14.663C14.72,17.834 14.774,17.864 14.804,17.913C14.835,17.962 14.838,18.023 14.812,18.075C14.607,18.488 14.63,18.977 14.873,19.369C15.116,19.761 15.544,20 16.005,20C16.468,20 16.898,19.76 17.14,19.366C17.383,18.972 17.404,18.48 17.195,18.067C17.17,18.017 17.173,17.958 17.202,17.91C17.231,17.862 17.283,17.833 17.339,17.833C17.799,17.833 18.172,17.46 18.172,17C18.172,16.54 17.799,16.167 17.339,16.167H9.754C9.518,16.166 9.314,16.001 9.265,15.77L9.145,15.2C9.135,15.151 9.148,15.1 9.18,15.061C9.211,15.023 9.259,15 9.309,15H16.478C17.38,15 18.17,14.396 18.407,13.526L19.775,8.509Z" />
</group>
</vector>

View File

@ -0,0 +1,23 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="24dp"
android:height="24dp"
android:autoMirrored="true"
android:viewportWidth="24"
android:viewportHeight="24">
<group>
<clip-path android:pathData="M4,4h16v16h-16z" />
<path android:pathData="M19.775,8.509C19.83,8.308 19.788,8.094 19.662,7.929C19.536,7.764 19.341,7.667 19.133,7.667H7.698C7.618,7.668 7.549,7.612 7.533,7.533L7.152,5.72C6.938,4.72 6.056,4.005 5.034,4C4.574,4 4.201,4.373 4.201,4.833C4.201,5.294 4.574,5.667 5.034,5.667C5.271,5.668 5.475,5.835 5.523,6.067L7.633,16.113C7.743,16.628 8.036,17.085 8.458,17.4C8.499,17.43 8.523,17.477 8.525,17.528C8.526,17.578 8.505,17.626 8.467,17.659C7.943,18.113 7.853,18.892 8.261,19.452C8.669,20.013 9.438,20.167 10.03,19.808C10.623,19.449 10.842,18.695 10.533,18.075C10.507,18.023 10.51,17.962 10.541,17.913C10.571,17.864 10.625,17.834 10.683,17.834H14.663C14.72,17.834 14.774,17.864 14.804,17.913C14.835,17.962 14.838,18.023 14.812,18.075C14.607,18.488 14.63,18.977 14.873,19.369C15.116,19.761 15.544,20 16.005,20C16.468,20 16.898,19.76 17.14,19.366C17.383,18.972 17.404,18.48 17.195,18.067C17.17,18.017 17.173,17.958 17.202,17.91C17.231,17.862 17.283,17.833 17.339,17.833C17.799,17.833 18.172,17.46 18.172,17C18.172,16.54 17.799,16.167 17.339,16.167H9.754C9.518,16.166 9.314,16.001 9.265,15.77L9.145,15.2C9.135,15.151 9.148,15.1 9.18,15.061C9.211,15.023 9.259,15 9.309,15H16.478C17.38,15 18.17,14.396 18.407,13.526L19.775,8.509Z">
<aapt:attr name="android:fillColor">
<gradient
android:endColor="@color/fx_mobile_icon_color_gradient_end"
android:endX="0"
android:endY="24"
android:startColor="@color/fx_mobile_icon_color_gradient_start"
android:startX="24"
android:startY="0"
android:type="linear" />
</aapt:attr>
</path>
</group>
</vector>

View File

@ -108,4 +108,10 @@
<string name="profiler_io_error">Something went wrong contacting the Profiler server.</string>
<string name="profiler_uploaded_url_to_clipboard">URL copied to clipboard successfully</string>
<!-- These strings are placeholders till they are finalised for review quality check -->
<!-- Browser menu button to open review quality check -->
<string name="browser_menu_review_quality_check" translatable="false">Review quality check</string>
<!-- Browser menu button content description to close review quality check-->
<string name="browser_menu_review_quality_check_close" translatable="false">Close review quality check</string>
</resources>