Skip to content
Open
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
Expand Up @@ -25,7 +25,8 @@ enum class StemAction {
PREVIOUS_TRACK,
NEXT_TRACK,
DIGITAL_ASSISTANT,
CYCLE_NOISE_CONTROL_MODES;
CYCLE_NOISE_CONTROL_MODES,
MUTE_CALL;
companion object {
fun fromString(action: String): StemAction? {
return entries.find { it.name == action }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -390,9 +390,8 @@ fun AirPodsSettingsScreen(viewModel: AirPodsViewModel, navController: NavControl
to = "head_tracking",
name = stringResource(R.string.head_gestures),
navController = navController,
currentState = if (sharedPreferences.getBoolean(
"head_gestures", false
)
currentState = if (sharedPreferences.getBoolean("head_gestures_answer_call", true)
|| sharedPreferences.getBoolean("head_gestures_mute_call", true)
) stringResource(R.string.on) else stringResource(R.string.off)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,13 +194,22 @@ fun HeadTrackingScreen(viewModel: AirPodsViewModel, navController: NavController
}

StyledToggle(
label = "Head Gestures",
checked = state.headGesturesEnabled,
onCheckedChange = { viewModel.setHeadGesturesEnabled(it) },
enabled = state.isPremium || state.headGesturesEnabled,
description = stringResource(R.string.head_gestures_details)
label = "Answer/decline incoming calls",
checked = state.headGesturesAnswerCall,
onCheckedChange = { viewModel.setHeadGesturesAnswerCall(it) },
enabled = state.isPremium || state.headGesturesAnswerCall,
description = "Nod to answer an incoming call, shake your head to decline."
)

StyledToggle(
label = "Mute/unmute during a call",
checked = state.headGesturesMuteCall,
onCheckedChange = { viewModel.setHeadGesturesMuteCall(it) },
enabled = state.isPremium || state.headGesturesMuteCall,
description = "Shake your head during an active call to mute the mic, nod to unmute."
)


Spacer(modifier = Modifier.height(16.dp))
Text(
"Head Orientation",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ data class AirPodsUiState(
val version3: String = "",

val headTrackingActive: Boolean = false,
val headGesturesEnabled: Boolean = true,
val headGesturesAnswerCall: Boolean = true,
val headGesturesMuteCall: Boolean = true,

val eqData: FloatArray = floatArrayOf(),

Expand Down Expand Up @@ -177,7 +178,8 @@ class AirPodsViewModel(
ControlCommandIdentifiers.CONVERSATION_DETECT_CONFIG,
false
)
setHeadGesturesEnabled(false)
setHeadGesturesAnswerCall(false)
setHeadGesturesMuteCall(false)
}
_uiState.update { it.copy(isPremium = premium) }
}
Expand Down Expand Up @@ -340,7 +342,8 @@ class AirPodsViewModel(
sharedPreferences.getBoolean("automatic_ear_detection", true)
val automaticConnectionEnabled =
sharedPreferences.getBoolean("automatic_connection_ctrl_cmd", true)
val headGesturesEnabled = sharedPreferences.getBoolean("head_gestures", true)
val headGesturesAnswerCall = sharedPreferences.getBoolean("head_gestures_answer_call", true)
val headGesturesMuteCall = sharedPreferences.getBoolean("head_gestures_mute_call", true)
val leftAction = StemAction.valueOf(
sharedPreferences.getString(
"left_long_press_action",
Expand All @@ -363,7 +366,8 @@ class AirPodsViewModel(
offListeningMode = offListeningModeEnabled,
automaticEarDetectionEnabled = automaticEarDetectionEnabled,
automaticConnectionEnabled = automaticConnectionEnabled,
headGesturesEnabled = headGesturesEnabled,
headGesturesAnswerCall = headGesturesAnswerCall,
headGesturesMuteCall = headGesturesMuteCall,
leftAction = leftAction,
rightAction = rightAction,
vendorIdHook = vendorIdHook,
Expand All @@ -381,10 +385,17 @@ class AirPodsViewModel(
}
}

fun setHeadGesturesEnabled(enabled: Boolean) {
sharedPreferences.edit { putBoolean("head_gestures", enabled) }
fun setHeadGesturesAnswerCall(enabled: Boolean) {
sharedPreferences.edit { putBoolean("head_gestures_answer_call", enabled) }
_uiState.update {
it.copy(headGesturesEnabled = enabled)
it.copy(headGesturesAnswerCall = enabled)
}
}

fun setHeadGesturesMuteCall(enabled: Boolean) {
sharedPreferences.edit { putBoolean("head_gestures_mute_call", enabled) }
_uiState.update {
it.copy(headGesturesMuteCall = enabled)
}
}

Expand Down
Loading