Skip to content
Open
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
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.commonvoice.saverio.ui.login

import android.content.ActivityNotFoundException
import android.content.Intent
import android.graphics.Bitmap
import android.os.Bundle
Expand All @@ -8,6 +9,7 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.webkit.CookieManager
import android.webkit.WebResourceRequest
import android.webkit.WebView
import android.webkit.WebViewClient
import android.widget.Toast
Expand Down Expand Up @@ -147,6 +149,27 @@ class LoginFragment : ViewBoundFragment<FragmentLoginBinding>() {

webViewClient = object : WebViewClient() {

override fun shouldOverrideUrlLoading(
view: WebView?,
request: WebResourceRequest?
): Boolean {
val uri = request?.url ?: return false
val host = uri.host
val isAuthHost = host == "commonvoice.mozilla.org"
|| host == "auth.mozilla.auth0.com"
|| host?.endsWith(".mozilla.org") == true
|| host?.endsWith(".auth0.com") == true
if (isAuthHost && (uri.scheme == "https" || uri.scheme == "http")) {
return false
}
try {
startActivity(Intent(Intent.ACTION_VIEW, uri))
} catch (e: ActivityNotFoundException) {
Timber.w(e, "No activity to handle %s", uri)
}
return true
}

override fun onPageStarted(view: WebView?, url: String?, favicon: Bitmap?) {
showLoading()
}
Expand Down