mirror of
https://github.com/kavishdevar/librepods.git
synced 2026-04-27 16:45:38 +00:00
improve notification when connected
This commit is contained in:
@@ -206,55 +206,83 @@ class AirPodsService: Service() {
|
|||||||
var updatedNotification: Notification? = null
|
var updatedNotification: Notification? = null
|
||||||
|
|
||||||
if (connected) {
|
if (connected) {
|
||||||
val collapsedRemoteViews = RemoteViews(packageName, R.layout.notification)
|
// val collapsedRemoteViews = RemoteViews(packageName, R.layout.notification)
|
||||||
val expandedRemoteViews = RemoteViews(packageName, R.layout.notification_expanded)
|
// val expandedRemoteViews = RemoteViews(packageName, R.layout.notification_expanded)
|
||||||
collapsedRemoteViews.setTextColor(R.id.notification_title, textColor.toInt())
|
// collapsedRemoteViews.setTextColor(R.id.notification_title, textColor.toInt())
|
||||||
|
//
|
||||||
|
// collapsedRemoteViews.setTextViewText(R.id.notification_title, "Connected to $airpodsName")
|
||||||
|
// expandedRemoteViews.setTextViewText(
|
||||||
|
// R.id.notification_title,
|
||||||
|
// "Connected to $airpodsName"
|
||||||
|
// )
|
||||||
|
// expandedRemoteViews.setTextViewText(
|
||||||
|
// R.id.left_battery_notification,
|
||||||
|
// batteryList?.find { it.component == BatteryComponent.LEFT }?.let {
|
||||||
|
// if (it.status != BatteryStatus.DISCONNECTED) {
|
||||||
|
// "Left ${if (it.status == BatteryStatus.CHARGING) "⚡" else ""} ${it.level}%"
|
||||||
|
// } else {
|
||||||
|
// ""
|
||||||
|
// }
|
||||||
|
// } ?: "")
|
||||||
|
// expandedRemoteViews.setTextViewText(
|
||||||
|
// R.id.right_battery_notification,
|
||||||
|
// batteryList?.find { it.component == BatteryComponent.RIGHT }?.let {
|
||||||
|
// if (it.status != BatteryStatus.DISCONNECTED) {
|
||||||
|
// "Right ${if (it.status == BatteryStatus.CHARGING) "⚡" else ""} ${it.level}%"
|
||||||
|
// } else {
|
||||||
|
// ""
|
||||||
|
// }
|
||||||
|
// } ?: "")
|
||||||
|
// expandedRemoteViews.setTextViewText(
|
||||||
|
// R.id.case_battery_notification,
|
||||||
|
// batteryList?.find { it.component == BatteryComponent.CASE }?.let {
|
||||||
|
// if (it.status != BatteryStatus.DISCONNECTED) {
|
||||||
|
// "Case ${if (it.status == BatteryStatus.CHARGING) "⚡" else ""} ${it.level}%"
|
||||||
|
// } else {
|
||||||
|
// ""
|
||||||
|
// }
|
||||||
|
// } ?: "")
|
||||||
|
// expandedRemoteViews.setTextColor(R.id.notification_title, textColor.toInt())
|
||||||
|
// expandedRemoteViews.setTextColor(R.id.left_battery_notification, textColor.toInt())
|
||||||
|
// expandedRemoteViews.setTextColor(R.id.right_battery_notification, textColor.toInt())
|
||||||
|
// expandedRemoteViews.setTextColor(R.id.case_battery_notification, textColor.toInt())
|
||||||
|
// updatedNotification = NotificationCompat.Builder(this, "background_service_status")
|
||||||
|
// .setSmallIcon(R.drawable.airpods)
|
||||||
|
// .setStyle(NotificationCompat.DecoratedCustomViewStyle())
|
||||||
|
// .setCustomContentView(collapsedRemoteViews)
|
||||||
|
// .setCustomBigContentView(expandedRemoteViews)
|
||||||
|
// .setPriority(NotificationCompat.PRIORITY_LOW)
|
||||||
|
// .setCategory(Notification.CATEGORY_SERVICE)
|
||||||
|
// .setOngoing(true)
|
||||||
|
// .build()
|
||||||
|
|
||||||
|
// Instead have something like L: 50% | R: 50% | C: 12% with the emojis, without using remote views, in thte title itself.
|
||||||
|
|
||||||
collapsedRemoteViews.setTextViewText(R.id.notification_title, "Connected to $airpodsName")
|
|
||||||
expandedRemoteViews.setTextViewText(
|
|
||||||
R.id.notification_title,
|
|
||||||
"Connected to $airpodsName"
|
|
||||||
)
|
|
||||||
expandedRemoteViews.setTextViewText(
|
|
||||||
R.id.left_battery_notification,
|
|
||||||
batteryList?.find { it.component == BatteryComponent.LEFT }?.let {
|
|
||||||
if (it.status != BatteryStatus.DISCONNECTED) {
|
|
||||||
"Left ${if (it.status == BatteryStatus.CHARGING) "⚡" else ""} ${it.level}%"
|
|
||||||
} else {
|
|
||||||
""
|
|
||||||
}
|
|
||||||
} ?: "")
|
|
||||||
expandedRemoteViews.setTextViewText(
|
|
||||||
R.id.right_battery_notification,
|
|
||||||
batteryList?.find { it.component == BatteryComponent.RIGHT }?.let {
|
|
||||||
if (it.status != BatteryStatus.DISCONNECTED) {
|
|
||||||
"Right ${if (it.status == BatteryStatus.CHARGING) "⚡" else ""} ${it.level}%"
|
|
||||||
} else {
|
|
||||||
""
|
|
||||||
}
|
|
||||||
} ?: "")
|
|
||||||
expandedRemoteViews.setTextViewText(
|
|
||||||
R.id.case_battery_notification,
|
|
||||||
batteryList?.find { it.component == BatteryComponent.CASE }?.let {
|
|
||||||
if (it.status != BatteryStatus.DISCONNECTED) {
|
|
||||||
"Case ${if (it.status == BatteryStatus.CHARGING) "⚡" else ""} ${it.level}%"
|
|
||||||
} else {
|
|
||||||
""
|
|
||||||
}
|
|
||||||
} ?: "")
|
|
||||||
expandedRemoteViews.setTextColor(R.id.notification_title, textColor.toInt())
|
|
||||||
expandedRemoteViews.setTextColor(R.id.left_battery_notification, textColor.toInt())
|
|
||||||
expandedRemoteViews.setTextColor(R.id.right_battery_notification, textColor.toInt())
|
|
||||||
expandedRemoteViews.setTextColor(R.id.case_battery_notification, textColor.toInt())
|
|
||||||
updatedNotification = NotificationCompat.Builder(this, "background_service_status")
|
updatedNotification = NotificationCompat.Builder(this, "background_service_status")
|
||||||
.setSmallIcon(R.drawable.airpods)
|
.setSmallIcon(R.drawable.airpods)
|
||||||
.setStyle(NotificationCompat.DecoratedCustomViewStyle())
|
.setContentTitle("""L: ${batteryList?.find { it.component == BatteryComponent.LEFT }?.let {
|
||||||
.setCustomContentView(collapsedRemoteViews)
|
if (it.status != BatteryStatus.DISCONNECTED) {
|
||||||
.setCustomBigContentView(expandedRemoteViews)
|
"${if (it.status == BatteryStatus.CHARGING) "⚡" else ""} ${it.level}%"
|
||||||
.setPriority(NotificationCompat.PRIORITY_LOW)
|
} else {
|
||||||
|
""
|
||||||
|
}
|
||||||
|
} ?: ""} R: ${batteryList?.find { it.component == BatteryComponent.RIGHT }?.let {
|
||||||
|
if (it.status != BatteryStatus.DISCONNECTED) {
|
||||||
|
"${if (it.status == BatteryStatus.CHARGING) "⚡" else ""} ${it.level}%"
|
||||||
|
} else {
|
||||||
|
""
|
||||||
|
}
|
||||||
|
} ?: ""} C: ${batteryList?.find { it.component == BatteryComponent.CASE }?.let {
|
||||||
|
if (it.status != BatteryStatus.DISCONNECTED) {
|
||||||
|
"${if (it.status == BatteryStatus.CHARGING) "⚡" else ""} ${it.level}%"
|
||||||
|
} else {
|
||||||
|
""
|
||||||
|
}
|
||||||
|
} ?: ""}""")
|
||||||
.setCategory(Notification.CATEGORY_SERVICE)
|
.setCategory(Notification.CATEGORY_SERVICE)
|
||||||
.setOngoing(true)
|
.setPriority(NotificationCompat.PRIORITY_LOW)
|
||||||
.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)
|
||||||
|
|||||||
Reference in New Issue
Block a user