diff --git a/app/src/main/assets/LICENSE_MATERIAL_DIALOGS.txt b/app/src/main/assets/LICENSE_MATERIAL_DIALOGS.txt new file mode 100644 index 000000000..f6bf77906 --- /dev/null +++ b/app/src/main/assets/LICENSE_MATERIAL_DIALOGS.txt @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2015 Aidan Michael Follestad + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. 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() { @Override public void call(Subscriber 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("")) { + //webViewData = webViewData.replace("\n\n", "

"); + webViewData = webViewData.replace("%", "%"); + webViewData = + "" + + "" + + "" + + " " + + " " + + "

" + webViewData + "

"; + webViewData = webViewData.replace("\n", "
"); + showingLicense = true; + } else { + showingLicense = false; + } webViewData = String.format(webViewData, colorString); subscriber.onNext(webViewData); } catch (IOException e) { @@ -86,12 +117,22 @@ 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(); diff --git a/app/src/main/templates/about.html b/app/src/main/templates/about.html index e6b47f285..3f26c2366 100644 --- a/app/src/main/templates/about.html +++ b/app/src/main/templates/about.html @@ -52,7 +52,7 @@

Created by Daniel Oeh

-

Copyright © 2015 AntennaPod Contributors (View)

+

Copyright © 2015 AntennaPod Contributors (View)

Licensed under the MIT License (View)

@@ -83,6 +83,9 @@ licensed under the MIT license (View)

Material Design Icons (Link)

by Google, licensed under an Attribution-ShareAlike 4.0 International license (View) +

Material Dialogs (Link)

+by Aidan Michael Follestad, licensed under the MIT License (View) +

OkHttp (Link)

by Square, licensed under the Apache 2.0 license (View)