Skip to content

Commit e4f3d0c

Browse files
committed
Reorganize logic into cleaner directories and better separation of concerns.
1 parent 563ce3f commit e4f3d0c

Some content is hidden

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

41 files changed

+798
-942
lines changed

Shrine/app/build.gradle.kts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ plugins {
2121
alias(libs.plugins.kotlin.android)
2222
id("dagger.hilt.android.plugin")
2323
alias(libs.plugins.ksp)
24+
alias(libs.plugins.kotlin.compose)
2425
}
2526

2627
repositories {
@@ -87,10 +88,6 @@ android {
8788
buildConfig = true
8889
}
8990

90-
composeOptions {
91-
kotlinCompilerExtensionVersion = "1.5.2"
92-
}
93-
9491
packaging {
9592
resources {
9693
excludes += "/META-INF/{AL2.0,LGPL2.1}"

Shrine/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ plugins {
2121
alias(libs.plugins.spotless) apply false
2222
alias(libs.plugins.ksp) apply false
2323
alias(libs.plugins.kotlin.serialization) apply false
24+
alias(libs.plugins.kotlin.compose) apply false
2425
}
2526

2627
tasks.register("clean", Delete::class) {

Shrine/gradle/libs.versions.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[versions]
22
activity = "1.9.0"
33
androidxAppcompat = "1.7.0"
4-
androidPlugin = "8.11.1"
4+
androidPlugin = "8.12.0"
55
browser = "1.8.0"
66
coil = "2.7.0"
77
coilSvg = "2.6.0"
@@ -14,12 +14,12 @@ googleid = "1.1.1"
1414
hilt = "2.51"
1515
hiltCompiler = "1.2.0"
1616
hiltNavigationCompose = "1.2.0"
17-
horologist = "0.6.23"
18-
kotlin = "1.9.0"
17+
horologist = "0.7.15"
18+
kotlin = "2.2.0"
1919
kotlinCoroutines = "1.0"
2020
kotlinxCoroutines = "1.9.0"
2121
kotlinxSerialization = "1.7.3"
22-
ksp = "1.9.0-1.0.13"
22+
ksp = "2.2.0-2.0.2"
2323
ktlint = "0.50.0"
2424
ktx = "1.13.1"
2525
lifecycle = "2.7.0"

Shrine/wear/build.gradle.kts

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,29 @@ plugins {
22
alias(libs.plugins.android.application)
33
alias(libs.plugins.kotlin.android)
44
alias(libs.plugins.kotlin.serialization)
5-
}
6-
7-
configurations.all {
8-
resolutionStrategy {
9-
// Force kotlin dependencies to use the versions needed for Wear so that I don't need to
10-
// modify mobile dependency versions in this change.
11-
// TODO(johnzoeller): Update mobile dependencies and remove this
12-
force("org.jetbrains.kotlin:kotlin-stdlib:1.9.0")
13-
force("org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.9.0")
14-
force("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.9.0")
15-
force("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3")
16-
force("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3")
17-
}
5+
alias(libs.plugins.kotlin.compose)
186
}
197

208
android {
219
namespace = "com.authentication.shrinewear"
22-
compileSdk = 35
10+
compileSdk = 36
2311

2412
defaultConfig {
25-
applicationId = "com.authentication.shrinewear"
13+
applicationId = "com.authentication.shrine"
2614
minSdk = 30
27-
targetSdk = 35
15+
targetSdk = 36
2816
versionCode = 1
2917
versionName = "1.0"
3018
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
31-
32-
buildConfigField("String", "API_BASE_URL", "\"https://project-sesame-426206.appspot.com\"")
19+
buildConfigField(
20+
"String", "API_BASE_URL",
21+
"\"https://project-sesame-426206.appspot.com\""
22+
)
23+
buildConfigField(
24+
"String", "GOOGLE_SIGN_IN_SERVER_CLIENT_ID",
25+
// "PASTE_YOUR_SERVER_CLIENT_ID_HERE"
26+
"\"493201854729-bposa1duevdn4nspp28cmn6anucu60pf.apps.googleusercontent.com\""
27+
)
3328
}
3429

3530
signingConfigs {
@@ -51,16 +46,16 @@ android {
5146
sourceCompatibility = JavaVersion.VERSION_1_8
5247
targetCompatibility = JavaVersion.VERSION_1_8
5348
}
54-
kotlinOptions {
55-
jvmTarget = "1.8"
49+
50+
kotlin {
51+
compilerOptions {
52+
jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_1_8)
53+
}
5654
}
5755
buildFeatures {
5856
compose = true
5957
buildConfig = true
6058
}
61-
composeOptions {
62-
kotlinCompilerExtensionVersion = "1.5.2"
63-
}
6459
packaging {
6560
resources {
6661
excludes += "/META-INF/{AL2.0,LGPL2.1}"
@@ -97,8 +92,8 @@ android {
9792
implementation(libs.kotlinx.serialization.json) // New
9893

9994
// Wear Horologist SIWG composables
100-
implementation(libs.horologist.auth.ui) // New
101-
implementation(libs.horologist.compose.layout) // New
95+
implementation(libs.horologist.auth.ui)
96+
implementation(libs.horologist.compose.layout)
10297

10398
// GMS
10499
implementation(libs.google.id) // NO CHANGE

Shrine/wear/src/main/AndroidManifest.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66

77
<application
88
android:name=".ShrineApplication"
9-
android:icon="@mipmap/ic_launcher"
9+
android:icon="@drawable/shrine"
10+
android:roundIcon="@drawable/shrine"
1011
android:label="@string/app_name"
1112
android:supportsRtl="true"
1213
android:theme="@android:style/Theme.DeviceDefault">

Shrine/wear/src/main/java/com/authentication/shrinewear/Graph.kt

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,23 @@ package com.authentication.shrinewear
1818
import android.content.Context
1919
import com.authentication.shrinewear.authenticator.AuthenticationServer
2020
import com.authentication.shrinewear.authenticator.CredentialManagerAuthenticator
21+
import com.authentication.shrinewear.network.AuthNetworkClient
22+
import kotlinx.coroutines.flow.MutableStateFlow
23+
import kotlinx.coroutines.flow.StateFlow
24+
import kotlinx.coroutines.flow.asStateFlow
25+
26+
27+
/**
28+
* Represents the possible authentication states of the application.
29+
*/
30+
enum class AuthenticationState {
31+
LOGGED_OUT,
32+
LOGGED_IN,
33+
DISMISSED_BY_USER,
34+
MISSING_CREDENTIALS,
35+
FAILED,
36+
UNKNOWN_ERROR,
37+
}
2138

2239
/**
2340
* A simple, manual dependency injection container for application-wide singletons.
@@ -29,6 +46,14 @@ import com.authentication.shrinewear.authenticator.CredentialManagerAuthenticato
2946
* to initialize its dependencies.
3047
*/
3148
object Graph {
49+
50+
private val authNetworkClient: AuthNetworkClient by lazy {
51+
AuthNetworkClient()
52+
}
53+
val authenticationServer: AuthenticationServer by lazy {
54+
AuthenticationServer(authNetworkClient)
55+
}
56+
3257
/**
3358
* The authenticated instance of [CredentialManagerAuthenticator].
3459
* This property is initialized once via the [provide] method and
@@ -39,16 +64,13 @@ object Graph {
3964
*/
4065
lateinit var credentialManagerAuthenticator: CredentialManagerAuthenticator
4166
private set
42-
lateinit var authenticationServer: AuthenticationServer
43-
private set
4467

68+
69+
private val _authenticationState = MutableStateFlow(AuthenticationState.LOGGED_OUT)
4570
/**
46-
* Stores the current authentication status code as an Android string resource ID.
47-
* This can be used to reflect the authentication state across different parts of the UI.
48-
*
49-
* Defaults to [R.string.credman_status_logged_out].
71+
* Stores the current authentication status code. Defaults to [AuthenticationState.LOGGED_OUT].
5072
*/
51-
var authenticationStatusCode: Int = R.string.credman_status_logged_out
73+
val authenticationState: StateFlow<AuthenticationState> = _authenticationState.asStateFlow()
5274

5375
/**
5476
* Provides and initializes the core dependencies for the application's [Graph].
@@ -59,7 +81,12 @@ object Graph {
5981
* @param context The application [Context] required to initialize services like [CredentialManagerAuthenticator].
6082
*/
6183
fun provide(context: Context) {
62-
credentialManagerAuthenticator = CredentialManagerAuthenticator(context)
63-
authenticationServer = AuthenticationServer()
84+
credentialManagerAuthenticator = CredentialManagerAuthenticator(
85+
context,
86+
authenticationServer)
87+
}
88+
89+
fun updateAuthenticationState(newState: AuthenticationState) {
90+
_authenticationState.value = newState
6491
}
6592
}

0 commit comments

Comments
 (0)