Skip to content
Merged
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Features

- Add support for passing custom headers to `WebView` (only for the openInWebView option). [RMET-4287](https://outsystemsrd.atlassian.net/browse/RMET-4287).

### Chores

- Migrate publishing from OSSRH to Central Portal (https://outsystemsrd.atlassian.net/browse/RMET-4217)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.outsystems.plugins.inappbrowser.osinappbrowserlib.routeradapters

import android.content.Context
import android.content.Intent
import android.os.Bundle
import com.outsystems.plugins.inappbrowser.osinappbrowserlib.OSIABEvents
import com.outsystems.plugins.inappbrowser.osinappbrowserlib.helpers.OSIABFlowHelperInterface
import com.outsystems.plugins.inappbrowser.osinappbrowserlib.models.OSIABWebViewOptions
Expand All @@ -19,7 +20,8 @@ class OSIABWebViewRouterAdapter(
flowHelper: OSIABFlowHelperInterface,
onBrowserPageLoaded: () -> Unit,
onBrowserFinished: () -> Unit,
private val onBrowserPageNavigationCompleted: (String?) -> Unit
private val onBrowserPageNavigationCompleted: (String?) -> Unit,
private val customHeaders: Map<String, String>? = null
) : OSIABBaseRouterAdapter<OSIABWebViewOptions, Boolean>(
context = context,
lifecycleScope = lifecycleScope,
Expand All @@ -33,6 +35,7 @@ class OSIABWebViewRouterAdapter(
companion object {
const val WEB_VIEW_URL_EXTRA = "WEB_VIEW_URL_EXTRA"
const val WEB_VIEW_OPTIONS_EXTRA = "WEB_VIEW_OPTIONS_EXTRA"
const val CUSTOM_HEADERS_EXTRA = "CUSTOM_HEADERS_EXTRA"
}

private var webViewActivityRef: WeakReference<OSIABWebViewActivity>? = null
Expand Down Expand Up @@ -101,6 +104,11 @@ class OSIABWebViewRouterAdapter(
putExtra(OSIABEvents.EXTRA_BROWSER_ID, browserId)
putExtra(WEB_VIEW_URL_EXTRA, url)
putExtra(WEB_VIEW_OPTIONS_EXTRA, options)
putExtra(CUSTOM_HEADERS_EXTRA, Bundle().apply {
customHeaders?.forEach { (key, value) ->
putString(key, value)
}
})
}
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ class OSIABWebViewActivity : AppCompatActivity() {
companion object {
const val WEB_VIEW_URL_EXTRA = "WEB_VIEW_URL_EXTRA"
const val WEB_VIEW_OPTIONS_EXTRA = "WEB_VIEW_OPTIONS_EXTRA"
const val CUSTOM_HEADERS_EXTRA = "CUSTOM_HEADERS_EXTRA"
const val DISABLED_ALPHA = 0.3f
const val ENABLED_ALPHA = 1.0f
const val REQUEST_STANDARD_PERMISSION = 622
Expand All @@ -104,7 +105,7 @@ class OSIABWebViewActivity : AppCompatActivity() {

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

sendWebViewEvent(OSIABWebViewEvent(browserId,this@OSIABWebViewActivity))
sendWebViewEvent(OSIABWebViewEvent(browserId, this@OSIABWebViewActivity))

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

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

val customHeaders: Map<String, String>? = intent.getBundleExtra(CUSTOM_HEADERS_EXTRA)?.let { bundle ->
bundle.keySet().associateWith { bundle.getString(it).orEmpty() }
}

setContentView(R.layout.activity_web_view)

//get elements in screen
Expand Down Expand Up @@ -157,7 +162,7 @@ class OSIABWebViewActivity : AppCompatActivity() {

setupWebView()
if (urlToOpen != null) {
webView.loadUrl(urlToOpen)
webView.loadUrl(urlToOpen, customHeaders ?: emptyMap())
showLoadingScreen()
}

Expand Down
Loading