Skip to content

Commit

Permalink
Revert "Integrate privacy dashboard (#5593)" (#5612)
Browse files Browse the repository at this point in the history
Task/Issue URL: https://app.asana.com/0/488551667048375/1209348998867204

### Description
Reverts recent Privacy Dashboard changes
(#5593)

### Steps to test this PR

_Feature 1_
- [x] install the app
- [x] visit any site
- [x] Click on Privacy Shield
- [x] Ensure it loads Privacy Dashboard

### UI changes
| Before  | After |
| ------ | ----- |
!(Upload before screenshot)|(Upload after screenshot)|
  • Loading branch information
cmonfortep authored Feb 7, 2025
1 parent 7f378dd commit 2bcb0e8
Show file tree
Hide file tree
Showing 14 changed files with 27 additions and 62 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ package com.duckduckgo.app.browser.omnibar.animations

import com.airbnb.lottie.LottieAnimationView
import com.duckduckgo.app.browser.R
import com.duckduckgo.app.global.model.PrivacyShield.MALICIOUS
import com.duckduckgo.app.global.model.PrivacyShield.PROTECTED
import com.duckduckgo.app.global.model.PrivacyShield.UNPROTECTED
import com.duckduckgo.app.global.model.PrivacyShield.WARNING
import com.duckduckgo.common.ui.store.AppTheme
import org.junit.Test
import org.mockito.kotlin.mock
Expand Down Expand Up @@ -80,28 +80,28 @@ class LottiePrivacyShieldAnimationHelperTest {
}

@Test
fun whenLightModeAndPrivacyShieldMaliciousThenUseLightAnimation() {
fun whenLightModeAndPrivacyShieldWarningThenUseLightAnimation() {
val holder: LottieAnimationView = mock()
val appTheme: AppTheme = mock()
whenever(appTheme.isLightModeEnabled()).thenReturn(true)
val testee = LottiePrivacyShieldAnimationHelper(appTheme)

testee.setAnimationView(holder, MALICIOUS)
testee.setAnimationView(holder, WARNING)

verify(holder).setAnimation(R.raw.alert_red)
verify(holder).progress = 0.0f
verify(holder).setAnimation(R.raw.unprotected_shield)
verify(holder).progress = 1.0f
}

@Test
fun whenDarkModeAndPrivacyShieldMaliciousThenUseDarkAnimation() {
fun whenDarkModeAndPrivacyShieldWarningThenUseDarkAnimation() {
val holder: LottieAnimationView = mock()
val appTheme: AppTheme = mock()
whenever(appTheme.isLightModeEnabled()).thenReturn(false)
val testee = LottiePrivacyShieldAnimationHelper(appTheme)

testee.setAnimationView(holder, MALICIOUS)
testee.setAnimationView(holder, WARNING)

verify(holder).setAnimation(R.raw.alert_red_dark)
verify(holder).progress = 0.0f
verify(holder).setAnimation(R.raw.dark_unprotected_shield)
verify(holder).progress = 1.0f
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ package com.duckduckgo.app.browser.omnibar.animations
import com.airbnb.lottie.LottieAnimationView
import com.duckduckgo.app.browser.R
import com.duckduckgo.app.global.model.PrivacyShield
import com.duckduckgo.app.global.model.PrivacyShield.MALICIOUS
import com.duckduckgo.app.global.model.PrivacyShield.PROTECTED
import com.duckduckgo.app.global.model.PrivacyShield.UNKNOWN
import com.duckduckgo.app.global.model.PrivacyShield.UNPROTECTED
import com.duckduckgo.app.global.model.PrivacyShield.WARNING
import com.duckduckgo.common.ui.store.AppTheme
import com.duckduckgo.di.scopes.AppScope
import com.squareup.anvil.annotations.ContributesBinding
Expand Down Expand Up @@ -54,10 +54,10 @@ class LottiePrivacyShieldAnimationHelper @Inject constructor(val appTheme: AppTh
UNKNOWN -> {
Timber.i("Shield: UNKNOWN")
}
MALICIOUS -> {
val res = if (appTheme.isLightModeEnabled()) R.raw.alert_red else R.raw.alert_red_dark
WARNING -> {
val res = if (appTheme.isLightModeEnabled()) R.raw.unprotected_shield else R.raw.dark_unprotected_shield
holder.setAnimation(res)
holder.progress = 0.0f
holder.progress = 1.0f
Timber.i("Shield: WARNING")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import androidx.annotation.WorkerThread
import androidx.core.net.toUri
import com.duckduckgo.app.browser.UriString
import com.duckduckgo.app.browser.certificates.BypassedSSLCertificatesRepository
import com.duckduckgo.app.global.model.PrivacyShield.MALICIOUS
import com.duckduckgo.app.global.model.PrivacyShield.PROTECTED
import com.duckduckgo.app.global.model.PrivacyShield.UNKNOWN
import com.duckduckgo.app.global.model.PrivacyShield.UNPROTECTED
Expand Down Expand Up @@ -168,7 +167,6 @@ class SiteMonitor(
userAllowList = domain?.let { isAllowListed(it) } ?: false
if (duckPlayer.isDuckPlayerUri(url)) return UNKNOWN
if (userAllowList || !isHttps) return UNPROTECTED
if (maliciousSiteStatus != null) return MALICIOUS

if (!fullSiteDetailsAvailable) {
Timber.i("Shield: not fullSiteDetailsAvailable for $domain")
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/raw/alert_red.json

This file was deleted.

1 change: 0 additions & 1 deletion app/src/main/res/raw/alert_red_dark.json

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ class OmnibarLayoutViewModelTest {

@Test
fun whenPrivacyShieldChangedToWarningThenViewStateCorrect() = runTest {
val privacyShield = PrivacyShield.MALICIOUS
val privacyShield = PrivacyShield.WARNING
testee.onPrivacyShieldChanged(privacyShield)

testee.viewState.test {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ package com.duckduckgo.app.global.model
enum class PrivacyShield {
PROTECTED,
UNPROTECTED,
MALICIOUS,
WARNING,
UNKNOWN,
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"@duckduckgo/autoconsent": "^12.9.0",
"@duckduckgo/autofill": "github:duckduckgo/duckduckgo-autofill#16.2.0",
"@duckduckgo/content-scope-scripts": "github:duckduckgo/content-scope-scripts#7.16.0",
"@duckduckgo/privacy-dashboard": "github:duckduckgo/privacy-dashboard#8.4.0",
"@duckduckgo/privacy-dashboard": "github:duckduckgo/privacy-dashboard#8.1.0",
"@duckduckgo/privacy-reference-tests": "github:duckduckgo/privacy-reference-tests#1738159777"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ class PrivacyDashboardHybridViewModel @Inject constructor(
val protectionStatus: ProtectionStatusViewState,
val cookiePromptManagementStatus: CookiePromptManagementState,
val remoteFeatureSettings: RemoteFeatureSettingsViewState,
val maliciousSiteStatus: String? = null,
)

data class ProtectionStatusViewState(
Expand Down Expand Up @@ -290,7 +289,6 @@ class PrivacyDashboardHybridViewModel @Inject constructor(
protectionStatus = protectionStatusViewStateMapper.mapFromSite(site),
cookiePromptManagementStatus = autoconsentStatusViewStateMapper.mapFromSite(site),
remoteFeatureSettings = createRemoteFeatureSettings(),
maliciousSiteStatus = site.maliciousSiteStatus?.name?.lowercase(),
),
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,6 @@ class PrivacyDashboardRenderer(
val cookiePromptManagementStatusJson = cookiePromptManagementStatusAdapter.toJson(viewState.cookiePromptManagementStatus)
webView.evaluateJavascript("javascript:onChangeConsentManaged($cookiePromptManagementStatusJson);", null)

val maliciousStateJson = """{"kind": "${viewState.maliciousSiteStatus}"}"""
webView.evaluateJavascript("javascript:onChangeMaliciousSiteStatus($maliciousStateJson);", null)

// remote feature settings
val remoteFeatureSettingsAdapter = moshi.adapter(RemoteFeatureSettingsViewState::class.java)
val remoteFeatureSettingsJson = remoteFeatureSettingsAdapter.toJson(viewState.remoteFeatureSettings)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class PrivacyDashboardRendererTest {

testee.render(aViewState())

verify(spyWebView, times(9)).evaluateJavascript(captor.capture(), eq(null))
verify(spyWebView, times(8)).evaluateJavascript(captor.capture(), eq(null))

assertNotNull(captor.allValues.find { it.startsWith("javascript:onChangeLocale") })
assertNotNull(captor.allValues.find { it.startsWith("javascript:onChangeFeatureSettings") })
Expand All @@ -123,7 +123,6 @@ class PrivacyDashboardRendererTest {
assertNotNull(captor.allValues.find { it.startsWith("javascript:onChangeUpgradedHttps") })
assertNotNull(captor.allValues.find { it.startsWith("javascript:onChangeRequestData") })
assertNotNull(captor.allValues.find { it.startsWith("javascript:onChangeConsentManaged") })
assertNotNull(captor.allValues.find { it.startsWith("javascript:onChangeMaliciousSiteStatus") })
}

fun aViewState() = ViewState(
Expand Down

0 comments on commit 2bcb0e8

Please sign in to comment.