Skip to content

Commit

Permalink
Merge branch 'develop' into feature/ondrej/swiping-tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
0nko committed Dec 20, 2024
2 parents c2c0743 + b7cf1ca commit 0f06a07
Show file tree
Hide file tree
Showing 250 changed files with 3,144 additions and 37,837 deletions.
17 changes: 0 additions & 17 deletions .github/workflows/action-pr-approved.yaml

This file was deleted.

6 changes: 3 additions & 3 deletions .github/workflows/pr-review-notifications.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
name: Pull Request Reviewed -> Asana Sync
name: Pull Request Reviewed -> Sync With Asana

on:
pull_request_review:
types: [submitted]

jobs:
pr-reviewed:
name: Update Asana task -> PR reviewed
uses: duckduckgo/native-github-asana-sync/.github/workflows/pr-review-notifications.yml@david/improve-pr-notifications
name: Add PR reviewed comment
uses: duckduckgo/native-github-asana-sync/.github/workflows/pr-review-notifications.yml@v1.4.1
with:
trigger-phrase: "Task/Issue URL:"
secrets:
Expand Down
11 changes: 11 additions & 0 deletions app/lint-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7679,4 +7679,15 @@
column="9"/>
</issue>

<issue
id="InvalidColorAttribute"
message="@colors are not allowed, used ?attr/daxColor instead"
errorLine1=" android:textColor=&quot;@color/blue50&quot;"
errorLine2=" ~~~~~~~~~~~~~~~~~">
<location
file="src/main/res/layout/view_menu_item_default_browser.xml"
line="35"
column="13"/>
</issue>

</issues>
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@
"requestType": "script",
"expectAction": "ignore"
},
{
"name": "same party ignore with deeper subdomain",
"siteURL": "https://bad.etld-plus-two.site/",
"requestURL": "https://bad.etld-plus-two.site/script.js",
"requestType": "script",
"expectAction": "ignore"
},
{
"name": "tracker loads ignore",
"siteURL": "https://bad.third-party.site/",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,21 @@
"rules": [],
"default": "ignore"
},
"bad.etld-plus-two.site": {
"domain": "bad.etld-plus-two.site",
"owner": {
"name": "Test Site for Tracker Blocking With eTLD+2",
"displayName": "Bad Third Party Site eTLD+2",
"privacyPolicy": "",
"url": "http://bad.etld-plus-two.site"
},
"prevalence": 0.1,
"fingerprinting": 3,
"cookies": 0.1,
"categories": [],
"default": "block",
"rules": []
},
"tracker.test": {
"domain": "tracker.test",
"owner": {
Expand Down Expand Up @@ -819,6 +834,13 @@
"prevalence": 0.1,
"displayName": "Test Site for Tracker Blocking"
},
"Test Site for Tracker Blocking With eTLD+2": {
"domains": [
"bad.etld-plus-two.site"
],
"prevalence": 0.1,
"displayName": "Bad Third Party Site eTLD+2"
},
"Tests for formatting": {
"domains": [
"format.test"
Expand Down Expand Up @@ -876,6 +898,7 @@
"bad.third-party.site": "Test Site for Tracker Blocking",
"sometimes-bad.third-party.site": "Test Site for Tracker Blocking",
"broken.third-party.site": "Test Site for Tracker Blocking",
"bad.etld-plus-two.site": "Test Site for Tracker Blocking With eTLD+2",
"format.test": "Tests for formatting",
"third-party.site": "Test Site for Tracker Blocking",
"tracker.test": "Test Site for Tracker Blocking",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1046,6 +1046,9 @@ class BrowserTabFragment :
onMenuItemClicked(changeBrowserModeMenuItem) {
viewModel.onChangeBrowserModeClicked()
}
onMenuItemClicked(defaultBrowserMenuItem) {
viewModel.onSetDefaultBrowserSelected()
}
onMenuItemClicked(sharePageMenuItem) {
pixel.fire(AppPixelName.MENU_ACTION_SHARE_PRESSED)
viewModel.onShareSelected()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2524,6 +2524,10 @@ class BrowserTabViewModel @Inject constructor(
}
}

fun onSetDefaultBrowserSelected() {
// no-op, to be implemented
}

fun onShareSelected() {
url?.let {
viewModelScope.launch(dispatchers.io()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,13 @@ class BrowserPopupMenu(
}
}

internal val defaultBrowserMenuItem: View by lazy {
when (omnibarPosition) {
TOP -> topBinding.includeDefaultBrowserMenuItem.defaultBrowserMenuItem
BOTTOM -> bottomBinding.includeDefaultBrowserMenuItem.defaultBrowserMenuItem
}
}

internal val sharePageMenuItem: View by lazy {
when (omnibarPosition) {
TOP -> topBinding.sharePageMenuItem
Expand Down Expand Up @@ -240,6 +247,8 @@ class BrowserPopupMenu(
newTabMenuItem.isVisible = browserShowing && !displayedInCustomTabScreen
sharePageMenuItem.isVisible = viewState.canSharePage

defaultBrowserMenuItem.isVisible = viewState.showSelectDefaultBrowserMenuItem

bookmarksMenuItem.isVisible = !displayedInCustomTabScreen
downloadsMenuItem.isVisible = !displayedInCustomTabScreen
settingsMenuItem.isVisible = !displayedInCustomTabScreen
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ data class BrowserViewState(
val showTabsButton: Boolean = true,
val fireButton: HighlightableButton = HighlightableButton.Visible(),
val showMenuButton: HighlightableButton = HighlightableButton.Visible(),
val showSelectDefaultBrowserMenuItem: Boolean = false,
val canSharePage: Boolean = false,
val canSaveSite: Boolean = false,
val bookmark: SavedSite.Bookmark? = null,
Expand Down
69 changes: 36 additions & 33 deletions app/src/main/java/com/duckduckgo/app/cta/ui/CtaViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -139,40 +139,41 @@ class CtaViewModel @Inject constructor(
}

suspend fun onCtaShown(cta: Cta) {
cta.shownPixel?.let {
val canSendPixel = when (cta) {
is DaxCta -> cta.canSendShownPixel()
else -> true
withContext(dispatchers.io()) {
cta.shownPixel?.let {
val canSendPixel = when (cta) {
is DaxCta -> cta.canSendShownPixel()
else -> true
}
if (canSendPixel) {
pixel.fire(it, cta.pixelShownParameters())
}
}
if (canSendPixel) {
pixel.fire(it, cta.pixelShownParameters())
if (cta is OnboardingDaxDialogCta && cta.markAsReadOnShow) {
dismissedCtaDao.insert(DismissedCta(cta.ctaId))
}
}
if (cta is OnboardingDaxDialogCta && cta.markAsReadOnShow) {
dismissedCtaDao.insert(DismissedCta(cta.ctaId))
}
if (cta is BrokenSitePromptDialogCta) {
brokenSitePrompt.ctaShown()
}
withContext(dispatchers.io()) {
if (cta is BrokenSitePromptDialogCta) {
brokenSitePrompt.ctaShown()
}

if (cta is DaxBubbleCta.DaxPrivacyProCta || cta is DaxBubbleCta.DaxExperimentPrivacyProCta) {
extendedOnboardingPixelsPlugin.testPrivacyProOnboardingShownMetricPixel()?.getPixelDefinitions()?.forEach {
pixel.fire(it.pixelName, it.params)
}
}
}

// Temporary pixel
val isVisitSiteSuggestionsCta =
cta is DaxBubbleCta.DaxIntroVisitSiteOptionsCta || cta is DaxBubbleCta.DaxExperimentIntroVisitSiteOptionsCta ||
cta is OnboardingDaxDialogCta.DaxSiteSuggestionsCta || cta is OnboardingDaxDialogCta.DaxExperimentSiteSuggestionsCta
if (isVisitSiteSuggestionsCta) {
if (userBrowserProperties.daysSinceInstalled() <= MIN_DAYS_TO_COUNT_ONBOARDING_CTA_SHOWN) {
val count = onboardingStore.visitSiteCtaDisplayCount ?: 0
pixel.fire(AppPixelName.ONBOARDING_VISIT_SITE_CTA_SHOWN, mapOf("count" to count.toString()))
onboardingStore.visitSiteCtaDisplayCount = count + 1
} else {
onboardingStore.clearVisitSiteCtaDisplayCount()
// Temporary pixel
val isVisitSiteSuggestionsCta =
cta is DaxBubbleCta.DaxIntroVisitSiteOptionsCta || cta is DaxBubbleCta.DaxExperimentIntroVisitSiteOptionsCta ||
cta is OnboardingDaxDialogCta.DaxSiteSuggestionsCta || cta is OnboardingDaxDialogCta.DaxExperimentSiteSuggestionsCta
if (isVisitSiteSuggestionsCta) {
if (userBrowserProperties.daysSinceInstalled() <= MIN_DAYS_TO_COUNT_ONBOARDING_CTA_SHOWN) {
val count = onboardingStore.visitSiteCtaDisplayCount ?: 0
pixel.fire(AppPixelName.ONBOARDING_VISIT_SITE_CTA_SHOWN, mapOf("count" to count.toString()))
onboardingStore.visitSiteCtaDisplayCount = count + 1
} else {
onboardingStore.clearVisitSiteCtaDisplayCount()
}
}
}
}
Expand Down Expand Up @@ -250,8 +251,8 @@ class CtaViewModel @Inject constructor(
}

suspend fun getFireDialogCta(): OnboardingDaxDialogCta? {
if (!daxOnboardingActive() || daxDialogFireEducationShown()) return null
return withContext(dispatchers.io()) {
if (!daxOnboardingActive() || daxDialogFireEducationShown()) return@withContext null
if (highlightsOnboardingExperimentManager.isHighlightsEnabled()) {
return@withContext OnboardingDaxDialogCta.DaxExperimentFireButtonCta(onboardingStore, appInstallStore)
} else {
Expand All @@ -261,8 +262,8 @@ class CtaViewModel @Inject constructor(
}

suspend fun getSiteSuggestionsDialogCta(): OnboardingDaxDialogCta? {
if (!daxOnboardingActive() || !canShowDaxIntroVisitSiteCta()) return null
return withContext(dispatchers.io()) {
if (!daxOnboardingActive() || !canShowDaxIntroVisitSiteCta()) return@withContext null
if (highlightsOnboardingExperimentManager.isHighlightsEnabled()) {
return@withContext OnboardingDaxDialogCta.DaxExperimentSiteSuggestionsCta(onboardingStore, appInstallStore)
} else {
Expand All @@ -272,8 +273,8 @@ class CtaViewModel @Inject constructor(
}

suspend fun getEndStaticDialogCta(): OnboardingDaxDialogCta.DaxExperimentEndStaticCta? {
if (!daxOnboardingActive() && daxDialogEndShown()) return null
return withContext(dispatchers.io()) {
if (!daxOnboardingActive() && daxDialogEndShown()) return@withContext null
return@withContext OnboardingDaxDialogCta.DaxExperimentEndStaticCta(onboardingStore, appInstallStore)
}
}
Expand Down Expand Up @@ -473,7 +474,7 @@ class CtaViewModel @Inject constructor(
}
}

private suspend fun isSiteNotAllowedForOnboarding(site: Site): Boolean {
private fun isSiteNotAllowedForOnboarding(site: Site): Boolean {
val uri = site.url.toUri()

if (subscriptions.isPrivacyProUrl(uri)) return true
Expand Down Expand Up @@ -502,9 +503,11 @@ class CtaViewModel @Inject constructor(
// We only want to show New Tab when the Home CTAs from Onboarding has finished
// https://app.asana.com/0/1157893581871903/1207769731595075/f
suspend fun areBubbleDaxDialogsCompleted(): Boolean {
val noBrowserCtaExperiment = extendedOnboardingFeatureToggles.noBrowserCtas().isEnabled()
val bubbleCtasShown = daxDialogEndShown() && (daxDialogNetworkShown() || daxDialogOtherShown() || daxDialogTrackersFoundShown())
return noBrowserCtaExperiment || bubbleCtasShown || hideTips() || !userStageStore.daxOnboardingActive()
return withContext(dispatchers.io()) {
val noBrowserCtaExperiment = extendedOnboardingFeatureToggles.noBrowserCtas().isEnabled()
val bubbleCtasShown = daxDialogEndShown() && (daxDialogNetworkShown() || daxDialogOtherShown() || daxDialogTrackersFoundShown())
noBrowserCtaExperiment || bubbleCtasShown || hideTips() || !userStageStore.daxOnboardingActive()
}
}

private fun daxDialogSerpShown(): Boolean = dismissedCtaDao.exists(CtaId.DAX_DIALOG_SERP)
Expand Down
20 changes: 20 additions & 0 deletions app/src/main/res/drawable/background_default_browser_menu_item.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ Copyright (c) 2024 DuckDuckGo
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/blue0" />
<corners android:radius="@dimen/smallShapeCornerRadius" />
</shape>
4 changes: 4 additions & 0 deletions app/src/main/res/layout/popup_window_browser_menu.xml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@
android:layout_width="match_parent"
android:layout_height="wrap_content" />

<include
android:id="@+id/includeDefaultBrowserMenuItem"
layout="@layout/view_menu_item_default_browser" />

<com.duckduckgo.common.ui.view.MenuItemView
android:id="@+id/sharePageMenuItem"
android:layout_width="match_parent"
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/layout/popup_window_browser_menu_bottom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@
android:layout_width="match_parent"
android:layout_height="wrap_content" />

<include
android:id="@+id/includeDefaultBrowserMenuItem"
layout="@layout/view_menu_item_default_browser" />

<com.duckduckgo.common.ui.view.MenuItemView
android:id="@+id/sharePageMenuItem"
android:layout_width="match_parent"
Expand Down
41 changes: 41 additions & 0 deletions app/src/main/res/layout/view_menu_item_default_browser.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/defaultBrowserMenuItem"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:contentDescription="@string/settingsDefaultBrowserEnabled"
android:paddingHorizontal="12dp">

<!--Menu item's style defines horizontal padding as 24dp but we want the accent background
to bleed by 12 dp, so we're applying 12dp on the parent and 12dp on contents. -->

<LinearLayout
style="@style/Widget.DuckDuckGo.MenuItemView"
android:background="@drawable/background_default_browser_menu_item"
android:paddingHorizontal="12dp">

<ImageView
android:id="@+id/icon"
android:layout_width="@dimen/keyline_4"
android:layout_height="@dimen/keyline_4"
android:layout_gravity="center_vertical"
android:src="@drawable/ic_default_browser_mobile_color_16"
tools:ignore="ContentDescription" />

<com.duckduckgo.common.ui.view.text.DaxTextView
android:id="@+id/label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="@dimen/keyline_2"
android:text="@string/settingsDefaultBrowserEnabled"
android:textColor="@color/blue50"
app:typography="body1"
tools:ignore="InvalidColorAttribute" />

</LinearLayout>

</FrameLayout>
Loading

0 comments on commit 0f06a07

Please sign in to comment.