Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Material You design changes and widgets update (Part 2) #211

Merged
merged 5 commits into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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
}
}
8 changes: 8 additions & 0 deletions app-common/src/main/res/layout/preference_material_switch.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<com.google.android.material.materialswitch.MaterialSwitch xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/switchWidget"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@null"
android:clickable="false"
android:focusable="false" />
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
d4rken marked this conversation as resolved.
Show resolved Hide resolved
// 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)
Expand Down
5 changes: 4 additions & 1 deletion app/src/main/res/layout/widget_pod_dual_wide_layout.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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">

<LinearLayout
Expand Down Expand Up @@ -118,7 +120,8 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="8dp"
android:layout_marginTop="4dp"
android:layout_marginBottom="8dp"
android:gravity="center"
android:textSize="12sp"
android:textStyle="bold"
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/res/xml/preferences_debug.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@
android:key="debug.log.record"
android:title="@string/debug_debuglog_record_action" />

<CheckBoxPreference
<eu.darken.capod.common.preferences.MaterialSwitchPreference
android:icon="@drawable/ic_baseline_bug_report_24"
android:key="debug.mode.enabled"
android:summary="@string/settings_debug_mode_description"
android:title="@string/settings_debug_mode_label" />

<CheckBoxPreference
<eu.darken.capod.common.preferences.MaterialSwitchPreference
android:icon="@drawable/ic_baseline_data_array_24"
android:key="debug.fakedata.enabled"
android:summary="@string/settings_fake_data_description"
android:title="@string/settings_fake_data_label" />

<CheckBoxPreference
<eu.darken.capod.common.preferences.MaterialSwitchPreference
android:icon="@drawable/ic_baseline_devices_other_24"
android:key="debug.blescanner.unfiltered.enabled"
android:summary="@string/settings_blescanner_unfiltered_description"
Expand Down
8 changes: 4 additions & 4 deletions app/src/main/res/xml/preferences_general.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
android:summary="@string/settings_scanner_mode_description"
android:title="@string/settings_scanner_mode_label" />

<CheckBoxPreference
<eu.darken.capod.common.preferences.MaterialSwitchPreference
android:icon="@drawable/ic_baseline_devices_other_24"
android:key="core.showall.enabled"
android:summary="@string/settings_showall_description"
Expand Down Expand Up @@ -49,19 +49,19 @@
android:title="@string/settings_category_compatibility_options_title"
app:icon="@drawable/ic_chip_24">

<CheckBoxPreference
<eu.darken.capod.common.preferences.MaterialSwitchPreference
android:icon="@drawable/ic_filter_cog_outline_24"
android:key="core.compat.offloaded.filtering.disabled"
android:summary="@string/settings_compat_offloaded_filtering_disabled_summary"
android:title="@string/settings_compat_offloaded_filtering_disabled_title" />

<CheckBoxPreference
<eu.darken.capod.common.preferences.MaterialSwitchPreference
android:icon="@drawable/ic_format_list_group_24"
android:key="core.compat.offloaded.batching.disabled"
android:summary="@string/settings_compat_offloaded_batching_disabled_summary"
android:title="@string/settings_compat_offloaded_batching_disabled_title" />

<CheckBoxPreference
<eu.darken.capod.common.preferences.MaterialSwitchPreference
android:icon="@drawable/ic_strategy_24"
android:key="core.compat.indirectcallback.enabled"
android:summary="@string/settings_compat_indirectcallback_summary"
Expand Down
16 changes: 8 additions & 8 deletions app/src/main/res/xml/preferences_reactions.xml
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">

<CheckBoxPreference
<eu.darken.capod.common.preferences.MaterialSwitchPreference
android:icon="@drawable/ic_baseline_looks_one_24"
android:key="reaction.onepod.enabled"
android:summary="@string/settings_onepod_mode_description"
android:title="@string/settings_onepod_mode_label" />


<CheckBoxPreference
<eu.darken.capod.common.preferences.MaterialSwitchPreference
android:icon="@drawable/ic_baseline_play_circle_24"
android:key="reaction.autoplay.enabled"
android:summary="@string/settings_autoplay_description"
android:title="@string/settings_autopplay_label" />

<CheckBoxPreference
<eu.darken.capod.common.preferences.MaterialSwitchPreference
android:icon="@drawable/ic_baseline_pause_circle_24"
android:key="reaction.autopause.enabled"
android:summary="@string/settings_autopause_description"
android:title="@string/settings_autopause_label" />

<CheckBoxPreference
<eu.darken.capod.common.preferences.MaterialSwitchPreference
android:icon="@drawable/ic_baseline_bluetooth_connected_24"
android:key="reaction.autoconnect.enabled"
android:summary="@string/settings_autoconnect_description"
Expand All @@ -32,13 +32,13 @@
android:summary="@string/settings_autoconnect_condition_description"
android:title="@string/settings_autoconnect_condition_label" />

<CheckBoxPreference
<eu.darken.capod.common.preferences.MaterialSwitchPreference
android:icon="@drawable/ic_message_outline_24"
android:key="reaction.popup.caseopen"
android:summary="@string/settings_popup_caseopen_description"
android:title="@string/settings_popup_caseopen_label" />

<CheckBoxPreference
<eu.darken.capod.common.preferences.MaterialSwitchPreference
android:icon="@drawable/ic_message_24"
android:key="reaction.popup.connected"
android:summary="@string/settings_popup_connected_description"
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/java/Dependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Loading