diff options
author | Martin Fietz <Martin.Fietz@gmail.com> | 2016-02-19 10:54:56 +0100 |
---|---|---|
committer | Martin Fietz <Martin.Fietz@gmail.com> | 2016-03-16 20:09:03 +0100 |
commit | 73069817f852c1b8cc584d143a0359d24cd2846c (patch) | |
tree | b2501b86715add6bc72a8006549f49356623bb9c /core | |
parent | 734b19e906bb12486726a9f055714411da859d24 (diff) | |
download | AntennaPod-73069817f852c1b8cc584d143a0359d24cd2846c.zip |
Show message if there are no shownotes
Diffstat (limited to 'core')
-rw-r--r-- | core/src/main/java/de/danoeh/antennapod/core/util/playback/Timeline.java | 52 | ||||
-rw-r--r-- | core/src/main/res/values/strings.xml | 2 |
2 files changed, 41 insertions, 13 deletions
diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/playback/Timeline.java b/core/src/main/java/de/danoeh/antennapod/core/util/playback/Timeline.java index dae8abb7a..13a980774 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/util/playback/Timeline.java +++ b/core/src/main/java/de/danoeh/antennapod/core/util/playback/Timeline.java @@ -2,7 +2,10 @@ package de.danoeh.antennapod.core.util.playback; import android.content.Context; import android.content.res.TypedArray; +import android.graphics.Color; +import android.support.annotation.ColorInt; import android.support.annotation.NonNull; +import android.text.TextUtils; import android.util.Log; import android.util.TypedValue; @@ -14,6 +17,7 @@ import org.jsoup.select.Elements; import java.util.regex.Matcher; import java.util.regex.Pattern; +import de.danoeh.antennapod.core.R; import de.danoeh.antennapod.core.util.Converter; import de.danoeh.antennapod.core.util.ShownotesProvider; @@ -32,21 +36,28 @@ public class Timeline { private ShownotesProvider shownotesProvider; - - private final String colorString; + private final String noShownotesLabel; + private final String colorPrimaryString; + private final String colorSecondaryString; private final int pageMargin; public Timeline(Context context, ShownotesProvider shownotesProvider) { if (shownotesProvider == null) throw new IllegalArgumentException("shownotesProvider = null"); this.shownotesProvider = shownotesProvider; - TypedArray res = context - .getTheme() - .obtainStyledAttributes( - new int[]{android.R.attr.textColorPrimary}); - int colorResource = res.getColor(0, 0); - colorString = String.format("#%06X", - 0xFFFFFF & colorResource); + noShownotesLabel = context.getString(R.string.no_shownotes_label); + + TypedArray res = context.getTheme().obtainStyledAttributes( + new int[]{ android.R.attr.textColorPrimary}); + @ColorInt int col = res.getColor(0, 0); + colorPrimaryString = "rgba(" + Color.red(col) + "," + Color.green(col) + "," + + Color.blue(col) + "," + (Color.alpha(col)/256.0) + ")"; + res.recycle(); + res = context.getTheme().obtainStyledAttributes( + new int[]{android.R.attr.textColorSecondary}); + col = res.getColor(0, 0); + colorSecondaryString = "rgba(" + Color.red(col) + "," + Color.green(col) + "," + + Color.blue(col) + "," + (Color.alpha(col)/256.0) + ")"; res.recycle(); pageMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, @@ -81,9 +92,24 @@ public class Timeline { e.printStackTrace(); return null; } - if (shownotes == null) { - Log.d(TAG, "shownotesProvider contained no shownotes. Returning empty string"); - return ""; + + if(TextUtils.isEmpty(shownotes)) { + Log.d(TAG, "shownotesProvider contained no shownotes. Returning 'no shownotes' message"); + shownotes ="<html>" + + "<head>" + + "<style type='text/css'>" + + "html, body { margin: 0; padding: 0; width: 100%; height: 100%; } " + + "html { display: table; }" + + "body { display: table-cell; vertical-align: middle; text-align:center;" + + "-webkit-text-size-adjust: none; font-size: 87%; color: " + colorSecondaryString + ";} " + + "</style>" + + "</head>" + + "<body>" + + "<p>" + noShownotesLabel + "</p>" + + "</body>" + + "</html>"; + Log.d(TAG, "shownotes: " + shownotes); + return shownotes; } // replace ASCII line breaks with HTML ones if shownotes don't contain HTML line breaks already @@ -94,7 +120,7 @@ public class Timeline { Document document = Jsoup.parse(shownotes); // apply style - String styleStr = String.format(WEBVIEW_STYLE, colorString, "100%", pageMargin, + String styleStr = String.format(WEBVIEW_STYLE, colorPrimaryString, "100%", pageMargin, pageMargin, pageMargin, pageMargin); document.head().appendElement("style").attr("type", "text/css").text(styleStr); diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml index 912a60f55..0d4518a15 100644 --- a/core/src/main/res/values/strings.xml +++ b/core/src/main/res/values/strings.xml @@ -278,6 +278,8 @@ <string name="no_items_label">There are no items in this list.</string> <string name="no_feeds_label">You haven\'t subscribed to any feeds yet.</string> <string name="no_chapters_label">This episode has no chapters.</string> + <string name="no_shownotes_label">This episode has no shownotes.</string> + <!-- Preferences --> <string name="other_pref">Other</string> |