Skip to content

Commit 039a43d

Browse files
committed
Untitled
Update `AirPodsService.kt` and `BatteryWidget.kt` to retain and display the last received battery levels when the case or bud gets disconnected. * **AirPodsService.kt** - Comment out the condition that sets battery levels to an empty string if the status is `BatteryStatus.DISCONNECTED`. * **BatteryWidget.kt** - Comment out the condition that sets battery levels to an empty string if the status is `BatteryStatus.DISCONNECTED`.
1 parent 5995c17 commit 039a43d

File tree

2 files changed

+24
-24
lines changed

2 files changed

+24
-24
lines changed

android/app/src/main/java/me/kavishdevar/aln/BatteryWidget.kt

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -56,27 +56,27 @@ internal fun updateAppWidget(
5656

5757
views.setTextViewText(R.id.left_battery_widget,
5858
batteryList?.find { it.component == BatteryComponent.LEFT }?.let {
59-
if (it.status != BatteryStatus.DISCONNECTED) {
59+
// if (it.status != BatteryStatus.DISCONNECTED) {
6060
"${if (it.status == BatteryStatus.CHARGING) "" else ""} ${it.level}%"
61-
} else {
62-
""
63-
}
61+
// } else {
62+
// ""
63+
// }
6464
} ?: "")
6565
views.setTextViewText(R.id.right_battery_widget,
6666
batteryList?.find { it.component == BatteryComponent.RIGHT }?.let {
67-
if (it.status != BatteryStatus.DISCONNECTED) {
67+
// if (it.status != BatteryStatus.DISCONNECTED) {
6868
"${if (it.status == BatteryStatus.CHARGING) "" else ""} ${it.level}%"
69-
} else {
70-
""
71-
}
69+
// } else {
70+
// ""
71+
// }
7272
} ?: "")
7373
views.setTextViewText(R.id.case_battery_widget,
7474
batteryList?.find { it.component == BatteryComponent.CASE }?.let {
75-
if (it.status != BatteryStatus.DISCONNECTED) {
75+
// if (it.status != BatteryStatus.DISCONNECTED) {
7676
"${if (it.status == BatteryStatus.CHARGING) "" else ""} ${it.level}%"
77-
} else {
78-
""
79-
}
77+
// } else {
78+
// ""
79+
// }
8080
} ?: "")
8181

8282
appWidgetManager.updateAppWidget(appWidgetId, views)

android/app/src/main/java/me/kavishdevar/aln/services/AirPodsService.kt

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -262,23 +262,23 @@ class AirPodsService: Service() {
262262
updatedNotification = NotificationCompat.Builder(this, "background_service_status")
263263
.setSmallIcon(R.drawable.airpods)
264264
.setContentTitle("""AirPods –${batteryList?.find { it.component == BatteryComponent.LEFT }?.let {
265-
if (it.status != BatteryStatus.DISCONNECTED) {
265+
// if (it.status != BatteryStatus.DISCONNECTED) {
266266
" L:${if (it.status == BatteryStatus.CHARGING) "" else ""} ${it.level}%"
267-
} else {
268-
""
269-
}
267+
// } else {
268+
// ""
269+
// }
270270
} ?: ""}${batteryList?.find { it.component == BatteryComponent.RIGHT }?.let {
271-
if (it.status != BatteryStatus.DISCONNECTED) {
271+
// if (it.status != BatteryStatus.DISCONNECTED) {
272272
" R:${if (it.status == BatteryStatus.CHARGING) "" else ""} ${it.level}%"
273-
} else {
274-
""
275-
}
273+
// } else {
274+
// ""
275+
// }
276276
} ?: ""}${batteryList?.find { it.component == BatteryComponent.CASE }?.let {
277-
if (it.status != BatteryStatus.DISCONNECTED) {
277+
// if (it.status != BatteryStatus.DISCONNECTED) {
278278
" C:${if (it.status == BatteryStatus.CHARGING) "" else ""} ${it.level}%"
279-
} else {
280-
""
281-
}
279+
// } else {
280+
// ""
281+
// }
282282
} ?: ""}""")
283283
.setCategory(Notification.CATEGORY_SERVICE)
284284
.setPriority(NotificationCompat.PRIORITY_LOW)

0 commit comments

Comments
 (0)