Commit eb7e608d authored by Mygod's avatar Mygod

Use custom tabs in AboutFragment

parent ef6a9e77
...@@ -38,9 +38,7 @@ class AboutFragment extends ToolbarFragment { ...@@ -38,9 +38,7 @@ class AboutFragment extends ToolbarFragment {
web.loadUrl("file:///android_asset/pages/about.html") web.loadUrl("file:///android_asset/pages/about.html")
web.setWebViewClient(new WebViewClient() { web.setWebViewClient(new WebViewClient() {
override def shouldOverrideUrlLoading(view: WebView, url: String): Boolean = { override def shouldOverrideUrlLoading(view: WebView, url: String): Boolean = {
try startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url))) catch { getActivity.asInstanceOf[MainActivity].launchUrl(url)
case _: android.content.ActivityNotFoundException => // Ignore
}
true true
} }
}) })
......
...@@ -89,6 +89,9 @@ class MainActivity extends Activity with ServiceBoundContext with Drawer.OnDrawe ...@@ -89,6 +89,9 @@ class MainActivity extends Activity with ServiceBoundContext with Drawer.OnDrawe
private lazy val customTabsIntent = new CustomTabsIntent.Builder() private lazy val customTabsIntent = new CustomTabsIntent.Builder()
.setToolbarColor(ContextCompat.getColor(this, R.color.material_primary_500)) .setToolbarColor(ContextCompat.getColor(this, R.color.material_primary_500))
.build() .build()
def launchUrl(url: String): Unit = try customTabsIntent.launchUrl(this, Uri.parse(url)) catch {
case _: ActivityNotFoundException => // Ignore
}
// Services // Services
var state: Int = _ var state: Int = _
...@@ -374,7 +377,7 @@ class MainActivity extends Activity with ServiceBoundContext with Drawer.OnDrawe ...@@ -374,7 +377,7 @@ class MainActivity extends Activity with ServiceBoundContext with Drawer.OnDrawe
case DRAWER_ABOUT => case DRAWER_ABOUT =>
app.track(TAG, "about") app.track(TAG, "about")
displayFragment(aboutFragment) 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 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