Skip to content

Commit

Permalink
show toast when can not find app to open unknown link
Browse files Browse the repository at this point in the history
  • Loading branch information
truefedex committed May 2, 2023
1 parent 681d534 commit 2d502bc
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ import com.phlox.tvwebbrowser.utils.activemodel.ActiveModelsRepository
import com.phlox.tvwebbrowser.webengine.WebEngine
import com.phlox.tvwebbrowser.webengine.WebEngineFactory
import com.phlox.tvwebbrowser.webengine.WebEngineWindowProviderCallback
import com.phlox.tvwebbrowser.webengine.common.Scripts
import com.phlox.tvwebbrowser.webengine.gecko.GeckoWebEngine
import com.phlox.tvwebbrowser.widgets.NotificationView
import kotlinx.coroutines.*
Expand Down Expand Up @@ -1153,6 +1152,9 @@ open class MainActivity : AppCompatActivity(), ActionBar.Callback {
true
} else {
Log.d(TAG, "shouldOverrideUrlLoading: no activity to handle intent")
runOnUiThread {
Utils.showToast(applicationContext, getString(R.string.err_no_app_to_handle_url))
}
false
}
} catch (e: Exception) {
Expand Down Expand Up @@ -1203,8 +1205,6 @@ open class MainActivity : AppCompatActivity(), ActionBar.Callback {
}
}
}

tab.webEngine.evaluateJavascript(Scripts.INITIAL_SCRIPT)
}

override fun onPageCertificateError(url: String?) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.phlox.tvwebbrowser.webengine.common
package com.phlox.tvwebbrowser.webengine.webview

object Scripts {
val INITIAL_SCRIPT = """
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import com.phlox.tvwebbrowser.Config
import com.phlox.tvwebbrowser.R
import com.phlox.tvwebbrowser.TVBro
import com.phlox.tvwebbrowser.utils.LogUtils
import com.phlox.tvwebbrowser.webengine.common.Scripts
import java.net.URLEncoder
import java.util.*

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ class WebViewWebEngine(val tab: WebTabState) : WebEngine {

override fun onPageFinished(url: String?) {
callback?.onPageFinished(url)
evaluateJavascript(Scripts.INITIAL_SCRIPT)
}

override fun onPageCertificateError(url: String?) {
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -196,4 +196,5 @@
<string name="webview_sunset_dialog_message">Hello! TV Bro changes engine. All this time, TV Bro has been using the WebView system component to display web content. But this all the time led to various problems due to the fact that the WebView is updated independently and often has own bugs. Now TV Bro is changing the engine to GeckoView which can be built in so there will be no such problems. Unfortunately, the internal data format of these engines is not compatible, so the data of open sessions will be lost during the transition. Therefore, for some time TV Bro will still support both engines (you can switch in the settings).\n\nSo are you ready to use the GeckoView version or want to stay on the WebView for now?</string>
<string name="webview_sunset_dialog_positive_button">Yes, let\'s start using new engine</string>
<string name="webview_sunset_dialog_negative_button">No, use old one for now</string>
<string name="err_no_app_to_handle_url">Can not find suitable application to handle this URL</string>
</resources>

0 comments on commit 2d502bc

Please sign in to comment.