This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [versions] | |
| # Define the dependency versions | |
| kotlin = "1.7.10" | |
| compose = "1.2.1" | |
| [libraries] | |
| # Define the libraries | |
| compose_ui = { module = "androidx.compose.ui:ui", version.ref = "compose" } | |
| compose_material = { module = "androidx.compose.material:material", version.ref = "compose" } | |
| compose_tooling = { module = "androidx.compose.ui:ui-tooling", version.ref = "compose" } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| internal val VersionCatalog.logcat: Provider<MinimalExternalModuleDependency> | |
| get() = getLibrary("logcat") | |
| private fun VersionCatalog.getLibrary(library: String) = findLibrary(library).get() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| plugins { | |
| id("com.android.library") | |
| } | |
| dependencies { | |
| // Won't be able to find this library | |
| implementation(libs.android.appcompat) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Test | |
| fun test_markAsReadViaNotificationActions() { | |
| // Send the notification | |
| val id = 99 | |
| val name = "New message received from Bruno" | |
| myNotification.send(id = id, name = name) | |
| val manager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager | |
| // Wait until the active notification list has a new one |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Test | |
| fun test_whenNotificationIsClickedOpensDetails() { | |
| // Send the notification | |
| val id = 13 | |
| val name = "New reward!" | |
| myNotification.send(id = id, name = name) | |
| val manager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager | |
| // Wait until the active notification list has a new one |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Test | |
| fun test_myNotification() { | |
| // Send the notification | |
| val id = 13 | |
| val name = "Testing my notification" | |
| myNotification.send(id = id, name = name) | |
| val manager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager | |
| // Wait until the active notification list has a new one |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @After | |
| fun tearDown() { | |
| val manager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager | |
| manager.cancelAll() | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Test | |
| fun test_myNotification() { | |
| // Send the notification | |
| val id = 13 | |
| val name = "Testing my notification" | |
| myNotification.send(id = id, name = name) | |
| // Validate the notification info | |
| val manager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager | |
| with(manager.activeNotifications.first()) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Button( | |
| text = "Update", | |
| modifier = GlanceModifier.clickable(actionRunCallback<UpdateAction>()) | |
| ) | |
| class UpdateAction : ActionCallback { | |
| override suspend fun onRun(context: Context, glanceId: GlanceId, parameters: ActionParameters) { | |
| // Update! | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Button( | |
| text = "Home", | |
| modifier = GlanceModifier.clickable(actionStartActivity<HomeActivity>()) | |
| ) |