diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 8f3d63f4b..d3621f1e3 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -121,7 +121,6 @@ dependencies { androidTestImplementation(projects.core.testing) androidTestImplementation(projects.core.dataTest) - androidTestImplementation(projects.core.datastoreTest) androidTestImplementation(libs.androidx.test.espresso.core) androidTestImplementation(libs.androidx.navigation.testing) androidTestImplementation(libs.accompanist.testharness) diff --git a/core/data/build.gradle.kts b/core/data/build.gradle.kts index 9ce32bc8a..bb16a65de 100644 --- a/core/data/build.gradle.kts +++ b/core/data/build.gradle.kts @@ -43,10 +43,9 @@ kotlin { } commonTest.dependencies { - implementation(libs.kotlinx.coroutines.test) + implementation(libs.multiplatform.settings.test) implementation(libs.kotlinx.serialization.json) -// implementation(projects.core.datastoreTest) -// implementation(projects.core.testing) + implementation(projects.core.testing) } androidMain.dependencies { diff --git a/core/datastore-proto/build.gradle.kts b/core/datastore-proto/build.gradle.kts deleted file mode 100644 index 53f2d19f6..000000000 --- a/core/datastore-proto/build.gradle.kts +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2023 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -plugins { - alias(libs.plugins.nowinandroid.kmp.library) - alias(libs.plugins.protobuf) - id("kotlinx-serialization") -} - -android { - namespace = "com.google.samples.apps.nowinandroid.core.datastore.proto" -} - -// Setup protobuf configuration, generating lite Java and Kotlin classes -protobuf { - protoc { - artifact = libs.protobuf.protoc.get().toString() - } - generateProtoTasks { - all().forEach { task -> - task.builtins { - register("kotlin") { - option("lite") - } - } - } - } -} - -kotlin { - sourceSets { - commonMain.dependencies { - api(libs.protobuf.kotlin.lite) - implementation(libs.kotlinx.serialization.core) - } - } -} diff --git a/core/datastore-proto/src/commonMain/kotlin/com/google/samples/apps/nowinandroid/core/datastore/DarkThemeConfigProto.kt b/core/datastore-proto/src/commonMain/kotlin/com/google/samples/apps/nowinandroid/core/datastore/DarkThemeConfigProto.kt deleted file mode 100644 index 38c047828..000000000 --- a/core/datastore-proto/src/commonMain/kotlin/com/google/samples/apps/nowinandroid/core/datastore/DarkThemeConfigProto.kt +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright 2024 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.samples.apps.nowinandroid.core.datastore - -enum class DarkThemeConfigProto { - DARK_THEME_CONFIG_UNSPECIFIED, - DARK_THEME_CONFIG_FOLLOW_SYSTEM, - DARK_THEME_CONFIG_LIGHT, - DARK_THEME_CONFIG_DARK, -} diff --git a/core/datastore-proto/src/commonMain/kotlin/com/google/samples/apps/nowinandroid/core/datastore/ThemeBrandProto.kt b/core/datastore-proto/src/commonMain/kotlin/com/google/samples/apps/nowinandroid/core/datastore/ThemeBrandProto.kt deleted file mode 100644 index 1b10258ff..000000000 --- a/core/datastore-proto/src/commonMain/kotlin/com/google/samples/apps/nowinandroid/core/datastore/ThemeBrandProto.kt +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright 2024 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.samples.apps.nowinandroid.core.datastore - -enum class ThemeBrandProto { - THEME_BRAND_UNSPECIFIED, - THEME_BRAND_DEFAULT, - THEME_BRAND_ANDROID, -} diff --git a/core/datastore-proto/src/commonMain/kotlin/com/google/samples/apps/nowinandroid/core/datastore/UserPreferences.kt b/core/datastore-proto/src/commonMain/kotlin/com/google/samples/apps/nowinandroid/core/datastore/UserPreferences.kt deleted file mode 100644 index f8168fc0c..000000000 --- a/core/datastore-proto/src/commonMain/kotlin/com/google/samples/apps/nowinandroid/core/datastore/UserPreferences.kt +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 2024 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.samples.apps.nowinandroid.core.datastore - -import com.google.samples.apps.nowinandroid.core.datastore.DarkThemeConfigProto.DARK_THEME_CONFIG_FOLLOW_SYSTEM -import com.google.samples.apps.nowinandroid.core.datastore.ThemeBrandProto.THEME_BRAND_UNSPECIFIED -import kotlinx.serialization.Serializable - -// A lot of workaround brought by Proto -@Serializable -data class UserPreferences( - val topicChangeListVersion: Int, - val authorChangeListVersion: Int, - val newsResourceChangeListVersion: Int, - val hasDoneIntToStringIdMigration: Boolean, - val hasDoneListToMapMigration: Boolean, - val followedTopicIds: Set = emptySet(), - val followedAuthorIds: Set = emptySet(), - val bookmarkedNewsResourceIds: Set = emptySet(), - val viewedNewsResourceIds: Set = emptySet(), - val themeBrand: ThemeBrandProto, - val darkThemeConfig: DarkThemeConfigProto, - val shouldHideOnboarding: Boolean, - val useDynamicColor: Boolean, -) { - companion object { - val DEFAULT = UserPreferences( - topicChangeListVersion = 0, - authorChangeListVersion = 0, - newsResourceChangeListVersion = 0, - hasDoneIntToStringIdMigration = false, - hasDoneListToMapMigration = false, - themeBrand = THEME_BRAND_UNSPECIFIED, - darkThemeConfig = DARK_THEME_CONFIG_FOLLOW_SYSTEM, - shouldHideOnboarding = false, - useDynamicColor = false, - ) - } -} diff --git a/core/datastore-proto/src/commonMain/proto/com/google/samples/apps/nowinandroid/data/dark_theme_config.proto b/core/datastore-proto/src/commonMain/proto/com/google/samples/apps/nowinandroid/data/dark_theme_config.proto deleted file mode 100644 index 82bac8366..000000000 --- a/core/datastore-proto/src/commonMain/proto/com/google/samples/apps/nowinandroid/data/dark_theme_config.proto +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (C) 2022 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -syntax = "proto3"; - -option java_package = "com.google.samples.apps.nowinandroid.core.datastore"; -option java_multiple_files = true; - -enum DarkThemeConfigProto { - DARK_THEME_CONFIG_UNSPECIFIED = 0; - DARK_THEME_CONFIG_FOLLOW_SYSTEM = 1; - DARK_THEME_CONFIG_LIGHT = 2; - DARK_THEME_CONFIG_DARK = 3; -} diff --git a/core/datastore-proto/src/commonMain/proto/com/google/samples/apps/nowinandroid/data/theme_brand.proto b/core/datastore-proto/src/commonMain/proto/com/google/samples/apps/nowinandroid/data/theme_brand.proto deleted file mode 100644 index 8bcf5859b..000000000 --- a/core/datastore-proto/src/commonMain/proto/com/google/samples/apps/nowinandroid/data/theme_brand.proto +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (C) 2022 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -syntax = "proto3"; - -option java_package = "com.google.samples.apps.nowinandroid.core.datastore"; -option java_multiple_files = true; - -enum ThemeBrandProto { - THEME_BRAND_UNSPECIFIED = 0; - THEME_BRAND_DEFAULT = 1; - THEME_BRAND_ANDROID = 2; -} diff --git a/core/datastore-proto/src/commonMain/proto/com/google/samples/apps/nowinandroid/data/user_preferences.proto b/core/datastore-proto/src/commonMain/proto/com/google/samples/apps/nowinandroid/data/user_preferences.proto deleted file mode 100644 index 11386613c..000000000 --- a/core/datastore-proto/src/commonMain/proto/com/google/samples/apps/nowinandroid/data/user_preferences.proto +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (C) 2022 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -syntax = "proto3"; - -import "com/google/samples/apps/nowinandroid/data/dark_theme_config.proto"; -import "com/google/samples/apps/nowinandroid/data/theme_brand.proto"; - -option java_package = "com.google.samples.apps.nowinandroid.core.datastore"; -option java_multiple_files = true; - -message UserPreferences { - reserved 2; - repeated int32 deprecated_int_followed_topic_ids = 1; - int32 topicChangeListVersion = 3; - int32 authorChangeListVersion = 4; - int32 newsResourceChangeListVersion = 6; - repeated int32 deprecated_int_followed_author_ids = 7; - bool has_done_int_to_string_id_migration = 8; - repeated string deprecated_followed_topic_ids = 9; - repeated string deprecated_followed_author_ids = 10; - repeated string deprecated_bookmarked_news_resource_ids = 11; - bool has_done_list_to_map_migration = 12; - - // Each map is used to store a set of string IDs. The bool has no meaning, but proto3 doesn't - // have a Set type so this is the closest we can get to a Set. - map followed_topic_ids = 13; - map followed_author_ids = 14; - map bookmarked_news_resource_ids = 15; - map viewed_news_resource_ids = 20; - - ThemeBrandProto theme_brand = 16; - DarkThemeConfigProto dark_theme_config = 17; - - bool should_hide_onboarding = 18; - - bool use_dynamic_color = 19; - - // NEXT AVAILABLE ID: 21 -} diff --git a/core/datastore-test/.gitignore b/core/datastore-test/.gitignore deleted file mode 100644 index 42afabfd2..000000000 --- a/core/datastore-test/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/build \ No newline at end of file diff --git a/core/datastore-test/README.md b/core/datastore-test/README.md deleted file mode 100644 index 45cc51a48..000000000 --- a/core/datastore-test/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# :core:datastore-test module - -![Dependency graph](../../docs/images/graphs/dep_graph_core_datastore_test.png) diff --git a/core/datastore-test/build.gradle.kts b/core/datastore-test/build.gradle.kts deleted file mode 100644 index 53e5e2c0c..000000000 --- a/core/datastore-test/build.gradle.kts +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2022 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -plugins { - alias(libs.plugins.nowinandroid.android.library) - alias(libs.plugins.nowinandroid.android.hilt) -} - -android { - namespace = "com.google.samples.apps.nowinandroid.core.datastore.test" -} - -dependencies { - implementation(libs.hilt.android.testing) - implementation(projects.core.common) - implementation(projects.core.datastore) -} diff --git a/core/datastore-test/src/main/AndroidManifest.xml b/core/datastore-test/src/main/AndroidManifest.xml deleted file mode 100644 index 51d0cfc2e..000000000 --- a/core/datastore-test/src/main/AndroidManifest.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - \ No newline at end of file diff --git a/core/datastore-test/src/main/kotlin/com/google/samples/apps/nowinandroid/core/datastore/test/TestDataStoreModule.kt b/core/datastore-test/src/main/kotlin/com/google/samples/apps/nowinandroid/core/datastore/test/TestDataStoreModule.kt deleted file mode 100644 index b4a5cb182..000000000 --- a/core/datastore-test/src/main/kotlin/com/google/samples/apps/nowinandroid/core/datastore/test/TestDataStoreModule.kt +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright 2022 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.samples.apps.nowinandroid.core.datastore.test - -import androidx.datastore.core.DataStore -import androidx.datastore.core.DataStoreFactory -import com.google.samples.apps.nowinandroid.core.datastore.UserPreferences -import com.google.samples.apps.nowinandroid.core.datastore.UserPreferencesSerializer -import com.google.samples.apps.nowinandroid.core.datastore.di.DataStoreModule -import com.google.samples.apps.nowinandroid.core.di.ApplicationScope -import dagger.Module -import dagger.Provides -import dagger.hilt.components.SingletonComponent -import dagger.hilt.testing.TestInstallIn -import kotlinx.coroutines.CoroutineScope -import org.junit.rules.TemporaryFolder -import javax.inject.Singleton - -@Module -@TestInstallIn( - components = [SingletonComponent::class], - replaces = [DataStoreModule::class], -) -internal object TestDataStoreModule { - - @Provides - @Singleton - fun providesUserPreferencesDataStore( - @ApplicationScope scope: CoroutineScope, - userPreferencesSerializer: UserPreferencesSerializer, - tmpFolder: TemporaryFolder, - ): DataStore = - tmpFolder.testUserPreferencesDataStore( - coroutineScope = scope, - userPreferencesSerializer = userPreferencesSerializer, - ) -} - -fun TemporaryFolder.testUserPreferencesDataStore( - coroutineScope: CoroutineScope, - userPreferencesSerializer: UserPreferencesSerializer = UserPreferencesSerializer(), -) = DataStoreFactory.create( - serializer = userPreferencesSerializer, - scope = coroutineScope, -) { - newFile("user_preferences_test.pb") -} diff --git a/core/datastore/build.gradle.kts b/core/datastore/build.gradle.kts index ffa4331da..9e28bae6e 100644 --- a/core/datastore/build.gradle.kts +++ b/core/datastore/build.gradle.kts @@ -42,7 +42,6 @@ kotlin { implementation(libs.kotlinx.serialization.core) implementation(projects.core.model) implementation(projects.core.common) - implementation(projects.core.datastoreProto) } commonTest.dependencies { implementation(libs.multiplatform.settings.test) diff --git a/settings.gradle.kts b/settings.gradle.kts index 2977bce34..e1b0eddfa 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -45,8 +45,6 @@ include(":core:data") include(":core:data-test") include(":core:database") include(":core:datastore") -include(":core:datastore-proto") -include(":core:datastore-test") include(":core:designsystem") include(":core:domain") include(":core:model")