From 46264667b0e4f0586a1e30c2eb6667afdbf37406 Mon Sep 17 00:00:00 2001 From: MOTOHARU ASANUMA Date: Thu, 17 Aug 2023 00:41:12 +0900 Subject: [PATCH 1/6] Changed to not include Firebase implementation on the iOS side MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit iOS側にFirebaseの実装を入れないように変更 --- core/data/build.gradle.kts | 2 +- .../github/droidkaigi/confsched2023/data/di/ApiModule.kt | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/core/data/build.gradle.kts b/core/data/build.gradle.kts index b8c81a68e..a2f286a60 100644 --- a/core/data/build.gradle.kts +++ b/core/data/build.gradle.kts @@ -24,7 +24,6 @@ kotlin { implementation(libs.ktorKotlinxSerialization) implementation(libs.ktorContentNegotiation) implementation(libs.kermit) - implementation(libs.firebaseRemoteConfig) } } val androidMain by getting { @@ -33,6 +32,7 @@ kotlin { implementation(libs.ktorClientOkHttp) implementation(libs.okHttpLoggingInterceptor) implementation(libs.okHttpLoggingInterceptor) + implementation(libs.firebaseRemoteConfig) } } val iosMain by getting { diff --git a/core/data/src/androidMain/kotlin/io/github/droidkaigi/confsched2023/data/di/ApiModule.kt b/core/data/src/androidMain/kotlin/io/github/droidkaigi/confsched2023/data/di/ApiModule.kt index 35e0ada79..8ce7950b5 100644 --- a/core/data/src/androidMain/kotlin/io/github/droidkaigi/confsched2023/data/di/ApiModule.kt +++ b/core/data/src/androidMain/kotlin/io/github/droidkaigi/confsched2023/data/di/ApiModule.kt @@ -10,7 +10,8 @@ import io.github.droidkaigi.confsched2023.data.auth.AndroidAuthenticator import io.github.droidkaigi.confsched2023.data.auth.AuthApi import io.github.droidkaigi.confsched2023.data.auth.Authenticator import io.github.droidkaigi.confsched2023.data.auth.DefaultAuthApi -import io.github.droidkaigi.confsched2023.data.remoteconfig.DefaultRemoteConfigApi +import io.github.droidkaigi.confsched2023.data.remoteconfig.FakeRemoteConfigApi +import io.github.droidkaigi.confsched2023.data.remoteconfig.FakeRemoteConfigApi.Status.Default import io.github.droidkaigi.confsched2023.data.remoteconfig.RemoteConfigApi import io.github.droidkaigi.confsched2023.data.user.UserDataStore import io.ktor.client.HttpClient @@ -159,6 +160,8 @@ class RemoteConfigModule { @Provides @Singleton fun provideFirebaseRemoteConfig(): RemoteConfigApi { - return DefaultRemoteConfigApi() + return FakeRemoteConfigApi().apply { + setUp(Default) + } } } From 07e9400877a2c4afc63436ba3f73a0c299db6a3e Mon Sep 17 00:00:00 2001 From: MOTOHARU ASANUMA Date: Thu, 17 Aug 2023 00:47:56 +0900 Subject: [PATCH 2/6] Changed to return DefaultRemoteConfigApi MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit DefaultRemoteConfigApiを返すように変更 --- .../github/droidkaigi/confsched2023/data/di/ApiModule.kt | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/core/data/src/androidMain/kotlin/io/github/droidkaigi/confsched2023/data/di/ApiModule.kt b/core/data/src/androidMain/kotlin/io/github/droidkaigi/confsched2023/data/di/ApiModule.kt index 8ce7950b5..35e0ada79 100644 --- a/core/data/src/androidMain/kotlin/io/github/droidkaigi/confsched2023/data/di/ApiModule.kt +++ b/core/data/src/androidMain/kotlin/io/github/droidkaigi/confsched2023/data/di/ApiModule.kt @@ -10,8 +10,7 @@ import io.github.droidkaigi.confsched2023.data.auth.AndroidAuthenticator import io.github.droidkaigi.confsched2023.data.auth.AuthApi import io.github.droidkaigi.confsched2023.data.auth.Authenticator import io.github.droidkaigi.confsched2023.data.auth.DefaultAuthApi -import io.github.droidkaigi.confsched2023.data.remoteconfig.FakeRemoteConfigApi -import io.github.droidkaigi.confsched2023.data.remoteconfig.FakeRemoteConfigApi.Status.Default +import io.github.droidkaigi.confsched2023.data.remoteconfig.DefaultRemoteConfigApi import io.github.droidkaigi.confsched2023.data.remoteconfig.RemoteConfigApi import io.github.droidkaigi.confsched2023.data.user.UserDataStore import io.ktor.client.HttpClient @@ -160,8 +159,6 @@ class RemoteConfigModule { @Provides @Singleton fun provideFirebaseRemoteConfig(): RemoteConfigApi { - return FakeRemoteConfigApi().apply { - setUp(Default) - } + return DefaultRemoteConfigApi() } } From 15a626d8720ee7719adb259d6a8491471ab12e3d Mon Sep 17 00:00:00 2001 From: MOTOHARU ASANUMA Date: Thu, 17 Aug 2023 01:37:36 +0900 Subject: [PATCH 3/6] Changed so that the key is passed across. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit keyが渡るように変更 --- .../data/remoteconfig/DefaultRemoteConfigApi.kt | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 core/data/src/iosMain/kotlin/io/github/droidkaigi/confsched2023/data/remoteconfig/DefaultRemoteConfigApi.kt diff --git a/core/data/src/iosMain/kotlin/io/github/droidkaigi/confsched2023/data/remoteconfig/DefaultRemoteConfigApi.kt b/core/data/src/iosMain/kotlin/io/github/droidkaigi/confsched2023/data/remoteconfig/DefaultRemoteConfigApi.kt new file mode 100644 index 000000000..e99f7630c --- /dev/null +++ b/core/data/src/iosMain/kotlin/io/github/droidkaigi/confsched2023/data/remoteconfig/DefaultRemoteConfigApi.kt @@ -0,0 +1,12 @@ +package io.github.droidkaigi.confsched2023.data.remoteconfig + +import io.github.droidkaigi.confsched2023.data.remoteconfig.FakeRemoteConfigApi.Status.Default + +actual class DefaultRemoteConfigApi : RemoteConfigApi { + + actual override suspend fun getBoolean(key: String): Boolean { + return FakeRemoteConfigApi().apply { + setUp(Default) + }.getBoolean(key) + } +} From 38b43736f1a63d2dae16ee06f1ad7fc7563543c0 Mon Sep 17 00:00:00 2001 From: MOTOHARU ASANUMA Date: Thu, 17 Aug 2023 01:38:08 +0900 Subject: [PATCH 4/6] Changed so that the key is passed across. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit keyが渡るように変更 --- .../confsched2023/data/remoteconfig/FakeRemoteConfigApi.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/data/src/commonMain/kotlin/io/github/droidkaigi/confsched2023/data/remoteconfig/FakeRemoteConfigApi.kt b/core/data/src/commonMain/kotlin/io/github/droidkaigi/confsched2023/data/remoteconfig/FakeRemoteConfigApi.kt index 65ec2dd23..80c9d89d2 100644 --- a/core/data/src/commonMain/kotlin/io/github/droidkaigi/confsched2023/data/remoteconfig/FakeRemoteConfigApi.kt +++ b/core/data/src/commonMain/kotlin/io/github/droidkaigi/confsched2023/data/remoteconfig/FakeRemoteConfigApi.kt @@ -25,6 +25,6 @@ class FakeRemoteConfigApi : RemoteConfigApi { } override suspend fun getBoolean(key: String): Boolean { - return status.getBoolean("key") + return status.getBoolean(key) } } From 200463e0de4617e82046228b0e7ea4a0cda95969 Mon Sep 17 00:00:00 2001 From: MOTOHARU ASANUMA Date: Thu, 17 Aug 2023 01:39:59 +0900 Subject: [PATCH 5/6] Revert "Changed so that the key is passed across." This reverts commit 15a626d8720ee7719adb259d6a8491471ab12e3d. --- .../data/remoteconfig/DefaultRemoteConfigApi.kt | 12 ------------ 1 file changed, 12 deletions(-) delete mode 100644 core/data/src/iosMain/kotlin/io/github/droidkaigi/confsched2023/data/remoteconfig/DefaultRemoteConfigApi.kt diff --git a/core/data/src/iosMain/kotlin/io/github/droidkaigi/confsched2023/data/remoteconfig/DefaultRemoteConfigApi.kt b/core/data/src/iosMain/kotlin/io/github/droidkaigi/confsched2023/data/remoteconfig/DefaultRemoteConfigApi.kt deleted file mode 100644 index e99f7630c..000000000 --- a/core/data/src/iosMain/kotlin/io/github/droidkaigi/confsched2023/data/remoteconfig/DefaultRemoteConfigApi.kt +++ /dev/null @@ -1,12 +0,0 @@ -package io.github.droidkaigi.confsched2023.data.remoteconfig - -import io.github.droidkaigi.confsched2023.data.remoteconfig.FakeRemoteConfigApi.Status.Default - -actual class DefaultRemoteConfigApi : RemoteConfigApi { - - actual override suspend fun getBoolean(key: String): Boolean { - return FakeRemoteConfigApi().apply { - setUp(Default) - }.getBoolean(key) - } -} From a1621d58758ec6481a33cc0499c15ed0de429bb8 Mon Sep 17 00:00:00 2001 From: MOTOHARU ASANUMA Date: Thu, 17 Aug 2023 01:43:20 +0900 Subject: [PATCH 6/6] Changed so that the key is passed across. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit iOSとAndroidで出し分け --- .../remoteconfig/DefaultRemoteConfigApi.kt | 26 +++++++++++++++++++ .../remoteconfig/DefaultRemoteConfigApi.kt | 25 ++---------------- .../remoteconfig/DefaultRemoteConfigApi.kt | 12 +++++++++ 3 files changed, 40 insertions(+), 23 deletions(-) create mode 100644 core/data/src/androidMain/kotlin/io/github/droidkaigi/confsched2023/data/remoteconfig/DefaultRemoteConfigApi.kt create mode 100644 core/data/src/iosMain/kotlin/io/github/droidkaigi/confsched2023/data/remoteconfig/DefaultRemoteConfigApi.kt diff --git a/core/data/src/androidMain/kotlin/io/github/droidkaigi/confsched2023/data/remoteconfig/DefaultRemoteConfigApi.kt b/core/data/src/androidMain/kotlin/io/github/droidkaigi/confsched2023/data/remoteconfig/DefaultRemoteConfigApi.kt new file mode 100644 index 000000000..0db955b74 --- /dev/null +++ b/core/data/src/androidMain/kotlin/io/github/droidkaigi/confsched2023/data/remoteconfig/DefaultRemoteConfigApi.kt @@ -0,0 +1,26 @@ +package io.github.droidkaigi.confsched2023.data.remoteconfig + +import dev.gitlive.firebase.Firebase +import dev.gitlive.firebase.remoteconfig.get +import dev.gitlive.firebase.remoteconfig.remoteConfig + +actual class DefaultRemoteConfigApi : RemoteConfigApi { + + private val firebaseRemoteConfig = Firebase.remoteConfig + + /** + * If you want to change the interval time to fetch, please change it here + */ +// init { +// CoroutineScope(Dispatchers.IO).launch { +// firebaseRemoteConfig.settings { +// minimumFetchIntervalInSeconds = 12 * 3600L +// } +// } +// } + + actual override suspend fun getBoolean(key: String): Boolean { + firebaseRemoteConfig.fetchAndActivate() + return firebaseRemoteConfig[key] + } +} diff --git a/core/data/src/commonMain/kotlin/io/github/droidkaigi/confsched2023/data/remoteconfig/DefaultRemoteConfigApi.kt b/core/data/src/commonMain/kotlin/io/github/droidkaigi/confsched2023/data/remoteconfig/DefaultRemoteConfigApi.kt index c07bd8f14..414d84884 100644 --- a/core/data/src/commonMain/kotlin/io/github/droidkaigi/confsched2023/data/remoteconfig/DefaultRemoteConfigApi.kt +++ b/core/data/src/commonMain/kotlin/io/github/droidkaigi/confsched2023/data/remoteconfig/DefaultRemoteConfigApi.kt @@ -1,26 +1,5 @@ package io.github.droidkaigi.confsched2023.data.remoteconfig -import dev.gitlive.firebase.Firebase -import dev.gitlive.firebase.remoteconfig.get -import dev.gitlive.firebase.remoteconfig.remoteConfig - -class DefaultRemoteConfigApi : RemoteConfigApi { - - private val firebaseRemoteConfig = Firebase.remoteConfig - - /** - * If you want to change the interval time to fetch, please change it here - */ -// init { -// CoroutineScope(Dispatchers.IO).launch { -// firebaseRemoteConfig.settings { -// minimumFetchIntervalInSeconds = 12 * 3600L -// } -// } -// } - - override suspend fun getBoolean(key: String): Boolean { - firebaseRemoteConfig.fetchAndActivate() - return firebaseRemoteConfig[key] - } +expect class DefaultRemoteConfigApi : RemoteConfigApi { + override suspend fun getBoolean(key: String): Boolean } diff --git a/core/data/src/iosMain/kotlin/io/github/droidkaigi/confsched2023/data/remoteconfig/DefaultRemoteConfigApi.kt b/core/data/src/iosMain/kotlin/io/github/droidkaigi/confsched2023/data/remoteconfig/DefaultRemoteConfigApi.kt new file mode 100644 index 000000000..e99f7630c --- /dev/null +++ b/core/data/src/iosMain/kotlin/io/github/droidkaigi/confsched2023/data/remoteconfig/DefaultRemoteConfigApi.kt @@ -0,0 +1,12 @@ +package io.github.droidkaigi.confsched2023.data.remoteconfig + +import io.github.droidkaigi.confsched2023.data.remoteconfig.FakeRemoteConfigApi.Status.Default + +actual class DefaultRemoteConfigApi : RemoteConfigApi { + + actual override suspend fun getBoolean(key: String): Boolean { + return FakeRemoteConfigApi().apply { + setUp(Default) + }.getBoolean(key) + } +}