diff --git a/app/build.gradle b/app/build.gradle index 70310d2..90e52b7 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -54,6 +54,9 @@ dependencies { implementation "androidx.compose.ui:ui:$compose_version" implementation "androidx.compose.ui:ui-tooling-preview:$compose_version" implementation 'androidx.compose.material3:material3:1.0.0-alpha02' + + implementation 'com.github.stargatex:strgtx-demo-android-sdk:1.0.0' + testImplementation 'junit:junit:4.13.2' androidTestImplementation 'androidx.test.ext:junit:1.1.5' androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' diff --git a/app/src/main/java/com/stargatex/lib/demo/MainActivity.kt b/app/src/main/java/com/stargatex/lib/demo/MainActivity.kt index 099654e..c5e0f68 100644 --- a/app/src/main/java/com/stargatex/lib/demo/MainActivity.kt +++ b/app/src/main/java/com/stargatex/lib/demo/MainActivity.kt @@ -11,6 +11,9 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.tooling.preview.Preview import com.stargatex.lib.demo.ui.theme.DemoLibAppTheme +import com.stargatex.lib.strgtxdemosdk.config.AccountConfig +import com.stargatex.lib.strgtxdemosdk.config.AccountConfigurationStore +import com.stargatex.lib.strgtxdemosdk.config.DefaultAccountConfiguration class MainActivity : ComponentActivity() { override fun onCreate(savedInstanceState: Bundle?) { @@ -22,7 +25,12 @@ class MainActivity : ComponentActivity() { modifier = Modifier.fillMaxSize(), color = MaterialTheme.colorScheme.background ) { - Greeting("Android") + val accountConfig: AccountConfig = + AccountConfigurationStore.loadAccountConfiguration( + DefaultAccountConfiguration(this), + R.raw.account + ) + Greeting(accountConfig.name) } } } diff --git a/app/src/main/res/raw/account.json b/app/src/main/res/raw/account.json new file mode 100644 index 0000000..22a42ba --- /dev/null +++ b/app/src/main/res/raw/account.json @@ -0,0 +1,4 @@ +{ + "name": "Demo SDK", + "type": "demo-auth" +} \ No newline at end of file diff --git a/settings.gradle b/settings.gradle index 8acda54..cf7a739 100644 --- a/settings.gradle +++ b/settings.gradle @@ -10,6 +10,7 @@ dependencyResolutionManagement { repositories { google() mavenCentral() + mavenLocal() } } rootProject.name = "Demo Lib App" diff --git a/strgtx-demo-android-sdk/build.gradle b/strgtx-demo-android-sdk/build.gradle index ae64a8a..a768175 100644 --- a/strgtx-demo-android-sdk/build.gradle +++ b/strgtx-demo-android-sdk/build.gradle @@ -1,6 +1,7 @@ plugins { id 'com.android.library' id 'org.jetbrains.kotlin.android' + id 'maven-publish' } android { @@ -32,10 +33,33 @@ android { dependencies { - implementation 'androidx.core:core-ktx:1.7.0' - implementation 'androidx.appcompat:appcompat:1.6.0' - implementation 'com.google.android.material:material:1.7.0' + implementation "com.squareup.okio:okio:3.2.0" + implementation "com.google.code.gson:gson:2.9.0" + testImplementation 'junit:junit:4.13.2' androidTestImplementation 'androidx.test.ext:junit:1.1.5' androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' +} + +afterEvaluate { + publishing { + publications{ + library(MavenPublication){ + setGroupId 'com.github.stargatex' + setArtifactId 'strgtx-demo-android-sdk' + version '1.0.0' + artifact bundleReleaseAar + + pom.withXml { + def dependenciesNode = asNode().appendNode('dependencies') + configurations.implementation.allDependencies.each { dependency -> + final dependencyNode = dependenciesNode.appendNode('dependency') + dependencyNode.appendNode('groupId', dependency.group) + dependencyNode.appendNode('artifactId', dependency.name) + dependencyNode.appendNode('version', dependency.version) + } + } + } + } + } } \ No newline at end of file diff --git a/strgtx-demo-android-sdk/src/main/java/com/stargatex/lib/strgtxdemosdk/config/AccountConfig.kt b/strgtx-demo-android-sdk/src/main/java/com/stargatex/lib/strgtxdemosdk/config/AccountConfig.kt new file mode 100644 index 0000000..3e47352 --- /dev/null +++ b/strgtx-demo-android-sdk/src/main/java/com/stargatex/lib/strgtxdemosdk/config/AccountConfig.kt @@ -0,0 +1,7 @@ +package com.stargatex.lib.strgtxdemosdk.config + +/** + * @author Lahiru J (lahirujay) + * @version 1.0 + */ +data class AccountConfig(var name: String, var type: String) diff --git a/strgtx-demo-android-sdk/src/main/java/com/stargatex/lib/strgtxdemosdk/config/AccountConfiguration.kt b/strgtx-demo-android-sdk/src/main/java/com/stargatex/lib/strgtxdemosdk/config/AccountConfiguration.kt new file mode 100644 index 0000000..aef95b4 --- /dev/null +++ b/strgtx-demo-android-sdk/src/main/java/com/stargatex/lib/strgtxdemosdk/config/AccountConfiguration.kt @@ -0,0 +1,9 @@ +package com.stargatex.lib.strgtxdemosdk.config + +/** + * @author Lahiru J (lahirujay) + * @version 1.0 + */ +interface AccountConfiguration { + fun retrieveConfig(resourceId: Int): AccountConfig +} \ No newline at end of file diff --git a/strgtx-demo-android-sdk/src/main/java/com/stargatex/lib/strgtxdemosdk/config/AccountConfigurationStore.kt b/strgtx-demo-android-sdk/src/main/java/com/stargatex/lib/strgtxdemosdk/config/AccountConfigurationStore.kt new file mode 100644 index 0000000..0910e07 --- /dev/null +++ b/strgtx-demo-android-sdk/src/main/java/com/stargatex/lib/strgtxdemosdk/config/AccountConfigurationStore.kt @@ -0,0 +1,14 @@ +package com.stargatex.lib.strgtxdemosdk.config + +/** + * @author Lahiru J (lahirujay) + * @version 1.0 + */ +object AccountConfigurationStore { + + fun loadAccountConfiguration( + accountConfiguration: AccountConfiguration, + resourceId: Int + ): AccountConfig = + accountConfiguration.retrieveConfig(resourceId) +} \ No newline at end of file diff --git a/strgtx-demo-android-sdk/src/main/java/com/stargatex/lib/strgtxdemosdk/config/DefaultAccountConfiguration.kt b/strgtx-demo-android-sdk/src/main/java/com/stargatex/lib/strgtxdemosdk/config/DefaultAccountConfiguration.kt new file mode 100644 index 0000000..d909b41 --- /dev/null +++ b/strgtx-demo-android-sdk/src/main/java/com/stargatex/lib/strgtxdemosdk/config/DefaultAccountConfiguration.kt @@ -0,0 +1,27 @@ +package com.stargatex.lib.strgtxdemosdk.config + + +import android.content.Context +import com.google.gson.Gson +import okio.Buffer +import okio.buffer +import okio.source +import java.nio.charset.Charset + +/** + * @author Lahiru J (lahirujay) + * @version 1.0 + */ +class DefaultAccountConfiguration(private val context: Context) : AccountConfiguration { + override fun retrieveConfig(resourceId: Int): AccountConfig { + val configBuffer = Buffer() + val rawResourceBufferedSource = + context.resources.openRawResource(resourceId).source().buffer() + rawResourceBufferedSource.readAll(configBuffer) + val jsonString = configBuffer.readString(Charset.forName("UTF-8")) + return Gson().fromJson(jsonString, AccountConfig::class.java) + } + +} + + diff --git a/strgtx-demo-android-sdk/src/main/res/raw/account.json b/strgtx-demo-android-sdk/src/main/res/raw/account.json new file mode 100644 index 0000000..a9e519d --- /dev/null +++ b/strgtx-demo-android-sdk/src/main/res/raw/account.json @@ -0,0 +1,4 @@ +{ + "name": "", + "type": "" +} \ No newline at end of file