this should work - didn't test yet tho

Signed-off-by: rapterjet2004 <juliuslinus1@gmail.com>
This commit is contained in:
rapterjet2004 2025-03-17 11:45:34 -05:00
parent 65e5be4798
commit 03c5d2561e
No known key found for this signature in database
GPG Key ID: A6A69CFF84968EA1
3 changed files with 20 additions and 3 deletions

View File

@ -506,10 +506,15 @@ class ChatActivity :
}
override fun onSaveInstanceState(outState: Bundle) {
chatViewModel.handleOrientationChange()
chatViewModel.handleSavedInstance()
super.onSaveInstanceState(outState)
}
override fun onRestoreInstanceState(savedInstanceState: Bundle) {
chatViewModel.handleRestoreInstance()
super.onRestoreInstanceState(savedInstanceState)
}
override fun onStop() {
super.onStop()
active = false

View File

@ -35,6 +35,7 @@ class MediaRecorderManager : LifecycleAwareManager {
}
var currentVoiceRecordFile: String = ""
private var lockRecording = false
enum class MediaRecorderState {
INITIAL,
@ -166,6 +167,12 @@ class MediaRecorderManager : LifecycleAwareManager {
}
override fun handleOnStop() {
if (!lockRecording) {
stop()
}
}
fun lockRecording(shouldLock: Boolean) {
lockRecording = shouldLock
}
}

View File

@ -667,8 +667,13 @@ class ChatViewModel @Inject constructor(
audioFocusRequestManager.audioFocusRequest(request, callback)
}
fun handleOrientationChange() {
fun handleSavedInstance() {
_getCapabilitiesViewState.value = GetCapabilitiesStartState
mediaRecorderManager.lockRecording(true)
}
fun handleRestoreInstance() {
mediaRecorderManager.lockRecording(false)
}
fun getMessageById(url: String, conversationModel: ConversationModel, messageId: Long): Flow<ChatMessage> =