mirror of
https://github.com/kavishdevar/librepods.git
synced 2026-02-10 19:52:24 +00:00
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`.
This commit is contained in:
@@ -56,27 +56,27 @@ internal fun updateAppWidget(
|
|||||||
|
|
||||||
views.setTextViewText(R.id.left_battery_widget,
|
views.setTextViewText(R.id.left_battery_widget,
|
||||||
batteryList?.find { it.component == BatteryComponent.LEFT }?.let {
|
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}%"
|
"${if (it.status == BatteryStatus.CHARGING) "⚡" else ""} ${it.level}%"
|
||||||
} else {
|
// } else {
|
||||||
""
|
// ""
|
||||||
}
|
// }
|
||||||
} ?: "")
|
} ?: "")
|
||||||
views.setTextViewText(R.id.right_battery_widget,
|
views.setTextViewText(R.id.right_battery_widget,
|
||||||
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}%"
|
"${if (it.status == BatteryStatus.CHARGING) "⚡" else ""} ${it.level}%"
|
||||||
} else {
|
// } else {
|
||||||
""
|
// ""
|
||||||
}
|
// }
|
||||||
} ?: "")
|
} ?: "")
|
||||||
views.setTextViewText(R.id.case_battery_widget,
|
views.setTextViewText(R.id.case_battery_widget,
|
||||||
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}%"
|
"${if (it.status == BatteryStatus.CHARGING) "⚡" else ""} ${it.level}%"
|
||||||
} else {
|
// } else {
|
||||||
""
|
// ""
|
||||||
}
|
// }
|
||||||
} ?: "")
|
} ?: "")
|
||||||
|
|
||||||
appWidgetManager.updateAppWidget(appWidgetId, views)
|
appWidgetManager.updateAppWidget(appWidgetId, views)
|
||||||
|
|||||||
@@ -262,23 +262,23 @@ 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("""AirPods –${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) {
|
||||||
" L:${if (it.status == BatteryStatus.CHARGING) "⚡" else ""} ${it.level}%"
|
" L:${if (it.status == BatteryStatus.CHARGING) "⚡" else ""} ${it.level}%"
|
||||||
} else {
|
// } else {
|
||||||
""
|
// ""
|
||||||
}
|
// }
|
||||||
} ?: ""}${batteryList?.find { it.component == BatteryComponent.RIGHT }?.let {
|
} ?: ""}${batteryList?.find { it.component == BatteryComponent.RIGHT }?.let {
|
||||||
if (it.status != BatteryStatus.DISCONNECTED) {
|
// if (it.status != BatteryStatus.DISCONNECTED) {
|
||||||
" R:${if (it.status == BatteryStatus.CHARGING) "⚡" else ""} ${it.level}%"
|
" R:${if (it.status == BatteryStatus.CHARGING) "⚡" else ""} ${it.level}%"
|
||||||
} else {
|
// } else {
|
||||||
""
|
// ""
|
||||||
}
|
// }
|
||||||
} ?: ""}${batteryList?.find { it.component == BatteryComponent.CASE }?.let {
|
} ?: ""}${batteryList?.find { it.component == BatteryComponent.CASE }?.let {
|
||||||
if (it.status != BatteryStatus.DISCONNECTED) {
|
// if (it.status != BatteryStatus.DISCONNECTED) {
|
||||||
" C:${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)
|
||||||
|
|||||||
Reference in New Issue
Block a user