From c85efa61a2a1de0a1ec643b93da915810efb03bc Mon Sep 17 00:00:00 2001 From: Michael Cavallaro Date: Tue, 21 May 2024 13:47:08 -0600 Subject: [PATCH 1/2] fix: allow urls to open in external browser --- .idea/deploymentTargetDropDown.xml | 10 ++++++++++ .idea/gradle.xml | 5 ++--- .idea/migrations.xml | 10 ++++++++++ app/src/main/AndroidManifest.xml | 1 + .../mainactivity/MainActivity.kt | 2 +- .../com/commandbar/android/HelpHubWebView.kt | 18 ++++++++++++++++-- 6 files changed, 40 insertions(+), 6 deletions(-) create mode 100644 .idea/deploymentTargetDropDown.xml create mode 100644 .idea/migrations.xml diff --git a/.idea/deploymentTargetDropDown.xml b/.idea/deploymentTargetDropDown.xml new file mode 100644 index 0000000..0c0c338 --- /dev/null +++ b/.idea/deploymentTargetDropDown.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml index f71a801..8c81493 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -4,10 +4,8 @@ diff --git a/.idea/migrations.xml b/.idea/migrations.xml new file mode 100644 index 0000000..f8051a6 --- /dev/null +++ b/.idea/migrations.xml @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 39d8c10..f747e5a 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -11,6 +11,7 @@ android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/Theme.MainActivity" + android:usesCleartextTraffic="true" tools:targetApi="31"> ) -> Unit) class HelpHubWebView(context: Context, options: CommandBarOptions? = null, onFallbackAction: FallbackActionCallback? = null) : WebView(context) { @@ -97,6 +102,15 @@ class HelpHubWebView(context: Context, options: CommandBarOptions? = null, onFal println(it) } } + + override fun shouldOverrideUrlLoading( + view: WebView?, + request: WebResourceRequest? + ): Boolean { + val intent = Intent(Intent.ACTION_VIEW, request!!.url) + view!!.context.startActivity(intent) + return true; + } } val html = getHTML(options) @@ -135,11 +149,11 @@ class HelpHubWebView(context: Context, options: CommandBarOptions? = null, onFal val hostname = "10.0.2.2" val apiHost = "api.commandbar.com"; val userId = if (options.userId == null) "null" else "\"${options.userId}\"" - + val launchCode = if (options.launchCode == null) "prod" else options.launchCode return """ (function() { window._cbIsWebView = true; - var o="${options.orgId}",n=["Object.assign","Symbol","Symbol.for"].join("%2C"),a=window;function t(o,n){void 0===n&&(n=!1),"complete"!==document.readyState&&window.addEventListener("load",t.bind(null,o,n),{capture:!1,once:!0});var a=document.createElement("script");a.type="text/javascript",a.async=n,a.src=o,document.head.appendChild(a)}function r(){var n;if(void 0===a.CommandBar){delete a.__CommandBarBootstrap__;var r=Symbol.for("CommandBar::configuration"),e=Symbol.for("CommandBar::orgConfig"),c=Symbol.for("CommandBar::disposed"),i=Symbol.for("CommandBar::isProxy"),m=Symbol.for("CommandBar::queue"),l=Symbol.for("CommandBar::unwrap"),d=[],s="${options.launchCode}",u=s&&s.includes("local")?"http://$hostname:8000":"https://$apiHost",f=Object.assign(((n={})[r]={uuid:o},n[e]={},n[c]=!1,n[i]=!0,n[m]=new Array,n[l]=function(){return f},n),a.CommandBar),p=["addCommand","boot"],y=f;Object.assign(f,{shareCallbacks:function(){return{}},shareContext:function(){return{}}}),a.CommandBar=new Proxy(f,{get:function(o,n){return n in y?f[n]:p.includes(n)?function(){var o=Array.prototype.slice.call(arguments);return new Promise((function(a,t){o.unshift(n,a,t),f[m].push(o)}))}:function(){var o=Array.prototype.slice.call(arguments);o.unshift(n),f[m].push(o)}}}),null!==s&&d.push("lc=".concat(s)),d.push("version=2"),t("".concat(u,"/latest/").concat(o,"?").concat(d.join("&")),!0)}}void 0===Object.assign||"undefined"==typeof Symbol||void 0===Symbol.for?(a.__CommandBarBootstrap__=r,t("https://polyfill.io/v3/polyfill.min.js?version=3.101.0&callback=__CommandBarBootstrap__&features="+n)):r(); + var o="${options.orgId}",n=["Object.assign","Symbol","Symbol.for"].join("%2C"),a=window;function t(o,n){void 0===n&&(n=!1),"complete"!==document.readyState&&window.addEventListener("load",t.bind(null,o,n),{capture:!1,once:!0});var a=document.createElement("script");a.type="text/javascript",a.async=n,a.src=o,document.head.appendChild(a)}function r(){var n;if(void 0===a.CommandBar){delete a.__CommandBarBootstrap__;var r=Symbol.for("CommandBar::configuration"),e=Symbol.for("CommandBar::orgConfig"),c=Symbol.for("CommandBar::disposed"),i=Symbol.for("CommandBar::isProxy"),m=Symbol.for("CommandBar::queue"),l=Symbol.for("CommandBar::unwrap"),d=[],s="api=$launchCode;commandbar=$launchCode",u=s&&s.includes("local")?"http://$hostname:8000":"https://$apiHost",f=Object.assign(((n={})[r]={uuid:o},n[e]={},n[c]=!1,n[i]=!0,n[m]=new Array,n[l]=function(){return f},n),a.CommandBar),p=["addCommand","boot"],y=f;Object.assign(f,{shareCallbacks:function(){return{}},shareContext:function(){return{}}}),a.CommandBar=new Proxy(f,{get:function(o,n){return n in y?f[n]:p.includes(n)?function(){var o=Array.prototype.slice.call(arguments);return new Promise((function(a,t){o.unshift(n,a,t),f[m].push(o)}))}:function(){var o=Array.prototype.slice.call(arguments);o.unshift(n),f[m].push(o)}}}),null!==s&&d.push("lc=".concat(s)),d.push("version=2"),t("".concat(u,"/latest/").concat(o,"?").concat(d.join("&")),!0)}}void 0===Object.assign||"undefined"==typeof Symbol||void 0===Symbol.for?(a.__CommandBarBootstrap__=r,t("https://polyfill.io/v3/polyfill.min.js?version=3.101.0&callback=__CommandBarBootstrap__&features="+n)):r(); window.CommandBar.boot($userId, {}, { products: ["help_hub"] }); window.CommandBar.openHelpHub(); })(); From 5fd8f6399bef0b4edfdc4497d08faa3ed12effff Mon Sep 17 00:00:00 2001 From: Michael Cavallaro Date: Tue, 21 May 2024 13:49:34 -0600 Subject: [PATCH 2/2] chore: bump version to 1.0.7 --- README.md | 2 +- commandbar/build.gradle.kts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0413783..6401c64 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ repositories { } dependencies { - implementation 'com.commandbar.android:commandbar:1.0.6' + implementation 'com.commandbar.android:commandbar:1.0.7' } ``` diff --git a/commandbar/build.gradle.kts b/commandbar/build.gradle.kts index bfda9aa..816f6e0 100644 --- a/commandbar/build.gradle.kts +++ b/commandbar/build.gradle.kts @@ -43,7 +43,7 @@ mavenPublishing { signAllPublications() - coordinates("com.commandbar.android", "commandbar", "1.0.6") + coordinates("com.commandbar.android", "commandbar", "1.0.7") pom { name.set("CommandBarAndroid")