Skip to content

Commit 51bbe6b

Browse files
authored
Merge pull request #49 from OutSystems/development
Development
2 parents 9d8375b + e5a5d1b commit 51bbe6b

3 files changed

Lines changed: 20 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88

9+
### Features
10+
11+
- Add support for passing custom headers to `WebView` (only for the openInWebView option). [RMET-4287](https://outsystemsrd.atlassian.net/browse/RMET-4287).
12+
913
### Chores
1014

1115
- Migrate publishing from OSSRH to Central Portal (https://outsystemsrd.atlassian.net/browse/RMET-4217)

src/main/java/com.outsystems.plugins.inappbrowser/osinappbrowserlib/routeradapters/OSIABWebViewRouterAdapter.kt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package com.outsystems.plugins.inappbrowser.osinappbrowserlib.routeradapters
22

33
import android.content.Context
44
import android.content.Intent
5+
import android.os.Bundle
56
import com.outsystems.plugins.inappbrowser.osinappbrowserlib.OSIABEvents
67
import com.outsystems.plugins.inappbrowser.osinappbrowserlib.helpers.OSIABFlowHelperInterface
78
import com.outsystems.plugins.inappbrowser.osinappbrowserlib.models.OSIABWebViewOptions
@@ -19,7 +20,8 @@ class OSIABWebViewRouterAdapter(
1920
flowHelper: OSIABFlowHelperInterface,
2021
onBrowserPageLoaded: () -> Unit,
2122
onBrowserFinished: () -> Unit,
22-
private val onBrowserPageNavigationCompleted: (String?) -> Unit
23+
private val onBrowserPageNavigationCompleted: (String?) -> Unit,
24+
private val customHeaders: Map<String, String>? = null
2325
) : OSIABBaseRouterAdapter<OSIABWebViewOptions, Boolean>(
2426
context = context,
2527
lifecycleScope = lifecycleScope,
@@ -33,6 +35,7 @@ class OSIABWebViewRouterAdapter(
3335
companion object {
3436
const val WEB_VIEW_URL_EXTRA = "WEB_VIEW_URL_EXTRA"
3537
const val WEB_VIEW_OPTIONS_EXTRA = "WEB_VIEW_OPTIONS_EXTRA"
38+
const val CUSTOM_HEADERS_EXTRA = "CUSTOM_HEADERS_EXTRA"
3639
}
3740

3841
private var webViewActivityRef: WeakReference<OSIABWebViewActivity>? = null
@@ -101,6 +104,11 @@ class OSIABWebViewRouterAdapter(
101104
putExtra(OSIABEvents.EXTRA_BROWSER_ID, browserId)
102105
putExtra(WEB_VIEW_URL_EXTRA, url)
103106
putExtra(WEB_VIEW_OPTIONS_EXTRA, options)
107+
putExtra(CUSTOM_HEADERS_EXTRA, Bundle().apply {
108+
customHeaders?.forEach { (key, value) ->
109+
putString(key, value)
110+
}
111+
})
104112
}
105113
)
106114

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ class OSIABWebViewActivity : AppCompatActivity() {
8787
companion object {
8888
const val WEB_VIEW_URL_EXTRA = "WEB_VIEW_URL_EXTRA"
8989
const val WEB_VIEW_OPTIONS_EXTRA = "WEB_VIEW_OPTIONS_EXTRA"
90+
const val CUSTOM_HEADERS_EXTRA = "CUSTOM_HEADERS_EXTRA"
9091
const val DISABLED_ALPHA = 0.3f
9192
const val ENABLED_ALPHA = 1.0f
9293
const val REQUEST_STANDARD_PERMISSION = 622
@@ -104,7 +105,7 @@ class OSIABWebViewActivity : AppCompatActivity() {
104105

105106
browserId = intent.getStringExtra(OSIABEvents.EXTRA_BROWSER_ID) ?: ""
106107

107-
sendWebViewEvent(OSIABWebViewEvent(browserId,this@OSIABWebViewActivity))
108+
sendWebViewEvent(OSIABWebViewEvent(browserId, this@OSIABWebViewActivity))
108109

109110
appName = applicationInfo.loadLabel(packageManager).toString()
110111

@@ -119,6 +120,10 @@ class OSIABWebViewActivity : AppCompatActivity() {
119120
intent.extras?.getSerializable(WEB_VIEW_OPTIONS_EXTRA) as OSIABWebViewOptions
120121
}
121122

123+
val customHeaders: Map<String, String>? = intent.getBundleExtra(CUSTOM_HEADERS_EXTRA)?.let { bundle ->
124+
bundle.keySet().associateWith { bundle.getString(it).orEmpty() }
125+
}
126+
122127
setContentView(R.layout.activity_web_view)
123128

124129
//get elements in screen
@@ -157,7 +162,7 @@ class OSIABWebViewActivity : AppCompatActivity() {
157162

158163
setupWebView()
159164
if (urlToOpen != null) {
160-
webView.loadUrl(urlToOpen)
165+
webView.loadUrl(urlToOpen, customHeaders ?: emptyMap())
161166
showLoadingScreen()
162167
}
163168

0 commit comments

Comments
 (0)