Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
327e4ef
start post-onboarding flow
amjiao Nov 15, 2026
3d1fc41
UI info and welcome banners
amjiao Nov 16, 2026
186e2f7
UI for banners
amjiao Nov 16, 2026
663ee82
Set up navigation placeholders for "to profile" button
amjiao Nov 17, 2026
8f1429c
Implement new empty state design for past games
amjiao Nov 17, 2026
d81a274
Add functionality for welcome banner
amjiao Nov 17, 2026
57834de
Use past games empty state
amjiao Nov 17, 2026
5905456
Order sports in sport filter by seasonality
amjiao Nov 17, 2026
b408a27
Merge latest auth into post-onboarding flow
EmilJiang Nov 18, 2026
95d3553
Route new accounts through profile and sports onboarding
EmilJiang Nov 18, 2026
4996c76
Add GenderFilter enum for HomeScreen filter
amjiao Nov 19, 2026
640a5af
[1/2] Add highlights networking and data layer (#137)
amjiao Nov 19, 2026
cf1baae
Merge branch 'main' of https://github.com/cuappdev/score-android into…
amjiao Nov 22, 2026
d7313fc
Add logic for when to display Welcome and FavoritesInfo banners
amjiao Nov 22, 2026
c7321ad
Fix lint failure
amjiao Nov 22, 2026
6e6d2b1
Address gender logic comment
amjiao Nov 24, 2026
10b530d
fix gender filter logic
amjiao Nov 24, 2026
8c86987
Bump com.google.devtools.ksp (#141)
dependabot[bot] Nov 26, 2026
5b4a65c
Bump org.jetbrains.kotlinx:kotlinx-serialization-json (#144)
dependabot[bot] Nov 26, 2026
9ec585f
Bump apollo from 4.4.4 to 5.2.0 (#142)
dependabot[bot] Nov 26, 2026
d63a295
Bump com.google.android.material:material from 1.12.0 to 1.14.0 (#143)
dependabot[bot] Nov 26, 2026
239cef7
Bump com.google.firebase:firebase-bom from 34.3.0 to 35.2.0 (#145)
dependabot[bot] Nov 26, 2026
85e4b98
[2/2] Add highlights UI (#139)
amjiao Nov 28, 2026
3c6e5b0
Fix session restoration logic
amjiao Nov 28, 2026
81cb405
Correct prod/dev servers
amjiao Nov 28, 2026
c68837b
Merge branch 'main' of https://github.com/cuappdev/score-android into…
amjiao Nov 28, 2026
cc4d803
Update onboarding sequence
amjiao Nov 28, 2026
78bfb04
Edit logs
amjiao Nov 28, 2026
59d553b
start post-onboarding flow
amjiao Nov 15, 2026
3f00ad2
UI info and welcome banners
amjiao Nov 16, 2026
33f7c69
UI for banners
amjiao Nov 16, 2026
4515acd
Set up navigation placeholders for "to profile" button
amjiao Nov 17, 2026
1132f74
Implement new empty state design for past games
amjiao Nov 17, 2026
6c2c46f
Add functionality for welcome banner
amjiao Nov 17, 2026
71c3f51
Use past games empty state
amjiao Nov 17, 2026
0671566
Order sports in sport filter by seasonality
amjiao Nov 17, 2026
9e98096
Route new accounts through profile and sports onboarding
EmilJiang Nov 18, 2026
5dbcaf6
Add GenderFilter enum for HomeScreen filter
amjiao Nov 19, 2026
9e6c3bf
Add logic for when to display Welcome and FavoritesInfo banners
amjiao Nov 22, 2026
65796c3
Address gender logic comment
amjiao Nov 24, 2026
cfb3b5f
fix gender filter logic
amjiao Nov 24, 2026
b42a1ee
Fix rebase errors
amjiao Nov 28, 2026
f0326a6
Merge branch 'post-onboarding-flow' of https://github.com/cuappdev/sc…
amjiao Nov 28, 2026
2514ac7
Fix ui issues
amjiao Nov 28, 2026
3606a85
Fix favorites info banner / filter logic
amjiao Nov 28, 2026
831c286
Make welcome banner disposable
amjiao Nov 28, 2026
210a717
Handle long-name case for welcome banner
amjiao Nov 28, 2026
36bd88f
Fix rebase
amjiao Nov 28, 2026
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
16 changes: 10 additions & 6 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,20 @@ android {
}
buildTypes {
debug {
buildConfigField("String", "BASE_URL", "\"${secrets.getProperty("API_URL_PROD")}\"")
buildConfigField("String", "SOCKET_URL", "\"${secrets.getProperty("SOCKET_URL_PROD")}\"")
}
release {
buildConfigField("String", "BASE_URL", "\"${secrets.getProperty("API_URL_DEV")}\"")
buildConfigField(
"String",
"SOCKET_URL",
"\"${secrets.getProperty("SOCKET_URL_DEV")}\"",
)
}
release {
buildConfigField("String", "BASE_URL", "\"${secrets.getProperty("API_URL_PROD")}\"")
buildConfigField(
"String",
"SOCKET_URL",
"\"${secrets.getProperty("SOCKET_URL_PROD")}\""
)
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
Expand Down Expand Up @@ -94,15 +98,15 @@ dependencies {
debugImplementation("androidx.compose.ui:ui-tooling")
androidTestImplementation(libs.androidx.junit)
androidTestImplementation(libs.androidx.espresso.core)
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.1")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.13.0")
implementation("io.socket:socket.io-client:2.1.1") {
exclude(group = "org.json", module = "json")
}
implementation(libs.apollo.runtime)
implementation("io.coil-kt.coil3:coil-compose:3.6.3")
implementation("io.coil-kt.coil3:coil-network-okhttp:3.1.0")
lintChecks(libs.compose.lint.checks)
implementation(platform("com.google.firebase:firebase-bom:34.3.0"))
implementation(platform("com.google.firebase:firebase-bom:35.2.0"))
implementation("com.google.firebase:firebase-analytics")
implementation("com.google.firebase:firebase-auth")
implementation("androidx.credentials:credentials:1.5.0")
Expand Down
17 changes: 17 additions & 0 deletions app/src/main/graphql/Highlights.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
query Highlights($sportsType: String) {
articles(sportsType: $sportsType) {
title
image
sportsType
publishedAt
url
}
youtubeVideos {
title
thumbnail
url
publishedAt
duration
sportsType
}
}
34 changes: 20 additions & 14 deletions app/src/main/java/com/cornellappdev/score/ScoreApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable
Expand All @@ -19,8 +18,9 @@ import com.cornellappdev.score.auth.AuthStatusOverlay
import com.cornellappdev.score.auth.AuthViewModel
import com.cornellappdev.score.model.OnboardingPreferencesRepository
import com.cornellappdev.score.nav.root.RootNavigation
import com.cornellappdev.score.screen.OnboardingScreen
import com.cornellappdev.score.screen.OnboardingSequence
import com.cornellappdev.score.theme.CrimsonPrimary
import com.cornellappdev.score.util.toWelcomeName

@Composable
fun ScoreApp(
Expand All @@ -34,30 +34,36 @@ fun ScoreApp(
var skippedWelcome by rememberSaveable {
mutableStateOf(onboardingPreferences.isOnboardingCompleted())
}
val signedIn = authState is AuthState.SignedIn

LaunchedEffect(signedIn) {
if (signedIn) {
onboardingPreferences.markOnboardingCompleted()
skippedWelcome = true
}
var profileSetupComplete by rememberSaveable {
mutableStateOf(onboardingPreferences.isProfileSetupCompleted())
}
val signedInState = authState as? AuthState.SignedIn
val signedIn = signedInState != null
val showMainApp = if (signedIn) profileSetupComplete else skippedWelcome

Box(modifier.fillMaxSize().background(Color.White)) {
when {
authState == AuthState.Loading ->
Box(Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {
CircularProgressIndicator(color = CrimsonPrimary)
}
signedIn || skippedWelcome -> RootNavigation()
showMainApp -> RootNavigation(
welcomeName = signedInState?.user?.toWelcomeName(),
isLoggedIn = signedIn,
)
else ->
OnboardingScreen(
onSignUp = onSignIn,
onLogIn = onSignIn,
onLater = {
OnboardingSequence(
signedIn = signedIn,
onSignIn = onSignIn,
onSkipSignIn = {
onboardingPreferences.markOnboardingCompleted()
skippedWelcome = true
},
onOnboardingComplete = {
onboardingPreferences.markProfileSetupCompleted()
profileSetupComplete = true
skippedWelcome = true
},
)
}
AuthStatusOverlay(signInState, authViewModel::dismissError)
Expand Down
35 changes: 33 additions & 2 deletions app/src/main/java/com/cornellappdev/score/auth/AuthRepository.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ package com.cornellappdev.score.auth

import javax.inject.Inject
import javax.inject.Singleton
import kotlin.time.Duration.Companion.milliseconds
import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.sync.Mutex
Expand All @@ -19,12 +21,36 @@ constructor(private val api: AuthApi, private val storage: SessionStorage) {
private var restored = false

suspend fun restoreSession() {
mutex.withLock { restoreStoredSession() }
var restoredFromStorage = false
for (attempt in 0 until RESTORE_ATTEMPTS) {
try {
mutex.withLock { restoreStoredSession() }
restoredFromStorage = true
break
} catch (error: CancellationException) {
throw error
} catch (_: Exception) {
if (attempt < RESTORE_ATTEMPTS - 1) {
delay((RESTORE_RETRY_DELAY_MILLIS * (attempt + 1)).milliseconds)
}
}
}

if (!restoredFromStorage) {
// Leave restored false so later accessToken calls or a future startup can retry.
mutex.withLock {
if (!restored) mutableState.value = AuthState.SignedOut
}
return
}

try {
accessToken()
} catch (error: CancellationException) {
throw error
} catch (_: Exception) {}
} catch (_: Exception) {
// Network or refresh failures should not prevent a later token request from retrying.
}
}

suspend fun signIn(identity: GoogleIdentity) =
Expand Down Expand Up @@ -98,4 +124,9 @@ constructor(private val api: AuthApi, private val storage: SessionStorage) {
private fun publishState() {
mutableState.value = session?.let { AuthState.SignedIn(it.user) } ?: AuthState.SignedOut
}

private companion object {
const val RESTORE_ATTEMPTS = 3
const val RESTORE_RETRY_DELAY_MILLIS = 100L
}
}
26 changes: 24 additions & 2 deletions app/src/main/java/com/cornellappdev/score/auth/AuthViewModel.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.cornellappdev.score.auth

import android.app.Activity
import android.util.Log
import androidx.credentials.exceptions.GetCredentialCancellationException
import androidx.credentials.exceptions.NoCredentialException
import androidx.lifecycle.ViewModel
Expand All @@ -20,13 +21,22 @@ class AuthViewModel
@Inject
constructor(private val repository: AuthRepository, private val google: GoogleSignInClient) :
ViewModel() {
private companion object {
const val TAG = "AuthViewModel"
}

val authState = repository.state
private val mutableSignInState = MutableStateFlow(SignInState(busy = true))
val signInState = mutableSignInState.asStateFlow()

init {
viewModelScope.launch {
Log.d(TAG, "Restoring saved Score session")
repository.restoreSession()
Log.d(
TAG,
"Session restoration complete; signedIn=${repository.state.value is AuthState.SignedIn}"
)
mutableSignInState.value = SignInState()
}
}
Expand All @@ -36,19 +46,31 @@ constructor(private val repository: AuthRepository, private val google: GoogleSi
viewModelScope.launch {
mutableSignInState.value = SignInState(busy = true)
try {
Log.i(TAG, "Google sign-in started")
val identity = google.signIn(activity)
Log.i(TAG, "Google/Firebase sign-in completed; starting backend authentication")
repository.signIn(identity)
Log.i(TAG, "Backend authentication completed; Score session saved")
mutableSignInState.value = SignInState()
} catch (_: GetCredentialCancellationException) {
} catch (error: GetCredentialCancellationException) {
Log.w(TAG, "Google credential flow was cancelled: ${error.message}", error)
mutableSignInState.value = SignInState()
} catch (_: NoCredentialException) {
Log.w(TAG, "No Google account is available for sign-in")
mutableSignInState.value = SignInState(error = R.string.auth_no_google_account)
} catch (_: CornellAccountRequiredException) {
Log.w(TAG, "Google sign-in rejected: account is not a Cornell account")
mutableSignInState.value = SignInState(error = R.string.auth_cornell_required)
} catch (error: CancellationException) {
Log.i(TAG, "Sign-in coroutine was cancelled")
mutableSignInState.value = SignInState()
throw error
} catch (_: Exception) {
} catch (error: Exception) {
Log.e(
TAG,
"Sign-in failed (${error.javaClass.simpleName}): ${error.message}",
error
)
google.signOut()
mutableSignInState.value = SignInState(error = R.string.auth_sign_in_failed)
}
Expand Down
58 changes: 46 additions & 12 deletions app/src/main/java/com/cornellappdev/score/auth/SessionStorage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,17 @@ import android.security.keystore.KeyProperties
import android.util.AtomicFile
import dagger.hilt.android.qualifiers.ApplicationContext
import java.io.File
import java.io.FileNotFoundException
import java.security.KeyStore
import javax.crypto.AEADBadTagException
import javax.crypto.Cipher
import javax.crypto.KeyGenerator
import javax.crypto.SecretKey
import javax.crypto.spec.GCMParameterSpec
import javax.inject.Inject
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import kotlinx.serialization.SerializationException
import kotlinx.serialization.encodeToString
import kotlinx.serialization.json.Json

Expand All @@ -31,17 +34,43 @@ class EncryptedSessionStorage @Inject constructor(@ApplicationContext context: C

override suspend fun read(): AuthSession? =
withContext(Dispatchers.IO) {
val bytes =
try {
file.readFully()
} catch (_: FileNotFoundException) {
return@withContext null
}

if (bytes.size < IV_SIZE + GCM_TAG_SIZE) {
file.delete()
return@withContext null
}

// Reading must not create a replacement key: it could never decrypt this saved session.
val key = existingEncryptionKey()
if (key == null) {
file.delete()
return@withContext null
}

val data =
try {
val cipher = Cipher.getInstance("AES/GCM/NoPadding")
cipher.init(
Cipher.DECRYPT_MODE,
key,
GCMParameterSpec(GCM_TAG_SIZE * 8, bytes.copyOfRange(0, IV_SIZE)),
)
cipher.doFinal(bytes.copyOfRange(IV_SIZE, bytes.size))
} catch (_: AEADBadTagException) {
// The current key failed AES-GCM authentication for these saved bytes.
file.delete()
return@withContext null
}

try {
val bytes = file.readFully()
val cipher = Cipher.getInstance("AES/GCM/NoPadding")
cipher.init(
Cipher.DECRYPT_MODE,
encryptionKey(),
GCMParameterSpec(128, bytes.copyOfRange(0, 12)),
)
val data = cipher.doFinal(bytes.copyOfRange(12, bytes.size))
Json.decodeFromString<AuthSession>(String(data, Charsets.UTF_8))
} catch (_: Exception) {
} catch (_: SerializationException) {
file.delete()
null
}
Expand All @@ -65,10 +94,13 @@ class EncryptedSessionStorage @Inject constructor(@ApplicationContext context: C

override suspend fun clear() = withContext(Dispatchers.IO) { file.delete() }

private fun encryptionKey(): SecretKey {
private fun existingEncryptionKey(): SecretKey? {
val keyStore = KeyStore.getInstance("AndroidKeyStore").apply { load(null) }
val existingKey = keyStore.getKey(KEY_ALIAS, null) as? SecretKey
if (existingKey != null) return existingKey
return keyStore.getKey(KEY_ALIAS, null) as? SecretKey
}

private fun encryptionKey(): SecretKey {
existingEncryptionKey()?.let { return it }
return KeyGenerator.getInstance(KeyProperties.KEY_ALGORITHM_AES, "AndroidKeyStore")
.apply {
init(
Expand All @@ -85,6 +117,8 @@ class EncryptedSessionStorage @Inject constructor(@ApplicationContext context: C
}

private companion object {
const val IV_SIZE = 12
const val GCM_TAG_SIZE = 16
const val KEY_ALIAS = "score_auth_session"
}
}
Loading