Skip to content

Commit

Permalink
Merge branch 'release/1.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Lahiru-J committed Jan 25, 2023
2 parents 4f6be1f + d2c2223 commit 244e253
Show file tree
Hide file tree
Showing 10 changed files with 105 additions and 4 deletions.
3 changes: 3 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
10 changes: 9 additions & 1 deletion app/src/main/java/com/stargatex/lib/demo/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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?) {
Expand All @@ -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)
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/raw/account.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "Demo SDK",
"type": "demo-auth"
}
1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ dependencyResolutionManagement {
repositories {
google()
mavenCentral()
mavenLocal()
}
}
rootProject.name = "Demo Lib App"
Expand Down
30 changes: 27 additions & 3 deletions strgtx-demo-android-sdk/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
plugins {
id 'com.android.library'
id 'org.jetbrains.kotlin.android'
id 'maven-publish'
}

android {
Expand Down Expand Up @@ -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)
}
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -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)
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.stargatex.lib.strgtxdemosdk.config

/**
* @author Lahiru J (lahirujay)
* @version 1.0
*/
interface AccountConfiguration {
fun retrieveConfig(resourceId: Int): AccountConfig
}
Original file line number Diff line number Diff line change
@@ -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)
}
Original file line number Diff line number Diff line change
@@ -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)
}

}


4 changes: 4 additions & 0 deletions strgtx-demo-android-sdk/src/main/res/raw/account.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "",
"type": ""
}

0 comments on commit 244e253

Please sign in to comment.