Skip to content

Commit 6942db5

Browse files
committed
Merge branch 'release/5.31.0'
2 parents bf0dba3 + e2d7bac commit 6942db5

File tree

59 files changed

+498
-681
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+498
-681
lines changed

app/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ android {
3636
}
3737
buildTypes {
3838
debug {
39+
pseudoLocalesEnabled false
3940
}
4041
release {
4142
minifyEnabled false

app/src/androidTest/java/com/duckduckgo/app/browser/WebViewRequestInterceptorTest.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,7 @@ class WebViewRequestInterceptorTest {
313313

314314
private fun configureShouldUpgrade() = runBlocking<Unit> {
315315
whenever(mockHttpsUpgrader.shouldUpgrade(any())).thenReturn(true)
316+
whenever(mockHttpsUpgrader.upgrade(any())).thenReturn(validHttpsUri())
316317
whenever(mockRequest.url).thenReturn(validUri())
317318
whenever(mockRequest.isForMainFrame).thenReturn(true)
318319
}
@@ -325,6 +326,7 @@ class WebViewRequestInterceptorTest {
325326
}
326327

327328
private fun validUri() = Uri.parse("example.com")
329+
private fun validHttpsUri() = Uri.parse("https://example.com")
328330

329331
private fun assertCancelledResponse(response: WebResourceResponse?) {
330332
assertNotNull(response)

app/src/androidTest/java/com/duckduckgo/app/onboarding/ui/OnboardingPageManagerPageCountTest.kt

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@
1717
package com.duckduckgo.app.onboarding.ui
1818

1919
import com.duckduckgo.app.browser.defaultbrowsing.DefaultBrowserDetector
20-
import com.duckduckgo.app.statistics.Variant
21-
import com.duckduckgo.app.statistics.VariantManager
22-
import com.duckduckgo.app.statistics.VariantManager.VariantFeature
2320
import com.nhaarman.mockitokotlin2.mock
2421
import com.nhaarman.mockitokotlin2.whenever
2522
import org.junit.Assert.assertEquals
@@ -32,32 +29,22 @@ import org.junit.runners.Parameterized
3229
class OnboardingPageManagerPageCountTest(private val testCase: TestCase) {
3330

3431
private lateinit var testee: OnboardingPageManager
35-
private val variantManager: VariantManager = mock()
3632
private val onboardingPageBuilder: OnboardingPageBuilder = mock()
3733
private val mockDefaultBrowserDetector: DefaultBrowserDetector = mock()
3834

3935
@Before
4036
fun setup() {
41-
testee = OnboardingPageManagerWithTrackerBlocking(variantManager, onboardingPageBuilder, mockDefaultBrowserDetector)
37+
testee = OnboardingPageManagerWithTrackerBlocking(onboardingPageBuilder, mockDefaultBrowserDetector)
4238
}
4339

4440
@Test
4541
fun ensurePageCountAsExpected() {
4642
configureDefaultBrowserPageConfig()
47-
configureTrackerBlockerOptInPageConfig()
4843

4944
testee.buildPageBlueprints()
5045
assertEquals(testCase.expectedPageCount, testee.pageCount())
5146
}
5247

53-
private fun configureTrackerBlockerOptInPageConfig() {
54-
if (testCase.trackerBlockerOptInPage) {
55-
configureShowTrackerBlockerOptInPage()
56-
} else {
57-
configureHideTrackerBlockerOptInPage()
58-
}
59-
}
60-
6148
private fun configureDefaultBrowserPageConfig() {
6249
if (testCase.defaultBrowserPage) {
6350
configureDeviceSupportsDefaultBrowser()
@@ -72,10 +59,8 @@ class OnboardingPageManagerPageCountTest(private val testCase: TestCase) {
7259
@Parameterized.Parameters(name = "Test case: {index} - {0}")
7360
fun testData(): Array<TestCase> {
7461
return arrayOf(
75-
TestCase(false, false, 1),
76-
TestCase(false, true, 2),
77-
TestCase(true, false, 2),
78-
TestCase(true, true, 3)
62+
TestCase(false, 1),
63+
TestCase(true, 2)
7964
)
8065
}
8166
}
@@ -88,13 +73,5 @@ class OnboardingPageManagerPageCountTest(private val testCase: TestCase) {
8873
whenever(mockDefaultBrowserDetector.deviceSupportsDefaultBrowserConfiguration()).thenReturn(false)
8974
}
9075

91-
private fun configureShowTrackerBlockerOptInPage() {
92-
whenever(variantManager.getVariant()).thenReturn(Variant("test", features = listOf(VariantFeature.TrackerBlockingOnboardingOptIn)))
93-
}
94-
95-
private fun configureHideTrackerBlockerOptInPage() {
96-
whenever(variantManager.getVariant()).thenReturn(Variant("test", features = emptyList()))
97-
}
98-
99-
data class TestCase(val trackerBlockerOptInPage: Boolean, val defaultBrowserPage: Boolean, val expectedPageCount: Int)
76+
data class TestCase(val defaultBrowserPage: Boolean, val expectedPageCount: Int)
10077
}

app/src/androidTest/java/com/duckduckgo/app/onboarding/ui/OnboardingPageManagerTest.kt

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ package com.duckduckgo.app.onboarding.ui
1818

1919
import com.duckduckgo.app.browser.R
2020
import com.duckduckgo.app.browser.defaultbrowsing.DefaultBrowserDetector
21-
import com.duckduckgo.app.statistics.Variant
2221
import com.duckduckgo.app.statistics.VariantManager
2322
import com.nhaarman.mockitokotlin2.mock
2423
import com.nhaarman.mockitokotlin2.whenever
@@ -35,40 +34,25 @@ class OnboardingPageManagerTest {
3534

3635
@Before
3736
fun setup() {
38-
testee = OnboardingPageManagerWithTrackerBlocking(variantManager, onboardingPageBuilder, mockDefaultBrowserDetector)
37+
testee = OnboardingPageManagerWithTrackerBlocking(onboardingPageBuilder, mockDefaultBrowserDetector)
3938
}
4039

4140
@Test
42-
fun whenDefaultBrowserSupportedAndTrackerBlockingOptInSupportedThenFirstPageShowsContinueTextOnButton() {
41+
fun whenDefaultBrowserSupportedThenFirstPageShowsContinueTextOnButton() {
4342
configureDeviceSupportsDefaultBrowser()
44-
configureShouldShowTrackerBlockerOptIn()
4543
testee.buildPageBlueprints()
4644
val resourceId = testee.getContinueButtonTextResourceId(0)
4745
assertEquals(R.string.onboardingContinue, resourceId)
4846
}
4947

5048
@Test
51-
fun whenDefaultBrowserNotSupportedAndTrackerBlockingOptInNotSupportedThenFirstPageShowsFinalTextOnButton() {
49+
fun whenDefaultBrowserNotSupportedThenFirstPageShowsFinalTextOnButton() {
5250
configureDeviceDoesNotSupportDefaultBrowser()
53-
configureShouldNotShowTrackerBlockerOptIn()
5451
testee.buildPageBlueprints()
5552
val resourceId = testee.getContinueButtonTextResourceId(0)
5653
assertEquals(R.string.onboardingContinueFinalPage, resourceId)
5754
}
5855

59-
private fun configureShouldNotShowTrackerBlockerOptIn() {
60-
whenever(variantManager.getVariant()).thenReturn(Variant("test", features = emptyList()))
61-
}
62-
63-
private fun configureShouldShowTrackerBlockerOptIn() {
64-
whenever(variantManager.getVariant()).thenReturn(
65-
Variant(
66-
"test",
67-
features = listOf(VariantManager.VariantFeature.TrackerBlockingOnboardingOptIn)
68-
)
69-
)
70-
}
71-
7256
private fun configureDeviceSupportsDefaultBrowser() {
7357
whenever(mockDefaultBrowserDetector.deviceSupportsDefaultBrowserConfiguration()).thenReturn(true)
7458
}

app/src/androidTest/java/com/duckduckgo/app/onboarding/ui/OnboardingViewModelTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ class OnboardingViewModelTest {
4343
private val mockDefaultBrowserCapabilityDetector: DefaultBrowserDetector = mock()
4444
private val pixelSender: Pixel = mock()
4545
private val mockPageLayout: OnboardingPageManager =
46-
OnboardingPageManagerWithTrackerBlocking(variantManager, OnboardingFragmentPageBuilder(), mockDefaultBrowserCapabilityDetector)
46+
OnboardingPageManagerWithTrackerBlocking(OnboardingFragmentPageBuilder(), mockDefaultBrowserCapabilityDetector)
4747

4848
private val testee: OnboardingViewModel by lazy {
49-
OnboardingViewModel(onboardingStore, privacySettingsStore, mockPageLayout, variantManager, pixelSender)
49+
OnboardingViewModel(onboardingStore, mockPageLayout)
5050
}
5151

5252
@Test

app/src/main/AndroidManifest.xml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,16 +71,19 @@
7171
<!-- Allows apps to consume links and text shared from other apps e.g chrome -->
7272
<intent-filter>
7373
<action android:name="android.intent.action.SEND" />
74-
7574
<category android:name="android.intent.category.DEFAULT" />
76-
7775
<data android:mimeType="text/plain" />
7876
</intent-filter>
7977

8078
<!-- Allow app to be default assistant -->
8179
<intent-filter>
8280
<action android:name="android.intent.action.ASSIST" />
81+
<category android:name="android.intent.category.DEFAULT" />
82+
</intent-filter>
8383

84+
<!-- Required to allow the browser to be launched externally, ensuring it is ready to allow users to search immediately -->
85+
<intent-filter>
86+
<action android:name="com.duckduckgo.mobile.android.NEW_SEARCH"/>
8487
<category android:name="android.intent.category.DEFAULT" />
8588
</intent-filter>
8689
</activity>

app/src/main/java/com/duckduckgo/app/browser/BrowserActivity.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ class BrowserActivity : DuckDuckGoActivity(), CoroutineScope {
253253
}
254254

255255
private fun launchNewSearch(intent: Intent): Boolean {
256-
return intent.getBooleanExtra(NEW_SEARCH_EXTRA, false) || intent.action == Intent.ACTION_ASSIST
256+
return intent.getBooleanExtra(NEW_SEARCH_EXTRA, false) || intent.action == Intent.ACTION_ASSIST || intent.action == NEW_SEARCH_ACTION
257257
}
258258

259259
fun launchPrivacyDashboard() {
@@ -321,6 +321,7 @@ class BrowserActivity : DuckDuckGoActivity(), CoroutineScope {
321321
return intent
322322
}
323323

324+
const val NEW_SEARCH_ACTION = "com.duckduckgo.mobile.android.NEW_SEARCH"
324325
const val NEW_SEARCH_EXTRA = "NEW_SEARCH_EXTRA"
325326
const val WIDGET_SEARCH_EXTRA = "WIDGET_SEARCH_EXTRA"
326327
const val PERFORM_FIRE_ON_ENTRY_EXTRA = "PERFORM_FIRE_ON_ENTRY_EXTRA"

app/src/main/java/com/duckduckgo/app/browser/WebViewRequestInterceptor.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ import com.duckduckgo.app.privacy.model.TrustedSites
2727
import com.duckduckgo.app.surrogates.ResourceSurrogates
2828
import com.duckduckgo.app.trackerdetection.TrackerDetector
2929
import com.duckduckgo.app.trackerdetection.model.ResourceType
30+
import kotlinx.coroutines.Dispatchers
31+
import kotlinx.coroutines.withContext
3032
import timber.log.Timber
3133

3234
interface RequestInterceptor {
@@ -69,7 +71,11 @@ class WebViewRequestInterceptor(
6971

7072
if (shouldUpgrade(request)) {
7173
val newUri = httpsUpgrader.upgrade(url)
72-
webView.post { webView.loadUrl(newUri.toString()) }
74+
75+
withContext(Dispatchers.Main) {
76+
webView.loadUrl(newUri.toString())
77+
}
78+
7379
privacyProtectionCountDao.incrementUpgradeCount()
7480
return WebResourceResponse(null, null, null)
7581
}

app/src/main/java/com/duckduckgo/app/di/AndroidBindingModule.kt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ import com.duckduckgo.app.launch.LaunchActivity
3737
import com.duckduckgo.app.notification.NotificationHandlerService
3838
import com.duckduckgo.app.onboarding.ui.OnboardingActivity
3939
import com.duckduckgo.app.onboarding.ui.page.DefaultBrowserPage
40-
import com.duckduckgo.app.onboarding.ui.page.TrackerBlockerOptInPage
4140
import com.duckduckgo.app.onboarding.ui.page.UnifiedSummaryPage
4241
import com.duckduckgo.app.privacy.ui.PrivacyDashboardActivity
4342
import com.duckduckgo.app.privacy.ui.PrivacyPracticesActivity
@@ -155,9 +154,6 @@ abstract class AndroidBindingModule {
155154
@ContributesAndroidInjector
156155
abstract fun brokenSiteNegativeFeedbackFragment(): BrokenSiteNegativeFeedbackFragment
157156

158-
@ContributesAndroidInjector
159-
abstract fun trackerBlockingOptInPage(): TrackerBlockerOptInPage
160-
161157
@ContributesAndroidInjector
162158
abstract fun unifiedSummaryPage(): UnifiedSummaryPage
163159

app/src/main/java/com/duckduckgo/app/global/ViewModelFactory.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ class ViewModelFactory @Inject constructor(
133133
}
134134
} as T
135135

136-
private fun onboardingViewModel() = OnboardingViewModel(onboardingStore, privacySettingsStore, onboardingPageManager, variantManager, pixel)
136+
private fun onboardingViewModel() = OnboardingViewModel(onboardingStore, onboardingPageManager)
137137

138138
private fun settingsViewModel(): SettingsViewModel {
139139
return SettingsViewModel(

0 commit comments

Comments
 (0)