diff --git a/app-nia-catalog/README.md b/app-nia-catalog/README.md
index edbbb5e46..99503ba84 100644
--- a/app-nia-catalog/README.md
+++ b/app-nia-catalog/README.md
@@ -1,3 +1,3 @@
# :app-nia-catalog module
-
-
+## Dependency graph
+
diff --git a/app/README.md b/app/README.md
index 9f151c245..f80083494 100644
--- a/app/README.md
+++ b/app/README.md
@@ -1,3 +1,3 @@
# :app module
-
-
+## Dependency graph
+
diff --git a/build.gradle.kts b/build.gradle.kts
index 6fe9b829e..1790cd202 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -27,9 +27,10 @@ buildscript {
exclude(group = "com.google.protobuf")
}
}
+
}
-// Lists all plugins used throughout the project without applying them.
+// Lists all plugins used throughout the project
plugins {
alias(libs.plugins.android.application) apply false
alias(libs.plugins.android.library) apply false
@@ -46,4 +47,15 @@ plugins {
alias(libs.plugins.roborazzi) apply false
alias(libs.plugins.secrets) apply false
alias(libs.plugins.room) apply false
+ alias(libs.plugins.module.graph) apply true // Plugin applied to allow module graph generation
}
+
+// Task to print all the module paths in the project e.g. :core:data
+// Used by module graph generator script
+tasks.register("printModulePaths") {
+ subprojects {
+ if (subprojects.size == 0) {
+ println(this.path)
+ }
+ }
+}
\ No newline at end of file
diff --git a/core/analytics/README.md b/core/analytics/README.md
new file mode 100644
index 000000000..d2bcd1ea7
--- /dev/null
+++ b/core/analytics/README.md
@@ -0,0 +1,3 @@
+# :core:analytics module
+## Dependency graph
+
diff --git a/core/common/README.md b/core/common/README.md
index ade22c076..96558bcc6 100644
--- a/core/common/README.md
+++ b/core/common/README.md
@@ -1,3 +1,3 @@
# :core:common module
-
-
+## Dependency graph
+
diff --git a/core/data-test/README.md b/core/data-test/README.md
index 4f623e629..977ee10e4 100644
--- a/core/data-test/README.md
+++ b/core/data-test/README.md
@@ -1,3 +1,3 @@
# :core:data-test module
-
-
+## Dependency graph
+
diff --git a/core/data-test/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/test/repository/FakeUserDataRepository.kt b/core/data-test/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/test/repository/FakeUserDataRepository.kt
index cdd23429f..4871baad9 100644
--- a/core/data-test/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/test/repository/FakeUserDataRepository.kt
+++ b/core/data-test/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/test/repository/FakeUserDataRepository.kt
@@ -43,7 +43,7 @@ internal class FakeUserDataRepository @Inject constructor(
override suspend fun setTopicIdFollowed(followedTopicId: String, followed: Boolean) =
niaPreferencesDataSource.setTopicIdFollowed(followedTopicId, followed)
- override suspend fun updateNewsResourceBookmark(newsResourceId: String, bookmarked: Boolean) {
+ override suspend fun setNewsResourceBookmarked(newsResourceId: String, bookmarked: Boolean) {
niaPreferencesDataSource.setNewsResourceBookmarked(newsResourceId, bookmarked)
}
diff --git a/core/data/README.md b/core/data/README.md
index 905d74615..5d30f1638 100644
--- a/core/data/README.md
+++ b/core/data/README.md
@@ -1,3 +1,3 @@
# :core:data module
-
-
+## Dependency graph
+
diff --git a/core/data/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/repository/OfflineFirstUserDataRepository.kt b/core/data/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/repository/OfflineFirstUserDataRepository.kt
index c0b1bcc33..089b7087d 100644
--- a/core/data/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/repository/OfflineFirstUserDataRepository.kt
+++ b/core/data/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/repository/OfflineFirstUserDataRepository.kt
@@ -42,7 +42,7 @@ internal class OfflineFirstUserDataRepository @Inject constructor(
analyticsHelper.logTopicFollowToggled(followedTopicId, followed)
}
- override suspend fun updateNewsResourceBookmark(newsResourceId: String, bookmarked: Boolean) {
+ override suspend fun setNewsResourceBookmarked(newsResourceId: String, bookmarked: Boolean) {
niaPreferencesDataSource.setNewsResourceBookmarked(newsResourceId, bookmarked)
analyticsHelper.logNewsResourceBookmarkToggled(
newsResourceId = newsResourceId,
diff --git a/core/data/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/repository/UserDataRepository.kt b/core/data/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/repository/UserDataRepository.kt
index ff616c179..c5202b02b 100644
--- a/core/data/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/repository/UserDataRepository.kt
+++ b/core/data/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/repository/UserDataRepository.kt
@@ -41,7 +41,7 @@ interface UserDataRepository {
/**
* Updates the bookmarked status for a news resource
*/
- suspend fun updateNewsResourceBookmark(newsResourceId: String, bookmarked: Boolean)
+ suspend fun setNewsResourceBookmarked(newsResourceId: String, bookmarked: Boolean)
/**
* Updates the viewed status for a news resource
diff --git a/core/data/src/test/kotlin/com/google/samples/apps/nowinandroid/core/data/repository/OfflineFirstUserDataRepositoryTest.kt b/core/data/src/test/kotlin/com/google/samples/apps/nowinandroid/core/data/repository/OfflineFirstUserDataRepositoryTest.kt
index 27e86f2f4..422e2cfb7 100644
--- a/core/data/src/test/kotlin/com/google/samples/apps/nowinandroid/core/data/repository/OfflineFirstUserDataRepositoryTest.kt
+++ b/core/data/src/test/kotlin/com/google/samples/apps/nowinandroid/core/data/repository/OfflineFirstUserDataRepositoryTest.kt
@@ -133,7 +133,7 @@ class OfflineFirstUserDataRepositoryTest {
@Test
fun offlineFirstUserDataRepository_bookmark_news_resource_logic_delegates_to_nia_preferences() =
testScope.runTest {
- subject.updateNewsResourceBookmark(newsResourceId = "0", bookmarked = true)
+ subject.setNewsResourceBookmarked(newsResourceId = "0", bookmarked = true)
assertEquals(
setOf("0"),
@@ -142,7 +142,7 @@ class OfflineFirstUserDataRepositoryTest {
.first(),
)
- subject.updateNewsResourceBookmark(newsResourceId = "1", bookmarked = true)
+ subject.setNewsResourceBookmarked(newsResourceId = "1", bookmarked = true)
assertEquals(
setOf("0", "1"),
diff --git a/core/database/README.md b/core/database/README.md
index 5cf339aed..855eab53e 100644
--- a/core/database/README.md
+++ b/core/database/README.md
@@ -1,3 +1,3 @@
# :core:database module
-
-
+## Dependency graph
+
diff --git a/core/datastore-proto/README.md b/core/datastore-proto/README.md
new file mode 100644
index 000000000..19ed58239
--- /dev/null
+++ b/core/datastore-proto/README.md
@@ -0,0 +1,3 @@
+# :core:datastore-proto module
+## Dependency graph
+
diff --git a/core/datastore-test/README.md b/core/datastore-test/README.md
index 45cc51a48..99cf13f1f 100644
--- a/core/datastore-test/README.md
+++ b/core/datastore-test/README.md
@@ -1,3 +1,3 @@
# :core:datastore-test module
-
-
+## Dependency graph
+
diff --git a/core/datastore/README.md b/core/datastore/README.md
index 56699a483..4785c5885 100644
--- a/core/datastore/README.md
+++ b/core/datastore/README.md
@@ -1,3 +1,3 @@
# :core:datastore module
-
-
+## Dependency graph
+
diff --git a/core/designsystem/README.md b/core/designsystem/README.md
index 52a793821..d1778cb14 100644
--- a/core/designsystem/README.md
+++ b/core/designsystem/README.md
@@ -1,3 +1,3 @@
# :core:designsystem module
-
-
+## Dependency graph
+
diff --git a/core/domain/README.md b/core/domain/README.md
new file mode 100644
index 000000000..cc6905846
--- /dev/null
+++ b/core/domain/README.md
@@ -0,0 +1,3 @@
+# :core:domain module
+## Dependency graph
+
diff --git a/core/model/README.md b/core/model/README.md
index 5279064f2..efd0eec76 100644
--- a/core/model/README.md
+++ b/core/model/README.md
@@ -1,3 +1,3 @@
# :core:model module
-
-
+## Dependency graph
+
diff --git a/core/network/README.md b/core/network/README.md
index cfd9fd369..516aa2d38 100644
--- a/core/network/README.md
+++ b/core/network/README.md
@@ -1,3 +1,3 @@
# :core:network module
-
-
+## Dependency graph
+
diff --git a/core/notifications/README.md b/core/notifications/README.md
new file mode 100644
index 000000000..8f5607bdf
--- /dev/null
+++ b/core/notifications/README.md
@@ -0,0 +1,3 @@
+# :core:notifications module
+## Dependency graph
+
diff --git a/core/screenshot-testing/README.md b/core/screenshot-testing/README.md
new file mode 100644
index 000000000..9bd4f1f9c
--- /dev/null
+++ b/core/screenshot-testing/README.md
@@ -0,0 +1,3 @@
+# :core:screenshot-testing module
+## Dependency graph
+
diff --git a/core/testing/README.md b/core/testing/README.md
index 8eea64ac9..5a35d379b 100644
--- a/core/testing/README.md
+++ b/core/testing/README.md
@@ -1,3 +1,3 @@
# :core:testing module
-
-
+## Dependency graph
+
diff --git a/core/testing/src/main/kotlin/com/google/samples/apps/nowinandroid/core/testing/repository/TestUserDataRepository.kt b/core/testing/src/main/kotlin/com/google/samples/apps/nowinandroid/core/testing/repository/TestUserDataRepository.kt
index 504e79217..be76112dc 100644
--- a/core/testing/src/main/kotlin/com/google/samples/apps/nowinandroid/core/testing/repository/TestUserDataRepository.kt
+++ b/core/testing/src/main/kotlin/com/google/samples/apps/nowinandroid/core/testing/repository/TestUserDataRepository.kt
@@ -61,7 +61,7 @@ class TestUserDataRepository : UserDataRepository {
}
}
- override suspend fun updateNewsResourceBookmark(newsResourceId: String, bookmarked: Boolean) {
+ override suspend fun setNewsResourceBookmarked(newsResourceId: String, bookmarked: Boolean) {
currentUserData.let { current ->
val bookmarkedNews = if (bookmarked) {
current.bookmarkedNewsResources + newsResourceId
diff --git a/core/ui/README.md b/core/ui/README.md
index 88c3561f1..38e514d01 100644
--- a/core/ui/README.md
+++ b/core/ui/README.md
@@ -1,3 +1,3 @@
# :core:ui module
-
-
+## Dependency graph
+
diff --git a/feature/interests/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/interests/InterestsItem.kt b/core/ui/src/main/kotlin/com/google/samples/apps/nowinandroid/core/ui/InterestsItem.kt
similarity index 95%
rename from feature/interests/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/interests/InterestsItem.kt
rename to core/ui/src/main/kotlin/com/google/samples/apps/nowinandroid/core/ui/InterestsItem.kt
index 6ac0340ee..28cd8d938 100644
--- a/feature/interests/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/interests/InterestsItem.kt
+++ b/core/ui/src/main/kotlin/com/google/samples/apps/nowinandroid/core/ui/InterestsItem.kt
@@ -1,5 +1,5 @@
/*
- * Copyright 2022 The Android Open Source Project
+ * 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.
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.google.samples.apps.nowinandroid.feature.interests
+package com.google.samples.apps.nowinandroid.core.ui
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
@@ -38,7 +38,7 @@ import com.google.samples.apps.nowinandroid.core.designsystem.component.DynamicA
import com.google.samples.apps.nowinandroid.core.designsystem.component.NiaIconToggleButton
import com.google.samples.apps.nowinandroid.core.designsystem.icon.NiaIcons
import com.google.samples.apps.nowinandroid.core.designsystem.theme.NiaTheme
-import com.google.samples.apps.nowinandroid.feature.interests.R.string
+import com.google.samples.apps.nowinandroid.core.ui.R.string
@Composable
fun InterestsItem(
@@ -70,7 +70,7 @@ fun InterestsItem(
Icon(
imageVector = NiaIcons.Add,
contentDescription = stringResource(
- id = string.feature_interests_card_follow_button_content_desc,
+ id = string.core_ui_interests_card_follow_button_content_desc,
),
)
},
@@ -78,7 +78,7 @@ fun InterestsItem(
Icon(
imageVector = NiaIcons.Check,
contentDescription = stringResource(
- id = string.feature_interests_card_unfollow_button_content_desc,
+ id = string.core_ui_interests_card_unfollow_button_content_desc,
),
)
},
diff --git a/core/ui/src/main/res/values/strings.xml b/core/ui/src/main/res/values/strings.xml
index 65a855fc9..ab76748ef 100644
--- a/core/ui/src/main/res/values/strings.xml
+++ b/core/ui/src/main/res/values/strings.xml
@@ -26,4 +26,7 @@
%1$s is followed
%1$s is not followed
+
+ Follow interest
+ Unfollow interest
diff --git a/docs/images/graphs/dep_graph_app.png b/docs/images/graphs/dep_graph_app.png
deleted file mode 100644
index dc1e0b7d7..000000000
Binary files a/docs/images/graphs/dep_graph_app.png and /dev/null differ
diff --git a/docs/images/graphs/dep_graph_app.svg b/docs/images/graphs/dep_graph_app.svg
new file mode 100644
index 000000000..57a592a8e
--- /dev/null
+++ b/docs/images/graphs/dep_graph_app.svg
@@ -0,0 +1,463 @@
+
+
+
+
+
diff --git a/docs/images/graphs/dep_graph_app_nia_catalog.png b/docs/images/graphs/dep_graph_app_nia_catalog.png
deleted file mode 100644
index e2698f0b0..000000000
Binary files a/docs/images/graphs/dep_graph_app_nia_catalog.png and /dev/null differ
diff --git a/docs/images/graphs/dep_graph_app_nia_catalog.svg b/docs/images/graphs/dep_graph_app_nia_catalog.svg
new file mode 100644
index 000000000..b58415cef
--- /dev/null
+++ b/docs/images/graphs/dep_graph_app_nia_catalog.svg
@@ -0,0 +1,73 @@
+
+
+
+
+
diff --git a/docs/images/graphs/dep_graph_benchmark.png b/docs/images/graphs/dep_graph_benchmark.png
deleted file mode 100644
index a724c2fca..000000000
Binary files a/docs/images/graphs/dep_graph_benchmark.png and /dev/null differ
diff --git a/docs/images/graphs/dep_graph_core_analytics.svg b/docs/images/graphs/dep_graph_core_analytics.svg
new file mode 100644
index 000000000..ac21c0707
--- /dev/null
+++ b/docs/images/graphs/dep_graph_core_analytics.svg
@@ -0,0 +1,19 @@
+
+
+
+
+
diff --git a/docs/images/graphs/dep_graph_core_common.png b/docs/images/graphs/dep_graph_core_common.png
deleted file mode 100644
index 8e5628068..000000000
Binary files a/docs/images/graphs/dep_graph_core_common.png and /dev/null differ
diff --git a/docs/images/graphs/dep_graph_core_common.svg b/docs/images/graphs/dep_graph_core_common.svg
new file mode 100644
index 000000000..c91f33853
--- /dev/null
+++ b/docs/images/graphs/dep_graph_core_common.svg
@@ -0,0 +1,19 @@
+
+
+
+
+
diff --git a/docs/images/graphs/dep_graph_core_data.png b/docs/images/graphs/dep_graph_core_data.png
deleted file mode 100644
index fc30029b7..000000000
Binary files a/docs/images/graphs/dep_graph_core_data.png and /dev/null differ
diff --git a/docs/images/graphs/dep_graph_core_data.svg b/docs/images/graphs/dep_graph_core_data.svg
new file mode 100644
index 000000000..cacf03a1f
--- /dev/null
+++ b/docs/images/graphs/dep_graph_core_data.svg
@@ -0,0 +1,151 @@
+
+
+
+
+
diff --git a/docs/images/graphs/dep_graph_core_data_test.png b/docs/images/graphs/dep_graph_core_data_test.png
deleted file mode 100644
index c3762b600..000000000
Binary files a/docs/images/graphs/dep_graph_core_data_test.png and /dev/null differ
diff --git a/docs/images/graphs/dep_graph_core_data_test.svg b/docs/images/graphs/dep_graph_core_data_test.svg
new file mode 100644
index 000000000..162c83f10
--- /dev/null
+++ b/docs/images/graphs/dep_graph_core_data_test.svg
@@ -0,0 +1,163 @@
+
+
+
+
+
diff --git a/docs/images/graphs/dep_graph_core_database.png b/docs/images/graphs/dep_graph_core_database.png
deleted file mode 100644
index dc3e65756..000000000
Binary files a/docs/images/graphs/dep_graph_core_database.png and /dev/null differ
diff --git a/docs/images/graphs/dep_graph_core_database.svg b/docs/images/graphs/dep_graph_core_database.svg
new file mode 100644
index 000000000..9e907b96f
--- /dev/null
+++ b/docs/images/graphs/dep_graph_core_database.svg
@@ -0,0 +1,31 @@
+
+
+
+
+
diff --git a/docs/images/graphs/dep_graph_core_datastore.png b/docs/images/graphs/dep_graph_core_datastore.png
deleted file mode 100644
index 861c2498a..000000000
Binary files a/docs/images/graphs/dep_graph_core_datastore.png and /dev/null differ
diff --git a/docs/images/graphs/dep_graph_core_datastore.svg b/docs/images/graphs/dep_graph_core_datastore.svg
new file mode 100644
index 000000000..cfcf78db2
--- /dev/null
+++ b/docs/images/graphs/dep_graph_core_datastore.svg
@@ -0,0 +1,55 @@
+
+
+
+
+
diff --git a/docs/images/graphs/dep_graph_core_datastore_proto.svg b/docs/images/graphs/dep_graph_core_datastore_proto.svg
new file mode 100644
index 000000000..d572d0ea7
--- /dev/null
+++ b/docs/images/graphs/dep_graph_core_datastore_proto.svg
@@ -0,0 +1,19 @@
+
+
+
+
+
diff --git a/docs/images/graphs/dep_graph_core_datastore_test.png b/docs/images/graphs/dep_graph_core_datastore_test.png
deleted file mode 100644
index efe51c7de..000000000
Binary files a/docs/images/graphs/dep_graph_core_datastore_test.png and /dev/null differ
diff --git a/docs/images/graphs/dep_graph_core_datastore_test.svg b/docs/images/graphs/dep_graph_core_datastore_test.svg
new file mode 100644
index 000000000..ca8d3f84b
--- /dev/null
+++ b/docs/images/graphs/dep_graph_core_datastore_test.svg
@@ -0,0 +1,73 @@
+
+
+
+
+
diff --git a/docs/images/graphs/dep_graph_core_designsystem.png b/docs/images/graphs/dep_graph_core_designsystem.png
deleted file mode 100644
index 1d6002d2a..000000000
Binary files a/docs/images/graphs/dep_graph_core_designsystem.png and /dev/null differ
diff --git a/docs/images/graphs/dep_graph_core_designsystem.svg b/docs/images/graphs/dep_graph_core_designsystem.svg
new file mode 100644
index 000000000..f46f075f0
--- /dev/null
+++ b/docs/images/graphs/dep_graph_core_designsystem.svg
@@ -0,0 +1,19 @@
+
+
+
+
+
diff --git a/docs/images/graphs/dep_graph_core_domain.svg b/docs/images/graphs/dep_graph_core_domain.svg
new file mode 100644
index 000000000..1c97b64e8
--- /dev/null
+++ b/docs/images/graphs/dep_graph_core_domain.svg
@@ -0,0 +1,169 @@
+
+
+
+
+
diff --git a/docs/images/graphs/dep_graph_core_model.png b/docs/images/graphs/dep_graph_core_model.png
deleted file mode 100644
index 205583afa..000000000
Binary files a/docs/images/graphs/dep_graph_core_model.png and /dev/null differ
diff --git a/docs/images/graphs/dep_graph_core_model.svg b/docs/images/graphs/dep_graph_core_model.svg
new file mode 100644
index 000000000..290457d6c
--- /dev/null
+++ b/docs/images/graphs/dep_graph_core_model.svg
@@ -0,0 +1,19 @@
+
+
+
+
+
diff --git a/docs/images/graphs/dep_graph_core_navigation.png b/docs/images/graphs/dep_graph_core_navigation.png
deleted file mode 100644
index 5ceab49b8..000000000
Binary files a/docs/images/graphs/dep_graph_core_navigation.png and /dev/null differ
diff --git a/docs/images/graphs/dep_graph_core_network.png b/docs/images/graphs/dep_graph_core_network.png
deleted file mode 100644
index 908715660..000000000
Binary files a/docs/images/graphs/dep_graph_core_network.png and /dev/null differ
diff --git a/docs/images/graphs/dep_graph_core_network.svg b/docs/images/graphs/dep_graph_core_network.svg
new file mode 100644
index 000000000..ea804bcff
--- /dev/null
+++ b/docs/images/graphs/dep_graph_core_network.svg
@@ -0,0 +1,43 @@
+
+
+
+
+
diff --git a/docs/images/graphs/dep_graph_core_notifications.svg b/docs/images/graphs/dep_graph_core_notifications.svg
new file mode 100644
index 000000000..cf25ca32e
--- /dev/null
+++ b/docs/images/graphs/dep_graph_core_notifications.svg
@@ -0,0 +1,43 @@
+
+
+
+
+
diff --git a/docs/images/graphs/dep_graph_core_screenshot_testing.svg b/docs/images/graphs/dep_graph_core_screenshot_testing.svg
new file mode 100644
index 000000000..e9fc6d48a
--- /dev/null
+++ b/docs/images/graphs/dep_graph_core_screenshot_testing.svg
@@ -0,0 +1,43 @@
+
+
+
+
+
diff --git a/docs/images/graphs/dep_graph_core_testing.png b/docs/images/graphs/dep_graph_core_testing.png
deleted file mode 100644
index 162830ae7..000000000
Binary files a/docs/images/graphs/dep_graph_core_testing.png and /dev/null differ
diff --git a/docs/images/graphs/dep_graph_core_testing.svg b/docs/images/graphs/dep_graph_core_testing.svg
new file mode 100644
index 000000000..29d367e4b
--- /dev/null
+++ b/docs/images/graphs/dep_graph_core_testing.svg
@@ -0,0 +1,199 @@
+
+
+
+
+
diff --git a/docs/images/graphs/dep_graph_core_ui.png b/docs/images/graphs/dep_graph_core_ui.png
deleted file mode 100644
index 31c9e6715..000000000
Binary files a/docs/images/graphs/dep_graph_core_ui.png and /dev/null differ
diff --git a/docs/images/graphs/dep_graph_core_ui.svg b/docs/images/graphs/dep_graph_core_ui.svg
new file mode 100644
index 000000000..2eba46866
--- /dev/null
+++ b/docs/images/graphs/dep_graph_core_ui.svg
@@ -0,0 +1,55 @@
+
+
+
+
+
diff --git a/docs/images/graphs/dep_graph_feature_author.png b/docs/images/graphs/dep_graph_feature_author.png
deleted file mode 100644
index ddd1f03f6..000000000
Binary files a/docs/images/graphs/dep_graph_feature_author.png and /dev/null differ
diff --git a/docs/images/graphs/dep_graph_feature_bookmarks.png b/docs/images/graphs/dep_graph_feature_bookmarks.png
deleted file mode 100644
index f07fe891e..000000000
Binary files a/docs/images/graphs/dep_graph_feature_bookmarks.png and /dev/null differ
diff --git a/docs/images/graphs/dep_graph_feature_bookmarks.svg b/docs/images/graphs/dep_graph_feature_bookmarks.svg
new file mode 100644
index 000000000..cfbb86412
--- /dev/null
+++ b/docs/images/graphs/dep_graph_feature_bookmarks.svg
@@ -0,0 +1,205 @@
+
+
+
+
+
diff --git a/docs/images/graphs/dep_graph_feature_foryou.png b/docs/images/graphs/dep_graph_feature_foryou.png
deleted file mode 100644
index cf483f1b1..000000000
Binary files a/docs/images/graphs/dep_graph_feature_foryou.png and /dev/null differ
diff --git a/docs/images/graphs/dep_graph_feature_foryou.svg b/docs/images/graphs/dep_graph_feature_foryou.svg
new file mode 100644
index 000000000..e196bc7da
--- /dev/null
+++ b/docs/images/graphs/dep_graph_feature_foryou.svg
@@ -0,0 +1,229 @@
+
+
+
+
+
diff --git a/docs/images/graphs/dep_graph_feature_interests.png b/docs/images/graphs/dep_graph_feature_interests.png
deleted file mode 100644
index 09c74f995..000000000
Binary files a/docs/images/graphs/dep_graph_feature_interests.png and /dev/null differ
diff --git a/docs/images/graphs/dep_graph_feature_interests.svg b/docs/images/graphs/dep_graph_feature_interests.svg
new file mode 100644
index 000000000..3728cb4f6
--- /dev/null
+++ b/docs/images/graphs/dep_graph_feature_interests.svg
@@ -0,0 +1,229 @@
+
+
+
+
+
diff --git a/docs/images/graphs/dep_graph_feature_search.svg b/docs/images/graphs/dep_graph_feature_search.svg
new file mode 100644
index 000000000..24c90cb0c
--- /dev/null
+++ b/docs/images/graphs/dep_graph_feature_search.svg
@@ -0,0 +1,229 @@
+
+
+
+
+
diff --git a/docs/images/graphs/dep_graph_feature_settings.svg b/docs/images/graphs/dep_graph_feature_settings.svg
new file mode 100644
index 000000000..93826715a
--- /dev/null
+++ b/docs/images/graphs/dep_graph_feature_settings.svg
@@ -0,0 +1,205 @@
+
+
+
+
+
diff --git a/docs/images/graphs/dep_graph_feature_topic.png b/docs/images/graphs/dep_graph_feature_topic.png
deleted file mode 100644
index 8385d1ed6..000000000
Binary files a/docs/images/graphs/dep_graph_feature_topic.png and /dev/null differ
diff --git a/docs/images/graphs/dep_graph_feature_topic.svg b/docs/images/graphs/dep_graph_feature_topic.svg
new file mode 100644
index 000000000..cbda3c225
--- /dev/null
+++ b/docs/images/graphs/dep_graph_feature_topic.svg
@@ -0,0 +1,205 @@
+
+
+
+
+
diff --git a/docs/images/graphs/dep_graph_lint.png b/docs/images/graphs/dep_graph_lint.png
deleted file mode 100644
index 176d1de5d..000000000
Binary files a/docs/images/graphs/dep_graph_lint.png and /dev/null differ
diff --git a/docs/images/graphs/dep_graph_sync.png b/docs/images/graphs/dep_graph_sync.png
deleted file mode 100644
index 26b79b9bc..000000000
Binary files a/docs/images/graphs/dep_graph_sync.png and /dev/null differ
diff --git a/docs/images/graphs/dep_graph_sync_sync_test.svg b/docs/images/graphs/dep_graph_sync_sync_test.svg
new file mode 100644
index 000000000..1e0753393
--- /dev/null
+++ b/docs/images/graphs/dep_graph_sync_sync_test.svg
@@ -0,0 +1,187 @@
+
+
+
+
+
diff --git a/docs/images/graphs/dep_graph_sync_work.svg b/docs/images/graphs/dep_graph_sync_work.svg
new file mode 100644
index 000000000..6901b5761
--- /dev/null
+++ b/docs/images/graphs/dep_graph_sync_work.svg
@@ -0,0 +1,169 @@
+
+
+
+
+
diff --git a/feature/bookmarks/README.md b/feature/bookmarks/README.md
index e2b8c65ac..54cbf91d0 100644
--- a/feature/bookmarks/README.md
+++ b/feature/bookmarks/README.md
@@ -1,3 +1,3 @@
# :feature:bookmarks module
-
-
+## Dependency graph
+
diff --git a/feature/bookmarks/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/bookmarks/BookmarksViewModel.kt b/feature/bookmarks/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/bookmarks/BookmarksViewModel.kt
index 7b6cac76a..f93602485 100644
--- a/feature/bookmarks/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/bookmarks/BookmarksViewModel.kt
+++ b/feature/bookmarks/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/bookmarks/BookmarksViewModel.kt
@@ -58,7 +58,7 @@ class BookmarksViewModel @Inject constructor(
viewModelScope.launch {
shouldDisplayUndoBookmark = true
lastRemovedBookmarkId = newsResourceId
- userDataRepository.updateNewsResourceBookmark(newsResourceId, false)
+ userDataRepository.setNewsResourceBookmarked(newsResourceId, false)
}
}
@@ -71,7 +71,7 @@ class BookmarksViewModel @Inject constructor(
fun undoBookmarkRemoval() {
viewModelScope.launch {
lastRemovedBookmarkId?.let {
- userDataRepository.updateNewsResourceBookmark(it, true)
+ userDataRepository.setNewsResourceBookmarked(it, true)
}
}
clearUndoState()
diff --git a/feature/bookmarks/src/test/kotlin/com/google/samples/apps/nowinandroid/feature/bookmarks/BookmarksViewModelTest.kt b/feature/bookmarks/src/test/kotlin/com/google/samples/apps/nowinandroid/feature/bookmarks/BookmarksViewModelTest.kt
index 807d3aaa8..71f4a8325 100644
--- a/feature/bookmarks/src/test/kotlin/com/google/samples/apps/nowinandroid/feature/bookmarks/BookmarksViewModelTest.kt
+++ b/feature/bookmarks/src/test/kotlin/com/google/samples/apps/nowinandroid/feature/bookmarks/BookmarksViewModelTest.kt
@@ -68,7 +68,7 @@ class BookmarksViewModelTest {
val collectJob = launch(UnconfinedTestDispatcher()) { viewModel.feedUiState.collect() }
newsRepository.sendNewsResources(newsResourcesTestData)
- userDataRepository.updateNewsResourceBookmark(newsResourcesTestData[0].id, true)
+ userDataRepository.setNewsResourceBookmarked(newsResourcesTestData[0].id, true)
val item = viewModel.feedUiState.value
assertIs(item)
assertEquals(item.feed.size, 1)
@@ -82,7 +82,7 @@ class BookmarksViewModelTest {
// Set the news resources to be used by this test
newsRepository.sendNewsResources(newsResourcesTestData)
// Start with the resource saved
- userDataRepository.updateNewsResourceBookmark(newsResourcesTestData[0].id, true)
+ userDataRepository.setNewsResourceBookmarked(newsResourcesTestData[0].id, true)
// Use viewModel to remove saved resource
viewModel.removeFromSavedResources(newsResourcesTestData[0].id)
// Verify list of saved resources is now empty
diff --git a/feature/foryou/README.md b/feature/foryou/README.md
index 1ca599859..0f08cb827 100644
--- a/feature/foryou/README.md
+++ b/feature/foryou/README.md
@@ -1,3 +1,3 @@
# :feature:foryou module
-
-
+## Dependency graph
+
diff --git a/feature/foryou/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/foryou/ForYouViewModel.kt b/feature/foryou/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/foryou/ForYouViewModel.kt
index 2a4b6f4ec..85035a77a 100644
--- a/feature/foryou/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/foryou/ForYouViewModel.kt
+++ b/feature/foryou/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/foryou/ForYouViewModel.kt
@@ -117,7 +117,7 @@ class ForYouViewModel @Inject constructor(
fun updateNewsResourceSaved(newsResourceId: String, isChecked: Boolean) {
viewModelScope.launch {
- userDataRepository.updateNewsResourceBookmark(newsResourceId, isChecked)
+ userDataRepository.setNewsResourceBookmarked(newsResourceId, isChecked)
}
}
diff --git a/feature/foryou/src/test/kotlin/com/google/samples/apps/nowinandroid/feature/foryou/ForYouViewModelTest.kt b/feature/foryou/src/test/kotlin/com/google/samples/apps/nowinandroid/feature/foryou/ForYouViewModelTest.kt
index d5b3704e9..65c34f180 100644
--- a/feature/foryou/src/test/kotlin/com/google/samples/apps/nowinandroid/feature/foryou/ForYouViewModelTest.kt
+++ b/feature/foryou/src/test/kotlin/com/google/samples/apps/nowinandroid/feature/foryou/ForYouViewModelTest.kt
@@ -36,6 +36,7 @@ import com.google.samples.apps.nowinandroid.core.testing.util.TestSyncManager
import com.google.samples.apps.nowinandroid.core.ui.NewsFeedUiState
import com.google.samples.apps.nowinandroid.feature.foryou.navigation.LINKED_NEWS_RESOURCE_ID
import kotlinx.coroutines.flow.collect
+import kotlinx.coroutines.flow.first
import kotlinx.coroutines.launch
import kotlinx.coroutines.test.UnconfinedTestDispatcher
import kotlinx.coroutines.test.advanceUntilIdle
@@ -72,6 +73,7 @@ class ForYouViewModelTest {
userDataRepository = userDataRepository,
defaultDispatcher = mainDispatcherRule.testDispatcher,
)
+
private val savedStateHandle = SavedStateHandle()
private lateinit var viewModel: ForYouViewModel
@@ -506,6 +508,24 @@ class ForYouViewModelTest {
collectJob.cancel()
}
+
+ @Test
+ fun whenUpdateNewsResourceSavedIsCalled_bookmarkStateIsUpdated() = runTest {
+ val newsResourceId = "123"
+ viewModel.updateNewsResourceSaved(newsResourceId, true)
+
+ assertEquals(
+ expected = setOf(newsResourceId),
+ actual = userDataRepository.userData.first().bookmarkedNewsResources,
+ )
+
+ viewModel.updateNewsResourceSaved(newsResourceId, false)
+
+ assertEquals(
+ expected = emptySet(),
+ actual = userDataRepository.userData.first().bookmarkedNewsResources,
+ )
+ }
}
private val sampleTopics = listOf(
diff --git a/feature/interests/README.md b/feature/interests/README.md
index b7601ecbc..90a4fbc9c 100644
--- a/feature/interests/README.md
+++ b/feature/interests/README.md
@@ -1,3 +1,3 @@
# :feature:interests module
-
-
+## Dependency graph
+
diff --git a/feature/interests/src/androidTest/kotlin/com/google/samples/apps/nowinandroid/interests/InterestsScreenTest.kt b/feature/interests/src/androidTest/kotlin/com/google/samples/apps/nowinandroid/interests/InterestsScreenTest.kt
index 1584662b8..a441f5a9d 100644
--- a/feature/interests/src/androidTest/kotlin/com/google/samples/apps/nowinandroid/interests/InterestsScreenTest.kt
+++ b/feature/interests/src/androidTest/kotlin/com/google/samples/apps/nowinandroid/interests/InterestsScreenTest.kt
@@ -27,10 +27,11 @@ import androidx.compose.ui.test.onNodeWithText
import com.google.samples.apps.nowinandroid.core.testing.data.followableTopicTestData
import com.google.samples.apps.nowinandroid.feature.interests.InterestsScreen
import com.google.samples.apps.nowinandroid.feature.interests.InterestsUiState
-import com.google.samples.apps.nowinandroid.feature.interests.R
import org.junit.Before
import org.junit.Rule
import org.junit.Test
+import com.google.samples.apps.nowinandroid.core.ui.R as CoreUiR
+import com.google.samples.apps.nowinandroid.feature.interests.R as InterestsR
/**
* UI test for checking the correct behaviour of the Interests screen;
@@ -50,12 +51,12 @@ class InterestsScreenTest {
@Before
fun setup() {
composeTestRule.activity.apply {
- interestsLoading = getString(R.string.feature_interests_loading)
- interestsEmptyHeader = getString(R.string.feature_interests_empty_header)
+ interestsLoading = getString(InterestsR.string.feature_interests_loading)
+ interestsEmptyHeader = getString(InterestsR.string.feature_interests_empty_header)
interestsTopicCardFollowButton =
- getString(R.string.feature_interests_card_follow_button_content_desc)
+ getString(CoreUiR.string.core_ui_interests_card_follow_button_content_desc)
interestsTopicCardUnfollowButton =
- getString(R.string.feature_interests_card_unfollow_button_content_desc)
+ getString(CoreUiR.string.core_ui_interests_card_unfollow_button_content_desc)
}
}
diff --git a/feature/interests/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/interests/TabContent.kt b/feature/interests/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/interests/TabContent.kt
index 4a48645c5..83058c12e 100644
--- a/feature/interests/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/interests/TabContent.kt
+++ b/feature/interests/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/interests/TabContent.kt
@@ -39,6 +39,7 @@ import com.google.samples.apps.nowinandroid.core.designsystem.component.scrollba
import com.google.samples.apps.nowinandroid.core.designsystem.component.scrollbar.rememberDraggableScroller
import com.google.samples.apps.nowinandroid.core.designsystem.component.scrollbar.scrollbarState
import com.google.samples.apps.nowinandroid.core.model.data.FollowableTopic
+import com.google.samples.apps.nowinandroid.core.ui.InterestsItem
@Composable
fun TopicsTabContent(
diff --git a/feature/interests/src/main/res/values/strings.xml b/feature/interests/src/main/res/values/strings.xml
index 2dd1c18a9..8d5322859 100644
--- a/feature/interests/src/main/res/values/strings.xml
+++ b/feature/interests/src/main/res/values/strings.xml
@@ -18,6 +18,4 @@
Interests
Loading data
"No available data"
- Follow interest
- Unfollow interest
diff --git a/feature/search/README.md b/feature/search/README.md
new file mode 100644
index 000000000..e205970f0
--- /dev/null
+++ b/feature/search/README.md
@@ -0,0 +1,3 @@
+# :feature:search module
+## Dependency graph
+
diff --git a/feature/search/build.gradle.kts b/feature/search/build.gradle.kts
index 206f4c0f9..98052e9ab 100644
--- a/feature/search/build.gradle.kts
+++ b/feature/search/build.gradle.kts
@@ -27,9 +27,7 @@ android {
dependencies {
implementation(projects.core.data)
implementation(projects.core.domain)
- implementation(projects.feature.bookmarks)
- implementation(projects.feature.foryou)
- implementation(projects.feature.interests)
+ implementation(projects.core.ui)
testImplementation(projects.core.testing)
diff --git a/feature/search/src/androidTest/kotlin/com/google/samples/apps/nowinandroid/feature/search/SearchScreenTest.kt b/feature/search/src/androidTest/kotlin/com/google/samples/apps/nowinandroid/feature/search/SearchScreenTest.kt
index 8a0532e1b..a9e2fa98f 100644
--- a/feature/search/src/androidTest/kotlin/com/google/samples/apps/nowinandroid/feature/search/SearchScreenTest.kt
+++ b/feature/search/src/androidTest/kotlin/com/google/samples/apps/nowinandroid/feature/search/SearchScreenTest.kt
@@ -35,10 +35,10 @@ import com.google.samples.apps.nowinandroid.core.model.data.UserData
import com.google.samples.apps.nowinandroid.core.model.data.UserNewsResource
import com.google.samples.apps.nowinandroid.core.testing.data.followableTopicTestData
import com.google.samples.apps.nowinandroid.core.testing.data.newsResourcesTestData
+import com.google.samples.apps.nowinandroid.core.ui.R.string
import org.junit.Before
import org.junit.Rule
import org.junit.Test
-import com.google.samples.apps.nowinandroid.feature.interests.R as interestsR
/**
* UI test for checking the correct behaviour of the Search screen.
@@ -73,9 +73,9 @@ class SearchScreenTest {
clearSearchContentDesc = getString(R.string.feature_search_clear_search_text_content_desc)
clearRecentSearchesContentDesc = getString(R.string.feature_search_clear_recent_searches_content_desc)
followButtonContentDesc =
- getString(interestsR.string.feature_interests_card_follow_button_content_desc)
+ getString(string.core_ui_interests_card_follow_button_content_desc)
unfollowButtonContentDesc =
- getString(interestsR.string.feature_interests_card_unfollow_button_content_desc)
+ getString(string.core_ui_interests_card_unfollow_button_content_desc)
topicsString = getString(R.string.feature_search_topics)
updatesString = getString(R.string.feature_search_updates)
tryAnotherSearchString = getString(R.string.feature_search_try_another_search) +
diff --git a/feature/search/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/search/SearchScreen.kt b/feature/search/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/search/SearchScreen.kt
index ca159c80b..1e4711016 100644
--- a/feature/search/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/search/SearchScreen.kt
+++ b/feature/search/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/search/SearchScreen.kt
@@ -88,14 +88,11 @@ import com.google.samples.apps.nowinandroid.core.designsystem.theme.NiaTheme
import com.google.samples.apps.nowinandroid.core.model.data.FollowableTopic
import com.google.samples.apps.nowinandroid.core.model.data.UserNewsResource
import com.google.samples.apps.nowinandroid.core.ui.DevicePreviews
+import com.google.samples.apps.nowinandroid.core.ui.InterestsItem
import com.google.samples.apps.nowinandroid.core.ui.NewsFeedUiState.Success
import com.google.samples.apps.nowinandroid.core.ui.R.string
import com.google.samples.apps.nowinandroid.core.ui.TrackScreenViewEvent
import com.google.samples.apps.nowinandroid.core.ui.newsFeed
-import com.google.samples.apps.nowinandroid.feature.bookmarks.BookmarksViewModel
-import com.google.samples.apps.nowinandroid.feature.foryou.ForYouViewModel
-import com.google.samples.apps.nowinandroid.feature.interests.InterestsItem
-import com.google.samples.apps.nowinandroid.feature.interests.InterestsViewModel
import com.google.samples.apps.nowinandroid.feature.search.R as searchR
@Composable
@@ -104,10 +101,7 @@ internal fun SearchRoute(
onInterestsClick: () -> Unit,
onTopicClick: (String) -> Unit,
modifier: Modifier = Modifier,
- bookmarksViewModel: BookmarksViewModel = hiltViewModel(),
- interestsViewModel: InterestsViewModel = hiltViewModel(),
searchViewModel: SearchViewModel = hiltViewModel(),
- forYouViewModel: ForYouViewModel = hiltViewModel(),
) {
val recentSearchQueriesUiState by searchViewModel.recentSearchQueriesUiState.collectAsStateWithLifecycle()
val searchResultUiState by searchViewModel.searchResultUiState.collectAsStateWithLifecycle()
@@ -120,9 +114,9 @@ internal fun SearchRoute(
onSearchQueryChanged = searchViewModel::onSearchQueryChanged,
onSearchTriggered = searchViewModel::onSearchTriggered,
onClearRecentSearches = searchViewModel::clearRecentSearches,
- onNewsResourcesCheckedChanged = forYouViewModel::updateNewsResourceSaved,
- onNewsResourceViewed = { bookmarksViewModel.setNewsResourceViewed(it, true) },
- onFollowButtonClick = interestsViewModel::followTopic,
+ onNewsResourcesCheckedChanged = searchViewModel::setNewsResourceBookmarked,
+ onNewsResourceViewed = { searchViewModel.setNewsResourceViewed(it, true) },
+ onFollowButtonClick = searchViewModel::followTopic,
onBackClick = onBackClick,
onInterestsClick = onInterestsClick,
onTopicClick = onTopicClick,
diff --git a/feature/search/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/search/SearchViewModel.kt b/feature/search/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/search/SearchViewModel.kt
index 7c05f81c5..ad6ca6112 100644
--- a/feature/search/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/search/SearchViewModel.kt
+++ b/feature/search/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/search/SearchViewModel.kt
@@ -23,6 +23,7 @@ import com.google.samples.apps.nowinandroid.core.analytics.AnalyticsEvent
import com.google.samples.apps.nowinandroid.core.analytics.AnalyticsEvent.Param
import com.google.samples.apps.nowinandroid.core.analytics.AnalyticsHelper
import com.google.samples.apps.nowinandroid.core.data.repository.RecentSearchRepository
+import com.google.samples.apps.nowinandroid.core.data.repository.UserDataRepository
import com.google.samples.apps.nowinandroid.core.domain.GetRecentSearchQueriesUseCase
import com.google.samples.apps.nowinandroid.core.domain.GetSearchContentsCountUseCase
import com.google.samples.apps.nowinandroid.core.domain.GetSearchContentsUseCase
@@ -44,6 +45,7 @@ class SearchViewModel @Inject constructor(
getSearchContentsCountUseCase: GetSearchContentsCountUseCase,
recentSearchQueriesUseCase: GetRecentSearchQueriesUseCase,
private val recentSearchRepository: RecentSearchRepository,
+ private val userDataRepository: UserDataRepository,
private val savedStateHandle: SavedStateHandle,
private val analyticsHelper: AnalyticsHelper,
) : ViewModel() {
@@ -111,6 +113,24 @@ class SearchViewModel @Inject constructor(
recentSearchRepository.clearRecentSearches()
}
}
+
+ fun setNewsResourceBookmarked(newsResourceId: String, isChecked: Boolean) {
+ viewModelScope.launch {
+ userDataRepository.setNewsResourceBookmarked(newsResourceId, isChecked)
+ }
+ }
+
+ fun followTopic(followedTopicId: String, followed: Boolean) {
+ viewModelScope.launch {
+ userDataRepository.setTopicIdFollowed(followedTopicId, followed)
+ }
+ }
+
+ fun setNewsResourceViewed(newsResourceId: String, viewed: Boolean) {
+ viewModelScope.launch {
+ userDataRepository.setNewsResourceViewed(newsResourceId, viewed)
+ }
+ }
}
private fun AnalyticsHelper.logEventSearchTriggered(query: String) =
diff --git a/feature/search/src/test/kotlin/com/google/samples/apps/nowinandroid/feature/search/SearchViewModelTest.kt b/feature/search/src/test/kotlin/com/google/samples/apps/nowinandroid/feature/search/SearchViewModelTest.kt
index 6558a251b..e410a3087 100644
--- a/feature/search/src/test/kotlin/com/google/samples/apps/nowinandroid/feature/search/SearchViewModelTest.kt
+++ b/feature/search/src/test/kotlin/com/google/samples/apps/nowinandroid/feature/search/SearchViewModelTest.kt
@@ -33,6 +33,7 @@ import com.google.samples.apps.nowinandroid.feature.search.SearchResultUiState.E
import com.google.samples.apps.nowinandroid.feature.search.SearchResultUiState.Loading
import com.google.samples.apps.nowinandroid.feature.search.SearchResultUiState.SearchNotReady
import kotlinx.coroutines.flow.collect
+import kotlinx.coroutines.flow.first
import kotlinx.coroutines.launch
import kotlinx.coroutines.test.UnconfinedTestDispatcher
import kotlinx.coroutines.test.runTest
@@ -61,6 +62,7 @@ class SearchViewModelTest {
private val recentSearchRepository = TestRecentSearchRepository()
private val getRecentQueryUseCase = GetRecentSearchQueriesUseCase(recentSearchRepository)
private val getSearchContentsCountUseCase = GetSearchContentsCountUseCase(searchContentsRepository)
+
private lateinit var viewModel: SearchViewModel
@Before
@@ -71,6 +73,7 @@ class SearchViewModelTest {
recentSearchQueriesUseCase = getRecentQueryUseCase,
savedStateHandle = SavedStateHandle(),
recentSearchRepository = recentSearchRepository,
+ userDataRepository = userDataRepository,
analyticsHelper = NoOpAnalyticsHelper(),
)
userDataRepository.setUserData(emptyUserData)
@@ -129,4 +132,22 @@ class SearchViewModelTest {
collectJob.cancel()
}
+
+ @Test
+ fun whenToggleNewsResourceSavedIsCalled_bookmarkStateIsUpdated() = runTest {
+ val newsResourceId = "123"
+ viewModel.setNewsResourceBookmarked(newsResourceId, true)
+
+ assertEquals(
+ expected = setOf(newsResourceId),
+ actual = userDataRepository.userData.first().bookmarkedNewsResources,
+ )
+
+ viewModel.setNewsResourceBookmarked(newsResourceId, false)
+
+ assertEquals(
+ expected = emptySet(),
+ actual = userDataRepository.userData.first().bookmarkedNewsResources,
+ )
+ }
}
diff --git a/feature/settings/README.md b/feature/settings/README.md
new file mode 100644
index 000000000..7a4df04fe
--- /dev/null
+++ b/feature/settings/README.md
@@ -0,0 +1,3 @@
+# :feature:settings module
+## Dependency graph
+
diff --git a/feature/topic/README.md b/feature/topic/README.md
index d74517e63..84588929c 100644
--- a/feature/topic/README.md
+++ b/feature/topic/README.md
@@ -1,3 +1,3 @@
# :feature:topic module
-
-
+## Dependency graph
+
diff --git a/feature/topic/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/topic/TopicViewModel.kt b/feature/topic/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/topic/TopicViewModel.kt
index 9fe6a2dd2..255e40f8b 100644
--- a/feature/topic/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/topic/TopicViewModel.kt
+++ b/feature/topic/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/topic/TopicViewModel.kt
@@ -81,7 +81,7 @@ class TopicViewModel @Inject constructor(
fun bookmarkNews(newsResourceId: String, bookmarked: Boolean) {
viewModelScope.launch {
- userDataRepository.updateNewsResourceBookmark(newsResourceId, bookmarked)
+ userDataRepository.setNewsResourceBookmarked(newsResourceId, bookmarked)
}
}
diff --git a/generateModuleGraphs.sh b/generateModuleGraphs.sh
new file mode 100755
index 000000000..27dea22da
--- /dev/null
+++ b/generateModuleGraphs.sh
@@ -0,0 +1,94 @@
+#!/bin/bash
+#
+# 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.
+#
+#
+# Script to generate dependency graphs for each of the modules. The --exclude-module parameter can
+# be used to exclude modules which are not part of the root dependency graph (and which, if included
+# would cause the script to fail.
+#
+# Usage: generateModuleGraphs.sh --exclude-module :benchmarks --exclude-module :lint --exclude-module :ui-test-hilt-manifest
+
+# Check if the dot command is available
+if ! command -v dot &> /dev/null
+then
+ echo "The 'dot' command is not found. This is required to generate SVGs from the Graphviz files."
+ echo "On macOS, you can install it using Homebrew: 'brew install graphviz'"
+ exit 1
+fi
+
+# Initialize an array to store excluded modules
+excluded_modules=()
+
+# Parse command-line arguments for excluded modules
+while [[ $# -gt 0 ]]; do
+ case "$1" in
+ --exclude-module)
+ excluded_modules+=("$2")
+ shift # Past argument
+ shift # Past value
+ ;;
+ *)
+ echo "Unknown parameter passed: $1"
+ exit 1
+ ;;
+ esac
+done
+
+# Get the module paths
+module_paths=$(./gradlew -q printModulePaths --no-configuration-cache)
+
+# Function to check and create a README.md for modules which don't have one.
+check_and_create_readme() {
+ local module_path="$1"
+ local file_name="$2"
+
+ local readme_path="${module_path:1}" # Remove leading colon
+ readme_path=${readme_path//:/\/} # Replace colons with slashes using sed
+ readme_path="${readme_path}/README.md" #Append the filename
+
+ # Check if README.md exists and create it if not
+ if [[ ! -f "$readme_path" ]]; then
+ echo "Creating README.md for ${module_path}"
+ # Calculate the correct relative path to the image
+ local relative_image_path="../../docs/images/graphs/${file_name}.svg"
+ echo "# ${module_path} module" > "$readme_path"
+ echo "## Dependency graph" >> "$readme_path"
+ echo "" >> "$readme_path"
+ fi
+}
+
+# Loop through each module path
+echo "$module_paths" | while read -r module_path; do
+ # Check if the module is in the excluded list
+ if [[ ! " ${excluded_modules[@]} " =~ " ${module_path} " ]]; then
+ # Derive the filename from the module path
+ file_name="dep_graph${module_path//:/_}" # Replace colons with underscores
+ file_name="${file_name//-/_}" # Replace dashes with underscores
+
+ check_and_create_readme "$module_path" "$file_name"
+
+ # Generate the .gv file in a temporary location
+ # "docs/images/graphs/${file_name}.svg"
+ # Remove the temporary .gv file
+ rm "/tmp/${file_name}.gv"
+ fi
+done
\ No newline at end of file
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
index 13e81df64..4e397175c 100644
--- a/gradle/libs.versions.toml
+++ b/gradle/libs.versions.toml
@@ -46,6 +46,7 @@ kotlinxCoroutines = "1.8.0"
kotlinxDatetime = "0.5.0"
kotlinxSerializationJson = "1.6.3"
ksp = "1.9.22-1.0.18"
+moduleGraph = "2.5.0"
okhttp = "4.12.0"
protobuf = "3.25.2"
protobufPlugin = "0.9.4"
@@ -162,6 +163,7 @@ hilt = { id = "com.google.dagger.hilt.android", version.ref = "hilt" }
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
+module-graph = { id = "com.jraska.module.graph.assertion", version.ref = "moduleGraph" }
protobuf = { id = "com.google.protobuf", version.ref = "protobufPlugin" }
roborazzi = { id = "io.github.takahirom.roborazzi", version.ref = "roborazzi" }
room = { id = "androidx.room", version.ref = "room" }
diff --git a/lint/README.md b/lint/README.md
deleted file mode 100644
index 3eceb434b..000000000
--- a/lint/README.md
+++ /dev/null
@@ -1,3 +0,0 @@
-# :lint module
-
-
diff --git a/settings.gradle.kts b/settings.gradle.kts
index 949dbfdd1..d4b6654b1 100644
--- a/settings.gradle.kts
+++ b/settings.gradle.kts
@@ -63,3 +63,4 @@ include(":lint")
include(":sync:work")
include(":sync:sync-test")
include(":ui-test-hilt-manifest")
+
diff --git a/sync/README.md b/sync/README.md
deleted file mode 100644
index b100e27ad..000000000
--- a/sync/README.md
+++ /dev/null
@@ -1,3 +0,0 @@
-# :sync module
-
-
diff --git a/sync/sync-test/README.md b/sync/sync-test/README.md
new file mode 100644
index 000000000..78876290f
--- /dev/null
+++ b/sync/sync-test/README.md
@@ -0,0 +1,3 @@
+# :sync:sync-test module
+## Dependency graph
+
diff --git a/sync/work/README.md b/sync/work/README.md
new file mode 100644
index 000000000..2fe66d616
--- /dev/null
+++ b/sync/work/README.md
@@ -0,0 +1,3 @@
+# :sync:work module
+## Dependency graph
+