From 734b19e906bb12486726a9f055714411da859d24 Mon Sep 17 00:00:00 2001 From: Martin Fietz Date: Fri, 19 Feb 2016 10:54:31 +0100 Subject: Refactor --- .../java/de/danoeh/antennapod/core/util/playback/Timeline.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'core/src/main') 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 2eee1ac87..dae8abb7a 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 @@ -49,9 +49,8 @@ public class Timeline { 0xFFFFFF & colorResource); res.recycle(); - pageMargin = (int) TypedValue.applyDimension( - TypedValue.COMPLEX_UNIT_DIP, 8, context.getResources() - .getDisplayMetrics() + pageMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, + context.getResources().getDisplayMetrics() ); } @@ -125,8 +124,7 @@ public class Timeline { element.html(buffer.toString()); } } - - Log.i(TAG, "Out: " + document.toString()); + return document.toString(); } -- cgit v1.2.3 From 73069817f852c1b8cc584d143a0359d24cd2846c Mon Sep 17 00:00:00 2001 From: Martin Fietz Date: Fri, 19 Feb 2016 10:54:56 +0100 Subject: Show message if there are no shownotes --- .../antennapod/core/util/playback/Timeline.java | 52 ++++++++++++++++------ core/src/main/res/values/strings.xml | 2 + 2 files changed, 41 insertions(+), 13 deletions(-) (limited to 'core/src/main') 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 ="" + + "" + + "" + + "" + + "" + + "

" + noShownotesLabel + "

" + + "" + + ""; + 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 @@ There are no items in this list. You haven\'t subscribed to any feeds yet. This episode has no chapters. + This episode has no shownotes. + Other -- cgit v1.2.3