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
17 changes: 13 additions & 4 deletions atox/src/main/kotlin/ui/call/CallFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import android.Manifest
import android.os.Bundle
import android.util.Log
import android.view.View
import android.widget.Toast
import androidx.activity.result.contract.ActivityResultContracts
Expand All @@ -26,6 +27,7 @@
import ltd.evilcorp.core.vo.PublicKey
import ltd.evilcorp.domain.feature.CallState

private const val TAG = "CallFragment"
private const val PERMISSION = Manifest.permission.RECORD_AUDIO

class CallFragment : BaseFragment<FragmentCallBinding>(FragmentCallBinding::inflate) {
Expand All @@ -37,11 +39,12 @@
if (granted) {
vm.startSendingAudio()
} else {
Toast.makeText(requireContext(), getString(R.string.call_mic_permission_needed), Toast.LENGTH_LONG).show()
Log.d(TAG, "Got no permission")
// Toast.makeText(requireContext(), getString(R.string.call_mic_permission_needed), Toast.LENGTH_LONG).show()

Check warning

Code scanning / detekt

Line detected, which is longer than the defined maximum line length in the code style. Warning

Line detected, which is longer than the defined maximum line length in the code style.
}
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) = binding.run {
override fun onViewCreated(view: View, savedInstanceState: Bundle?): Unit = binding.run {
ViewCompat.setOnApplyWindowInsetsListener(view) { _, compat ->
val insets = compat.getInsets(WindowInsetsCompat.Type.systemBars())
controlContainer.updatePadding(bottom = insets.bottom + controlContainer.paddingTop)
Expand Down Expand Up @@ -73,7 +76,11 @@
if (requireContext().hasPermission(PERMISSION)) {
vm.startSendingAudio()
} else {
requestPermissionLauncher.launch(PERMISSION)
Toast.makeText(
context,
R.string.call_mic_permission_needed,
Toast.LENGTH_LONG,
).show()
}
}
}
Expand All @@ -99,7 +106,9 @@

startCall()

if (requireContext().hasPermission(PERMISSION)) {
if (!requireContext().hasPermission(PERMISSION)) {
requestPermissionLauncher.launch(PERMISSION)
} else {
vm.startSendingAudio()
}
}
Expand Down
3 changes: 3 additions & 0 deletions domain/src/main/kotlin/feature/CallManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ class CallManager @Inject constructor(private val tox: Tox, private val scope: C

fun startSendingAudio(): Boolean {
val to = (inCall.value as CallState.InCall?)?.publicKey ?: return false
if (_sendingAudio.value) {
return true
}
val recorder =
AudioCapture.create(AUDIO_SAMPLING_RATE_HZ, AUDIO_CHANNELS, AUDIO_SEND_INTERVAL_MS) ?: return false
startAudioSender(recorder, to)
Expand Down
Loading