Add support for specific left/right/case icons.

Add AirPods Pro 2 Icons by @christoschronopoulos
This commit is contained in:
darken
2022-12-23 09:52:17 +01:00
committed by Matthias Urhahn
parent 1cfc4e6f65
commit 8eb6ce19f7
53 changed files with 142 additions and 51 deletions
@@ -39,6 +39,8 @@ class DualPodsCardVH(parent: ViewGroup) :
}
}
deviceIcon.setImageResource(device.iconRes)
podLeftIcon.setImageResource(device.leftPodIcon)
podRightIcon.setImageResource(device.rightPodIcon)
lastSeen.text = context.getString(R.string.last_seen_x, device.lastSeenFormatted(item.now))
firstSeen.text = context.getString(R.string.first_seen_x, device.firstSeenFormatted(item.now))
@@ -109,6 +111,7 @@ class DualPodsCardVH(parent: ViewGroup) :
// Case charge state
device.apply {
if (this is HasCase) {
podCaseIcon.setImageResource(caseIcon)
podCaseBatteryIcon.isGone = false
podCaseBatteryIcon.setImageResource(getBatteryDrawable(batteryCasePercent))
podCaseBatteryLabel.text = getBatteryLevelCase(context)
@@ -172,6 +172,7 @@ class WidgetProvider : AppWidgetProvider() {
setTextViewText(R.id.headphones_label, podDevice.getLabel(context))
// Left
setImageViewResource(R.id.pod_left_icon, podDevice.leftPodIcon)
setTextViewText(R.id.pod_left_label, podDevice.getBatteryLevelLeftPod(context))
setViewVisibility(
R.id.pod_left_charging,
@@ -183,6 +184,7 @@ class WidgetProvider : AppWidgetProvider() {
)
// Case
(podDevice as? HasCase)?.let { setImageViewResource(R.id.pod_case_icon, it.caseIcon) }
setTextViewText(R.id.pod_case_label, (podDevice as? HasCase)?.getBatteryLevelCase(context))
setViewVisibility(
R.id.pod_case_charging,
@@ -190,6 +192,7 @@ class WidgetProvider : AppWidgetProvider() {
)
// Right
setImageViewResource(R.id.pod_right_icon, podDevice.rightPodIcon)
setTextViewText(R.id.pod_right_label, podDevice.getBatteryLevelRightPod(context))
setViewVisibility(
R.id.pod_right_charging,
@@ -216,6 +219,7 @@ class WidgetProvider : AppWidgetProvider() {
setOnClickPendingIntent(R.id.widget_root, pendingIntent)
setTextViewText(R.id.headphones_label, podDevice.getLabel(context))
setImageViewResource(R.id.headphones_icon, podDevice.iconRes)
setImageViewResource(R.id.headphones_battery_icon, getBatteryDrawable(podDevice.batteryHeadsetPercent))
setTextViewText(R.id.headphones_battery_label, podDevice.getBatteryLevelHeadset(context))
@@ -27,15 +27,18 @@ class MonitorNotificationViewFactory @Inject constructor(
).apply {
device.apply {
// Left
setImageViewResource(R.id.pod_left_icon, device.leftPodIcon)
setTextViewText(R.id.pod_left_label, getBatteryLevelLeftPod(context))
setViewVisibility(R.id.pod_left_charging, if (isLeftPodCharging) View.VISIBLE else View.GONE)
setViewVisibility(R.id.pod_left_ear, if (isLeftPodInEar) View.VISIBLE else View.GONE)
// Case
setImageViewResource(R.id.pod_case_icon, device.caseIcon)
setTextViewText(R.id.pod_case_label, getBatteryLevelCase(context))
setViewVisibility(R.id.pod_case_charging, if (isCaseCharging) View.VISIBLE else View.GONE)
// Right
setImageViewResource(R.id.pod_right_icon, device.rightPodIcon)
setTextViewText(R.id.pod_right_label, getBatteryLevelRightPod(context))
setViewVisibility(R.id.pod_right_charging, if (isRightPodCharging) View.VISIBLE else View.GONE)
setViewVisibility(R.id.pod_right_ear, if (isRightPodInEar) View.VISIBLE else View.GONE)
@@ -48,6 +51,7 @@ class MonitorNotificationViewFactory @Inject constructor(
).apply {
device.apply {
setTextViewText(R.id.headphones_label, getLabel(context))
setImageViewResource(R.id.headphones_icon, device.iconRes)
setImageViewResource(R.id.headphones_battery_icon, getBatteryDrawable(batteryHeadsetPercent))
setTextViewText(R.id.headphones_battery_label, getBatteryLevelHeadset(context))
if (this is HasEarDetection) {
@@ -50,7 +50,7 @@ class MonitorNotifications @Inject constructor(
setChannelId(NOTIFICATION_CHANNEL_ID)
setContentIntent(openPi)
priority = NotificationCompat.PRIORITY_LOW
setSmallIcon(R.drawable.ic_device_generic_earbuds)
setSmallIcon(R.drawable.devic_earbuds_generic_both)
setOngoing(true)
setContentTitle(context.getString(R.string.app_name))
}
@@ -63,7 +63,7 @@ class MonitorNotifications @Inject constructor(
setStyle(NotificationCompat.BigTextStyle())
setContentTitle(context.getString(R.string.pods_none_label_short))
setSubText(context.getString(R.string.app_name))
setSmallIcon(R.drawable.ic_device_generic_earbuds)
setSmallIcon(R.drawable.devic_earbuds_generic_both)
}
}
@@ -41,14 +41,17 @@ class PopUpPodViewFactory @Inject constructor(
signal.isInvisible = debugSettings.isDebugModeEnabled.value
// Left
podLeftIcon.setImageResource(device.leftPodIcon)
podLeftBatteryIcon.setImageResource(getBatteryDrawable(batteryLeftPodPercent))
podLeftBatteryLabel.text = getBatteryLevelLeftPod(context)
// Case
podCaseIcon.setImageResource(device.caseIcon)
podCaseBatteryIcon.setImageResource(getBatteryDrawable(batteryCasePercent))
podCaseBatteryLabel.text = getBatteryLevelCase(context)
// Right
podRightIcon.setImageResource(device.rightPodIcon)
podRightBatteryIcon.setImageResource(getBatteryDrawable(batteryRightPodPercent))
podRightBatteryLabel.text = getBatteryLevelRightPod(context)
}
@@ -1,11 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
style="@style/Notification.Container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/Notification.Container"
android:layout_marginHorizontal="8dp"
android:orientation="horizontal">
android:orientation="horizontal"
android:paddingVertical="8dp">
<FrameLayout
android:layout_width="0dp"
@@ -15,12 +16,13 @@
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal">
<ImageView
android:id="@+id/pod_left_icon"
style="@style/PodInfoItemIcon.Notification"
android:src="@drawable/ic_airpod_left_24" />
android:src="@drawable/devic_airpods_gen1_left" />
<TextView
android:id="@+id/pod_left_label"
@@ -28,16 +30,21 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:paddingHorizontal="2dp"
tools:text="100%" />
<ImageView
android:id="@+id/pod_left_charging"
style="@style/PodInfoItemIcon.Notification"
android:layout_width="18dp"
android:layout_height="18dp"
android:src="@drawable/ic_baseline_power_24" />
<ImageView
android:id="@+id/pod_left_ear"
style="@style/PodInfoItemIcon.Notification"
android:layout_width="18dp"
android:layout_height="18dp"
android:src="@drawable/ic_baseline_hearing_24" />
</LinearLayout>
@@ -49,12 +56,13 @@
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal">
<ImageView
android:id="@+id/pod_case_icon"
style="@style/PodInfoItemIcon.Notification"
android:src="@drawable/ic_airpod_case_24" />
android:src="@drawable/devic_airpods_gen1_case" />
<TextView
android:id="@+id/pod_case_label"
@@ -62,11 +70,14 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:paddingHorizontal="4dp"
tools:text="100%" />
<ImageView
android:id="@+id/pod_case_charging"
style="@style/PodInfoItemIcon.Notification"
android:layout_width="18dp"
android:layout_height="18dp"
android:src="@drawable/ic_baseline_power_24" />
</LinearLayout>
@@ -78,12 +89,13 @@
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal">
<ImageView
android:id="@+id/pod_right_icon"
style="@style/PodInfoItemIcon.Notification"
android:src="@drawable/ic_airpod_right_24" />
android:src="@drawable/devic_airpods_gen1_right" />
<TextView
android:id="@+id/pod_right_label"
@@ -91,16 +103,21 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:paddingHorizontal="2dp"
tools:text="100%" />
<ImageView
android:id="@+id/pod_right_charging"
style="@style/PodInfoItemIcon.Notification"
android:layout_width="18dp"
android:layout_height="18dp"
android:src="@drawable/ic_baseline_power_24" />
<ImageView
android:id="@+id/pod_right_ear"
style="@style/PodInfoItemIcon.Notification"
android:layout_width="18dp"
android:layout_height="18dp"
android:src="@drawable/ic_baseline_hearing_24" />
</LinearLayout>
@@ -4,6 +4,7 @@
android:layout_width="match_parent"
style="@style/Notification.Container"
android:layout_height="wrap_content"
android:paddingVertical="8dp"
android:gravity="center_horizontal">
<TextView
@@ -17,6 +18,7 @@
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:layout_marginHorizontal="8dp"
android:orientation="horizontal">
@@ -37,11 +39,15 @@
<ImageView
android:id="@+id/headphones_charging"
style="@style/PodInfoItemIcon.Notification"
android:layout_width="18dp"
android:layout_height="18dp"
android:src="@drawable/ic_baseline_power_24" />
<ImageView
android:id="@+id/headphones_worn"
style="@style/PodInfoItemIcon.Notification"
android:layout_width="18dp"
android:layout_height="18dp"
android:src="@drawable/ic_baseline_hearing_24" />
</LinearLayout>
@@ -1,8 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
style="@style/Notification.Container"
android:layout_width="match_parent"
android:paddingVertical="8dp"
android:layout_height="wrap_content">
<TextView
@@ -11,8 +13,8 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginHorizontal="8dp"
android:drawableStart="@drawable/ic_baseline_question_mark_24"
android:gravity="center"
tools:text="100%" />
tools:text="100%"
app:drawableStartCompat="@drawable/ic_baseline_question_mark_24" />
</LinearLayout>
@@ -20,10 +20,11 @@
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_marginStart="16dp"
style="@style/PodInfoItemIcon"
app:layout_constraintBottom_toBottomOf="@id/name"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@id/name"
app:srcCompat="@drawable/ic_airpod_both_24" />
app:srcCompat="@drawable/devic_airpods_gen1_both" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/name"
@@ -118,7 +119,7 @@
android:id="@+id/pod_left_icon"
style="@style/PodInfoItemIcon"
android:contentDescription="@string/pods_dual_left_label"
android:src="@drawable/ic_airpod_left_24"
android:src="@drawable/devic_airpods_gen1_left"
app:layout_constraintBottom_toBottomOf="@id/pod_left_label"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@id/pod_left_label" />
@@ -230,7 +231,7 @@
<ImageView
android:id="@+id/pod_case_icon"
style="@style/PodInfoItemIcon"
android:src="@drawable/ic_airpod_case_24"
android:src="@drawable/devic_airpods_gen1_case"
app:layout_constraintBottom_toBottomOf="@id/pod_case_label"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@id/pod_case_label" />
@@ -324,7 +325,7 @@
android:id="@+id/pod_right_icon"
style="@style/PodInfoItemIcon"
android:contentDescription="@string/pods_dual_right_label"
android:src="@drawable/ic_airpod_right_24"
android:src="@drawable/devic_airpods_gen1_right"
app:layout_constraintBottom_toBottomOf="@id/pod_right_label"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@id/pod_right_label" />
@@ -19,11 +19,12 @@
android:id="@+id/device_icon"
android:layout_width="24dp"
android:layout_height="24dp"
style="@style/PodInfoItemIcon"
android:layout_marginStart="16dp"
app:layout_constraintBottom_toBottomOf="@id/name"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@id/name"
app:srcCompat="@drawable/ic_device_generic_headphones" />
app:srcCompat="@drawable/devic_headphones_generic" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/name"
@@ -7,9 +7,10 @@
<ImageView
android:id="@+id/pod_icon"
style="@style/PodInfoItemIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_device_generic_earbuds"
android:src="@drawable/devic_earbuds_generic_both"
app:layout_constraintBottom_toBottomOf="@id/pod_label"
app:layout_constraintEnd_toStartOf="@id/pod_label"
app:layout_constraintHorizontal_bias="0.0"
@@ -54,10 +55,11 @@
<ImageView
android:id="@+id/pod_left_icon"
style="@style/PodInfoItemIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="@drawable/ic_airpod_left_24"
android:src="@drawable/devic_airpods_gen1_left"
app:layout_constraintBottom_toBottomOf="@id/pod_left_battery_label"
app:layout_constraintEnd_toStartOf="@id/pod_left_battery_icon"
app:layout_constraintStart_toStartOf="parent"
@@ -65,6 +67,7 @@
<ImageView
android:id="@id/pod_left_battery_icon"
style="@style/PodInfoItemIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_baseline_battery_unknown_24"
@@ -100,10 +103,11 @@
<ImageView
android:id="@+id/pod_case_icon"
style="@style/PodInfoItemIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="@drawable/ic_airpod_case_24"
android:src="@drawable/devic_airpods_gen1_case"
app:layout_constraintBottom_toBottomOf="@id/pod_case_battery_label"
app:layout_constraintEnd_toStartOf="@id/pod_case_battery_icon"
app:layout_constraintStart_toStartOf="parent"
@@ -111,6 +115,7 @@
<ImageView
android:id="@id/pod_case_battery_icon"
style="@style/PodInfoItemIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_baseline_battery_unknown_24"
@@ -145,10 +150,11 @@
<ImageView
android:id="@+id/pod_right_icon"
style="@style/PodInfoItemIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="@drawable/ic_airpod_right_24"
android:src="@drawable/devic_airpods_gen1_right"
app:layout_constraintBottom_toBottomOf="@id/pod_right_battery_label"
app:layout_constraintEnd_toStartOf="@id/pod_right_battery_icon"
app:layout_constraintStart_toStartOf="parent"
@@ -156,6 +162,7 @@
<ImageView
android:id="@id/pod_right_battery_icon"
style="@style/PodInfoItemIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_baseline_battery_unknown_24"
@@ -8,8 +8,9 @@
<ImageView
android:id="@+id/headphones_icon"
android:layout_width="wrap_content"
style="@style/PodInfoItemIcon"
android:layout_height="wrap_content"
android:src="@drawable/ic_device_generic_earbuds"
android:src="@drawable/devic_earbuds_generic_both"
app:layout_constraintBottom_toBottomOf="@id/headphones_label"
app:layout_constraintEnd_toStartOf="@id/headphones_label"
app:layout_constraintHorizontal_bias="0.0"
@@ -56,6 +57,7 @@
<ImageView
android:id="@id/headphones_battery_icon"
android:layout_width="wrap_content"
style="@style/PodInfoItemIcon"
android:layout_height="wrap_content"
android:src="@drawable/ic_baseline_battery_unknown_24"
app:layout_constraintBottom_toBottomOf="@id/headphones_battery_label"
@@ -11,6 +11,7 @@
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginBottom="2dp"
android:textStyle="bold"
android:textSize="12sp"
tools:text="AirPods Max" />
@@ -23,7 +24,7 @@
<ImageView
android:id="@+id/pod_left_icon"
style="@style/PodInfoItemIcon.Notification"
android:src="@drawable/ic_airpod_left_24"
android:src="@drawable/devic_airpods_gen1_left"
tools:ignore="ContentDescription" />
<TextView
@@ -57,7 +58,7 @@
<ImageView
android:id="@+id/pod_right_icon"
style="@style/PodInfoItemIcon.Notification"
android:src="@drawable/ic_airpod_right_24"
android:src="@drawable/devic_airpods_gen1_right"
tools:ignore="ContentDescription" />
<TextView
@@ -91,7 +92,7 @@
<ImageView
android:id="@+id/pod_case_icon"
style="@style/PodInfoItemIcon.Notification"
android:src="@drawable/ic_airpod_case_24"
android:src="@drawable/devic_airpods_gen1_case"
tools:ignore="ContentDescription" />
<TextView
@@ -8,6 +8,7 @@
android:id="@+id/headphones_label"
style="@style/PodWidget.TextPrimary"
android:layout_width="wrap_content"
android:textStyle="bold"
android:layout_height="wrap_content"
android:layout_gravity="center"
tools:text="AirPods Max" />
@@ -13,7 +13,7 @@
<ImageView
android:id="@+id/pod_left_icon"
style="@style/PodInfoItemIcon.Notification"
android:src="@drawable/ic_airpod_left_24"
android:src="@drawable/devic_airpods_gen1_left"
tools:ignore="ContentDescription" />
<TextView
@@ -47,7 +47,7 @@
<ImageView
android:id="@+id/pod_right_icon"
style="@style/PodInfoItemIcon.Notification"
android:src="@drawable/ic_airpod_right_24"
android:src="@drawable/devic_airpods_gen1_right"
tools:ignore="ContentDescription" />
<TextView
@@ -81,7 +81,7 @@
<ImageView
android:id="@+id/pod_case_icon"
style="@style/PodInfoItemIcon.Notification"
android:src="@drawable/ic_airpod_case_24"
android:src="@drawable/devic_airpods_gen1_case"
tools:ignore="ContentDescription" />
<TextView
+4
View File
@@ -19,6 +19,7 @@
<style name="PodInfoItemIcon.Notification" parent="TextAppearance.Compat.Notification.Title">
<item name="android:layout_height">20dp</item>
<item name="android:layout_width">20dp</item>
<item name="android:tintMode">multiply</item>
<item name="android:tint">?android:attr/colorAccent</item>
<item name="tint">?android:attr/colorAccent</item>
</style>
@@ -32,6 +33,9 @@
<style name="PodInfoItemIcon" parent="TextAppearance.MaterialComponents.Body2">
<item name="android:layout_height">20dp</item>
<item name="android:layout_width">20dp</item>
<item name="android:tintMode">multiply</item>
<item name="android:tint">?android:attr/colorControlNormal</item>
<item name="tint">?android:attr/colorControlNormal</item>
</style>
<style name="PodInfoItemText" parent="TextAppearance.MaterialComponents.Body2">
+1 -1
View File
@@ -43,7 +43,7 @@
android:title="@string/settings_maindevice_address_label" />
<Preference
android:icon="@drawable/ic_device_generic_headphones"
android:icon="@drawable/devic_headphones_generic"
android:key="core.maindevice.model"
android:summary="@string/settings_maindevice_model_description"
android:title="@string/settings_maindevice_model_label" />