Skip to content

Commit

Permalink
Open default browser if url contains open=system
Browse files Browse the repository at this point in the history
  • Loading branch information
ariel10aguero committed Sep 22, 2023
1 parent 186db84 commit fe4f92b
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 fe4f92b

Please sign in to comment.