diff --git a/app-common/src/main/java/eu/darken/capod/common/preferences/MaterialSwitchPreference.kt b/app-common/src/main/java/eu/darken/capod/common/preferences/MaterialSwitchPreference.kt new file mode 100644 index 00000000..7f8d1e07 --- /dev/null +++ b/app-common/src/main/java/eu/darken/capod/common/preferences/MaterialSwitchPreference.kt @@ -0,0 +1,14 @@ +package eu.darken.capod.common.preferences + +import android.content.Context +import android.util.AttributeSet +import androidx.preference.SwitchPreferenceCompat + +class MaterialSwitchPreference(context: Context, attrs: AttributeSet?) : + SwitchPreferenceCompat(context, attrs) { + + init { + // Use material switch + widgetLayoutResource = eu.darken.capod.common.R.layout.preference_material_switch + } +} \ No newline at end of file diff --git a/app-common/src/main/res/layout/preference_material_switch.xml b/app-common/src/main/res/layout/preference_material_switch.xml new file mode 100644 index 00000000..764709d2 --- /dev/null +++ b/app-common/src/main/res/layout/preference_material_switch.xml @@ -0,0 +1,8 @@ + + \ No newline at end of file diff --git a/app/src/main/java/eu/darken/capod/monitor/ui/MonitorNotifications.kt b/app/src/main/java/eu/darken/capod/monitor/ui/MonitorNotifications.kt index eb103ffe..428d9837 100644 --- a/app/src/main/java/eu/darken/capod/monitor/ui/MonitorNotifications.kt +++ b/app/src/main/java/eu/darken/capod/monitor/ui/MonitorNotifications.kt @@ -22,7 +22,6 @@ import eu.darken.capod.common.notifications.PendingIntentCompat import eu.darken.capod.main.ui.MainActivity import eu.darken.capod.pods.core.HasCase import eu.darken.capod.pods.core.HasChargeDetection -import eu.darken.capod.pods.core.HasDualMicrophone import eu.darken.capod.pods.core.HasEarDetection import eu.darken.capod.pods.core.PodDevice import kotlinx.coroutines.sync.Mutex @@ -80,31 +79,30 @@ class MonitorNotifications @Inject constructor( // Options here should be mutually exclusive, and are prioritized by their order of importance // Some options are omitted here, as they will conflict with other options // TODO: Implement a settings pane to allow user to customize this - device.apply { + when (device) { // Pods charging state // This goes first as pods should not be worn if it is still charging - if (this is HasChargeDetection && isHeadsetBeingCharged) { - contentTitleRes = eu.darken.capod.common.R.string.pods_charging_label - return@apply + is HasChargeDetection -> { + if (device.isHeadsetBeingCharged) + contentTitleRes = eu.darken.capod.common.R.string.pods_charging_label } // Pods wear state - if (this is HasEarDetection) { - contentTitleRes = if (isBeingWorn) eu.darken.capod.common.R.string.headset_being_worn_label - else eu.darken.capod.common.R.string.headset_not_being_worn_label - return@apply + is HasEarDetection -> { + contentTitleRes = if (device.isBeingWorn) eu.darken.capod.common.R.string.headset_being_worn_label + else eu.darken.capod.common.R.string.headset_not_being_worn_label } // Case charge state // This is under pods wear state as we don't want it conflicting with it - if (this is HasCase && isCaseCharging) { - contentTitleRes = eu.darken.capod.common.R.string.pods_charging_label - return@apply + is HasCase -> { + if (device.isCaseCharging) + contentTitleRes = eu.darken.capod.common.R.string.pods_charging_label } } setStyle(NotificationCompat.DecoratedCustomViewStyle()) - setCustomContentView(notificationViewFactory.createContentView(device)) + setCustomBigContentView(notificationViewFactory.createContentView(device)) setSmallIcon(device.iconRes) setContentTitle(context.getString(contentTitleRes)) setSubText(null) diff --git a/app/src/main/res/layout/widget_pod_dual_wide_layout.xml b/app/src/main/res/layout/widget_pod_dual_wide_layout.xml index de3068c6..5b375536 100644 --- a/app/src/main/res/layout/widget_pod_dual_wide_layout.xml +++ b/app/src/main/res/layout/widget_pod_dual_wide_layout.xml @@ -8,6 +8,8 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" + android:layout_marginTop="8dp" + android:layout_marginBottom="4dp" android:orientation="horizontal"> - - - - - - - - + - - - - - - -