diff options
author | Martin Fietz <Martin.Fietz@gmail.com> | 2015-08-31 10:50:56 +0200 |
---|---|---|
committer | Martin Fietz <Martin.Fietz@gmail.com> | 2015-08-31 10:52:00 +0200 |
commit | 0514a486f6802cc7026bd4bfe2bd5e7af1768738 (patch) | |
tree | 4dc401d5bf130fa83f35acf1dd2f6cbe37050520 | |
parent | ad0212c039a0a9116c48c1d7bb7ef0beac0d6670 (diff) | |
download | AntennaPod-0514a486f6802cc7026bd4bfe2bd5e7af1768738.zip |
Apply theme to about activity, smaller changes to appearence
-rw-r--r-- | app/src/main/java/de/danoeh/antennapod/activity/AboutActivity.java | 60 | ||||
-rw-r--r-- | app/src/main/templates/about.html | 14 |
2 files changed, 69 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 035ab2f22..6ba84c249 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/AboutActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/AboutActivity.java @@ -1,22 +1,42 @@ package de.danoeh.antennapod.activity; +import android.content.res.TypedArray; +import android.graphics.Color; +import android.os.Build; import android.os.Bundle; import android.support.v7.app.ActionBarActivity; +import android.util.Log; +import android.view.View; import android.webkit.WebView; import android.webkit.WebViewClient; import android.widget.LinearLayout; +import org.apache.commons.io.IOUtils; + +import java.io.IOException; +import java.io.InputStream; +import java.nio.charset.Charset; + import de.danoeh.antennapod.R; import de.danoeh.antennapod.core.preferences.UserPreferences; +import rx.Observable; +import rx.Subscriber; +import rx.Subscription; +import rx.android.schedulers.AndroidSchedulers; +import rx.schedulers.Schedulers; /** * Displays the 'about' screen */ public class AboutActivity extends ActionBarActivity { + private static final String TAG = AboutActivity.class.getSimpleName(); + private WebView webview; private LinearLayout webviewContainer; + private Subscription subscription; + @Override protected void onCreate(Bundle savedInstanceState) { setTheme(UserPreferences.getTheme()); @@ -25,6 +45,13 @@ public class AboutActivity extends ActionBarActivity { setContentView(R.layout.about); webviewContainer = (LinearLayout) findViewById(R.id.webvContainer); webview = (WebView) findViewById(R.id.webvAbout); + if (UserPreferences.getTheme() == R.style.Theme_AntennaPod_Dark) { + if (Build.VERSION.SDK_INT >= 11 + && Build.VERSION.SDK_INT <= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) { + webview.setLayerType(View.LAYER_TYPE_SOFTWARE, null); + } + webview.setBackgroundColor(Color.TRANSPARENT); + } webview.setWebViewClient(new WebViewClient() { @Override @@ -34,12 +61,43 @@ public class AboutActivity extends ActionBarActivity { } }); - webview.loadUrl("file:///android_asset/about.html"); + subscription = Observable.create(new Observable.OnSubscribe<String>() { + @Override + public void call(Subscriber<? super String> subscriber) { + InputStream input = null; + try { + TypedArray res = AboutActivity.this.getTheme().obtainStyledAttributes( + new int[] { android.R.attr.textColorPrimary }); + int colorResource = res.getColor(0, 0); + String colorString = String.format("#%06X", 0xFFFFFF & colorResource); + res.recycle(); + input = getAssets().open("about.html"); + String webViewData = IOUtils.toString(input, Charset.defaultCharset()); + webViewData = String.format(webViewData, colorString); + subscriber.onNext(webViewData); + } catch (IOException e) { + subscriber.onError(e); + } finally { + IOUtils.closeQuietly(input); + } + subscriber.onCompleted(); + } + }) + .subscribeOn(Schedulers.newThread()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(webviewData -> { + webview.loadDataWithBaseURL(null, webviewData, "text/html", "utf-8", "about:blank"); + }, error -> { + Log.e(TAG, Log.getStackTraceString(error)); + }); } @Override protected void onDestroy() { super.onDestroy(); + if(subscription != null) { + subscription.unsubscribe(); + } if (webviewContainer != null && webview != null) { webviewContainer.removeAllViews(); webview.destroy(); diff --git a/app/src/main/templates/about.html b/app/src/main/templates/about.html index 887b547f4..e6b47f285 100644 --- a/app/src/main/templates/about.html +++ b/app/src/main/templates/about.html @@ -4,16 +4,22 @@ <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'); + } + * { - font-family: Helvetica + color: %s; + font-family: roboto-Light; + font-size: 12pt; } + header { display: block; margin-left: auto; margin-right: auto; padding-bottom: 500px; - - } versiontag { @@ -39,7 +45,7 @@ </head> <body> <div id="header" align="center"> - <img src="logo.png" alt="Logo" width="100px" height="100px"/> + <img src="file:///android_asset/logo.png" alt="Logo" width="100px" height="100px"/> <p>AntennaPod, Version @versionname@</p> <p>Commit: @commit@</p> |