Use custom tabs in AboutFragment
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user