diff options
author | Martin Fietz <Martin.Fietz@gmail.com> | 2015-09-10 12:33:22 +0200 |
---|---|---|
committer | Martin Fietz <Martin.Fietz@gmail.com> | 2015-09-10 12:33:22 +0200 |
commit | 8270e435b58773ee346230ee89c53034cddf248f (patch) | |
tree | d937a5a0636e6bba5886a5c226a682d273becbb3 /app/src/main | |
parent | 54fb6aa31445fa894e7b4d1e3a7643199676c305 (diff) | |
download | AntennaPod-8270e435b58773ee346230ee89c53034cddf248f.zip |
Fix license view
Diffstat (limited to 'app/src/main')
-rw-r--r-- | app/src/main/java/de/danoeh/antennapod/activity/AboutActivity.java | 49 | ||||
-rw-r--r-- | app/src/main/templates/about.html | 2 |
2 files changed, 46 insertions, 5 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/activity/AboutActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/AboutActivity.java index 6ba84c249..df764e829 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/AboutActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/AboutActivity.java @@ -34,6 +34,7 @@ public class AboutActivity extends ActionBarActivity { private WebView webview; private LinearLayout webviewContainer; + private boolean showingLicense = false; private Subscription subscription; @@ -56,11 +57,16 @@ public class AboutActivity extends ActionBarActivity { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { - view.loadUrl(url); - return false; + url = url.replace("file:///android_asset/", ""); + loadAsset(url); + return true; } }); + loadAsset("about.html"); + } + + private void loadAsset(String filename) { subscription = Observable.create(new Observable.OnSubscribe<String>() { @Override public void call(Subscriber<? super String> subscriber) { @@ -71,8 +77,33 @@ public class AboutActivity extends ActionBarActivity { int colorResource = res.getColor(0, 0); String colorString = String.format("#%06X", 0xFFFFFF & colorResource); res.recycle(); - input = getAssets().open("about.html"); + input = getAssets().open(filename); String webViewData = IOUtils.toString(input, Charset.defaultCharset()); + if(false == webViewData.startsWith("<!DOCTYPE html>")) { + //webViewData = webViewData.replace("\n\n", "</p><p>"); + webViewData = webViewData.replace("%", "%"); + webViewData = + "<!DOCTYPE html>" + + "<html>" + + "<head>" + + " <meta http-equiv=\"Content-Type\" content=\"text/html;charset=UTF-8\">" + + " <style type=\"text/css\">" + + " @font-face {" + + " font-family: 'Roboto-Light';" + + " src: url('file:///android_asset/Roboto-Light.ttf');" + + " }" + + " * {" + + " color: %s;" + + " font-family: roboto-Light;" + + " font-size: 8pt;" + + " }" + + " </style>" + + "</head><body><p>" + webViewData + "</p></body></html>"; + webViewData = webViewData.replace("\n", "<br/>"); + showingLicense = true; + } else { + showingLicense = false; + } webViewData = String.format(webViewData, colorString); subscriber.onNext(webViewData); } catch (IOException e) { @@ -86,13 +117,23 @@ public class AboutActivity extends ActionBarActivity { .subscribeOn(Schedulers.newThread()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(webviewData -> { - webview.loadDataWithBaseURL(null, webviewData, "text/html", "utf-8", "about:blank"); + webview.loadDataWithBaseURL("file:///android_asset/", webviewData, "text/html", + "utf-8", "about:blank"); }, error -> { Log.e(TAG, Log.getStackTraceString(error)); }); } @Override + public void onBackPressed() { + if(showingLicense) { + loadAsset("about.html"); + } else { + super.onBackPressed(); + } + } + + @Override protected void onDestroy() { super.onDestroy(); if(subscription != null) { diff --git a/app/src/main/templates/about.html b/app/src/main/templates/about.html index 61b8c2bc5..3f26c2366 100644 --- a/app/src/main/templates/about.html +++ b/app/src/main/templates/about.html @@ -52,7 +52,7 @@ <p>Created by Daniel Oeh</p> - <p>Copyright © 2015 AntennaPod Contributors <a href="https://github.com/AntennaPod/AntennaPod/blob/master/CONTRIBUTORS">(View)</a></p> + <p>Copyright © 2015 AntennaPod Contributors <a href="https://github.com/AntennaPod/AntennaPod/blob/master/CONTRIBUTORS">(View)</a></p> <p>Licensed under the MIT License <a href="LICENSE.html">(View)</a></p> </div> |