Skip to content

Commit c1f6a4b

Browse files
refactor: no need to duplicate variables
References: https://outsystemsrd.atlassian.net/browse/RMET-4466
1 parent 0a05230 commit c1f6a4b

1 file changed

Lines changed: 9 additions & 11 deletions

File tree

src/main/java/com.outsystems.plugins.inappbrowser/osinappbrowserlib/views/OSIABWebViewActivity.kt

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -552,8 +552,8 @@ class OSIABWebViewActivity : AppCompatActivity() {
552552
private inner class OSIABWebChromeClient : WebChromeClient() {
553553

554554
// for handling uploads (photo, video, gallery, files)
555-
private var pendingAcceptTypes: String = ""
556-
private var pendingCaptureEnabled: Boolean = false
555+
private var acceptTypes: String = ""
556+
private var captureEnabled: Boolean = false
557557

558558
// handle standard permissions (e.g. audio, camera)
559559
override fun onPermissionRequest(request: PermissionRequest?) {
@@ -579,10 +579,8 @@ class OSIABWebViewActivity : AppCompatActivity() {
579579
fileChooserParams: FileChooserParams
580580
): Boolean {
581581
this@OSIABWebViewActivity.filePathCallback = filePathCallback
582-
val acceptTypes = fileChooserParams.acceptTypes.joinToString()
583-
val captureEnabled = fileChooserParams.isCaptureEnabled
584-
pendingAcceptTypes = acceptTypes
585-
pendingCaptureEnabled = captureEnabled
582+
acceptTypes = fileChooserParams.acceptTypes.joinToString()
583+
captureEnabled = fileChooserParams.isCaptureEnabled
586584

587585
// if camera permission is declared in manifest but is not granted, request it
588586
if (hasCameraPermissionDeclared() && !isCameraPermissionGranted()) {
@@ -616,19 +614,19 @@ class OSIABWebViewActivity : AppCompatActivity() {
616614
fun cancelFileChooser() {
617615
filePathCallback?.onReceiveValue(null)
618616
filePathCallback = null
619-
pendingAcceptTypes = ""
620-
pendingCaptureEnabled = false
617+
acceptTypes = ""
618+
captureEnabled = false
621619
}
622620

623621
fun retryFileChooser() {
624622
try {
625-
launchFileChooser(pendingAcceptTypes, pendingCaptureEnabled)
623+
launchFileChooser(acceptTypes, captureEnabled)
626624
} catch (e: Exception) {
627625
e.printStackTrace()
628626
cancelFileChooser()
629627
}
630-
pendingAcceptTypes = ""
631-
pendingCaptureEnabled = false
628+
acceptTypes = ""
629+
captureEnabled = false
632630
}
633631

634632
private fun launchFileChooser(acceptTypes: String = "", isCaptureEnabled: Boolean = false) {

0 commit comments

Comments
 (0)