From aa93e08d201d405a27640fefab4ed8933ea0bf3c Mon Sep 17 00:00:00 2001 From: cip Date: Fri, 5 Apr 2013 11:30:50 +0200 Subject: [PATCH] set action bar title to article title if available --- src/org/kiwix/kiwixmobile/KiwixMobileActivity.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/org/kiwix/kiwixmobile/KiwixMobileActivity.java b/src/org/kiwix/kiwixmobile/KiwixMobileActivity.java index c5a579f42..e7122562f 100644 --- a/src/org/kiwix/kiwixmobile/KiwixMobileActivity.java +++ b/src/org/kiwix/kiwixmobile/KiwixMobileActivity.java @@ -172,7 +172,7 @@ public class KiwixMobileActivity extends Activity { // (i.p. internal urls load in webview, external urls in browser) // as currently no custom setWebViewClient required it is commented webView.setWebViewClient(new WebViewClient() { - + @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { if (url.startsWith(ZimContentProvider.CONTENT_URI.toString())) { @@ -184,12 +184,21 @@ public class KiwixMobileActivity extends Activity { startActivity(intent); return true; } - + public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { String errorString = String.format(getResources().getString(R.string.error_articleurlnotfound), failingUrl); //TODO apparently screws up back/forward webView.loadDataWithBaseURL("file://error",""+errorString+"", "text/html", "utf-8", failingUrl); + String title = getResources().getString(R.string.app_name); + getActionBar().setTitle(title); } + + public void onPageFinished(WebView view, String url) { + String title = getResources().getString(R.string.app_name); + if (webView.getTitle()!=null && !webView.getTitle().isEmpty()) + title = webView.getTitle(); + getActionBar().setTitle(title); + } }); //Pinch to zoom