Files
LLeMbas-Android/app/src/main/java/eu/llembas/android/notify/NotificationReader.kt
T
HomerandClaude Fable 5.2 f2a2acf996
CI / check (push) Canceled after 0s
Three APKs: the notification listener leaves the standard builds; releases drop x86_64
Google Play Protect blocked installing beta.7, most likely for the
notification listener (notification summaries).

- A second flavour dimension, `reading`: `standard` declares no listener and
  no permission of it; `notifications` is the full build plus the listener,
  with the same application id and key. Variants: fullStandard,
  fullNotifications, fdroidStandard (no F-Droid build with the listener).
  The listener class and its manifest entry live in src/notifications only.
- Settings in a standard build says where notification summaries went and
  why. The self-updater installs only its own kind: a notifications build
  takes latest.json's optional `notifications {url, sha256}` or nothing.
- Release builds carry arm64-v8a and armeabi-v7a only; debug keeps x86_64
  for the emulator. The engine's unused C and C++ API libraries are left out.
- scripts/check-apk.sh checks the built files (listener only where it may
  be, model stored, no x86 in a release); CI runs it on the three debug APKs
  and on an unsigned release build, release.yml on what it publishes.
- release.yml publishes llembas-android-<version>.apk, -notifications.apk
  and -fdroid.apk with SHA256SUMS.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-12 09:58:07 +00:00

30 lines
1.3 KiB
Kotlin

package eu.llembas.android.notify
/** One notification, as the question carries it. */
data class Notice(val app: String, val title: String, val text: String, val at: Long)
/**
* Notification summaries, the half every build has: how the notifications are written into a
* question, and when a question asks for them. Reading them is [NotificationAccess]'s, which only
* the `notifications` build can do.
*/
object NotificationReader {
/** The notifications as the question's attachment of text: one block per notification. */
fun asText(notices: List<Notice>, now: Long = System.currentTimeMillis()): String = notices.joinToString("\n\n") { n ->
val minutes = ((now - n.at) / 60_000).coerceAtLeast(0)
val ago = if (minutes < 60) "${minutes}m ago" else "${minutes / 60}h ago"
listOf("[${n.app} · $ago] ${n.title}".trim(), n.text).filter { it.isNotBlank() }.joinToString("\n")
}.take(MAX_CHARS)
/**
* Whether a question asks about the notifications: one of [phrases] (in the app's language,
* "my notifications" and the like) is in it.
*/
fun asksAbout(question: String, phrases: List<String>): Boolean {
val q = question.lowercase()
return phrases.map { it.trim().lowercase() }.any { it.isNotEmpty() && it in q }
}
private const val MAX_CHARS = 12_000
}