Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions Shrine/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ plugins {
alias(libs.plugins.kotlin.android)
id("dagger.hilt.android.plugin")
alias(libs.plugins.ksp)
alias(libs.plugins.kotlin.compose)
}

repositories {
Expand Down Expand Up @@ -87,10 +88,6 @@ android {
buildConfig = true
}

composeOptions {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!

kotlinCompilerExtensionVersion = "1.5.2"
}

packaging {
resources {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
Expand Down
1 change: 1 addition & 0 deletions Shrine/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ plugins {
alias(libs.plugins.spotless) apply false
alias(libs.plugins.ksp) apply false
alias(libs.plugins.kotlin.serialization) apply false
alias(libs.plugins.kotlin.compose) apply false
}

tasks.register("clean", Delete::class) {
Expand Down
10 changes: 5 additions & 5 deletions Shrine/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[versions]
activity = "1.9.0"
androidxAppcompat = "1.7.0"
androidPlugin = "8.11.1"
androidPlugin = "8.12.1"
browser = "1.8.0"
coil = "2.7.0"
coilSvg = "2.6.0"
Expand All @@ -11,15 +11,15 @@ datastorePrefs = "1.1.1"
googleFonts = "1.6.8"
googleServicesPlugin = "4.4.1"
googleid = "1.1.1"
hilt = "2.51"
hilt = "2.57.1"
hiltCompiler = "1.2.0"
hiltNavigationCompose = "1.2.0"
horologist = "0.6.23"
kotlin = "1.9.0"
horologist = "0.7.15"
kotlin = "2.2.0"
kotlinCoroutines = "1.0"
kotlinxCoroutines = "1.9.0"
kotlinxSerialization = "1.7.3"
ksp = "1.9.0-1.0.13"
ksp = "2.2.0-2.0.2"
ktlint = "0.50.0"
ktx = "1.13.1"
lifecycle = "2.7.0"
Expand Down
44 changes: 19 additions & 25 deletions Shrine/wear/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,28 @@ plugins {
alias(libs.plugins.android.application)
alias(libs.plugins.kotlin.android)
alias(libs.plugins.kotlin.serialization)
}

configurations.all {
resolutionStrategy {
// Force kotlin dependencies to use the versions needed for Wear so that I don't need to
// modify mobile dependency versions in this change.
// TODO(johnzoeller): Update mobile dependencies and remove this
force("org.jetbrains.kotlin:kotlin-stdlib:1.9.0")
force("org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.9.0")
force("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.9.0")
force("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3")
force("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3")
}
alias(libs.plugins.kotlin.compose)
}

android {
namespace = "com.authentication.shrinewear"
compileSdk = 35
compileSdk = 36

defaultConfig {
applicationId = "com.authentication.shrinewear"
applicationId = "com.authentication.shrine"
minSdk = 30
targetSdk = 35
targetSdk = 36

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

versionCode = 1
versionName = "1.0"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"

buildConfigField("String", "API_BASE_URL", "\"https://project-sesame-426206.appspot.com\"")
buildConfigField(
"String", "API_BASE_URL",
"\"https://project-sesame-426206.appspot.com\""
)
buildConfigField(
"String", "GOOGLE_SIGN_IN_SERVER_CLIENT_ID",
"\"PASTE_YOUR_SERVER_CLIENT_ID_HERE\""
)
}

signingConfigs {
Expand All @@ -51,16 +45,16 @@ android {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"

kotlin {
compilerOptions {
jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_1_8)
}
}
buildFeatures {
compose = true
buildConfig = true
}
composeOptions {
kotlinCompilerExtensionVersion = "1.5.2"
}
packaging {
resources {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
Expand Down Expand Up @@ -97,8 +91,8 @@ android {
implementation(libs.kotlinx.serialization.json) // New

// Wear Horologist SIWG composables
implementation(libs.horologist.auth.ui) // New
implementation(libs.horologist.compose.layout) // New
implementation(libs.horologist.auth.ui)
implementation(libs.horologist.compose.layout)

// GMS
implementation(libs.google.id) // NO CHANGE
Expand Down
3 changes: 2 additions & 1 deletion Shrine/wear/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

<application
android:name=".ShrineApplication"
android:icon="@mipmap/ic_launcher"
android:icon="@drawable/shrine"
android:roundIcon="@drawable/shrine"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@android:style/Theme.DeviceDefault">
Expand Down
45 changes: 36 additions & 9 deletions Shrine/wear/src/main/java/com/authentication/shrinewear/Graph.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,23 @@ package com.authentication.shrinewear
import android.content.Context
import com.authentication.shrinewear.authenticator.AuthenticationServer
import com.authentication.shrinewear.authenticator.CredentialManagerAuthenticator
import com.authentication.shrinewear.network.AuthNetworkClient
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.asStateFlow


/**
* Represents the possible authentication states of the application.
*/
enum class AuthenticationState {
LOGGED_OUT,
LOGGED_IN,
DISMISSED_BY_USER,
MISSING_CREDENTIALS,
FAILED,
UNKNOWN_ERROR,
}

/**
* A simple, manual dependency injection container for application-wide singletons.
Expand All @@ -29,6 +46,14 @@ import com.authentication.shrinewear.authenticator.CredentialManagerAuthenticato
* to initialize its dependencies.
*/
object Graph {

private val authNetworkClient: AuthNetworkClient by lazy {
AuthNetworkClient()
}
val authenticationServer: AuthenticationServer by lazy {
AuthenticationServer(authNetworkClient)
}

/**
* The authenticated instance of [CredentialManagerAuthenticator].
* This property is initialized once via the [provide] method and
Expand All @@ -39,16 +64,13 @@ object Graph {
*/
lateinit var credentialManagerAuthenticator: CredentialManagerAuthenticator
private set
lateinit var authenticationServer: AuthenticationServer
private set


private val _authenticationState = MutableStateFlow(AuthenticationState.LOGGED_OUT)
/**
* Stores the current authentication status code as an Android string resource ID.
* This can be used to reflect the authentication state across different parts of the UI.
*
* Defaults to [R.string.credman_status_logged_out].
* Stores the current authentication status code. Defaults to [AuthenticationState.LOGGED_OUT].
*/
var authenticationStatusCode: Int = R.string.credman_status_logged_out
val authenticationState: StateFlow<AuthenticationState> = _authenticationState.asStateFlow()

/**
* Provides and initializes the core dependencies for the application's [Graph].
Expand All @@ -59,7 +81,12 @@ object Graph {
* @param context The application [Context] required to initialize services like [CredentialManagerAuthenticator].
*/
fun provide(context: Context) {
credentialManagerAuthenticator = CredentialManagerAuthenticator(context)
authenticationServer = AuthenticationServer()
credentialManagerAuthenticator = CredentialManagerAuthenticator(
context,
authenticationServer)
}

fun updateAuthenticationState(newState: AuthenticationState) {
_authenticationState.value = newState
}
}
Loading