Skip to content

Commit

Permalink
Prevent return@apply duplicates
Browse files Browse the repository at this point in the history
Signed-off-by: Ricky Cheung <[email protected]>
  • Loading branch information
Ricky Cheung authored and d4rken committed Jul 12, 2024
1 parent fbcd595 commit 051677e
Showing 1 changed file with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand Down

0 comments on commit 051677e

Please sign in to comment.