From 61c7d71870bc20393cbc0984068dac77e7b9d723 Mon Sep 17 00:00:00 2001 From: Simon Marquis Date: Fri, 22 Dec 2023 14:40:30 +0100 Subject: [PATCH] Migrate `:core:common` to pure JVM module The notification icons are now stored in `:core:notifications`. This forces `:sync:work` to depend on it. Another solution could be to provide the resource id through Hilt, but it would require more changes. --- core/common/build.gradle.kts | 10 +++------- core/common/src/main/AndroidManifest.xml | 17 ----------------- core/notifications/build.gradle.kts | 1 - .../core/notifications/SystemTrayNotifier.kt | 8 ++------ ...core_notifications_ic_nia_notification.xml} | 0 ...core_notifications_ic_nia_notification.png} | Bin ...core_notifications_ic_nia_notification.png} | Bin ...core_notifications_ic_nia_notification.png} | Bin ...core_notifications_ic_nia_notification.png} | Bin sync/work/build.gradle.kts | 1 + .../sync/initializers/SyncWorkHelpers.kt | 2 +- 11 files changed, 7 insertions(+), 32 deletions(-) delete mode 100644 core/common/src/main/AndroidManifest.xml rename core/{common/src/main/res/drawable-anydpi-v24/core_common_ic_nia_notification.xml => notifications/src/main/res/drawable-anydpi-v24/core_notifications_ic_nia_notification.xml} (100%) rename core/{common/src/main/res/drawable-hdpi/core_common_ic_nia_notification.png => notifications/src/main/res/drawable-hdpi/core_notifications_ic_nia_notification.png} (100%) rename core/{common/src/main/res/drawable-mdpi/core_common_ic_nia_notification.png => notifications/src/main/res/drawable-mdpi/core_notifications_ic_nia_notification.png} (100%) rename core/{common/src/main/res/drawable-xhdpi/core_common_ic_nia_notification.png => notifications/src/main/res/drawable-xhdpi/core_notifications_ic_nia_notification.png} (100%) rename core/{common/src/main/res/drawable-xxhdpi/core_common_ic_nia_notification.png => notifications/src/main/res/drawable-xxhdpi/core_notifications_ic_nia_notification.png} (100%) diff --git a/core/common/build.gradle.kts b/core/common/build.gradle.kts index 51ae627dc..94dd3c09e 100644 --- a/core/common/build.gradle.kts +++ b/core/common/build.gradle.kts @@ -14,16 +14,12 @@ * limitations under the License. */ plugins { - alias(libs.plugins.nowinandroid.android.library) - alias(libs.plugins.nowinandroid.android.library.jacoco) - alias(libs.plugins.nowinandroid.android.hilt) -} - -android { - namespace = "com.google.samples.apps.nowinandroid.core.common" + alias(libs.plugins.nowinandroid.jvm.library) + alias(libs.plugins.nowinandroid.jvm.hilt) } dependencies { + implementation(libs.kotlinx.coroutines.core) testImplementation(libs.kotlinx.coroutines.test) testImplementation(libs.turbine) } \ No newline at end of file diff --git a/core/common/src/main/AndroidManifest.xml b/core/common/src/main/AndroidManifest.xml deleted file mode 100644 index 51d0cfc2e..000000000 --- a/core/common/src/main/AndroidManifest.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - \ No newline at end of file diff --git a/core/notifications/build.gradle.kts b/core/notifications/build.gradle.kts index 92871b72b..7b0f14fc8 100644 --- a/core/notifications/build.gradle.kts +++ b/core/notifications/build.gradle.kts @@ -28,5 +28,4 @@ dependencies { implementation(projects.core.common) compileOnly(platform(libs.androidx.compose.bom)) - compileOnly(libs.androidx.compose.runtime) } diff --git a/core/notifications/src/main/kotlin/com/google/samples/apps/nowinandroid/core/notifications/SystemTrayNotifier.kt b/core/notifications/src/main/kotlin/com/google/samples/apps/nowinandroid/core/notifications/SystemTrayNotifier.kt index ebad9fda3..38d905ad1 100644 --- a/core/notifications/src/main/kotlin/com/google/samples/apps/nowinandroid/core/notifications/SystemTrayNotifier.kt +++ b/core/notifications/src/main/kotlin/com/google/samples/apps/nowinandroid/core/notifications/SystemTrayNotifier.kt @@ -71,9 +71,7 @@ internal class SystemTrayNotifier @Inject constructor( val newsNotifications = truncatedNewsResources .map { newsResource -> createNewsNotification { - setSmallIcon( - com.google.samples.apps.nowinandroid.core.common.R.drawable.core_common_ic_nia_notification, - ) + setSmallIcon(R.drawable.core_notifications_ic_nia_notification) .setContentTitle(newsResource.title) .setContentText(newsResource.content) .setContentIntent(newsPendingIntent(newsResource)) @@ -88,9 +86,7 @@ internal class SystemTrayNotifier @Inject constructor( ) setContentTitle(title) .setContentText(title) - .setSmallIcon( - com.google.samples.apps.nowinandroid.core.common.R.drawable.core_common_ic_nia_notification, - ) + .setSmallIcon(R.drawable.core_notifications_ic_nia_notification) // Build summary info into InboxStyle template. .setStyle(newsNotificationStyle(truncatedNewsResources, title)) .setGroup(NEWS_NOTIFICATION_GROUP) diff --git a/core/common/src/main/res/drawable-anydpi-v24/core_common_ic_nia_notification.xml b/core/notifications/src/main/res/drawable-anydpi-v24/core_notifications_ic_nia_notification.xml similarity index 100% rename from core/common/src/main/res/drawable-anydpi-v24/core_common_ic_nia_notification.xml rename to core/notifications/src/main/res/drawable-anydpi-v24/core_notifications_ic_nia_notification.xml diff --git a/core/common/src/main/res/drawable-hdpi/core_common_ic_nia_notification.png b/core/notifications/src/main/res/drawable-hdpi/core_notifications_ic_nia_notification.png similarity index 100% rename from core/common/src/main/res/drawable-hdpi/core_common_ic_nia_notification.png rename to core/notifications/src/main/res/drawable-hdpi/core_notifications_ic_nia_notification.png diff --git a/core/common/src/main/res/drawable-mdpi/core_common_ic_nia_notification.png b/core/notifications/src/main/res/drawable-mdpi/core_notifications_ic_nia_notification.png similarity index 100% rename from core/common/src/main/res/drawable-mdpi/core_common_ic_nia_notification.png rename to core/notifications/src/main/res/drawable-mdpi/core_notifications_ic_nia_notification.png diff --git a/core/common/src/main/res/drawable-xhdpi/core_common_ic_nia_notification.png b/core/notifications/src/main/res/drawable-xhdpi/core_notifications_ic_nia_notification.png similarity index 100% rename from core/common/src/main/res/drawable-xhdpi/core_common_ic_nia_notification.png rename to core/notifications/src/main/res/drawable-xhdpi/core_notifications_ic_nia_notification.png diff --git a/core/common/src/main/res/drawable-xxhdpi/core_common_ic_nia_notification.png b/core/notifications/src/main/res/drawable-xxhdpi/core_notifications_ic_nia_notification.png similarity index 100% rename from core/common/src/main/res/drawable-xxhdpi/core_common_ic_nia_notification.png rename to core/notifications/src/main/res/drawable-xxhdpi/core_notifications_ic_nia_notification.png diff --git a/sync/work/build.gradle.kts b/sync/work/build.gradle.kts index 7e61c7389..1bcc15964 100644 --- a/sync/work/build.gradle.kts +++ b/sync/work/build.gradle.kts @@ -34,6 +34,7 @@ dependencies { implementation(libs.hilt.ext.work) implementation(projects.core.analytics) implementation(projects.core.data) + implementation(projects.core.notifications) prodImplementation(libs.firebase.cloud.messaging) prodImplementation(platform(libs.firebase.bom)) diff --git a/sync/work/src/main/kotlin/com/google/samples/apps/nowinandroid/sync/initializers/SyncWorkHelpers.kt b/sync/work/src/main/kotlin/com/google/samples/apps/nowinandroid/sync/initializers/SyncWorkHelpers.kt index 843510aaf..6c4a29373 100644 --- a/sync/work/src/main/kotlin/com/google/samples/apps/nowinandroid/sync/initializers/SyncWorkHelpers.kt +++ b/sync/work/src/main/kotlin/com/google/samples/apps/nowinandroid/sync/initializers/SyncWorkHelpers.kt @@ -71,7 +71,7 @@ private fun Context.syncWorkNotification(): Notification { SYNC_NOTIFICATION_CHANNEL_ID, ) .setSmallIcon( - com.google.samples.apps.nowinandroid.core.common.R.drawable.core_common_ic_nia_notification, + com.google.samples.apps.nowinandroid.core.notifications.R.drawable.core_notifications_ic_nia_notification, ) .setContentTitle(getString(R.string.sync_work_notification_title)) .setPriority(NotificationCompat.PRIORITY_DEFAULT)