merge #21 from devnoname120/improve-notification

improve notifications
This commit is contained in:
Kavish Devar
2025-01-07 01:23:05 +05:30
committed by GitHub

View File

@@ -148,10 +148,10 @@ class AirPodsService: Service() {
notificationManager.createNotificationChannel(notificationChannel) notificationManager.createNotificationChannel(notificationChannel)
val notification = NotificationCompat.Builder(this, "background_service_status") val notification = NotificationCompat.Builder(this, "background_service_status")
.setSmallIcon(R.drawable.airpods) .setSmallIcon(R.drawable.airpods)
.setContentTitle("AirPods Service") .setContentTitle("AirPods are not connected")
.setContentText("Service is running in the background")
.setCategory(Notification.CATEGORY_SERVICE) .setCategory(Notification.CATEGORY_SERVICE)
.setPriority(NotificationCompat.PRIORITY_LOW) .setPriority(NotificationCompat.PRIORITY_LOW)
.setOngoing(true)
.build() .build()
try { try {
@@ -261,36 +261,37 @@ class AirPodsService: Service() {
updatedNotification = NotificationCompat.Builder(this, "background_service_status") updatedNotification = NotificationCompat.Builder(this, "background_service_status")
.setSmallIcon(R.drawable.airpods) .setSmallIcon(R.drawable.airpods)
.setContentTitle("""L: ${batteryList?.find { it.component == BatteryComponent.LEFT }?.let { .setContentTitle("""AirPods ${batteryList?.find { it.component == BatteryComponent.LEFT }?.let {
// if (it.status != BatteryStatus.DISCONNECTED) { if (it.status != BatteryStatus.DISCONNECTED) {
"${if (it.status == BatteryStatus.CHARGING) "⚡" else ""} ${it.level}%" " L:${if (it.status == BatteryStatus.CHARGING) "⚡" else ""} ${it.level}%"
// } else { } else {
// "" ""
// } }
} ?: ""} R: ${batteryList?.find { it.component == BatteryComponent.RIGHT }?.let { } ?: ""}${batteryList?.find { it.component == BatteryComponent.RIGHT }?.let {
// if (it.status != BatteryStatus.DISCONNECTED) { if (it.status != BatteryStatus.DISCONNECTED) {
"${if (it.status == BatteryStatus.CHARGING) "⚡" else ""} ${it.level}%" " R:${if (it.status == BatteryStatus.CHARGING) "⚡" else ""} ${it.level}%"
// } else { } else {
// "" ""
// } }
} ?: ""} C: ${batteryList?.find { it.component == BatteryComponent.CASE }?.let { } ?: ""}${batteryList?.find { it.component == BatteryComponent.CASE }?.let {
// if (it.status != BatteryStatus.DISCONNECTED) { if (it.status != BatteryStatus.DISCONNECTED) {
"${if (it.status == BatteryStatus.CHARGING) "⚡" else ""} ${it.level}%" " C:${if (it.status == BatteryStatus.CHARGING) "⚡" else ""} ${it.level}%"
// } else { } else {
// "" ""
// } }
} ?: ""}""") } ?: ""}""")
.setCategory(Notification.CATEGORY_SERVICE) .setCategory(Notification.CATEGORY_SERVICE)
.setPriority(NotificationCompat.PRIORITY_LOW) .setPriority(NotificationCompat.PRIORITY_LOW)
.setOngoing(true)
.build() .build()
} else { } else {
updatedNotification = NotificationCompat.Builder(this, "background_service_status") updatedNotification = NotificationCompat.Builder(this, "background_service_status")
.setSmallIcon(R.drawable.airpods) .setSmallIcon(R.drawable.airpods)
.setContentTitle("AirPods Service") .setContentTitle("AirPods are not connected")
.setContentText("Service is running in the background!")
.setCategory(Notification.CATEGORY_SERVICE) .setCategory(Notification.CATEGORY_SERVICE)
.setPriority(NotificationCompat.PRIORITY_LOW) .setPriority(NotificationCompat.PRIORITY_LOW)
.setOngoing(true)
.build() .build()
} }