Skip to content

Commit

Permalink
Merge pull request #553 from splendo/feature/kotlin-duration
Browse files Browse the repository at this point in the history
Changes the use of Intervals/Timestamps as long into Kotlin Duration/Instant
  • Loading branch information
nbransby authored Jun 27, 2024
2 parents 6b1571a + e0a0339 commit e996b7c
Show file tree
Hide file tree
Showing 36 changed files with 293 additions and 155 deletions.
3 changes: 2 additions & 1 deletion firebase-analytics/api/android/firebase-analytics.api
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ public final class dev/gitlive/firebase/analytics/AnalyticEventConstantsKt {
public final class dev/gitlive/firebase/analytics/AnalyticsKt {
public static final fun logEvent (Ldev/gitlive/firebase/analytics/FirebaseAnalytics;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)V
public static final fun setConsent (Ldev/gitlive/firebase/analytics/FirebaseAnalytics;Lkotlin/jvm/functions/Function1;)V
public static final fun setSessionTimeoutInterval (Ldev/gitlive/firebase/analytics/FirebaseAnalytics;J)V
}

public final class dev/gitlive/firebase/analytics/FirebaseAnalytics {
Expand All @@ -19,7 +20,7 @@ public final class dev/gitlive/firebase/analytics/FirebaseAnalytics {
public final fun setAnalyticsCollectionEnabled (Z)V
public final fun setConsent (Ljava/util/Map;)V
public final fun setDefaultEventParameters (Ljava/util/Map;)V
public final fun setSessionTimeoutInterval (J)V
public final fun setSessionTimeoutInterval-LRDsOJo (J)V
public final fun setUserId (Ljava/lang/String;)V
public final fun setUserProperty (Ljava/lang/String;Ljava/lang/String;)V
}
Expand Down
3 changes: 2 additions & 1 deletion firebase-analytics/api/jvm/firebase-analytics.api
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ public final class dev/gitlive/firebase/analytics/AnalyticEventConstantsKt {
public final class dev/gitlive/firebase/analytics/AnalyticsKt {
public static final fun logEvent (Ldev/gitlive/firebase/analytics/FirebaseAnalytics;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)V
public static final fun setConsent (Ldev/gitlive/firebase/analytics/FirebaseAnalytics;Lkotlin/jvm/functions/Function1;)V
public static final fun setSessionTimeoutInterval (Ldev/gitlive/firebase/analytics/FirebaseAnalytics;J)V
}

public final class dev/gitlive/firebase/analytics/Analytics_jvmKt {
Expand All @@ -23,7 +24,7 @@ public final class dev/gitlive/firebase/analytics/FirebaseAnalytics {
public final fun setAnalyticsCollectionEnabled (Z)V
public final fun setConsent (Ljava/util/Map;)V
public final fun setDefaultEventParameters (Ljava/util/Map;)V
public final fun setSessionTimeoutInterval (J)V
public final fun setSessionTimeoutInterval-LRDsOJo (J)V
public final fun setUserId (Ljava/lang/String;)V
public final fun setUserProperty (Ljava/lang/String;Ljava/lang/String;)V
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import com.google.firebase.analytics.setConsent
import dev.gitlive.firebase.Firebase
import dev.gitlive.firebase.FirebaseApp
import kotlinx.coroutines.tasks.await
import kotlin.time.Duration

public actual val Firebase.analytics: FirebaseAnalytics
get() = FirebaseAnalytics(com.google.firebase.Firebase.analytics)
Expand Down Expand Up @@ -36,8 +37,8 @@ public actual class FirebaseAnalytics(public val android: com.google.firebase.an
android.setAnalyticsCollectionEnabled(enabled)
}

public actual fun setSessionTimeoutInterval(sessionTimeoutInterval: Long) {
android.setSessionTimeoutDuration(sessionTimeoutInterval)
public actual fun setSessionTimeoutInterval(sessionTimeoutInterval: Duration) {
android.setSessionTimeoutDuration(sessionTimeoutInterval.inWholeMilliseconds)
}

public actual suspend fun getSessionId(): Long? = android.sessionId.await()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package dev.gitlive.firebase.analytics

import dev.gitlive.firebase.Firebase
import dev.gitlive.firebase.FirebaseApp
import kotlin.time.Duration
import kotlin.time.Duration.Companion.milliseconds

public expect val Firebase.analytics: FirebaseAnalytics

Expand All @@ -13,7 +15,7 @@ public expect class FirebaseAnalytics {
public fun setUserProperty(name: String, value: String)
public fun setUserId(id: String)
public fun setAnalyticsCollectionEnabled(enabled: Boolean)
public fun setSessionTimeoutInterval(sessionTimeoutInterval: Long)
public fun setSessionTimeoutInterval(sessionTimeoutInterval: Duration)
public suspend fun getSessionId(): Long?
public fun resetAnalyticsData()
public fun setDefaultEventParameters(parameters: Map<String, String>)
Expand All @@ -32,6 +34,11 @@ public expect class FirebaseAnalytics {
}
}

@Deprecated("Use Kotlin Duration", replaceWith = ReplaceWith("setSessionTimeoutInterval(sessionTimeoutInterval.milliseconds)"))
public fun FirebaseAnalytics.setSessionTimeoutInterval(sessionTimeoutInterval: Long) {
setSessionTimeoutInterval(sessionTimeoutInterval.milliseconds)
}

public fun FirebaseAnalytics.setConsent(builder: FirebaseAnalyticsConsentBuilder.() -> Unit) {
val consentBuilder = FirebaseAnalyticsConsentBuilder()
consentBuilder.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import dev.gitlive.firebase.FirebaseApp
import dev.gitlive.firebase.FirebaseException
import kotlinx.coroutines.CompletableDeferred
import platform.Foundation.NSError
import kotlin.time.Duration
import kotlin.time.DurationUnit

public actual val Firebase.analytics: FirebaseAnalytics
get() = FirebaseAnalytics(FIRAnalytics)
Expand All @@ -32,8 +34,8 @@ public actual class FirebaseAnalytics(public val ios: FIRAnalytics.Companion) {
ios.setAnalyticsCollectionEnabled(enabled)
}

public actual fun setSessionTimeoutInterval(sessionTimeoutInterval: Long) {
ios.setSessionTimeoutInterval(sessionTimeoutInterval.toDouble())
public actual fun setSessionTimeoutInterval(sessionTimeoutInterval: Duration) {
ios.setSessionTimeoutInterval(sessionTimeoutInterval.toDouble(DurationUnit.SECONDS))
}

public actual suspend fun getSessionId(): Long? = ios.awaitResult { sessionIDWithCompletion(it) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import dev.gitlive.firebase.FirebaseApp
import dev.gitlive.firebase.FirebaseException
import dev.gitlive.firebase.analytics.externals.getAnalytics
import kotlinx.coroutines.await
import kotlin.time.Duration

public actual val Firebase.analytics: FirebaseAnalytics
get() = FirebaseAnalytics(getAnalytics())
Expand Down Expand Up @@ -32,8 +33,8 @@ public actual class FirebaseAnalytics(public val js: dev.gitlive.firebase.analyt
dev.gitlive.firebase.analytics.externals.setAnalyticsCollectionEnabled(js, enabled)
}

public actual fun setSessionTimeoutInterval(sessionTimeoutInterval: Long) {
dev.gitlive.firebase.analytics.externals.setSessionTimeoutInterval(js, sessionTimeoutInterval)
public actual fun setSessionTimeoutInterval(sessionTimeoutInterval: Duration) {
dev.gitlive.firebase.analytics.externals.setSessionTimeoutInterval(js, sessionTimeoutInterval.inWholeMilliseconds)
}

public actual suspend fun getSessionId(): Long? = rethrow { dev.gitlive.firebase.analytics.externals.getSessionId(js).await() }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package dev.gitlive.firebase.analytics
import dev.gitlive.firebase.Firebase
import dev.gitlive.firebase.FirebaseApp
import dev.gitlive.firebase.FirebaseException
import kotlin.time.Duration

public actual val Firebase.analytics: FirebaseAnalytics
get() = TODO("Not yet implemented")
Expand All @@ -16,7 +17,7 @@ public actual class FirebaseAnalytics {
public actual fun setUserId(id: String) {}
public actual fun resetAnalyticsData() {}
public actual fun setAnalyticsCollectionEnabled(enabled: Boolean) {}
public actual fun setSessionTimeoutInterval(sessionTimeoutInterval: Long) {}
public actual fun setSessionTimeoutInterval(sessionTimeoutInterval: Duration) {}
public actual suspend fun getSessionId(): Long? = TODO("Not yet implemented")
public actual fun setDefaultEventParameters(parameters: Map<String, String>) {}
public actual fun logEvent(name: String, parameters: Map<String, Any>?) {}
Expand Down
32 changes: 20 additions & 12 deletions firebase-config/api/android/firebase-config.api
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ public final class dev/gitlive/firebase/remoteconfig/FetchStatus : java/lang/Enu
public final class dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig {
public final fun activate (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public final fun ensureInitialized (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public final fun fetch (Ljava/lang/Long;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static synthetic fun fetch$default (Ldev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig;Ljava/lang/Long;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
public final fun fetch-dnQKTGw (Lkotlin/time/Duration;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static synthetic fun fetch-dnQKTGw$default (Ldev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig;Lkotlin/time/Duration;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
public final fun fetchAndActivate (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public final fun getAll ()Ljava/util/Map;
public final fun getAndroid ()Lcom/google/firebase/remoteconfig/FirebaseRemoteConfig;
Expand All @@ -25,33 +25,41 @@ public final class dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig {
}

public final class dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigInfo {
public fun <init> (Ldev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigSettings;JLdev/gitlive/firebase/remoteconfig/FetchStatus;)V
public fun <init> (Ldev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigSettings;Lkotlinx/datetime/Instant;Ldev/gitlive/firebase/remoteconfig/FetchStatus;)V
public final fun component1 ()Ldev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigSettings;
public final fun component2 ()J
public final fun component2 ()Lkotlinx/datetime/Instant;
public final fun component3 ()Ldev/gitlive/firebase/remoteconfig/FetchStatus;
public final fun copy (Ldev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigSettings;JLdev/gitlive/firebase/remoteconfig/FetchStatus;)Ldev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigInfo;
public static synthetic fun copy$default (Ldev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigInfo;Ldev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigSettings;JLdev/gitlive/firebase/remoteconfig/FetchStatus;ILjava/lang/Object;)Ldev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigInfo;
public final fun copy (Ldev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigSettings;Lkotlinx/datetime/Instant;Ldev/gitlive/firebase/remoteconfig/FetchStatus;)Ldev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigInfo;
public static synthetic fun copy$default (Ldev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigInfo;Ldev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigSettings;Lkotlinx/datetime/Instant;Ldev/gitlive/firebase/remoteconfig/FetchStatus;ILjava/lang/Object;)Ldev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigInfo;
public fun equals (Ljava/lang/Object;)Z
public final fun getConfigSettings ()Ldev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigSettings;
public final fun getFetchTime ()Lkotlinx/datetime/Instant;
public final fun getFetchTimeMillis ()J
public final fun getLastFetchStatus ()Ldev/gitlive/firebase/remoteconfig/FetchStatus;
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
}

public final class dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigKt {
public static final fun fetch (Ldev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig;JLkotlin/coroutines/Continuation;)Ljava/lang/Object;
}

public final class dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigSettings {
public fun <init> ()V
public fun <init> (JJ)V
public synthetic fun <init> (JJILkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun component1 ()J
public final fun component2 ()J
public final fun copy (JJ)Ldev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigSettings;
public static synthetic fun copy$default (Ldev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigSettings;JJILjava/lang/Object;)Ldev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigSettings;
public synthetic fun <init> (JJLkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun component1-UwyO8pc ()J
public final fun component2-UwyO8pc ()J
public final fun copy-QTBD994 (JJ)Ldev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigSettings;
public static synthetic fun copy-QTBD994$default (Ldev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigSettings;JJILjava/lang/Object;)Ldev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigSettings;
public fun equals (Ljava/lang/Object;)Z
public final fun getFetchTimeout-UwyO8pc ()J
public final fun getFetchTimeoutInSeconds ()J
public final fun getMinimumFetchInterval-UwyO8pc ()J
public final fun getMinimumFetchIntervalInSeconds ()J
public fun hashCode ()I
public final fun setFetchTimeout-LRDsOJo (J)V
public final fun setFetchTimeoutInSeconds (J)V
public final fun setMinimumFetchInterval-LRDsOJo (J)V
public final fun setMinimumFetchIntervalInSeconds (J)V
public fun toString ()Ljava/lang/String;
}
Expand Down
32 changes: 20 additions & 12 deletions firebase-config/api/jvm/firebase-config.api
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ public final class dev/gitlive/firebase/remoteconfig/FetchStatus : java/lang/Enu
public final class dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig {
public final fun activate (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public final fun ensureInitialized (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public final fun fetch (Ljava/lang/Long;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static synthetic fun fetch$default (Ldev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig;Ljava/lang/Long;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
public final fun fetch-dnQKTGw (Lkotlin/time/Duration;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static synthetic fun fetch-dnQKTGw$default (Ldev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig;Lkotlin/time/Duration;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
public final fun fetchAndActivate (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public final fun getAll ()Ljava/util/Map;
public final fun getAndroid ()Lcom/google/firebase/remoteconfig/FirebaseRemoteConfig;
Expand All @@ -25,33 +25,41 @@ public final class dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig {
}

public final class dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigInfo {
public fun <init> (Ldev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigSettings;JLdev/gitlive/firebase/remoteconfig/FetchStatus;)V
public fun <init> (Ldev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigSettings;Lkotlinx/datetime/Instant;Ldev/gitlive/firebase/remoteconfig/FetchStatus;)V
public final fun component1 ()Ldev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigSettings;
public final fun component2 ()J
public final fun component2 ()Lkotlinx/datetime/Instant;
public final fun component3 ()Ldev/gitlive/firebase/remoteconfig/FetchStatus;
public final fun copy (Ldev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigSettings;JLdev/gitlive/firebase/remoteconfig/FetchStatus;)Ldev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigInfo;
public static synthetic fun copy$default (Ldev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigInfo;Ldev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigSettings;JLdev/gitlive/firebase/remoteconfig/FetchStatus;ILjava/lang/Object;)Ldev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigInfo;
public final fun copy (Ldev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigSettings;Lkotlinx/datetime/Instant;Ldev/gitlive/firebase/remoteconfig/FetchStatus;)Ldev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigInfo;
public static synthetic fun copy$default (Ldev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigInfo;Ldev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigSettings;Lkotlinx/datetime/Instant;Ldev/gitlive/firebase/remoteconfig/FetchStatus;ILjava/lang/Object;)Ldev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigInfo;
public fun equals (Ljava/lang/Object;)Z
public final fun getConfigSettings ()Ldev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigSettings;
public final fun getFetchTime ()Lkotlinx/datetime/Instant;
public final fun getFetchTimeMillis ()J
public final fun getLastFetchStatus ()Ldev/gitlive/firebase/remoteconfig/FetchStatus;
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
}

public final class dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigKt {
public static final fun fetch (Ldev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig;JLkotlin/coroutines/Continuation;)Ljava/lang/Object;
}

public final class dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigSettings {
public fun <init> ()V
public fun <init> (JJ)V
public synthetic fun <init> (JJILkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun component1 ()J
public final fun component2 ()J
public final fun copy (JJ)Ldev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigSettings;
public static synthetic fun copy$default (Ldev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigSettings;JJILjava/lang/Object;)Ldev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigSettings;
public synthetic fun <init> (JJLkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun component1-UwyO8pc ()J
public final fun component2-UwyO8pc ()J
public final fun copy-QTBD994 (JJ)Ldev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigSettings;
public static synthetic fun copy-QTBD994$default (Ldev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigSettings;JJILjava/lang/Object;)Ldev/gitlive/firebase/remoteconfig/FirebaseRemoteConfigSettings;
public fun equals (Ljava/lang/Object;)Z
public final fun getFetchTimeout-UwyO8pc ()J
public final fun getFetchTimeoutInSeconds ()J
public final fun getMinimumFetchInterval-UwyO8pc ()J
public final fun getMinimumFetchIntervalInSeconds ()J
public fun hashCode ()I
public final fun setFetchTimeout-LRDsOJo (J)V
public final fun setFetchTimeoutInSeconds (J)V
public final fun setMinimumFetchInterval-LRDsOJo (J)V
public final fun setMinimumFetchIntervalInSeconds (J)V
public fun toString ()Ljava/lang/String;
}
Expand Down
6 changes: 6 additions & 0 deletions firebase-config/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ android {
}

compileOptions {
isCoreLibraryDesugaringEnabled = true
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
Expand All @@ -44,6 +45,10 @@ android {
}
}

dependencies {
coreLibraryDesugaring(libs.android.desugarjdk)
}

val supportIosTarget = project.property("skipIosTarget") != "true"

kotlin {
Expand Down Expand Up @@ -120,6 +125,7 @@ kotlin {
dependencies {
api(project(":firebase-app"))
implementation(project(":firebase-common"))
api(libs.kotlinx.datetime)
}
}

Expand Down
Loading

0 comments on commit e996b7c

Please sign in to comment.