Skip to content

Commit

Permalink
Merge pull request #640 from stakwork/aa/feature/open-default-browser
Browse files Browse the repository at this point in the history
Open default browser when click for certain urls on WebViewFragment
  • Loading branch information
ariel10aguero authored Sep 25, 2023
2 parents 186db84 + fe4f92b commit 992f093
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package chat.sphinx.web_view.ui

import android.animation.Animator
import android.content.Intent
import android.graphics.Bitmap
import android.net.Uri
import android.os.Bundle
import android.view.KeyEvent
import android.view.View
Expand Down Expand Up @@ -200,6 +202,13 @@ internal class WebViewFragment: SideEffectDetailFragment<
webView.webViewClient = object : WebViewClient() {
override fun shouldOverrideUrlLoading(view: WebView?, request: WebResourceRequest?): Boolean {
val url = request?.url.toString()

if (url.contains("open=system")) {
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url))
view?.context?.startActivity(intent)
return true
}

view?.loadUrl(url)
return super.shouldOverrideUrlLoading(view, request)
}
Expand Down

0 comments on commit 992f093

Please sign in to comment.