Skip to content

Commit 471a8f2

Browse files
authored
Use dummy subscriptions for fdroid flavor (#4683)
Task/Issue URL: https://app.asana.com/0/1205648422731273/1207600736669442/f ### Description This PR adds dummy implementation of subscriptions-api and makes the fdroid flavor of the app depend on it instead of the actual implementation. The goal is to remove dependency on Google Play Billing Library from the F-Droid builds of the app. ### Steps to test this PR See task. ### No UI changes
1 parent 87f910c commit 471a8f2

File tree

3 files changed

+104
-1
lines changed

3 files changed

+104
-1
lines changed

app/build.gradle

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,10 @@ dependencies {
308308

309309
implementation project(':subscriptions-api')
310310

311-
implementation project(':subscriptions-impl')
311+
internalImplementation project(':subscriptions-impl')
312+
playImplementation project(':subscriptions-impl')
313+
fdroidImplementation project(':subscriptions-dummy-impl')
314+
312315
internalImplementation project(':subscriptions-internal')
313316

314317
implementation project(':user-agent-api')
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
* Copyright (c) 2021 DuckDuckGo
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
plugins {
18+
id 'com.android.library'
19+
id 'kotlin-android'
20+
id 'com.squareup.anvil'
21+
}
22+
23+
apply from: "$rootProject.projectDir/gradle/android-library.gradle"
24+
25+
dependencies {
26+
anvil project(path: ':anvil-compiler')
27+
implementation project(':anvil-annotations')
28+
implementation project(':di')
29+
implementation project(':subscriptions-api')
30+
31+
implementation KotlinX.coroutines.android
32+
implementation Google.dagger
33+
34+
coreLibraryDesugaring Android.tools.desugarJdkLibs
35+
}
36+
37+
android {
38+
namespace "com.duckduckgo.subscriptions.dummy.impl"
39+
anvil {
40+
generateDaggerFactories = true // default is false
41+
}
42+
testOptions {
43+
unitTests {
44+
includeAndroidResources = true
45+
}
46+
}
47+
compileOptions {
48+
coreLibraryDesugaringEnabled = true
49+
}
50+
}
51+
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
* Copyright (c) 2024 DuckDuckGo
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.duckduckgo.subscriptions.impl
18+
19+
import android.content.Context
20+
import android.net.Uri
21+
import com.duckduckgo.di.scopes.AppScope
22+
import com.duckduckgo.subscriptions.api.Product
23+
import com.duckduckgo.subscriptions.api.SubscriptionStatus
24+
import com.duckduckgo.subscriptions.api.SubscriptionStatus.UNKNOWN
25+
import com.duckduckgo.subscriptions.api.Subscriptions
26+
import com.squareup.anvil.annotations.ContributesBinding
27+
import javax.inject.Inject
28+
import kotlinx.coroutines.flow.Flow
29+
import kotlinx.coroutines.flow.flowOf
30+
31+
@ContributesBinding(AppScope::class)
32+
class SubscriptionsDummy @Inject constructor() : Subscriptions {
33+
override suspend fun getAccessToken(): String? = null
34+
35+
override fun getEntitlementStatus(): Flow<List<Product>> = flowOf(emptyList())
36+
37+
override suspend fun isEligible(): Boolean = false
38+
39+
override suspend fun getSubscriptionStatus(): SubscriptionStatus = UNKNOWN
40+
41+
override fun shouldLaunchPrivacyProForUrl(url: String): Boolean = false
42+
43+
override fun launchPrivacyPro(
44+
context: Context,
45+
uri: Uri?,
46+
) {
47+
// no-op
48+
}
49+
}

0 commit comments

Comments
 (0)