Skip to content

Commit

Permalink
Merge branch 'main' into renovate/com.google.auth-google-auth-library…
Browse files Browse the repository at this point in the history
…-oauth2-http-1.x
  • Loading branch information
ashdavies authored Dec 13, 2024
2 parents 438e188 + eaaf598 commit 7b31441
Show file tree
Hide file tree
Showing 21 changed files with 109 additions and 99 deletions.
5 changes: 3 additions & 2 deletions analytics/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ android {
}

kotlin {
sourceSets.commonMain.dependencies {
implementation(libs.gitlive.firebase.analytics)
sourceSets.androidMain.dependencies {
implementation(dependencies.platform(libs.google.firebase.bom))
implementation(libs.google.firebase.analytics)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package io.ashdavies.analytics

import com.google.firebase.analytics.ktx.analytics
import com.google.firebase.analytics.logEvent
import com.google.firebase.ktx.Firebase

internal actual val firebaseAnalytics = RemoteAnalytics { name, block ->
Firebase.analytics.logEvent(name) { block(ParametersBuilder(::param)) }
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,12 @@ public fun <P> OnClickWith(
analytics.logEvent(name, parameters)
action(it)
}

private fun RemoteAnalytics.logEvent(
name: String,
parameters: Map<String, Any>?,
) = logEvent(name) {
parameters?.forEach { (key, value) ->
param(key, value.toString())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@ package io.ashdavies.analytics
import androidx.compose.runtime.ProvidableCompositionLocal
import androidx.compose.runtime.staticCompositionLocalOf

public val LocalAnalytics: ProvidableCompositionLocal<RemoteAnalytics> = staticCompositionLocalOf {
RemoteAnalytics { name, parameters -> firebaseAnalytics.logEvent(name, parameters) }
}
public val LocalAnalytics: ProvidableCompositionLocal<RemoteAnalytics> =
staticCompositionLocalOf { firebaseAnalytics }
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package io.ashdavies.analytics

public fun interface RemoteAnalytics {
public fun logEvent(name: String, parameters: Map<String, Any>?)
public fun logEvent(name: String, block: ParametersBuilder.() -> Unit)
}

public fun interface ParametersBuilder {
public fun param(key: String, value: String)
}
8 changes: 0 additions & 8 deletions conferences-app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,6 @@ android {
}
}

compileOptions {
isCoreLibraryDesugaringEnabled = true
}

defaultConfig {
val versionCode by stringProperty { _, value ->
versionCode = value?.toInt() ?: 1
Expand All @@ -76,8 +72,6 @@ android {
}

dependencies {
coreLibraryDesugaring(libs.android.tools.desugarjdk)

screenshotTestImplementation(compose.material3)
screenshotTestImplementation(compose.uiTooling)

Expand Down Expand Up @@ -148,8 +142,6 @@ kotlin {
implementation(libs.compose.adaptive.layout)
implementation(libs.compose.adaptive.navigation)
implementation(libs.compose.window.size)
implementation(libs.gitlive.firebase.app)
implementation(libs.gitlive.firebase.config)
implementation(libs.kotlinx.collections.immutable)
implementation(libs.kotlinx.datetime)
implementation(libs.kotlinx.serialization.core)
Expand Down
10 changes: 2 additions & 8 deletions conferences-app/src/jvmMain/kotlin/io/ashdavies/party/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import com.slack.circuit.overlay.ContentWithOverlays
import io.ashdavies.analytics.LocalAnalytics
import io.ashdavies.analytics.RemoteAnalytics
import io.ashdavies.check.ProvideAppCheckToken
import io.ashdavies.config.LocalConfigValue
import io.ashdavies.config.Default
import io.ashdavies.config.LocalRemoteConfig
import io.ashdavies.config.RemoteConfig
import io.ashdavies.content.PlatformContext
Expand All @@ -24,7 +24,6 @@ import io.ashdavies.http.publicStorage
import io.ashdavies.io.resolveCacheDir
import io.ashdavies.material.dynamicColorScheme
import io.ashdavies.party.config.rememberCircuit
import io.ashdavies.party.firebase.EmptyLocalConfigValue
import io.ashdavies.party.home.HomeScreen
import io.ashdavies.party.material.ProvideLocalWindowSizeClass
import io.ashdavies.playground.BuildConfig
Expand Down Expand Up @@ -106,12 +105,7 @@ private fun ConferencesApp(
private fun ProvideRemoteLocals(content: @Composable () -> Unit) {
CompositionLocalProvider(
LocalAnalytics provides RemoteAnalytics { _, _ -> },
LocalRemoteConfig provides object : RemoteConfig {
override suspend fun <T : Any> getValue(
key: String,
transform: (LocalConfigValue) -> T,
): T = transform(EmptyLocalConfigValue)
},
LocalRemoteConfig provides RemoteConfig.Default,
content = content,
)
}

This file was deleted.

8 changes: 2 additions & 6 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ cash-sqldelight = "2.0.2"
coil-kt = "3.0.4"
compose-adaptive = "1.0.1"
compose-plugin = "1.7.1"
gitlive-firebase = "2.1.0"
google-accompanist = "0.36.0"
google-android = "8.7.3"
google-maps-compose = "4.3.2"
Expand All @@ -22,7 +21,6 @@ slack-circuit = "0.25.0"

[libraries]
ajalt-clikt = "com.github.ajalt.clikt:clikt:5.0.2"
android-tools-desugarjdk = "com.android.tools:desugar_jdk_libs:2.1.3"

androidx-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "androidx-activity" }
androidx-annotation = "androidx.annotation:annotation:1.9.1"
Expand All @@ -45,10 +43,6 @@ compose-window-size = { module = "org.jetbrains.compose.material3:material3-wind
detekt-compose = "io.nlopez.compose.rules:detekt:0.4.22"
fusesource-jansi = "org.fusesource.jansi:jansi:2.4.1"

gitlive-firebase-analytics = { module = "dev.gitlive:firebase-analytics", version.ref = "gitlive-firebase" }
gitlive-firebase-app = { module = "dev.gitlive:firebase-app", version.ref = "gitlive-firebase" }
gitlive-firebase-config = { module = "dev.gitlive:firebase-config", version.ref = "gitlive-firebase" }

google-accompanist-flowlayout = { module = "com.google.accompanist:accompanist-flowlayout", version.ref = "google-accompanist" }
google-accompanist-permissions = { module = "com.google.accompanist:accompanist-permissions", version.ref = "google-accompanist" }

Expand All @@ -60,7 +54,9 @@ google-auth-http = "com.google.auth:google-auth-library-oauth2-http:1.30.1"

google-firebase-admin = "com.google.firebase:firebase-admin:9.4.2"
google-firebase-appcheck-playintegrity = { module = "com.google.firebase:firebase-appcheck-playintegrity" }
google-firebase-analytics = { module = "com.google.firebase:firebase-analytics" }
google-firebase-bom = "com.google.firebase:firebase-bom:33.7.0"
google-firebase-config = { module = "com.google.firebase:firebase-config" }
google-firebase-crashlytics = { module = "com.google.firebase:firebase-crashlytics" }

google-guava-jre = "com.google.guava:guava:33.3.1-jre"
Expand Down
13 changes: 3 additions & 10 deletions remote-config/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,12 @@ plugins {
}

android {
compileOptions {
isCoreLibraryDesugaringEnabled = true
}

dependencies {
coreLibraryDesugaring(libs.android.tools.desugarjdk)
}

namespace = "io.ashdavies.config"
}

kotlin {
sourceSets.commonMain.dependencies {
implementation(libs.gitlive.firebase.config)
sourceSets.androidMain.dependencies {
implementation(dependencies.platform(libs.google.firebase.bom))
implementation(libs.google.firebase.config)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package io.ashdavies.config

import com.google.firebase.ktx.Firebase
import com.google.firebase.remoteconfig.FirebaseRemoteConfigValue
import com.google.firebase.remoteconfig.ktx.remoteConfig
import com.google.firebase.remoteconfig.ktx.remoteConfigSettings

private const val ONE_MINUTE_IN_SECONDS = 3600L

@Suppress("ObjectPropertyName")
private val _firebaseRemoteConfig by lazy {
Firebase.remoteConfig.apply {
val configSettings = remoteConfigSettings {
minimumFetchIntervalInSeconds = ONE_MINUTE_IN_SECONDS
}

setConfigSettingsAsync(configSettings)
fetchAndActivate()
}
}

internal actual val firebaseRemoteConfig = object : RemoteConfig {
override suspend fun <T : Any> getValue(key: String, transform: (RemoteConfigValue) -> T): T {
return transform(remoteConfigValue(_firebaseRemoteConfig.getValue(key)))
}
}

private fun remoteConfigValue(value: FirebaseRemoteConfigValue) = object : RemoteConfigValue {
override fun asLong(): Long = value.asLong()
override fun asDouble(): Double = value.asDouble()
override fun asString(): String = value.asString()
override fun asByteArray(): ByteArray = value.asByteArray()
override fun asBoolean(): Boolean = value.asBoolean()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package io.ashdavies.config

internal expect val firebaseRemoteConfig: RemoteConfig

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ import androidx.compose.runtime.ProvidableCompositionLocal
import androidx.compose.runtime.staticCompositionLocalOf

public val LocalRemoteConfig: ProvidableCompositionLocal<RemoteConfig> = staticCompositionLocalOf {
LazyRemoteConfig()
firebaseRemoteConfig
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package io.ashdavies.config

public interface RemoteConfig {
public suspend fun <T : Any> getValue(key: String, transform: (LocalConfigValue) -> T): T
public suspend fun <T : Any> getValue(key: String, transform: (RemoteConfigValue) -> T): T
public companion object
}

public suspend fun RemoteConfig.getBoolean(key: String): Boolean {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package io.ashdavies.config

public interface RemoteConfigValue {
public fun asLong(): Long
public fun asDouble(): Double
public fun asString(): String
public fun asByteArray(): ByteArray
public fun asBoolean(): Boolean
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package io.ashdavies.config

internal actual val firebaseRemoteConfig = object : RemoteConfig {
override suspend fun <T : Any> getValue(key: String, transform: (RemoteConfigValue) -> T): T {
TODO("Not yet implemented")
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package io.ashdavies.config

public val RemoteConfig.Companion.Default: RemoteConfig
get() = emptyRemoteConfig

private val emptyRemoteConfig = object : RemoteConfig {
override suspend fun <T : Any> getValue(key: String, transform: (RemoteConfigValue) -> T): T {
return transform(EmptyLocalConfigValue)
}
}

private object EmptyLocalConfigValue : RemoteConfigValue {
override fun asLong() = 0L
override fun asDouble() = 0.0
override fun asString() = ""
override fun asByteArray() = byteArrayOf()
override fun asBoolean() = false
}

0 comments on commit 7b31441

Please sign in to comment.