diff --git a/settings.gradle.kts b/settings.gradle.kts index b9f1b28..6392540 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -16,3 +16,4 @@ dependencyResolutionManagement { rootProject.name = "NotificationLog" include(":app") +include(":test-helper") diff --git a/test-helper/build.gradle.kts b/test-helper/build.gradle.kts new file mode 100644 index 0000000..1380fdc --- /dev/null +++ b/test-helper/build.gradle.kts @@ -0,0 +1,7 @@ +plugins { alias(libs.plugins.android.application); alias(libs.plugins.kotlin.android) } +android { namespace = "se.ajpanton.notificationlog.helper"; compileSdk = 36 + defaultConfig { applicationId = "se.ajpanton.notificationlog.helper"; minSdk = 34; targetSdk = 36; versionCode = 1; versionName = "0.1" } + compileOptions { sourceCompatibility = JavaVersion.VERSION_17; targetCompatibility = JavaVersion.VERSION_17 } + kotlin { compilerOptions { jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17) } } +} +dependencies { implementation(libs.appcompat); implementation(libs.material) } diff --git a/test-helper/src/main/AndroidManifest.xml b/test-helper/src/main/AndroidManifest.xml new file mode 100644 index 0000000..02be513 --- /dev/null +++ b/test-helper/src/main/AndroidManifest.xml @@ -0,0 +1 @@ + diff --git a/test-helper/src/main/java/se/ajpanton/notificationlog/helper/MainActivity.kt b/test-helper/src/main/java/se/ajpanton/notificationlog/helper/MainActivity.kt new file mode 100644 index 0000000..693e4af --- /dev/null +++ b/test-helper/src/main/java/se/ajpanton/notificationlog/helper/MainActivity.kt @@ -0,0 +1,14 @@ +package se.ajpanton.notificationlog.helper + +import android.app.* +import android.graphics.Bitmap +import android.os.Bundle +import android.widget.* +import androidx.appcompat.app.AppCompatActivity + +class MainActivity : AppCompatActivity() { + private val manager by lazy { getSystemService(NotificationManager::class.java) } + override fun onCreate(state: Bundle?) { super.onCreate(state); manager.createNotificationChannel(NotificationChannel("test", "Test", NotificationManager.IMPORTANCE_DEFAULT)); setContentView(LinearLayout(this).apply { orientation=LinearLayout.VERTICAL; listOf("Post text" to { post("Text message") }, "Edit text" to { post("Edited message") }, "Post image" to { image() }, "Cancel" to { manager.cancel(1) }).forEach { (label, action) -> addView(Button(this@MainActivity).apply { text=label; setOnClickListener { action() } }) } }) } + private fun post(text:String)=manager.notify(1, Notification.Builder(this,"test").setSmallIcon(android.R.drawable.ic_dialog_info).setContentTitle("Helper").setContentText(text).build()) + private fun image(){ val b=Bitmap.createBitmap(20,20,Bitmap.Config.ARGB_8888).apply{eraseColor(0xffff0000.toInt())}; manager.notify(2,Notification.Builder(this,"test").setSmallIcon(android.R.drawable.ic_menu_gallery).setStyle(Notification.BigPictureStyle().bigPicture(b)).build()) } +}