mirror of
https://github.com/kavishdevar/librepods.git
synced 2026-01-29 06:10:52 +00:00
show last battery status when a pod or case is disconnected
This commit is contained in:
@@ -127,21 +127,21 @@ fun BatteryView(service: AirPodsService, preview: Boolean = false) {
|
||||
.fillMaxWidth(),
|
||||
horizontalArrangement = Arrangement.Center
|
||||
) {
|
||||
if (left?.status != BatteryStatus.DISCONNECTED) {
|
||||
// if (left?.status != BatteryStatus.DISCONNECTED) {
|
||||
BatteryIndicator(
|
||||
left?.level ?: 0,
|
||||
left?.status == BatteryStatus.CHARGING
|
||||
)
|
||||
}
|
||||
if (left?.status != BatteryStatus.DISCONNECTED && right?.status != BatteryStatus.DISCONNECTED) {
|
||||
// }
|
||||
// if (left?.status != BatteryStatus.DISCONNECTED && right?.status != BatteryStatus.DISCONNECTED) {
|
||||
Spacer(modifier = Modifier.width(16.dp))
|
||||
}
|
||||
if (right?.status != BatteryStatus.DISCONNECTED) {
|
||||
// }
|
||||
// if (right?.status != BatteryStatus.DISCONNECTED) {
|
||||
BatteryIndicator(
|
||||
right?.level ?: 0,
|
||||
right?.status == BatteryStatus.CHARGING
|
||||
)
|
||||
}
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -160,9 +160,9 @@ fun BatteryView(service: AirPodsService, preview: Boolean = false) {
|
||||
.fillMaxWidth()
|
||||
.scale(1.25f)
|
||||
)
|
||||
if (case?.status != BatteryStatus.DISCONNECTED) {
|
||||
// if (case?.status != BatteryStatus.DISCONNECTED) {
|
||||
BatteryIndicator(case?.level ?: 0, case?.status == BatteryStatus.CHARGING)
|
||||
}
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -171,31 +171,31 @@ class AirPodsService: Service() {
|
||||
it.setTextViewText(
|
||||
R.id.left_battery_widget,
|
||||
batteryNotification.getBattery().find { it.component == BatteryComponent.LEFT }?.let {
|
||||
if (it.status != BatteryStatus.DISCONNECTED) {
|
||||
// if (it.status != BatteryStatus.DISCONNECTED) {
|
||||
"${if (it.status == BatteryStatus.CHARGING) "⚡" else ""} ${it.level}%"
|
||||
} else {
|
||||
""
|
||||
}
|
||||
// } else {
|
||||
// ""
|
||||
// }
|
||||
} ?: ""
|
||||
)
|
||||
it.setTextViewText(
|
||||
R.id.right_battery_widget,
|
||||
batteryNotification.getBattery().find { it.component == BatteryComponent.RIGHT }?.let {
|
||||
if (it.status != BatteryStatus.DISCONNECTED) {
|
||||
// if (it.status != BatteryStatus.DISCONNECTED) {
|
||||
"${if (it.status == BatteryStatus.CHARGING) "⚡" else ""} ${it.level}%"
|
||||
} else {
|
||||
""
|
||||
}
|
||||
// } else {
|
||||
// ""
|
||||
// }
|
||||
} ?: ""
|
||||
)
|
||||
it.setTextViewText(
|
||||
R.id.case_battery_widget,
|
||||
batteryNotification.getBattery().find { it.component == BatteryComponent.CASE }?.let {
|
||||
if (it.status != BatteryStatus.DISCONNECTED) {
|
||||
// if (it.status != BatteryStatus.DISCONNECTED) {
|
||||
"${if (it.status == BatteryStatus.CHARGING) "⚡" else ""} ${it.level}%"
|
||||
} else {
|
||||
""
|
||||
}
|
||||
// } else {
|
||||
// ""
|
||||
// }
|
||||
} ?: ""
|
||||
)
|
||||
}
|
||||
@@ -205,7 +205,7 @@ class AirPodsService: Service() {
|
||||
|
||||
fun updateNotificationContent(connected: Boolean, airpodsName: String? = null, batteryList: List<Battery>? = null) {
|
||||
val notificationManager = getSystemService(NotificationManager::class.java)
|
||||
val textColor = this.getSharedPreferences("settings", MODE_PRIVATE).getLong("textColor", 0)
|
||||
// val textColor = this.getSharedPreferences("settings", MODE_PRIVATE).getLong("textColor", 0)
|
||||
var updatedNotification: Notification? = null
|
||||
|
||||
if (connected) {
|
||||
@@ -262,23 +262,23 @@ class AirPodsService: Service() {
|
||||
updatedNotification = NotificationCompat.Builder(this, "background_service_status")
|
||||
.setSmallIcon(R.drawable.airpods)
|
||||
.setContentTitle("""L: ${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}%"
|
||||
} else {
|
||||
""
|
||||
}
|
||||
// } else {
|
||||
// ""
|
||||
// }
|
||||
} ?: ""} R: ${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}%"
|
||||
} else {
|
||||
""
|
||||
}
|
||||
// } else {
|
||||
// ""
|
||||
// }
|
||||
} ?: ""} C: ${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}%"
|
||||
} else {
|
||||
""
|
||||
}
|
||||
// } else {
|
||||
// ""
|
||||
// }
|
||||
} ?: ""}""")
|
||||
.setCategory(Notification.CATEGORY_SERVICE)
|
||||
.setPriority(NotificationCompat.PRIORITY_LOW)
|
||||
|
||||
Reference in New Issue
Block a user