Skip to content

Instantly share code, notes, and snippets.

View igorescodro's full-sized avatar
♥️
Coding with love

Igor Escodro igorescodro

♥️
Coding with love
View GitHub Profile
[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" }
internal val VersionCatalog.logcat: Provider<MinimalExternalModuleDependency>
get() = getLibrary("logcat")
private fun VersionCatalog.getLibrary(library: String) = findLibrary(library).get()
plugins {
id("com.android.library")
}
dependencies {
// Won't be able to find this library
implementation(libs.android.appcompat)
}
@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
@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
@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
@After
fun tearDown() {
val manager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
manager.cancelAll()
}
@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()) {
Button(
text = "Update",
modifier = GlanceModifier.clickable(actionRunCallback<UpdateAction>())
)
class UpdateAction : ActionCallback {
override suspend fun onRun(context: Context, glanceId: GlanceId, parameters: ActionParameters) {
// Update!
}
}
Button(
text = "Home",
modifier = GlanceModifier.clickable(actionStartActivity<HomeActivity>())
)