-
Notifications
You must be signed in to change notification settings - Fork 392
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add dev implementation of subscriptions
- Loading branch information
1 parent
3c29623
commit 66fc4d6
Showing
11 changed files
with
164 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
plugins { | ||
id 'com.android.library' | ||
id 'org.jetbrains.kotlin.android' | ||
} | ||
|
||
android { | ||
namespace 'io.horizontalsystems.subscriptions.dev' | ||
compileSdk 34 | ||
|
||
defaultConfig { | ||
minSdk 27 | ||
|
||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | ||
consumerProguardFiles "consumer-rules.pro" | ||
} | ||
|
||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_11 | ||
targetCompatibility JavaVersion.VERSION_11 | ||
} | ||
kotlinOptions { | ||
jvmTarget = '11' | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation project(':subscriptions-core') | ||
implementation "androidx.startup:startup-runtime:1.2.0" | ||
|
||
implementation 'androidx.core:core-ktx:1.15.0' | ||
implementation 'androidx.appcompat:appcompat:1.7.0' | ||
implementation 'com.google.android.material:material:1.12.0' | ||
testImplementation 'junit:junit:4.13.2' | ||
androidTestImplementation 'androidx.test.ext:junit:1.2.1' | ||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1' | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Add project specific ProGuard rules here. | ||
# You can control the set of applied configuration files using the | ||
# proguardFiles setting in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |
22 changes: 22 additions & 0 deletions
22
...ev/src/androidTest/java/io/horizontalsystems/subscriptions/dev/ExampleInstrumentedTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package io.horizontalsystems.subscriptions.dev | ||
|
||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
import androidx.test.platform.app.InstrumentationRegistry | ||
import org.junit.Assert.assertEquals | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
/** | ||
* Instrumented test, which will execute on an Android device. | ||
* | ||
* See [testing documentation](http://d.android.com/tools/testing). | ||
*/ | ||
@RunWith(AndroidJUnit4::class) | ||
class ExampleInstrumentedTest { | ||
@Test | ||
fun useAppContext() { | ||
// Context of the app under test. | ||
val appContext = InstrumentationRegistry.getInstrumentation().targetContext | ||
assertEquals("io.horizontalsystems.subscriptions.dev.test", appContext.packageName) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools"> | ||
<application> | ||
<provider android:name="androidx.startup.InitializationProvider" | ||
android:authorities="${applicationId}.androidx-startup" | ||
android:exported="false" | ||
tools:node="merge"> | ||
<meta-data android:name="io.horizontalsystems.subscriptions.dev.SubscriptionServiceInitializer" | ||
android:value="androidx.startup" /> | ||
</provider> | ||
</application> | ||
</manifest> |
26 changes: 26 additions & 0 deletions
26
...ptions-dev/src/main/java/io/horizontalsystems/subscriptions/dev/SubscriptionServiceDev.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package io.horizontalsystems.subscriptions.dev | ||
|
||
import android.app.Activity | ||
import io.horizontalsystems.subscriptions.core.BasePlan | ||
import io.horizontalsystems.subscriptions.core.IPaidAction | ||
import io.horizontalsystems.subscriptions.core.Subscription | ||
import io.horizontalsystems.subscriptions.core.SubscriptionService | ||
|
||
class SubscriptionServiceDev : SubscriptionService { | ||
|
||
override var predefinedSubscriptions: List<Subscription> = listOf() | ||
|
||
override suspend fun onResume() = Unit | ||
|
||
override fun isActionAllowed(paidAction: IPaidAction) = true | ||
|
||
override fun getBasePlans(subscriptionId: String): List<BasePlan> = listOf() | ||
|
||
override suspend fun getSubscriptions(): List<Subscription> = listOf() | ||
|
||
override suspend fun launchPurchaseFlow( | ||
subscriptionId: String, | ||
planId: String, | ||
activity: Activity, | ||
) = null | ||
} |
17 changes: 17 additions & 0 deletions
17
...ev/src/main/java/io/horizontalsystems/subscriptions/dev/SubscriptionServiceInitializer.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package io.horizontalsystems.subscriptions.dev | ||
|
||
import android.content.Context | ||
import androidx.startup.Initializer | ||
import io.horizontalsystems.subscriptions.core.UserSubscriptionManager | ||
|
||
class SubscriptionServiceInitializer : Initializer<SubscriptionServiceDev> { | ||
override fun create(context: Context): SubscriptionServiceDev { | ||
val service = SubscriptionServiceDev() | ||
UserSubscriptionManager.registerService(service) | ||
return service | ||
} | ||
|
||
override fun dependencies(): List<Class<out Initializer<*>>> { | ||
return emptyList() | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
subscriptions-dev/src/test/java/io/horizontalsystems/subscriptions/dev/ExampleUnitTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package io.horizontalsystems.subscriptions.dev | ||
|
||
import org.junit.Assert.assertEquals | ||
import org.junit.Test | ||
|
||
/** | ||
* Example local unit test, which will execute on the development machine (host). | ||
* | ||
* See [testing documentation](http://d.android.com/tools/testing). | ||
*/ | ||
class ExampleUnitTest { | ||
@Test | ||
fun addition_isCorrect() { | ||
assertEquals(4, 2 + 2) | ||
} | ||
} |