1
0
Fork 0

For #5263 - Hide ETP Panel Settings for custom tab

master
Emily Kager 2019-09-12 10:03:56 -07:00 committed by Emily Kager
parent 3fd44e8d83
commit b83ae45c36
4 changed files with 12 additions and 0 deletions

View File

@ -88,6 +88,7 @@ class TrackingProtectionPanelDialogFragment : AppCompatDialogFragment(), BackHan
trackingProtectionStore = StoreProvider.get(this) { trackingProtectionStore = StoreProvider.get(this) {
TrackingProtectionStore( TrackingProtectionStore(
TrackingProtectionState( TrackingProtectionState(
session,
url, url,
trackingProtectionEnabled, trackingProtectionEnabled,
session?.trackersBlocked ?: listOf(), session?.trackersBlocked ?: listOf(),

View File

@ -110,6 +110,8 @@ class TrackingProtectionPanelView(
private fun setUIForNormalMode(state: TrackingProtectionState) { private fun setUIForNormalMode(state: TrackingProtectionState) {
details_mode.visibility = View.GONE details_mode.visibility = View.GONE
normal_mode.visibility = View.VISIBLE normal_mode.visibility = View.VISIBLE
protection_settings.visibility =
if (state.session?.customTabConfig != null) View.GONE else View.VISIBLE
not_blocking_header.visibility = not_blocking_header.visibility =
if (bucketedLoadedTrackers.size == 0) View.GONE else View.VISIBLE if (bucketedLoadedTrackers.size == 0) View.GONE else View.VISIBLE

View File

@ -4,6 +4,7 @@
package org.mozilla.fenix.trackingprotection package org.mozilla.fenix.trackingprotection
import mozilla.components.browser.session.Session
import mozilla.components.concept.engine.content.blocking.Tracker import mozilla.components.concept.engine.content.blocking.Tracker
import mozilla.components.lib.state.Action import mozilla.components.lib.state.Action
import mozilla.components.lib.state.State import mozilla.components.lib.state.State
@ -56,6 +57,7 @@ sealed class TrackingProtectionAction : Action {
* @property mode Current Mode of TrackingProtection * @property mode Current Mode of TrackingProtection
*/ */
data class TrackingProtectionState( data class TrackingProtectionState(
val session: Session?,
val url: String, val url: String,
val isTrackingProtectionEnabled: Boolean, val isTrackingProtectionEnabled: Boolean,
val listTrackers: List<Tracker>, val listTrackers: List<Tracker>,

View File

@ -4,13 +4,18 @@
package org.mozilla.fenix.trackingprotection package org.mozilla.fenix.trackingprotection
import io.mockk.mockk
import org.junit.Assert.assertEquals import org.junit.Assert.assertEquals
import org.junit.Assert.assertNotSame import org.junit.Assert.assertNotSame
import kotlinx.coroutines.runBlocking import kotlinx.coroutines.runBlocking
import mozilla.components.browser.session.Session
import mozilla.components.concept.engine.content.blocking.Tracker import mozilla.components.concept.engine.content.blocking.Tracker
import org.junit.Test import org.junit.Test
class TrackingProtectionStoreTest { class TrackingProtectionStoreTest {
val session: Session = mockk(relaxed = true)
@Test @Test
fun enterDetailsMode() = runBlocking { fun enterDetailsMode() = runBlocking {
val initialState = defaultState() val initialState = defaultState()
@ -143,6 +148,7 @@ class TrackingProtectionStoreTest {
} }
private fun defaultState(): TrackingProtectionState = TrackingProtectionState( private fun defaultState(): TrackingProtectionState = TrackingProtectionState(
session = session,
url = "www.mozilla.org", url = "www.mozilla.org",
isTrackingProtectionEnabled = true, isTrackingProtectionEnabled = true,
listTrackers = listOf(), listTrackers = listOf(),
@ -151,6 +157,7 @@ class TrackingProtectionStoreTest {
) )
private fun detailsState(): TrackingProtectionState = TrackingProtectionState( private fun detailsState(): TrackingProtectionState = TrackingProtectionState(
session = session,
url = "www.mozilla.org", url = "www.mozilla.org",
isTrackingProtectionEnabled = true, isTrackingProtectionEnabled = true,
listTrackers = listOf(), listTrackers = listOf(),