Skip to content

Commit 5a03727

Browse files
authored
Merge pull request #15 from stslex/dev
init google auth for android and signing
2 parents 3307e1b + 26bc564 commit 5a03727

60 files changed

Lines changed: 942 additions & 332 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/build_linux.yml

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ jobs:
1818
- name: Checkout branch
1919
uses: actions/checkout@v2
2020

21+
- run: |
22+
echo "${{ secrets.KEYSTORE }}" > keystore.jks.asc
23+
gpg -d --passphrase "${{ secrets.KEYSTORE_PASSPHRASE }}" --batch keystore.jks.asc > keystore.jks
24+
2125
- name: set up JDK 17
2226
uses: actions/setup-java@v3
2327
with:
@@ -28,11 +32,21 @@ jobs:
2832
- name: Grant execute permission for gradlew
2933
run: chmod +x gradlew
3034

31-
# local properties not needed now
32-
# - name: set up LOCAL_PROPERTIES
33-
# env:
34-
# LOCAL_PROPERTIES: ${{ secrets.LOCAL_PROPERTIES }}
35-
# run: echo "$LOCAL_PROPERTIES" > ./local.properties
35+
- name: Configure Keystore
36+
env:
37+
KEYSTORE_KEY_ALIAS: ${{ secrets.KEYSTORE_KEY_ALIAS }}
38+
KEYSTORE_KEY_PASSWORD: ${{ secrets.KEYSTORE_KEY_PASSWORD }}
39+
KEYSTORE_STORE_PASSWORD: ${{ secrets.KEYSTORE_STORE_PASSWORD }}
40+
run: |
41+
echo "storeFile=keystore.jks" >> keystore.properties
42+
echo "keyAlias=$KEYSTORE_KEY_ALIAS" >> keystore.properties
43+
echo "storePassword=$KEYSTORE_STORE_PASSWORD" >> keystore.properties
44+
echo "keyPassword=$KEYSTORE_KEY_PASSWORD" >> keystore.properties
45+
46+
- name: set up LOCAL_PROPERTIES
47+
env:
48+
LOCAL_PROPERTIES: ${{ secrets.LOCAL_PROPERTIES }}
49+
run: echo "$LOCAL_PROPERTIES" > ./local.properties
3650

3751
- name: Build with Gradle
38-
run: ./gradlew assembleAndroidTest
52+
run: ./gradlew assembleAndroidTest

.github/workflows/build_mac_os.yml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ jobs:
1616
- name: Checkout branch
1717
uses: actions/checkout@v4
1818

19+
- run: |
20+
echo "${{ secrets.KEYSTORE }}" > keystore.jks.asc
21+
gpg -d --passphrase "${{ secrets.KEYSTORE_PASSPHRASE }}" --batch keystore.jks.asc > keystore.jks
22+
1923
- name: Set up JDK 21
2024
uses: actions/setup-java@v4
2125
with:
@@ -28,6 +32,17 @@ jobs:
2832
- name: Set Xcode version
2933
run: sudo xcode-select -s /Applications/Xcode_15.3.app/Contents/Developer
3034

35+
- name: Configure Keystore
36+
env:
37+
KEYSTORE_KEY_ALIAS: ${{ secrets.KEYSTORE_KEY_ALIAS }}
38+
KEYSTORE_KEY_PASSWORD: ${{ secrets.KEYSTORE_KEY_PASSWORD }}
39+
KEYSTORE_STORE_PASSWORD: ${{ secrets.KEYSTORE_STORE_PASSWORD }}
40+
run: |
41+
echo "storeFile=keystore.jks" >> keystore.properties
42+
echo "keyAlias=$KEYSTORE_KEY_ALIAS" >> keystore.properties
43+
echo "storePassword=$KEYSTORE_STORE_PASSWORD" >> keystore.properties
44+
echo "keyPassword=$KEYSTORE_KEY_PASSWORD" >> keystore.properties
45+
3146
- name: set up LOCAL_PROPERTIES
3247
env:
3348
LOCAL_PROPERTIES: ${{ secrets.LOCAL_PROPERTIES }}
@@ -37,4 +52,4 @@ jobs:
3752
run: ./gradlew kspKotlinMetadata
3853

3954
- name: Build with Gradle
40-
run: cd iosApp && xcodebuild -workspace ./iosApp.xcworkspace -scheme iosApp -configuration Debug -destination 'platform=iOS Simulator,OS=latest,name=iPhone 15' CODE_SIGNING_ALLOWED='NO'
55+
run: cd iosApp && xcodebuild -workspace ./iosApp.xcworkspace -scheme iosApp -configuration Debug -destination 'platform=iOS Simulator,OS=latest,name=iPhone 15' CODE_SIGNING_ALLOWED='NO'

build-logic/convention/src/main/kotlin/KMPApplicationConventionPlugin.kt

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ import com.stslex.atten.convention.configureKsp
1414
import org.gradle.api.Plugin
1515
import org.gradle.api.Project
1616
import org.gradle.kotlin.dsl.configure
17+
import java.io.File
18+
import java.io.FileInputStream
19+
import java.io.InputStreamReader
20+
import java.util.Properties
1721

1822
class KMPApplicationConventionPlugin : Plugin<Project> {
1923

@@ -43,5 +47,61 @@ class KMPApplicationConventionPlugin : Plugin<Project> {
4347
versionCode = libs.findVersionInt("versionCode")
4448
}
4549
}
50+
configureSigning()
4651
}
52+
}
53+
54+
fun Project.configureSigning() = extensions.configure<ApplicationExtension> {
55+
signingConfigs {
56+
val keystoreProperties = gradleKeystoreProperties(project.rootProject.projectDir)
57+
create("release") {
58+
keyAlias = keystoreProperties.getProperty("keyAlias")
59+
keyPassword = keystoreProperties.getProperty("keyPassword")
60+
storeFile = project.getFile(keystoreProperties.getProperty("storeFile"))
61+
storePassword = keystoreProperties.getProperty("storePassword")
62+
}
63+
with(getByName("debug")) {
64+
keyAlias = keystoreProperties.getProperty("keyAlias")
65+
keyPassword = keystoreProperties.getProperty("keyPassword")
66+
storeFile = project.getFile(keystoreProperties.getProperty("storeFile"))
67+
storePassword = keystoreProperties.getProperty("storePassword")
68+
}
69+
}
70+
buildTypes {
71+
getByName("release") {
72+
isMinifyEnabled = false
73+
proguardFiles(
74+
getDefaultProguardFile("proguard-android-optimize.txt"),
75+
"proguard-rules.pro"
76+
)
77+
signingConfig = signingConfigs.getByName("release")
78+
isDebuggable = false
79+
}
80+
getByName("debug") {
81+
signingConfig = signingConfigs.getByName("debug")
82+
isDebuggable = true
83+
}
84+
}
85+
}
86+
87+
88+
fun Project.getFile(path: String): File {
89+
val file = File(project.rootProject.projectDir, path)
90+
if (file.isFile) {
91+
return file
92+
} else {
93+
throw IllegalStateException("${file.name} is inValid")
94+
}
95+
}
96+
97+
fun gradleKeystoreProperties(projectRootDir: File): Properties {
98+
val properties = Properties()
99+
val localProperties = File(projectRootDir, "keystore.properties")
100+
101+
if (localProperties.isFile) {
102+
InputStreamReader(FileInputStream(localProperties), Charsets.UTF_8).use { reader ->
103+
properties.load(reader)
104+
}
105+
}
106+
return properties
47107
}

commonApp/build.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@ kotlin {
1313
implementation(project(":core:database"))
1414
implementation(project(":core:paging"))
1515
implementation(project(":core:todo"))
16+
implementation(project(":core:auth"))
1617

1718
implementation(project(":feature:home"))
1819
implementation(project(":feature:details"))
20+
implementation(project(":feature:settings"))
1921
}
2022
}
2123
}

commonApp/src/androidMain/kotlin/com/stslex/atten/MainActivity.kt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,21 @@ import androidx.core.view.WindowCompat
1010
import androidx.lifecycle.compose.LocalLifecycleOwner
1111
import com.arkivanov.decompose.DefaultComponentContext
1212
import com.arkivanov.decompose.defaultComponentContext
13+
import com.stslex.atten.core.ui.kit.utils.ActivityHolderProducer
1314
import com.stslex.atten.host.DefaultRootComponent
15+
import org.koin.android.ext.android.getKoin
1416

1517
class MainActivity : ComponentActivity() {
1618

19+
private val activityProducer: ActivityHolderProducer by lazy { getKoin().get() }
20+
1721
override fun onCreate(savedInstanceState: Bundle?) {
1822
enableEdgeToEdge()
1923
super.onCreate(savedInstanceState)
2024
val rootComponent = DefaultRootComponent(defaultComponentContext())
2125
val windowController = WindowCompat.getInsetsController(window, window.decorView)
26+
27+
activityProducer.produce(this)
2228
setContent {
2329
App(
2430
rootComponent = rootComponent,
@@ -28,6 +34,11 @@ class MainActivity : ComponentActivity() {
2834
)
2935
}
3036
}
37+
38+
override fun onDestroy() {
39+
super.onDestroy()
40+
activityProducer.produce(null)
41+
}
3142
}
3243

3344
@Preview

commonApp/src/commonMain/kotlin/com/stslex/atten/di/AppModules.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
package com.stslex.atten.di
22

3+
import com.stslex.atten.core.auth.di.ModuleCoreAuth
34
import com.stslex.atten.core.core.di.ModuleCore
45
import com.stslex.atten.core.database.di.ModuleCoreDatabase
56
import com.stslex.atten.core.paging.di.ModuleCorePaging
67
import com.stslex.atten.core.todo.di.ModuleCoreToDo
8+
import com.stslex.atten.core.ui.kit.utils.ModuleCoreUiUtils
79
import com.stslex.atten.feature.details.di.ModuleFeatureDetails
810
import com.stslex.atten.feature.home.di.ModuleFeatureHome
11+
import com.stslex.atten.feature.settings.di.ModuleFeatureSettings
912
import org.koin.core.module.Module
1013
import org.koin.ksp.generated.module
1114

@@ -14,6 +17,9 @@ val appModules: List<Module> = listOf(
1417
ModuleCoreDatabase().module,
1518
ModuleCoreToDo().module,
1619
ModuleCorePaging().module,
20+
ModuleCoreUiUtils().module,
21+
ModuleCoreAuth().module,
1722
ModuleFeatureHome().module,
1823
ModuleFeatureDetails().module,
24+
ModuleFeatureSettings().module
1925
)

commonApp/src/commonMain/kotlin/com/stslex/atten/host/AppNavigationHost.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import androidx.compose.runtime.Composable
55
import androidx.compose.ui.Modifier
66
import com.arkivanov.decompose.extensions.compose.stack.Children
77
import com.arkivanov.decompose.extensions.compose.stack.animation.stackAnimation
8+
import com.stslex.atten.feature.settings.ui.SettingsScreen
89
import com.stslex.atten.feature.details.ui.DetailsScreen
910
import com.stslex.atten.feature.home.ui.HomeScreen
1011

@@ -21,6 +22,7 @@ internal fun AppNavigationHost(
2122
when (val instance = created.instance) {
2223
is RootComponent.Child.Details -> DetailsScreen(instance.component)
2324
is RootComponent.Child.Home -> HomeScreen(instance.component)
25+
is RootComponent.Child.Settings -> SettingsScreen(instance.component)
2426
}
2527
}
2628
}

commonApp/src/commonMain/kotlin/com/stslex/atten/host/DefaultRootComponent.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import com.arkivanov.decompose.router.stack.childStack
88
import com.arkivanov.decompose.router.stack.navigate
99
import com.arkivanov.decompose.router.stack.pop
1010
import com.arkivanov.decompose.value.Value
11+
import com.stslex.atten.feature.settings.mvi.SettingsComponent
1112
import com.stslex.atten.core.ui.navigation.Config
1213
import com.stslex.atten.core.ui.navigation.Router
1314
import com.stslex.atten.feature.details.ui.mvi.DetailsComponent
@@ -40,6 +41,7 @@ class DefaultRootComponent(
4041
): Child = when (config) {
4142
is Config.Home -> Child.Home(HomeComponent.create(context.router))
4243
is Config.Detail -> Child.Details(DetailsComponent.create(context.router, config.uuid))
44+
is Config.Settings -> Child.Settings(SettingsComponent.create(context.router))
4345
}
4446

4547
@OptIn(DelicateDecomposeApi::class)

commonApp/src/commonMain/kotlin/com/stslex/atten/host/RootComponent.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package com.stslex.atten.host
33
import com.arkivanov.decompose.Cancellation
44
import com.arkivanov.decompose.router.stack.ChildStack
55
import com.arkivanov.decompose.value.Value
6+
import com.stslex.atten.feature.settings.mvi.SettingsComponent
67
import com.stslex.atten.core.ui.navigation.Config
78
import com.stslex.atten.feature.details.ui.mvi.DetailsComponent
89
import com.stslex.atten.feature.home.ui.mvi.HomeComponent
@@ -18,6 +19,8 @@ interface RootComponent {
1819
data class Home(val component: HomeComponent) : Child
1920

2021
data class Details(val component: DetailsComponent) : Child
22+
23+
data class Settings(val component: SettingsComponent) : Child
2124
}
2225

2326
}

core/auth/build.gradle.kts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
plugins {
2+
alias(libs.plugins.convention.kmp.library.compose)
3+
}
4+
5+
kotlin {
6+
sourceSets.apply {
7+
commonMain.dependencies {
8+
implementation(project(":core:core"))
9+
implementation(project(":core:ui:kit"))
10+
}
11+
androidMain.dependencies {
12+
implementation(libs.gms.auth)
13+
}
14+
}
15+
}

0 commit comments

Comments
 (0)