Skip to content

Commit

Permalink
Add dev implementation of subscriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
abdrasulov committed Jan 2, 2025
1 parent 3c29623 commit 66fc4d6
Show file tree
Hide file tree
Showing 11 changed files with 164 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,11 @@ dependencies {
implementation project(':components:chartview')

implementation project(':subscriptions-core')
implementation project(':subscriptions-google-play')

releaseImplementation project(':subscriptions-google-play')
debugImplementation project(':subscriptions-dev')
appcenterdebugImplementation project(':subscriptions-dev')
appcenterreleaseImplementation project(':subscriptions-dev')

// Integration with activities
implementation 'androidx.activity:activity-compose:1.9.3'
Expand Down
1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ include ':components:icons'
include ':components:chartview'
include ':subscriptions-core'
include ':subscriptions-google-play'
include ':subscriptions-dev'
1 change: 1 addition & 0 deletions subscriptions-dev/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
42 changes: 42 additions & 0 deletions subscriptions-dev/build.gradle
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.
21 changes: 21 additions & 0 deletions subscriptions-dev/proguard-rules.pro
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
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)
}
}
13 changes: 13 additions & 0 deletions subscriptions-dev/src/main/AndroidManifest.xml
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>
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
}
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()
}
}
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)
}
}

0 comments on commit 66fc4d6

Please sign in to comment.