mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-17 15:26:23 +00:00
Bug 1841676 - Fix NavigationToolbarTest.swipeToSwitchTabInRTLTest failure
This commit is contained in:
parent
e36eeb6091
commit
427e39810c
@ -10,13 +10,11 @@ import android.view.View
|
|||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.annotation.VisibleForTesting
|
import androidx.annotation.VisibleForTesting
|
||||||
import androidx.appcompat.content.res.AppCompatResources
|
import androidx.appcompat.content.res.AppCompatResources
|
||||||
import androidx.fragment.app.activityViewModels
|
|
||||||
import androidx.lifecycle.Observer
|
import androidx.lifecycle.Observer
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
import androidx.navigation.fragment.findNavController
|
import androidx.navigation.fragment.findNavController
|
||||||
import com.google.android.material.snackbar.Snackbar
|
import com.google.android.material.snackbar.Snackbar
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.flow.collectLatest
|
|
||||||
import kotlinx.coroutines.flow.mapNotNull
|
import kotlinx.coroutines.flow.mapNotNull
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
@ -37,7 +35,6 @@ import mozilla.components.lib.state.ext.consumeFlow
|
|||||||
import mozilla.components.service.glean.private.NoExtras
|
import mozilla.components.service.glean.private.NoExtras
|
||||||
import mozilla.components.support.base.feature.UserInteractionHandler
|
import mozilla.components.support.base.feature.UserInteractionHandler
|
||||||
import mozilla.components.support.base.feature.ViewBoundFeatureWrapper
|
import mozilla.components.support.base.feature.ViewBoundFeatureWrapper
|
||||||
import mozilla.components.support.ktx.android.view.toScope
|
|
||||||
import mozilla.components.support.ktx.kotlinx.coroutines.flow.ifAnyChanged
|
import mozilla.components.support.ktx.kotlinx.coroutines.flow.ifAnyChanged
|
||||||
import org.mozilla.fenix.GleanMetrics.ReaderMode
|
import org.mozilla.fenix.GleanMetrics.ReaderMode
|
||||||
import org.mozilla.fenix.R
|
import org.mozilla.fenix.R
|
||||||
@ -54,7 +51,6 @@ import org.mozilla.fenix.nimbus.FxNimbus
|
|||||||
import org.mozilla.fenix.settings.quicksettings.protections.cookiebanners.dialog.CookieBannerReEngagementDialogUtils
|
import org.mozilla.fenix.settings.quicksettings.protections.cookiebanners.dialog.CookieBannerReEngagementDialogUtils
|
||||||
import org.mozilla.fenix.settings.quicksettings.protections.cookiebanners.getCookieBannerUIMode
|
import org.mozilla.fenix.settings.quicksettings.protections.cookiebanners.getCookieBannerUIMode
|
||||||
import org.mozilla.fenix.shopping.ReviewQualityCheckFeature
|
import org.mozilla.fenix.shopping.ReviewQualityCheckFeature
|
||||||
import org.mozilla.fenix.shopping.ReviewQualityCheckViewModel
|
|
||||||
import org.mozilla.fenix.shortcut.PwaOnboardingObserver
|
import org.mozilla.fenix.shortcut.PwaOnboardingObserver
|
||||||
import org.mozilla.fenix.theme.ThemeManager
|
import org.mozilla.fenix.theme.ThemeManager
|
||||||
|
|
||||||
@ -67,7 +63,6 @@ class BrowserFragment : BaseBrowserFragment(), UserInteractionHandler {
|
|||||||
private val windowFeature = ViewBoundFeatureWrapper<WindowFeature>()
|
private val windowFeature = ViewBoundFeatureWrapper<WindowFeature>()
|
||||||
private val openInAppOnboardingObserver = ViewBoundFeatureWrapper<OpenInAppOnboardingObserver>()
|
private val openInAppOnboardingObserver = ViewBoundFeatureWrapper<OpenInAppOnboardingObserver>()
|
||||||
private val reviewQualityCheckFeature = ViewBoundFeatureWrapper<ReviewQualityCheckFeature>()
|
private val reviewQualityCheckFeature = ViewBoundFeatureWrapper<ReviewQualityCheckFeature>()
|
||||||
private val reviewQualityCheckViewModel: ReviewQualityCheckViewModel by activityViewModels()
|
|
||||||
|
|
||||||
private var readerModeAvailable = false
|
private var readerModeAvailable = false
|
||||||
private var reviewQualityCheckAvailable = false
|
private var reviewQualityCheckAvailable = false
|
||||||
@ -204,17 +199,15 @@ class BrowserFragment : BaseBrowserFragment(), UserInteractionHandler {
|
|||||||
)!!,
|
)!!,
|
||||||
imageSelected = AppCompatResources.getDrawable(
|
imageSelected = AppCompatResources.getDrawable(
|
||||||
context,
|
context,
|
||||||
R.drawable.ic_shopping_cart_selected,
|
R.drawable.ic_shopping_cart,
|
||||||
)!!,
|
)!!,
|
||||||
contentDescription = context.getString(R.string.browser_menu_review_quality_check),
|
contentDescription = context.getString(R.string.browser_menu_review_quality_check),
|
||||||
contentDescriptionSelected = context.getString(R.string.browser_menu_review_quality_check_close),
|
contentDescriptionSelected = context.getString(R.string.browser_menu_review_quality_check_close),
|
||||||
visible = { reviewQualityCheckAvailable },
|
visible = { reviewQualityCheckAvailable },
|
||||||
listener = { isSelected ->
|
listener = {
|
||||||
if (isSelected) {
|
|
||||||
findNavController().navigate(
|
findNavController().navigate(
|
||||||
BrowserFragmentDirections.actionBrowserFragmentToReviewQualityCheckDialogFragment(),
|
BrowserFragmentDirections.actionBrowserFragmentToReviewQualityCheckDialogFragment(),
|
||||||
)
|
)
|
||||||
}
|
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -227,12 +220,6 @@ class BrowserFragment : BaseBrowserFragment(), UserInteractionHandler {
|
|||||||
owner = this,
|
owner = this,
|
||||||
view = view,
|
view = view,
|
||||||
)
|
)
|
||||||
|
|
||||||
view.toScope().launch {
|
|
||||||
reviewQualityCheckViewModel.isBottomSheetVisible.collectLatest {
|
|
||||||
reviewQualityCheck.setSelected(selected = it, notifyListener = false)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onUpdateToolbarForConfigurationChange(toolbar: BrowserToolbarView) {
|
override fun onUpdateToolbarForConfigurationChange(toolbar: BrowserToolbarView) {
|
||||||
|
@ -5,13 +5,14 @@
|
|||||||
package org.mozilla.fenix.shopping
|
package org.mozilla.fenix.shopping
|
||||||
|
|
||||||
import android.app.Dialog
|
import android.app.Dialog
|
||||||
import android.content.DialogInterface
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.input.nestedscroll.nestedScroll
|
||||||
import androidx.compose.ui.platform.ComposeView
|
import androidx.compose.ui.platform.ComposeView
|
||||||
import androidx.fragment.app.activityViewModels
|
import androidx.compose.ui.platform.rememberNestedScrollInteropConnection
|
||||||
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
||||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
|
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
|
||||||
import org.mozilla.fenix.shopping.ui.ReviewQualityCheckContent
|
import org.mozilla.fenix.shopping.ui.ReviewQualityCheckContent
|
||||||
@ -22,7 +23,6 @@ import org.mozilla.fenix.theme.FirefoxTheme
|
|||||||
*/
|
*/
|
||||||
class ReviewQualityCheckFragment : BottomSheetDialogFragment() {
|
class ReviewQualityCheckFragment : BottomSheetDialogFragment() {
|
||||||
|
|
||||||
private val viewModel: ReviewQualityCheckViewModel by activityViewModels()
|
|
||||||
private var behavior: BottomSheetBehavior<View>? = null
|
private var behavior: BottomSheetBehavior<View>? = null
|
||||||
|
|
||||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog =
|
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog =
|
||||||
@ -46,18 +46,9 @@ class ReviewQualityCheckFragment : BottomSheetDialogFragment() {
|
|||||||
onRequestDismiss = {
|
onRequestDismiss = {
|
||||||
behavior?.state = BottomSheetBehavior.STATE_HIDDEN
|
behavior?.state = BottomSheetBehavior.STATE_HIDDEN
|
||||||
},
|
},
|
||||||
|
modifier = Modifier.nestedScroll(rememberNestedScrollInteropConnection()),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
|
||||||
super.onCreate(savedInstanceState)
|
|
||||||
viewModel.onDialogCreated()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onDismiss(dialog: DialogInterface) {
|
|
||||||
super.onDismiss(dialog)
|
|
||||||
viewModel.onDialogDismissed()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,34 +0,0 @@
|
|||||||
/* 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 androidx.lifecycle.ViewModel
|
|
||||||
import kotlinx.coroutines.flow.MutableStateFlow
|
|
||||||
import kotlinx.coroutines.flow.StateFlow
|
|
||||||
import kotlinx.coroutines.flow.update
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A ViewModel to communicate between ReviewQualityCheckFragment bottom sheet and the parent
|
|
||||||
* fragment.
|
|
||||||
*/
|
|
||||||
class ReviewQualityCheckViewModel : ViewModel() {
|
|
||||||
|
|
||||||
private val _isBottomSheetVisible = MutableStateFlow(false)
|
|
||||||
val isBottomSheetVisible: StateFlow<Boolean> = _isBottomSheetVisible
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Invoked when bottom sheet dialog is created.
|
|
||||||
*/
|
|
||||||
fun onDialogCreated() {
|
|
||||||
_isBottomSheetVisible.update { true }
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Invoked when bottom sheet dialog is dismissed.
|
|
||||||
*/
|
|
||||||
fun onDialogDismissed() {
|
|
||||||
_isBottomSheetVisible.update { false }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,23 +0,0 @@
|
|||||||
<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>
|
|
Loading…
Reference in New Issue
Block a user