Skip to content

Commit

Permalink
Aperture: Add support for mute button and mic mute gesture
Browse files Browse the repository at this point in the history
Change-Id: I99d5384ef3c49069d9f9564213622a345b3a1f36
  • Loading branch information
SebaUbuntu authored and luk1337 committed Aug 27, 2024
1 parent 1e1064c commit 48ba5fc
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 0 deletions.
13 changes: 13 additions & 0 deletions app/src/main/java/org/lineageos/aperture/CameraActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2493,6 +2493,15 @@ open class CameraActivity : AppCompatActivity(R.layout.activity_camera) {
true
}

GestureAction.MIC_MUTE -> {
if (cameraMode == CameraMode.VIDEO && micButton.isEnabled &&
event?.repeatCount == 0
) {
toggleMicrophoneMode()
}
true
}

GestureAction.ZOOM -> {
when (increase) {
true -> zoomIn()
Expand Down Expand Up @@ -2545,6 +2554,10 @@ open class CameraActivity : AppCompatActivity(R.layout.activity_camera) {
true
}

GestureAction.MIC_MUTE -> {
true
}

GestureAction.ZOOM -> {
true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,7 @@ internal fun SharedPreferences.getHardwareKeyAction(
) = when (getString("${hardwareKey.sharedPreferencesKeyPrefix}_action", null)) {
"shutter" -> GestureAction.SHUTTER
"focus" -> GestureAction.FOCUS
"mic_mute" -> GestureAction.MIC_MUTE
"zoom" -> GestureAction.ZOOM
"volume", "default" -> GestureAction.DEFAULT // volume for compat
"nothing" -> GestureAction.NOTHING
Expand All @@ -485,6 +486,7 @@ internal fun SharedPreferences.getHardwareKeyInvert(
internal fun gestureActionToString(gestureAction: GestureAction) = when (gestureAction) {
GestureAction.SHUTTER -> "shutter"
GestureAction.FOCUS -> "focus"
GestureAction.MIC_MUTE -> "mic_mute"
GestureAction.ZOOM -> "zoom"
GestureAction.DEFAULT -> "default"
GestureAction.NOTHING -> "nothing"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ enum class GestureAction(
*/
FOCUS(false),

/**
* Microphone mute during video recording.
*/
MIC_MUTE(false),

/**
* Zoom in or out.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ enum class HardwareKey(
GestureAction.FOCUS,
R.string.focus_button_action_title,
),
MUTE(
KeyEvent.KEYCODE_MUTE,
null,
"mute_button",
false,
GestureAction.MIC_MUTE,
R.string.mute_button_action_title,
),
VOLUME(
KeyEvent.KEYCODE_VOLUME_UP,
KeyEvent.KEYCODE_VOLUME_DOWN,
Expand Down
8 changes: 8 additions & 0 deletions app/src/main/res/values/arrays.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<string-array name="gesture_actions_entries" translatable="false">
<item>@string/gesture_action_shutter</item>
<item>@string/gesture_action_focus</item>
<item>@string/gesture_action_mic_mute</item>
<item>@string/gesture_action_zoom</item>
<item>@string/gesture_action_default</item>
<item>@string/gesture_action_nothing</item>
Expand All @@ -16,6 +17,7 @@
<string-array name="gesture_actions_values" translatable="false">
<item>shutter</item>
<item>focus</item>
<item>mic_mute</item>
<item>zoom</item>
<item>default</item>
<item>nothing</item>
Expand All @@ -25,13 +27,15 @@
<string-array name="gesture_actions_no_two_way_entries" translatable="false">
<item>@string/gesture_action_shutter</item>
<item>@string/gesture_action_focus</item>
<item>@string/gesture_action_mic_mute</item>
<item>@string/gesture_action_default</item>
<item>@string/gesture_action_nothing</item>
</string-array>

<string-array name="gesture_actions_no_two_way_values" translatable="false">
<item>shutter</item>
<item>focus</item>
<item>mic_mute</item>
<item>default</item>
<item>nothing</item>
</string-array>
Expand All @@ -40,13 +44,15 @@
<string-array name="gesture_actions_no_default_entries" translatable="false">
<item>@string/gesture_action_shutter</item>
<item>@string/gesture_action_focus</item>
<item>@string/gesture_action_mic_mute</item>
<item>@string/gesture_action_zoom</item>
<item>@string/gesture_action_nothing</item>
</string-array>

<string-array name="gesture_actions_no_default_values" translatable="false">
<item>shutter</item>
<item>focus</item>
<item>mic_mute</item>
<item>zoom</item>
<item>nothing</item>
</string-array>
Expand All @@ -55,12 +61,14 @@
<string-array name="gesture_actions_no_default_no_two_way_entries" translatable="false">
<item>@string/gesture_action_shutter</item>
<item>@string/gesture_action_focus</item>
<item>@string/gesture_action_mic_mute</item>
<item>@string/gesture_action_nothing</item>
</string-array>

<string-array name="gesture_actions_no_default_no_two_way_values" translatable="false">
<item>shutter</item>
<item>focus</item>
<item>mic_mute</item>
<item>nothing</item>
</string-array>

Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@
<string name="single_buttons_title">Single buttons</string>
<string name="camera_button_action_title">Camera button action</string>
<string name="focus_button_action_title">Focus button action</string>
<string name="mute_button_action_title">Mute button action</string>
<string name="volume_buttons_title">Volume buttons</string>
<string name="volume_buttons_action_title">Volume buttons action</string>
<string name="volume_buttons_invert_title">Invert volume buttons</string>
Expand Down Expand Up @@ -211,6 +212,7 @@
<!-- Gesture actions -->
<string name="gesture_action_shutter">Shutter</string>
<string name="gesture_action_focus">Focus</string>
<string name="gesture_action_mic_mute">Microphone mute</string>
<string name="gesture_action_zoom">Zoom</string>
<string name="gesture_action_default">Android\'s default</string>
<string name="gesture_action_nothing">Nothing</string>
Expand Down

0 comments on commit 48ba5fc

Please sign in to comment.