Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RMET-3680 OSInAppBrowserLib-Android - Don't try to resolve activity before opening URL #28

Merged
merged 3 commits into from
Sep 20, 2024
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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 1.0.1

### Fixes
- Fix issue where some URLs weren't being open in Custom Tabs and the External Browser (https://outsystemsrd.atlassian.net/browse/RMET-3680)

## 1.0.0

### Fixes
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.github.outsystems</groupId>
<artifactId>osinappbrowser-android</artifactId>
<version>1.0.0</version>
<version>1.0.1</version>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,4 @@ class OSIABEngine {
) {
return webViewRouter.handleOpen(url, completionHandler)
}
}

fun Context.canOpenURL(uri: Uri): Boolean {
val intent = Intent(Intent.ACTION_VIEW, uri)
return intent.resolveActivity(packageManager) != null
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import android.net.Uri
import androidx.browser.customtabs.CustomTabsIntent
import androidx.browser.customtabs.CustomTabsSession
import com.outsystems.plugins.inappbrowser.osinappbrowserlib.OSIABEvents
import com.outsystems.plugins.inappbrowser.osinappbrowserlib.canOpenURL
import com.outsystems.plugins.inappbrowser.osinappbrowserlib.helpers.OSIABCustomTabsSessionHelper
import com.outsystems.plugins.inappbrowser.osinappbrowserlib.helpers.OSIABCustomTabsSessionHelperInterface
import com.outsystems.plugins.inappbrowser.osinappbrowserlib.helpers.OSIABFlowHelperInterface
Expand Down Expand Up @@ -145,11 +144,6 @@ class OSIABCustomTabsRouterAdapter(
lifecycleScope.launch {
try {
val uri = Uri.parse(url)
if (!context.canOpenURL(uri)) {
completionHandler(false)
return@launch
}

customTabsSessionHelper.generateNewCustomTabsSession(
browserId,
context,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,11 @@ import android.content.Intent
import android.net.Uri
import android.provider.Browser.EXTRA_APPLICATION_ID
import com.outsystems.plugins.inappbrowser.osinappbrowserlib.OSIABRouter
import com.outsystems.plugins.inappbrowser.osinappbrowserlib.canOpenURL

class OSIABExternalBrowserRouterAdapter(private val context: Context) : OSIABRouter<Boolean> {
override fun handleOpen(url: String, completionHandler: (Boolean) -> Unit) {
try {
val uri = Uri.parse(url)
if (!context.canOpenURL(uri)) {
completionHandler(false)
return
}
val intent = Intent(Intent.ACTION_VIEW, uri)
intent.putExtra(EXTRA_APPLICATION_ID, context.packageName)
context.startActivity(intent)
Expand Down