Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wear app: show sessions #207

Merged
merged 7 commits into from
Mar 26, 2024
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
8 changes: 6 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ pullrefresh = "1.3.0"
androidx-wear-compose = "1.3.0"
playServicesWearable = "18.1.0"
compose-ui-tooling = "1.3.0"
horologist = "0.5.24"
horologist = "0.6.5"
kprefs = "1.7.2"

[libraries]
androidx-activity-compose = { group = "androidx.activity", name = "activity-compose", version.ref = "androidxActivity" }
Expand All @@ -45,6 +46,7 @@ compose-material = { group = "androidx.compose.material", name = "material", ver
compose-ui-tooling = { module = "androidx.compose.ui:ui-tooling", version.ref = "compose" }
espresso-core = "androidx.test.espresso:espresso-core:3.5.1"
firebase-analytics-ktx = { module = "com.google.firebase:firebase-analytics-ktx" }
firebase-auth-ktx = { module = "com.google.firebase:firebase-auth-ktx" }
firebase-bom = "com.google.firebase:firebase-bom:32.7.2"
firebase-crashlytics-ktx = { module = "com.google.firebase:firebase-crashlytics-ktx" }
firebase-inappmessaging = { module = "com.google.firebase:firebase-inappmessaging-display-ktx" }
Expand Down Expand Up @@ -91,14 +93,16 @@ play-services-wearable = { group = "com.google.android.gms", name = "play-servic
androidx-splashscreen = "androidx.core:core-splashscreen:1.0.1"
wear-compose-material = { module = "androidx.wear.compose:compose-material", version.ref = "androidx-wear-compose" }
wear-compose-foundation = { module = "androidx.wear.compose:compose-foundation", version.ref = "androidx-wear-compose" }
androidx-material-icons-core = { module = "androidx.compose.material:material-icons-core", version.ref = "compose" }
androidx-material-icons-extended = { module = "androidx.compose.material:material-icons-extended", version.ref = "compose" }
horologist-composables = { module = "com.google.android.horologist:horologist-composables", version.ref = "horologist" }
horologist-compose-layout = { module = "com.google.android.horologist:horologist-compose-layout", version.ref = "horologist" }
horologist-compose-material = { module = "com.google.android.horologist:horologist-compose-material", version.ref = "horologist" }
horologist-auth-ui = { module = "com.google.android.horologist:horologist-auth-ui", version.ref = "horologist" }
compose-ui-tooling-preview = { module = "androidx.compose.ui:ui-tooling-preview", version.ref = "compose" }
androidx-compose-ui-tooling = { module = "androidx.wear.compose:compose-ui-tooling", version.ref = "compose-ui-tooling" }
wear-compose-navigation = { module = "androidx.wear.compose:compose-navigation", version.ref = "androidx-wear-compose" }
desugar-jdk-libs = "com.android.tools:desugar_jdk_libs:2.0.4"
kprefs = { module = "org.jraf:kprefs", version.ref = "kprefs" }

[plugins]
android-application = { id = "com.android.application", version.ref = "android-gradle-plugin" }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package fr.androidmakers.store.graphql

import android.content.Context
import android.os.Build
import com.apollographql.apollo3.ApolloClient
import com.apollographql.apollo3.api.http.HttpRequest
import com.apollographql.apollo3.api.http.HttpResponse
Expand All @@ -12,7 +11,6 @@ import com.apollographql.apollo3.network.http.HttpInterceptor
import com.apollographql.apollo3.network.http.HttpInterceptorChain
import com.google.firebase.auth.ktx.auth
import com.google.firebase.ktx.Firebase
import kotlinx.coroutines.runBlocking

actual class ApolloClientBuilder(
context: Context,
Expand All @@ -29,9 +27,7 @@ actual class ApolloClientBuilder(
request.newBuilder()
.addHeader("conference", conference)
.apply {
val token = runBlocking {
Firebase.auth.currentUser?.getIdToken(false)?.result?.token
}
val token = Firebase.auth.currentUser?.getIdToken(false)?.result?.token
if (token != null) {
addHeader("Authorization", "Bearer $token")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import fr.androidmakers.domain.model.User
import fr.androidmakers.domain.repo.UserRepository

class FirebaseUserRepository : UserRepository {
override suspend fun getUser(): User? {
override fun getUser(): User? {
return try {
Firebase.auth.currentUser?.toUser()
} catch (e: Exception) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package fr.androidmakers.store.graphql

import fr.androidmakers.store.graphql.fragment.RoomDetails
import fr.androidmakers.store.graphql.fragment.SessionDetails
import fr.androidmakers.store.graphql.fragment.SpeakerDetails
import fr.androidmakers.domain.model.Complexity
import fr.androidmakers.domain.model.Room
import fr.androidmakers.domain.model.Session
import fr.androidmakers.domain.model.SocialsItem
import fr.androidmakers.domain.model.Speaker
import fr.androidmakers.domain.model.Venue
import fr.androidmakers.store.graphql.fragment.RoomDetails
import fr.androidmakers.store.graphql.fragment.SessionDetails
import fr.androidmakers.store.graphql.fragment.SpeakerDetails

fun SpeakerDetails.toSpeaker(): Speaker {
return Speaker(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package fr.androidmakers.domain.model

import kotlinx.datetime.LocalDateTime
import kotlinx.datetime.TimeZone
import kotlinx.datetime.toInstant
import kotlin.time.Duration

data class Session(
Expand All @@ -16,11 +18,11 @@ data class Session(
val platformUrl: String? = null,
//TODO unsure
val slidesUrl: String? = null,
val duration: Duration = Duration.ZERO,

// TODO move to instant to handle timezone
val startsAt: LocalDateTime,
val endsAt: LocalDateTime,
val duration: Duration = endsAt.toInstant(TimeZone.UTC) - startsAt.toInstant(TimeZone.UTC),
val roomId: String,
val isServiceSession: Boolean,
)
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ package fr.androidmakers.domain.repo
import fr.androidmakers.domain.model.User

interface UserRepository {
suspend fun getUser(): User?
fun getUser(): User?
}
18 changes: 10 additions & 8 deletions wearApp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@ plugins {
alias(libs.plugins.android.application)
alias(libs.plugins.kotlin.android)
alias(libs.plugins.google.services)

alias(libs.plugins.androidmakers.android.signing)
}

android {
namespace = "fr.paug.androidmakers.wear"
compileSdk = 34

defaultConfig {
applicationId = "fr.paug.androidmakers"
minSdk = 30
targetSdk = 34
versionCode = 1
Expand All @@ -18,13 +21,6 @@ android {
}
}

buildTypes {
release {
isMinifyEnabled = false
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
}
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
Expand Down Expand Up @@ -52,21 +48,27 @@ android {

dependencies {
implementation(libs.play.services.wearable)
implementation(libs.play.services.auth)
implementation(libs.androidx.activity.compose)
implementation(libs.androidx.splashscreen)
implementation(libs.wear.compose.material)
implementation(libs.wear.compose.foundation)
implementation(libs.androidx.material.icons.core)
implementation(libs.androidx.material.icons.extended)
implementation(libs.horologist.composables)
implementation(libs.horologist.compose.layout)
implementation(libs.horologist.compose.material)
implementation(libs.horologist.auth.ui)
implementation(libs.compose.ui.tooling.preview)
implementation(libs.androidx.compose.ui.tooling)
implementation(libs.wear.compose.navigation)
implementation(platform(libs.firebase.bom))
implementation(libs.firebase.auth.ktx)
implementation(libs.kprefs)
coreLibraryDesugaring(libs.desugar.jdk.libs)
debugImplementation(libs.compose.ui.tooling)

implementation(libs.koin.android)
implementation(libs.koin.androidx.compose)
implementation(project(":shared:di"))
implementation(project(":shared:domain"))
}
55 changes: 0 additions & 55 deletions wearApp/google-services.json

This file was deleted.

1 change: 1 addition & 0 deletions wearApp/google-services.json
1 change: 1 addition & 0 deletions wearApp/keystore.debug
1 change: 1 addition & 0 deletions wearApp/keystore.release
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
package fr.paug.androidmakers.wear;

import android.app.Application
import android.content.Context
import fr.androidmakers.di.DependenciesBuilder
import fr.paug.androidmakers.wear.di.androidViewModelModule
import fr.paug.androidmakers.wear.di.dataModule

lateinit var applicationContext: Context

class AndroidMakersWearApplication : Application() {
override fun onCreate() {
super.onCreate()
fr.paug.androidmakers.wear.applicationContext = applicationContext
DependenciesBuilder(this).inject(
listOf(androidViewModelModule)
listOf(
androidViewModelModule,
dataModule,
)
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package fr.paug.androidmakers.wear.data

import android.content.Context
import kotlinx.coroutines.flow.MutableStateFlow
import org.jraf.android.kprefs.Prefs

class LocalPreferencesRepository(applicationContext: Context) {
private val localPrefs = Prefs(applicationContext)

val showOnlyBookmarkedSessions: MutableStateFlow<Boolean> by localPrefs.BooleanFlow(false)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is is possible to use the data store ? Like in the BookmarksDatastoreRepository :

private val dataStore: DataStore<Preferences>

dataStore.data.map { prefs ->
        prefs[booleanPreferenceKey("MY_KEY")]
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Probably!

Used my own little lib kprefs because I know it 😅. I'll have a look at DataStore, but I'll merge this one now to iterate fast.

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package fr.paug.androidmakers.wear.di

import fr.paug.androidmakers.wear.data.LocalPreferencesRepository
import org.koin.dsl.module

val dataModule = module {
single<LocalPreferencesRepository> { LocalPreferencesRepository(get()) }
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package fr.paug.androidmakers.wear.di

import fr.paug.androidmakers.wear.ui.main.MainViewModel
import fr.paug.androidmakers.wear.ui.settings.SettingsViewModel
import org.koin.androidx.viewmodel.dsl.viewModel
import org.koin.dsl.module

val androidViewModelModule = module {
viewModel { MainViewModel(get(), get()) }
viewModel { MainViewModel(get(), get(), get(), get(), get(), get()) }
viewModel { SettingsViewModel(get(), get()) }
}
Loading
Loading