Skip to content

Commit

Permalink
For mozilla-mobile#19886 - Remove the tracking protection indicator
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielluong authored and Amejia481 committed Aug 16, 2021
1 parent fd18900 commit 465f553
Show file tree
Hide file tree
Showing 9 changed files with 9 additions and 330 deletions.
15 changes: 0 additions & 15 deletions app/src/main/java/org/mozilla/fenix/browser/BaseBrowserFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ import org.mozilla.fenix.ext.breadcrumb
import org.mozilla.fenix.ext.components
import org.mozilla.fenix.ext.getPreferenceKey
import org.mozilla.fenix.ext.hideToolbar
import org.mozilla.fenix.ext.metrics
import org.mozilla.fenix.ext.nav
import org.mozilla.fenix.ext.requireComponents
import org.mozilla.fenix.ext.settings
Expand Down Expand Up @@ -397,11 +396,6 @@ abstract class BaseBrowserFragment :
showQuickSettingsDialog()
}

browserToolbarView.view.display.setOnTrackingProtectionClickedListener {
context.metrics.track(Event.TrackingProtectionIconPressed)
showTrackingProtectionPanel()
}

contextMenuFeature.set(
feature = ContextMenuFeature(
fragmentManager = parentFragmentManager,
Expand Down Expand Up @@ -1163,8 +1157,6 @@ abstract class BaseBrowserFragment :
sitePermissions: SitePermissions?
)

protected abstract fun navToTrackingProtectionPanel(tab: SessionState)

/**
* Returns the layout [android.view.Gravity] for the quick settings and ETP dialog.
*/
Expand Down Expand Up @@ -1200,13 +1192,6 @@ abstract class BaseBrowserFragment :
}
}

private fun showTrackingProtectionPanel() {
val tab = getCurrentTab() ?: return
view?.let {
navToTrackingProtectionPanel(tab)
}
}

/**
* Set the activity normal/private theme to match the current session.
*/
Expand Down
19 changes: 0 additions & 19 deletions app/src/main/java/org/mozilla/fenix/browser/BrowserFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,8 @@ import org.mozilla.fenix.components.toolbar.ToolbarMenu
import org.mozilla.fenix.components.metrics.Event
import org.mozilla.fenix.ext.components
import org.mozilla.fenix.ext.nav
import org.mozilla.fenix.ext.navigateSafe
import org.mozilla.fenix.ext.requireComponents
import org.mozilla.fenix.ext.settings
import org.mozilla.fenix.ext.runIfFragmentIsAttached
import org.mozilla.fenix.shortcut.PwaOnboardingObserver
import org.mozilla.fenix.theme.ThemeManager
import org.mozilla.fenix.trackingprotection.TrackingProtectionOverlay
Expand Down Expand Up @@ -337,23 +335,6 @@ class BrowserFragment : BaseBrowserFragment(), UserInteractionHandler {
nav(R.id.browserFragment, directions)
}

override fun navToTrackingProtectionPanel(tab: SessionState) {
val navController = findNavController()
requireComponents.useCases.trackingProtectionUseCases.containsException(tab.id) { contains ->
runIfFragmentIsAttached {
val isEnabled = tab.trackingProtection.enabled && !contains
val directions =
BrowserFragmentDirections.actionBrowserFragmentToTrackingProtectionPanelDialogFragment(
sessionId = tab.id,
url = tab.content.url,
trackingProtectionEnabled = isEnabled,
gravity = getAppropriateLayoutGravity()
)
navController.navigateSafe(R.id.browserFragment, directions)
}
}
}

private val collectionStorageObserver = object : TabCollectionStorage.Observer {
override fun onCollectionCreated(
title: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
package org.mozilla.fenix.components.toolbar

import android.content.Context
import android.content.res.Configuration
import androidx.appcompat.content.res.AppCompatResources
import androidx.core.content.ContextCompat
import androidx.lifecycle.LifecycleOwner
import kotlinx.coroutines.ExperimentalCoroutinesApi
Expand Down Expand Up @@ -104,49 +102,10 @@ class DefaultToolbarIntegration(
toolbar.display.menuBuilder = toolbarMenu.menuBuilder
toolbar.private = isPrivate

val drawable =
if (isPrivate) AppCompatResources.getDrawable(
context,
R.drawable.shield_dark
) else when (context.resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK) {
Configuration.UI_MODE_NIGHT_UNDEFINED, // We assume light here per Android doc's recommendation
Configuration.UI_MODE_NIGHT_NO -> {
AppCompatResources.getDrawable(context, R.drawable.shield_light)
}
Configuration.UI_MODE_NIGHT_YES -> {
AppCompatResources.getDrawable(context, R.drawable.shield_dark)
}
else -> AppCompatResources.getDrawable(context, R.drawable.shield_light)
}

toolbar.display.indicators =
if (context.settings().shouldUseTrackingProtection) {
listOf(
DisplayToolbar.Indicators.TRACKING_PROTECTION,
DisplayToolbar.Indicators.SECURITY,
DisplayToolbar.Indicators.EMPTY,
DisplayToolbar.Indicators.HIGHLIGHT
)
} else {
listOf(
DisplayToolbar.Indicators.SECURITY,
DisplayToolbar.Indicators.EMPTY,
DisplayToolbar.Indicators.HIGHLIGHT
)
}
context.settings().shouldUseTrackingProtection

toolbar.display.icons = toolbar.display.icons.copy(
emptyIcon = null,
trackingProtectionTrackersBlocked = drawable!!,
trackingProtectionNothingBlocked = AppCompatResources.getDrawable(
context,
R.drawable.ic_tracking_protection_enabled
)!!,
trackingProtectionException = AppCompatResources.getDrawable(
context,
R.drawable.ic_tracking_protection_disabled
)!!
toolbar.display.indicators = listOf(
DisplayToolbar.Indicators.SECURITY,
DisplayToolbar.Indicators.EMPTY,
DisplayToolbar.Indicators.HIGHLIGHT
)

val tabCounterMenu = FenixTabCounterMenu(
Expand All @@ -155,11 +114,11 @@ class DefaultToolbarIntegration(
interactor.onTabCounterMenuItemTapped(it)
},
iconColor =
if (isPrivate) {
ContextCompat.getColor(context, R.color.primary_text_private_theme)
} else {
null
}
if (isPrivate) {
ContextCompat.getColor(context, R.color.primary_text_private_theme)
} else {
null
}
).also {
it.updateMenu(context.settings().toolbarPosition)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import org.mozilla.fenix.ext.components
import org.mozilla.fenix.ext.nav
import org.mozilla.fenix.ext.requireComponents
import org.mozilla.fenix.ext.settings
import org.mozilla.fenix.ext.runIfFragmentIsAttached

/**
* Fragment used for browsing the web within external apps.
Expand Down Expand Up @@ -192,23 +191,6 @@ class ExternalAppBrowserFragment : BaseBrowserFragment(), UserInteractionHandler
nav(R.id.externalAppBrowserFragment, directions)
}

override fun navToTrackingProtectionPanel(tab: SessionState) {
requireComponents.useCases.trackingProtectionUseCases.containsException(tab.id) { contains ->
runIfFragmentIsAttached {
val isEnabled = tab.trackingProtection.enabled && !contains
val directions =
ExternalAppBrowserFragmentDirections
.actionGlobalTrackingProtectionPanelDialogFragment(
sessionId = tab.id,
url = tab.content.url,
trackingProtectionEnabled = isEnabled,
gravity = getAppropriateLayoutGravity()
)
nav(R.id.externalAppBrowserFragment, directions)
}
}
}

override fun getContextMenuCandidates(
context: Context,
view: View
Expand Down
81 changes: 0 additions & 81 deletions app/src/main/res/drawable-v24/shield_dark.xml

This file was deleted.

0 comments on commit 465f553

Please sign in to comment.