mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-15 18:12:54 +00:00
Bug 1845232 - Adds action to clear private browsing
This commit is contained in:
parent
0bd49e299e
commit
5d75244515
@ -37,6 +37,7 @@ 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.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.HomeActivity
|
||||||
import org.mozilla.fenix.R
|
import org.mozilla.fenix.R
|
||||||
import org.mozilla.fenix.components.FenixSnackbar
|
import org.mozilla.fenix.components.FenixSnackbar
|
||||||
import org.mozilla.fenix.components.TabCollectionStorage
|
import org.mozilla.fenix.components.TabCollectionStorage
|
||||||
@ -96,7 +97,19 @@ class BrowserFragment : BaseBrowserFragment(), UserInteractionHandler {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
val homeAction = BrowserToolbar.Button(
|
val isPrivate = (activity as HomeActivity).browsingModeManager.mode.isPrivate
|
||||||
|
val leadingAction = if (isPrivate && context.settings().feltPrivateBrowsingEnabled) {
|
||||||
|
BrowserToolbar.Button(
|
||||||
|
imageDrawable = AppCompatResources.getDrawable(
|
||||||
|
context,
|
||||||
|
R.drawable.mozac_ic_data_clearance_24,
|
||||||
|
)!!,
|
||||||
|
contentDescription = context.getString(R.string.browser_toolbar_erase),
|
||||||
|
iconTintColorResource = ThemeManager.resolveAttribute(R.attr.textPrimary, context),
|
||||||
|
listener = browserToolbarInteractor::onEraseButtonClicked,
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
BrowserToolbar.Button(
|
||||||
imageDrawable = AppCompatResources.getDrawable(
|
imageDrawable = AppCompatResources.getDrawable(
|
||||||
context,
|
context,
|
||||||
R.drawable.mozac_ic_home_24,
|
R.drawable.mozac_ic_home_24,
|
||||||
@ -105,8 +118,9 @@ class BrowserFragment : BaseBrowserFragment(), UserInteractionHandler {
|
|||||||
iconTintColorResource = ThemeManager.resolveAttribute(R.attr.textPrimary, context),
|
iconTintColorResource = ThemeManager.resolveAttribute(R.attr.textPrimary, context),
|
||||||
listener = browserToolbarInteractor::onHomeButtonClicked,
|
listener = browserToolbarInteractor::onHomeButtonClicked,
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
|
||||||
browserToolbarView.view.addNavigationAction(homeAction)
|
browserToolbarView.view.addNavigationAction(leadingAction)
|
||||||
|
|
||||||
updateToolbarActions(isTablet = resources.getBoolean(R.bool.tablet))
|
updateToolbarActions(isTablet = resources.getBoolean(R.bool.tablet))
|
||||||
|
|
||||||
|
@ -29,6 +29,7 @@ import org.mozilla.fenix.components.toolbar.interactor.BrowserToolbarInteractor
|
|||||||
import org.mozilla.fenix.ext.components
|
import org.mozilla.fenix.ext.components
|
||||||
import org.mozilla.fenix.ext.nav
|
import org.mozilla.fenix.ext.nav
|
||||||
import org.mozilla.fenix.ext.settings
|
import org.mozilla.fenix.ext.settings
|
||||||
|
import org.mozilla.fenix.home.HomeFragment
|
||||||
import org.mozilla.fenix.home.HomeScreenViewModel
|
import org.mozilla.fenix.home.HomeScreenViewModel
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -47,6 +48,11 @@ interface BrowserToolbarController {
|
|||||||
* @see [BrowserToolbarInteractor.onHomeButtonClicked]
|
* @see [BrowserToolbarInteractor.onHomeButtonClicked]
|
||||||
*/
|
*/
|
||||||
fun handleHomeButtonClick()
|
fun handleHomeButtonClick()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see [BrowserToolbarInteractor.onEraseButtonClicked]
|
||||||
|
*/
|
||||||
|
fun handleEraseButtonClick()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Suppress("LongParameterList")
|
@Suppress("LongParameterList")
|
||||||
@ -180,6 +186,12 @@ class DefaultBrowserToolbarController(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun handleEraseButtonClick() {
|
||||||
|
homeViewModel.sessionToDelete = HomeFragment.ALL_PRIVATE_TABS
|
||||||
|
val directions = BrowserFragmentDirections.actionGlobalHome()
|
||||||
|
navController.navigate(directions)
|
||||||
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
internal const val TELEMETRY_BROWSER_IDENTIFIER = "browserMenu"
|
internal const val TELEMETRY_BROWSER_IDENTIFIER = "browserMenu"
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,11 @@ interface BrowserToolbarInteractor {
|
|||||||
* Navigates to the Home screen. Called when a user taps on the Home button.
|
* Navigates to the Home screen. Called when a user taps on the Home button.
|
||||||
*/
|
*/
|
||||||
fun onHomeButtonClicked()
|
fun onHomeButtonClicked()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletase all tabs and navigates to the Home screen. Called when a user taps on the erase button.
|
||||||
|
*/
|
||||||
|
fun onEraseButtonClicked()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -77,4 +82,8 @@ class DefaultBrowserToolbarInteractor(
|
|||||||
override fun onHomeButtonClicked() {
|
override fun onHomeButtonClicked() {
|
||||||
browserToolbarController.handleHomeButtonClick()
|
browserToolbarController.handleHomeButtonClick()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onEraseButtonClicked() {
|
||||||
|
browserToolbarController.handleEraseButtonClick()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -664,7 +664,11 @@ class HomeFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
val snackbarMessage = if (sessionCode == ALL_PRIVATE_TABS) {
|
val snackbarMessage = if (sessionCode == ALL_PRIVATE_TABS) {
|
||||||
|
if (requireContext().settings().feltPrivateBrowsingEnabled) {
|
||||||
|
getString(R.string.snackbar_private_data_deleted)
|
||||||
|
} else {
|
||||||
getString(R.string.snackbar_private_tabs_closed)
|
getString(R.string.snackbar_private_tabs_closed)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
getString(R.string.snackbar_tabs_closed)
|
getString(R.string.snackbar_tabs_closed)
|
||||||
}
|
}
|
||||||
|
@ -214,7 +214,9 @@
|
|||||||
<!-- Browser Toolbar -->
|
<!-- Browser Toolbar -->
|
||||||
<!-- Content description for the Home screen button on the browser toolbar -->
|
<!-- Content description for the Home screen button on the browser toolbar -->
|
||||||
<string name="browser_toolbar_home">Home screen</string>
|
<string name="browser_toolbar_home">Home screen</string>
|
||||||
|
<!-- Content description (not visible, for screen readers etc.): Erase button: Erase the browsing
|
||||||
|
history and go back to the home screen. -->
|
||||||
|
<string name="browser_toolbar_erase">Erase browsing history</string>
|
||||||
<!-- Locale Settings Fragment -->
|
<!-- Locale Settings Fragment -->
|
||||||
<!-- Content description for tick mark on selected language -->
|
<!-- Content description for tick mark on selected language -->
|
||||||
<string name="a11y_selected_locale_content_description">Selected language</string>
|
<string name="a11y_selected_locale_content_description">Selected language</string>
|
||||||
@ -1273,6 +1275,8 @@
|
|||||||
<string name="snackbar_private_tab_closed">Private tab closed</string>
|
<string name="snackbar_private_tab_closed">Private tab closed</string>
|
||||||
<!-- Text shown in snackbar when user closes all private tabs -->
|
<!-- Text shown in snackbar when user closes all private tabs -->
|
||||||
<string name="snackbar_private_tabs_closed">Private tabs closed</string>
|
<string name="snackbar_private_tabs_closed">Private tabs closed</string>
|
||||||
|
<!-- Text shown in snackbar when user erases their private browsing data -->
|
||||||
|
<string name="snackbar_private_data_deleted">Private browsing data deleted</string>
|
||||||
<!-- Text shown in snackbar to undo deleting a tab, top site or collection -->
|
<!-- Text shown in snackbar to undo deleting a tab, top site or collection -->
|
||||||
<string name="snackbar_deleted_undo">UNDO</string>
|
<string name="snackbar_deleted_undo">UNDO</string>
|
||||||
<!-- Text shown in snackbar when user removes a top site -->
|
<!-- Text shown in snackbar when user removes a top site -->
|
||||||
|
@ -53,6 +53,7 @@ import org.mozilla.fenix.browser.readermode.ReaderModeController
|
|||||||
import org.mozilla.fenix.ext.components
|
import org.mozilla.fenix.ext.components
|
||||||
import org.mozilla.fenix.ext.settings
|
import org.mozilla.fenix.ext.settings
|
||||||
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
|
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
|
||||||
|
import org.mozilla.fenix.home.HomeFragment
|
||||||
import org.mozilla.fenix.home.HomeScreenViewModel
|
import org.mozilla.fenix.home.HomeScreenViewModel
|
||||||
|
|
||||||
@RunWith(FenixRobolectricTestRunner::class)
|
@RunWith(FenixRobolectricTestRunner::class)
|
||||||
@ -366,6 +367,17 @@ class DefaultBrowserToolbarControllerTest {
|
|||||||
assertNotNull(Events.browserToolbarHomeTapped.testGetValue())
|
assertNotNull(Events.browserToolbarHomeTapped.testGetValue())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun handleEraseButtonClicked() {
|
||||||
|
val controller = createController()
|
||||||
|
controller.handleEraseButtonClick()
|
||||||
|
|
||||||
|
verify {
|
||||||
|
homeViewModel.sessionToDelete = HomeFragment.ALL_PRIVATE_TABS
|
||||||
|
navController.navigate(BrowserFragmentDirections.actionGlobalHome())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun createController(
|
private fun createController(
|
||||||
activity: HomeActivity = this.activity,
|
activity: HomeActivity = this.activity,
|
||||||
customTabSessionId: String? = null,
|
customTabSessionId: String? = null,
|
||||||
|
@ -80,4 +80,11 @@ class DefaultBrowserToolbarInteractorTest {
|
|||||||
|
|
||||||
verify { browserToolbarController.handleHomeButtonClick() }
|
verify { browserToolbarController.handleHomeButtonClick() }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun onEraseButtonClicked() {
|
||||||
|
interactor.onEraseButtonClicked()
|
||||||
|
|
||||||
|
verify { browserToolbarController.handleEraseButtonClick() }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user