Don't paste text on clipboard when app is in background

This is an attempt to fix mysterious ANRs being reported on Google Play
This commit is contained in:
Gaurav Ujjwal 2023-02-09 17:11:23 +05:30
parent d803aa469a
commit e4feff0488
2 changed files with 7 additions and 4 deletions

View file

@ -113,6 +113,7 @@ class VncActivity : AppCompatActivity() {
//Observers
viewModel.credentialRequest.observe(this) { showCredentialDialog() }
viewModel.sshHostKeyVerifyRequest.observe(this) { showHostKeyDialog() }
viewModel.clipTextReceivedEvent.observe(this) { viewModel.setClipboardText(it) }
viewModel.state.observe(this) { onClientStateChanged(it) }
}

View file

@ -160,6 +160,10 @@ class VncViewModel(val profile: ServerProfile, app: Application) : BaseViewModel
*/
val sshHostKeyVerifyRequest = LiveRequest<HostKey, Boolean>(false, viewModelScope)
/**
* Fired when clip text is received from server and clipboard sharing is ON.
*/
val clipTextReceivedEvent = LiveEvent<String>()
/**************************************************************************
* Connection management
@ -298,10 +302,8 @@ class VncViewModel(val profile: ServerProfile, app: Application) : BaseViewModel
}
private fun receiveClipboardText(text: String) {
viewModelScope.launch(Dispatchers.Main) {
if (pref.server.clipboardSync)
setClipboardText(text)
}
if (pref.server.clipboardSync)
clipTextReceivedEvent.fireAsync(text)
}
/**************************************************************************