Merge pull request #1193 from mfietz/cropped_dialog_buttons

Licenses: Material Dialogs, bug fix, nicer layout
This commit is contained in:
Tom Hennen 2015-09-15 17:16:11 -04:00
commit 8d4bdd5ba1
3 changed files with 70 additions and 5 deletions

View File

@ -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.

View File

@ -34,6 +34,7 @@ public class AboutActivity extends ActionBarActivity {
private WebView webview; private WebView webview;
private LinearLayout webviewContainer; private LinearLayout webviewContainer;
private boolean showingLicense = false;
private Subscription subscription; private Subscription subscription;
@ -56,11 +57,16 @@ public class AboutActivity extends ActionBarActivity {
@Override @Override
public boolean shouldOverrideUrlLoading(WebView view, String url) { public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url); url = url.replace("file:///android_asset/", "");
return false; loadAsset(url);
return true;
} }
}); });
loadAsset("about.html");
}
private void loadAsset(String filename) {
subscription = Observable.create(new Observable.OnSubscribe<String>() { subscription = Observable.create(new Observable.OnSubscribe<String>() {
@Override @Override
public void call(Subscriber<? super String> subscriber) { public void call(Subscriber<? super String> subscriber) {
@ -71,8 +77,33 @@ public class AboutActivity extends ActionBarActivity {
int colorResource = res.getColor(0, 0); int colorResource = res.getColor(0, 0);
String colorString = String.format("#%06X", 0xFFFFFF & colorResource); String colorString = String.format("#%06X", 0xFFFFFF & colorResource);
res.recycle(); res.recycle();
input = getAssets().open("about.html"); input = getAssets().open(filename);
String webViewData = IOUtils.toString(input, Charset.defaultCharset()); String webViewData = IOUtils.toString(input, Charset.defaultCharset());
if(false == webViewData.startsWith("<!DOCTYPE html>")) {
//webViewData = webViewData.replace("\n\n", "</p><p>");
webViewData = webViewData.replace("%", "&#37;");
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); webViewData = String.format(webViewData, colorString);
subscriber.onNext(webViewData); subscriber.onNext(webViewData);
} catch (IOException e) { } catch (IOException e) {
@ -86,12 +117,22 @@ public class AboutActivity extends ActionBarActivity {
.subscribeOn(Schedulers.newThread()) .subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribe(webviewData -> { .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 -> { }, error -> {
Log.e(TAG, Log.getStackTraceString(error)); Log.e(TAG, Log.getStackTraceString(error));
}); });
} }
@Override
public void onBackPressed() {
if(showingLicense) {
loadAsset("about.html");
} else {
super.onBackPressed();
}
}
@Override @Override
protected void onDestroy() { protected void onDestroy() {
super.onDestroy(); super.onDestroy();

View File

@ -52,7 +52,7 @@
<p>Created by Daniel Oeh</p> <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 &copy; 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> <p>Licensed under the MIT License <a href="LICENSE.html">(View)</a></p>
</div> </div>
@ -83,6 +83,9 @@ licensed under the MIT license <a href="LICENSE_JSOUP.txt">(View)</a>
<h2>Material Design Icons <a href="https://github.com/google/material-design-icons">(Link)</a></h2> <h2>Material Design Icons <a href="https://github.com/google/material-design-icons">(Link)</a></h2>
by Google, licensed under an Attribution-ShareAlike 4.0 International license <a href="LICENSE_MATERIAL_DESIGN_ICONS.txt">(View)</a> by Google, licensed under an Attribution-ShareAlike 4.0 International license <a href="LICENSE_MATERIAL_DESIGN_ICONS.txt">(View)</a>
<h2>Material Dialogs <a href="https://github.com/afollestad/material-dialogs">(Link)</a></h2>
by Aidan Michael Follestad, licensed under the MIT License <a href="LICENSE_MATERIAL_DIALOGS.txt">(View)</a>
<h2>OkHttp <a href="https://github.com/square/okhttp">(Link)</a></h2> <h2>OkHttp <a href="https://github.com/square/okhttp">(Link)</a></h2>
by Square, licensed under the Apache 2.0 license <a href="LICENSE_OKHTTP.txt">(View)</a> by Square, licensed under the Apache 2.0 license <a href="LICENSE_OKHTTP.txt">(View)</a>