Commit eb7e608d authored by Mygod's avatar Mygod

Use custom tabs in AboutFragment

parent ef6a9e77
......@@ -38,9 +38,7 @@ class AboutFragment extends ToolbarFragment {
web.loadUrl("file:///android_asset/pages/about.html")
web.setWebViewClient(new WebViewClient() {
override def shouldOverrideUrlLoading(view: WebView, url: String): Boolean = {
try startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url))) catch {
case _: android.content.ActivityNotFoundException => // Ignore
}
getActivity.asInstanceOf[MainActivity].launchUrl(url)
true
}
})
......
......@@ -89,6 +89,9 @@ class MainActivity extends Activity with ServiceBoundContext with Drawer.OnDrawe
private lazy val customTabsIntent = new CustomTabsIntent.Builder()
.setToolbarColor(ContextCompat.getColor(this, R.color.material_primary_500))
.build()
def launchUrl(url: String): Unit = try customTabsIntent.launchUrl(this, Uri.parse(url)) catch {
case _: ActivityNotFoundException => // Ignore
}
// Services
var state: Int = _
......@@ -374,7 +377,7 @@ class MainActivity extends Activity with ServiceBoundContext with Drawer.OnDrawe
case DRAWER_ABOUT =>
app.track(TAG, "about")
displayFragment(aboutFragment)
case DRAWER_FAQ => customTabsIntent.launchUrl(this, Uri.parse(getString(R.string.faq_url)))
case DRAWER_FAQ => launchUrl(getString(R.string.faq_url))
}
true // unexpected cases will throw exception
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment