Skip to content
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
Expand Up @@ -183,6 +183,24 @@ sealed class ActionData : Comparable<ActionData> {
}
}

@Serializable
sealed class Microphone : ActionData() {
@Serializable
data object Mute : Microphone() {
override val id = ActionId.MUTE_MICROPHONE
}

@Serializable
data object UnMute : Microphone() {
override val id = ActionId.UNMUTE_MICROPHONE
}

@Serializable
data object Toggle : Microphone() {
override val id = ActionId.TOGGLE_MUTE_MICROPHONE
}
}

@Serializable
sealed class Flashlight : ActionData() {
abstract val lens: CameraLens
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,10 @@ object ActionDataEntityMapper {
}
}

ActionId.MUTE_MICROPHONE -> ActionData.Microphone.Mute
ActionId.UNMUTE_MICROPHONE -> ActionData.Microphone.UnMute
ActionId.TOGGLE_MUTE_MICROPHONE -> ActionData.Microphone.Toggle

ActionId.TOGGLE_FLASHLIGHT,
ActionId.ENABLE_FLASHLIGHT,
ActionId.CHANGE_FLASHLIGHT_STRENGTH,
Expand Down Expand Up @@ -1139,6 +1143,9 @@ object ActionDataEntityMapper {
ActionId.VOLUME_UNMUTE to "volume_unmute",
ActionId.VOLUME_MUTE to "volume_mute",
ActionId.VOLUME_TOGGLE_MUTE to "volume_toggle_mute",
ActionId.MUTE_MICROPHONE to "mute_microphone",
ActionId.UNMUTE_MICROPHONE to "unmute_microphone",
ActionId.TOGGLE_MUTE_MICROPHONE to "toggle_mute_microphone",

ActionId.EXPAND_NOTIFICATION_DRAWER to "expand_notification_drawer",
ActionId.TOGGLE_NOTIFICATION_DRAWER to "toggle_notification_drawer",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ enum class ActionId {
VOLUME_UNMUTE,
VOLUME_MUTE,
VOLUME_TOGGLE_MUTE,
MUTE_MICROPHONE,
UNMUTE_MICROPHONE,
TOGGLE_MUTE_MICROPHONE,

EXPAND_NOTIFICATION_DRAWER,
TOGGLE_NOTIFICATION_DRAWER,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,9 @@ object ActionUtils {
ActionId.VOLUME_UNMUTE -> ActionCategory.VOLUME
ActionId.VOLUME_MUTE -> ActionCategory.VOLUME
ActionId.VOLUME_TOGGLE_MUTE -> ActionCategory.VOLUME
ActionId.MUTE_MICROPHONE -> ActionCategory.VOLUME
ActionId.UNMUTE_MICROPHONE -> ActionCategory.VOLUME
ActionId.TOGGLE_MUTE_MICROPHONE -> ActionCategory.VOLUME

ActionId.EXPAND_NOTIFICATION_DRAWER -> ActionCategory.NAVIGATION
ActionId.TOGGLE_NOTIFICATION_DRAWER -> ActionCategory.NAVIGATION
Expand Down Expand Up @@ -289,6 +292,9 @@ object ActionUtils {
ActionId.VOLUME_UNMUTE -> R.string.action_volume_unmute
ActionId.VOLUME_MUTE -> R.string.action_volume_mute
ActionId.VOLUME_TOGGLE_MUTE -> R.string.action_toggle_mute
ActionId.MUTE_MICROPHONE -> R.string.action_mute_microphone
ActionId.UNMUTE_MICROPHONE -> R.string.action_unmute_microphone
ActionId.TOGGLE_MUTE_MICROPHONE -> R.string.action_toggle_mute_microphone
ActionId.EXPAND_NOTIFICATION_DRAWER -> R.string.action_expand_notification_drawer
ActionId.TOGGLE_NOTIFICATION_DRAWER -> R.string.action_toggle_notification_drawer
ActionId.EXPAND_QUICK_SETTINGS -> R.string.action_expand_quick_settings
Expand Down Expand Up @@ -413,6 +419,9 @@ object ActionUtils {
ActionId.VOLUME_UNMUTE -> R.drawable.ic_outline_volume_up_24
ActionId.VOLUME_MUTE -> R.drawable.ic_outline_volume_mute_24
ActionId.VOLUME_TOGGLE_MUTE -> R.drawable.ic_outline_volume_mute_24
ActionId.MUTE_MICROPHONE -> null
ActionId.UNMUTE_MICROPHONE -> null
ActionId.TOGGLE_MUTE_MICROPHONE -> null
ActionId.EXPAND_NOTIFICATION_DRAWER -> null
ActionId.TOGGLE_NOTIFICATION_DRAWER -> null
ActionId.EXPAND_QUICK_SETTINGS -> null
Expand Down Expand Up @@ -507,6 +516,9 @@ object ActionUtils {
ActionId.VOLUME_MUTE,
ActionId.VOLUME_UNMUTE,
ActionId.VOLUME_TOGGLE_MUTE,
ActionId.MUTE_MICROPHONE,
ActionId.UNMUTE_MICROPHONE,
ActionId.TOGGLE_MUTE_MICROPHONE,
ActionId.TOGGLE_DND_MODE,
ActionId.ENABLE_DND_MODE,
ActionId.DISABLE_DND_MODE,
Expand Down Expand Up @@ -653,6 +665,9 @@ object ActionUtils {
ActionId.VOLUME_MUTE,
ActionId.VOLUME_UNMUTE,
ActionId.VOLUME_TOGGLE_MUTE,
ActionId.MUTE_MICROPHONE,
ActionId.UNMUTE_MICROPHONE,
ActionId.TOGGLE_MUTE_MICROPHONE,
ActionId.TOGGLE_DND_MODE,
ActionId.DISABLE_DND_MODE,
ActionId.ENABLE_DND_MODE,
Expand Down Expand Up @@ -784,6 +799,9 @@ object ActionUtils {
ActionId.VOLUME_UNMUTE -> Icons.AutoMirrored.Outlined.VolumeUp
ActionId.VOLUME_MUTE -> Icons.AutoMirrored.Outlined.VolumeMute
ActionId.VOLUME_TOGGLE_MUTE -> Icons.AutoMirrored.Outlined.VolumeMute
ActionId.MUTE_MICROPHONE -> Icons.Outlined.MicOff
ActionId.UNMUTE_MICROPHONE -> Icons.Outlined.Mic
ActionId.TOGGLE_MUTE_MICROPHONE -> Icons.Outlined.MicOff
ActionId.EXPAND_NOTIFICATION_DRAWER -> KeyMapperIcons.TopPanelOpen
ActionId.TOGGLE_NOTIFICATION_DRAWER -> KeyMapperIcons.TopPanelClose
ActionId.EXPAND_QUICK_SETTINGS -> KeyMapperIcons.TopPanelOpen
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,18 @@ class CreateActionDelegate(
return action
}

ActionId.MUTE_MICROPHONE -> {
return ActionData.Microphone.Mute
}

ActionId.UNMUTE_MICROPHONE -> {
return ActionData.Microphone.UnMute
}

ActionId.TOGGLE_MUTE_MICROPHONE -> {
return ActionData.Microphone.Toggle
}

ActionId.VOLUME_INCREASE_STREAM,
ActionId.VOLUME_DECREASE_STREAM,
-> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,18 @@ class PerformActionsUseCaseImpl @AssistedInject constructor(
result = audioAdapter.unmuteVolume(showVolumeUi = action.showVolumeUi)
}

is ActionData.Microphone.Mute -> {
result = audioAdapter.muteMicrophone()
}

is ActionData.Microphone.UnMute -> {
result = audioAdapter.unmuteMicrophone()
}

is ActionData.Microphone.Toggle -> {
result = audioAdapter.toggleMuteMicrophone()
}

is ActionData.TapScreen -> {
result = service.tapScreen(action.x, action.y, inputEventAction)
}
Expand Down
3 changes: 3 additions & 0 deletions base/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -883,6 +883,9 @@
<string name="action_volume_mute">Mute volume</string>
<string name="action_toggle_mute">Toggle mute</string>
<string name="action_volume_unmute">Unmute volume</string>
<string name="action_mute_microphone">Mute microphone</string>
<string name="action_unmute_microphone">Unmute microphone</string>
<string name="action_toggle_mute_microphone">Toggle mute microphone</string>
<string name="action_volume_show_dialog">Show volume dialog</string>
<string name="action_increase_stream">Increase stream</string>
<string name="action_increase_stream_formatted">Increase %s stream</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,21 @@ class AndroidVolumeAdapter @Inject constructor(
override fun isDndEnabled(): Boolean =
notificationManager.currentInterruptionFilter != NotificationManager.INTERRUPTION_FILTER_ALL

override fun muteMicrophone(): KMResult<*> {
audioManager.isMicrophoneMute = true
return Success(Unit)
}

override fun unmuteMicrophone(): KMResult<*> {
audioManager.isMicrophoneMute = false
return Success(Unit)
}

override fun toggleMuteMicrophone(): KMResult<*> {
audioManager.isMicrophoneMute = !audioManager.isMicrophoneMute
return Success(Unit)
}

private fun DndMode.convert(): Int = when (this) {
DndMode.ALARMS -> NotificationManager.INTERRUPTION_FILTER_ALARMS
DndMode.PRIORITY -> NotificationManager.INTERRUPTION_FILTER_PRIORITY
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ interface VolumeAdapter {
fun showVolumeUi(): KMResult<*>
fun setRingerMode(mode: RingerMode): KMResult<*>

fun muteMicrophone(): KMResult<*>
fun unmuteMicrophone(): KMResult<*>
fun toggleMuteMicrophone(): KMResult<*>

fun isDndEnabled(): Boolean
fun enableDndMode(dndMode: DndMode): KMResult<*>
fun disableDndMode(): KMResult<*>
Expand Down
Loading