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
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@ 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.4.1]

### Features

- Added support for predictive back navigation for Android 13+ (https://outsystemsrd.atlassian.net/browse/RMET-4335)

### Fixes

- Migrate back button navigation on `OSIABWebViewActivity` to support apps targeting Android 16 (https://outsystemsrd.atlassian.net/browse/RMET-4335)

## [1.4.0]

### Features
Expand Down
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
buildscript {
ext.kotlin_version = "1.9.24"
ext.kotlin_version = "1.9.25"
ext.jacocoVersion = '0.8.7'
repositories {
google()
Expand All @@ -12,7 +12,7 @@ buildscript {
if (System.getenv("SHOULD_PUBLISH") == "true") {
classpath("io.github.gradle-nexus:publish-plugin:1.1.0")
}
classpath 'com.android.tools.build:gradle:8.7.3'
classpath 'com.android.tools.build:gradle:8.11.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jacoco:org.jacoco.core:$jacocoVersion"
}
Expand Down Expand Up @@ -41,11 +41,11 @@ apply plugin: "jacoco"

android {
namespace "com.outsystems.plugins.inappbrowser.osinappbrowserlib"
compileSdk 35
compileSdk 36

defaultConfig {
minSdk 26
targetSdk 35
targetSdk 36
versionCode 1
versionName "1.0"

Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Wed May 29 18:08:54 CDT 2024
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
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>io.ionic.libs</groupId>
<artifactId>ioninappbrowser-android</artifactId>
<version>1.4.0</version>
<version>1.4.1</version>
</project>
5 changes: 4 additions & 1 deletion src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.outsystems.plugins.inappbrowser.osinappbrowserlib">

<uses-permission android:name="android.permission.INTERNET" />
Expand All @@ -18,7 +19,9 @@
android:exported="false"
android:configChanges="orientation|screenSize|uiMode"
android:label="OSIABWebViewActivity"
android:theme="@style/AppTheme.WebView" />
android:theme="@style/AppTheme.WebView"
android:enableOnBackInvokedCallback="true"
tools:targetApi="33" />
<activity android:name=".views.OSIABCustomTabsControllerActivity"
android:exported="false"
android:theme="@style/Theme.Transparent"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import android.widget.Button
import android.widget.ImageButton
import android.widget.LinearLayout
import android.widget.TextView
import androidx.activity.OnBackPressedCallback
import androidx.activity.enableEdgeToEdge
import androidx.activity.result.contract.ActivityResultContracts
import androidx.appcompat.app.AppCompatActivity
Expand Down Expand Up @@ -84,6 +85,9 @@ class OSIABWebViewActivity : AppCompatActivity() {
filePathCallback = null
}

// for back navigation
private lateinit var onBackPressedCallback: OnBackPressedCallback

companion object {
const val WEB_VIEW_URL_EXTRA = "WEB_VIEW_URL_EXTRA"
const val WEB_VIEW_OPTIONS_EXTRA = "WEB_VIEW_OPTIONS_EXTRA"
Expand All @@ -103,6 +107,15 @@ class OSIABWebViewActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

onBackPressedCallback = object : OnBackPressedCallback(true) {
override fun handleOnBackPressed() {
if (!webView.canGoBack()) return
hideErrorScreen()
webView.goBack()
}
}
onBackPressedDispatcher.addCallback(this, onBackPressedCallback)

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

sendWebViewEvent(OSIABWebViewEvent(browserId, this@OSIABWebViewActivity))
Expand Down Expand Up @@ -137,8 +150,6 @@ class OSIABWebViewActivity : AppCompatActivity() {
closeButton = findViewById(R.id.close_button)
closeButton.text = options.closeButtonText.ifBlank { "Close" }
closeButton.setOnClickListener {
sendWebViewEvent(OSIABEvents.BrowserFinished(browserId))
webView.destroy()
finish()
}

Expand Down Expand Up @@ -176,6 +187,18 @@ class OSIABWebViewActivity : AppCompatActivity() {
}
}

override fun onStop() {
super.onStop()
if (isFinishing) {
sendWebViewEvent(OSIABEvents.BrowserFinished(browserId))
}
}

override fun onDestroy() {
webView.destroy()
super.onDestroy()
}

override fun onResume() {
super.onResume()
if (options.pauseMedia) {
Expand Down Expand Up @@ -237,7 +260,7 @@ class OSIABWebViewActivity : AppCompatActivity() {
*/
private fun customWebViewClient(
hasNavigationButtons: Boolean,
showURL: Boolean,
showURL: Boolean
): WebViewClient {
return OSIABWebViewClient(hasNavigationButtons, showURL)
}
Expand All @@ -249,20 +272,6 @@ class OSIABWebViewActivity : AppCompatActivity() {
return OSIABWebChromeClient()
}

/**
* Handle the back button press
*/
override fun onBackPressed() {
if (options.hardwareBack && webView.canGoBack()) {
hideErrorScreen()
webView.goBack()
} else {
sendWebViewEvent(OSIABEvents.BrowserFinished(browserId))
webView.destroy()
onBackPressedDispatcher.onBackPressed()
}
}

/**
* Handle permission requests
*/
Expand Down Expand Up @@ -300,7 +309,7 @@ class OSIABWebViewActivity : AppCompatActivity() {
*/
private inner class OSIABWebViewClient(
val hasNavigationButtons: Boolean,
val showURL: Boolean
val showURL: Boolean,
) : WebViewClient() {

override fun onPageStarted(view: WebView?, url: String?, favicon: Bitmap?) {
Expand Down Expand Up @@ -385,6 +394,15 @@ class OSIABWebViewActivity : AppCompatActivity() {
}
}

override fun doUpdateVisitedHistory(view: WebView?, url: String?, isReload: Boolean) {
// to implement predictive back navigation
// we only want to have the callback enabled if the WebView can go back to previous page
// and if the hardwareBack option is enabled
// if not, we want the system to handle the back press, which will enable the
// predictive back animation and simply close the WebView
onBackPressedCallback.isEnabled = webView.canGoBack() && options.hardwareBack
}

/**
* Responsible for handling and launching intents based on a URL.
* @param intentAction Action for the intent
Expand Down
Loading