From 00f0173683d5712440c234c39634050c98d2ad07 Mon Sep 17 00:00:00 2001 From: Ricky Cheung Date: Thu, 27 Jun 2024 13:26:09 +0800 Subject: [PATCH 1/5] Update com.google.android.material to 1.12.0 Signed-off-by: Ricky Cheung --- buildSrc/src/main/java/Dependencies.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildSrc/src/main/java/Dependencies.kt b/buildSrc/src/main/java/Dependencies.kt index 7e18ba4c..87a62d56 100644 --- a/buildSrc/src/main/java/Dependencies.kt +++ b/buildSrc/src/main/java/Dependencies.kt @@ -98,7 +98,7 @@ fun DependencyHandlerScope.addBaseAndroidUi() { implementation("androidx.activity:activity-ktx:1.8.0") implementation("androidx.fragment:fragment-ktx:1.6.1") - implementation("com.google.android.material:material:1.5.0-rc01") + implementation("com.google.android.material:material:1.12.0") val lifecycleVers = "2.6.2" implementation("androidx.lifecycle:lifecycle-extensions:2.2.0") From 51460f6228a6fccaed002b610494c42439459966 Mon Sep 17 00:00:00 2001 From: Ricky Cheung Date: Thu, 27 Jun 2024 13:31:03 +0800 Subject: [PATCH 2/5] Update all checkbox preferences to SUW switches Signed-off-by: Ricky Cheung --- .../preferences/MaterialSwitchPreference.kt | 14 ++++++++++++++ .../res/layout/preference_material_switch.xml | 8 ++++++++ app/src/main/res/xml/preferences_debug.xml | 6 +++--- app/src/main/res/xml/preferences_general.xml | 8 ++++---- app/src/main/res/xml/preferences_reactions.xml | 16 ++++++++-------- 5 files changed, 37 insertions(+), 15 deletions(-) create mode 100644 app-common/src/main/java/eu/darken/capod/common/preferences/MaterialSwitchPreference.kt create mode 100644 app-common/src/main/res/layout/preference_material_switch.xml 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/res/xml/preferences_debug.xml b/app/src/main/res/xml/preferences_debug.xml index 3ba4a05e..ac2730ca 100644 --- a/app/src/main/res/xml/preferences_debug.xml +++ b/app/src/main/res/xml/preferences_debug.xml @@ -6,19 +6,19 @@ android:key="debug.log.record" android:title="@string/debug_debuglog_record_action" /> - - - - - - - - + - - - - - - - Date: Thu, 27 Jun 2024 14:06:39 +0800 Subject: [PATCH 3/5] setCustomContentView() -> setCustomBigContentView() Signed-off-by: Ricky Cheung --- .../java/eu/darken/capod/monitor/ui/MonitorNotifications.kt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) 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..a265f8ba 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 @@ -104,7 +103,7 @@ class MonitorNotifications @Inject constructor( } setStyle(NotificationCompat.DecoratedCustomViewStyle()) - setCustomContentView(notificationViewFactory.createContentView(device)) + setCustomBigContentView(notificationViewFactory.createContentView(device)) setSmallIcon(device.iconRes) setContentTitle(context.getString(contentTitleRes)) setSubText(null) From fc427c9d26ef392cf667b74c28ae1ec2749d2fac Mon Sep 17 00:00:00 2001 From: Ricky Cheung Date: Thu, 27 Jun 2024 14:11:56 +0800 Subject: [PATCH 4/5] Add more spacing around the wide variant of dual pods widgets Signed-off-by: Ricky Cheung --- app/src/main/res/layout/widget_pod_dual_wide_layout.xml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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"> Date: Thu, 27 Jun 2024 15:03:11 +0800 Subject: [PATCH 5/5] Prevent return@apply duplicates Signed-off-by: Ricky Cheung --- .../capod/monitor/ui/MonitorNotifications.kt | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) 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 a265f8ba..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 @@ -79,26 +79,25 @@ 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 } }