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

Separate mute toggle from include audio toggle option #453

Merged
merged 8 commits into from
Nov 29, 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
20 changes: 20 additions & 0 deletions app/src/main/java/app/grapheneos/camera/capturer/VideoCapturer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ class VideoCapturer(private val mActivity: MainActivity) {

private var recording: Recording? = null

var isMuted = false
private set

var includeAudio: Boolean = false

var isPaused = false
Expand Down Expand Up @@ -298,6 +301,16 @@ class VideoCapturer(private val mActivity: MainActivity) {
mActivity.tabLayout.visibility = View.INVISIBLE
mActivity.timerView.setText(R.string.start_value_timer)
mActivity.timerView.visibility = View.VISIBLE

mActivity.settingsDialog.includeAudioToggle.isEnabled = false

if (camConfig.includeAudio) {
isMuted = false
mActivity.muteToggle.setImageResource(R.drawable.mic_on)
mActivity.muteToggle.setBackgroundColor(mActivity.getColor(R.color.red))
mActivity.muteToggle.tooltipText = mActivity.getString(R.string.tap_to_mute_audio)
mActivity.muteToggle.visibility = View.VISIBLE
}
}

private fun afterRecordingStops() {
Expand Down Expand Up @@ -341,16 +354,23 @@ class VideoCapturer(private val mActivity: MainActivity) {
// if (!mActivity.config.includeAudio)
// mActivity.micOffIcon.visibility = View.VISIBLE

mActivity.settingsDialog.includeAudioToggle.isEnabled = true
mActivity.muteToggle.visibility = View.GONE

isRecording = false

mActivity.forceUpdateOrientationSensor()
}

fun muteRecording() {
check(isRecording && camConfig.includeAudio)
isMuted = true
recording?.mute(true)
}

fun unmuteRecording() {
check(isRecording && camConfig.includeAudio)
isMuted = false
recording?.mute(false)
}

Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/app/grapheneos/camera/ui/SettingsDialog.kt
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,9 @@ class SettingsDialog(val mActivity: MainActivity, themedContext: Context) :
mActivity.videoCapturer.muteRecording()
}
}
}

includeAudioToggle.setOnClickListener {
mActivity.micOffIcon.visibility = if (includeAudioToggle.isChecked) {
View.GONE
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@ open class MainActivity : AppCompatActivity(),
private lateinit var gLeftDash: View
private lateinit var gRightDash: View

lateinit var muteToggle: ShapeableImageView

private var bottomNavigationBarPadding: Int = 0

val thumbnailLoaderExecutor = Executors.newSingleThreadExecutor()
Expand Down Expand Up @@ -1009,6 +1011,23 @@ open class MainActivity : AppCompatActivity(),
gRightDash = binding.gCircleRightDash

gCircleFrame = binding.gCircleFrame

muteToggle = binding.muteToggle
muteToggle.setOnClickListener {
if (videoCapturer.isMuted) {
videoCapturer.unmuteRecording()
muteToggle.setImageResource(R.drawable.mic_on)
muteToggle.setBackgroundColor(getColor(R.color.red))
muteToggle.tooltipText = getString(R.string.tap_to_mute_audio)
showMessage(R.string.video_audio_recording_unmuted)
} else {
videoCapturer.muteRecording()
muteToggle.setImageResource(R.drawable.mic_off)
muteToggle.setBackgroundColor(getColor(android.R.color.darker_gray))
muteToggle.tooltipText = getString(R.string.tap_to_unmute_audio)
showMessage(R.string.video_audio_recording_muted)
}
}
}

private fun repositionTabLayout() {
Expand Down
14 changes: 9 additions & 5 deletions app/src/main/res/drawable/mic_off.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<vector android:height="24dp" android:tint="#FFFFFF"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M19,11h-1.7c0,0.74 -0.16,1.43 -0.43,2.05l1.23,1.23c0.56,-0.98 0.9,-2.09 0.9,-3.28zM14.98,11.17c0,-0.06 0.02,-0.11 0.02,-0.17L15,5c0,-1.66 -1.34,-3 -3,-3S9,3.34 9,5v0.18l5.98,5.99zM4.27,3L3,4.27l6.01,6.01L9.01,11c0,1.66 1.33,3 2.99,3 0.22,0 0.44,-0.03 0.65,-0.08l1.66,1.66c-0.71,0.33 -1.5,0.52 -2.31,0.52 -2.76,0 -5.3,-2.1 -5.3,-5.1L5,11c0,3.41 2.72,6.23 6,6.72L11,21h2v-3.28c0.91,-0.13 1.77,-0.45 2.54,-0.9L19.73,21 21,19.73 4.27,3z"/>
</vector>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="960"
android:viewportHeight="960">
<path
android:fillColor="@android:color/white"
android:pathData="M710,598L652,540Q666,517 673,492Q680,467 680,440L760,440Q760,484 747,523.5Q734,563 710,598ZM480,366Q480,366 480,366Q480,366 480,366L480,366L480,366L480,366Q480,366 480,366Q480,366 480,366ZM592,478L520,406L520,200Q520,183 508.5,171.5Q497,160 480,160Q463,160 451.5,171.5Q440,183 440,200L440,326L360,246L360,200Q360,150 395,115Q430,80 480,80Q530,80 565,115Q600,150 600,200L600,440Q600,451 597.5,460Q595,469 592,478ZM440,840L440,717Q336,703 268,624Q200,545 200,440L280,440Q280,523 337.5,581.5Q395,640 480,640Q514,640 544.5,629.5Q575,619 600,600L657,657Q628,680 593.5,696Q559,712 520,717L520,840L440,840ZM792,904L56,168L112,112L848,848L792,904Z"/>
</vector>
10 changes: 10 additions & 0 deletions app/src/main/res/drawable/mic_on.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="960"
android:viewportHeight="960"
>
<path
android:fillColor="@android:color/white"
android:pathData="M480,560Q430,560 395,525Q360,490 360,440L360,200Q360,150 395,115Q430,80 480,80Q530,80 565,115Q600,150 600,200L600,440Q600,490 565,525Q530,560 480,560ZM480,320Q480,320 480,320Q480,320 480,320L480,320Q480,320 480,320Q480,320 480,320Q480,320 480,320Q480,320 480,320L480,320Q480,320 480,320Q480,320 480,320ZM440,840L440,717Q336,703 268,624Q200,545 200,440L280,440Q280,523 338.5,581.5Q397,640 480,640Q563,640 621.5,581.5Q680,523 680,440L760,440Q760,545 692,624Q624,703 520,717L520,840L440,840ZM480,480Q497,480 508.5,468.5Q520,457 520,440L520,200Q520,183 508.5,171.5Q497,160 480,160Q463,160 451.5,171.5Q440,183 440,200L440,440Q440,457 451.5,468.5Q463,480 480,480Z"/>
</vector>
38 changes: 38 additions & 0 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,44 @@

</FrameLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="3"
android:layout_above="@id/three_buttons"
android:layout_marginBottom="8dp">

<FrameLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">

<com.google.android.material.imageview.ShapeableImageView
android:id="@+id/mute_toggle"
android:layout_width="40dp"
android:layout_height="40dp"
android:src="@drawable/mic_on"
android:background="@color/red"
app:contentPadding="8dp"
android:layout_gravity="center"
app:shapeAppearance="@style/ShapeAppearance.Image.PILL"
android:tooltipText="@string/tap_to_mute_audio"
android:visibility="gone" />

</FrameLayout>

<View
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="1"/>

<View
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="1"/>

</LinearLayout>

<LinearLayout
android:id="@+id/three_buttons"
android:layout_height="wrap_content"
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,8 @@
<color name="self_illumination_light">#ffe8cf</color>

<color name="z_yellow">#ffdf00</color>

<color name="qr_result_background">#E1E3E5</color>

<color name="red">#ff0000</color>
</resources>
6 changes: 6 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -189,4 +189,10 @@
<string name="zsl_setting_title">Use ZSL in Latency mode</string>
<string name="zsl_setting_desc">Uses Zero Shutter Lag (ZSL) in Latency mode for faster capture. Certain devices may have a buggy implementation for this.</string>
<string name="audio_permission_failed_in_recording">Unable to request for audio permission in between a recording</string>

<string name="tap_to_mute_audio">Tap to mute audio</string>
<string name="tap_to_unmute_audio">Tap to unmute audio</string>

<string name="video_audio_recording_muted">The video\'s audio recording has been muted</string>
<string name="video_audio_recording_unmuted">The video\'s audio recording has been unmuted</string>
</resources>