diff options
Diffstat (limited to 'core/src')
5 files changed, 57 insertions, 30 deletions
diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackServiceMediaPlayer.java b/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackServiceMediaPlayer.java index a82e82506..20bdd1f75 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackServiceMediaPlayer.java +++ b/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackServiceMediaPlayer.java @@ -693,7 +693,7 @@ public class PlaybackServiceMediaPlayer implements SharedPreferences.OnSharedPre } /** - * Sets the playback speed. + * Sets the playback volume. * This method is executed on an internal executor service. */ public void setVolume(final float volumeLeft, float volumeRight) { @@ -701,7 +701,7 @@ public class PlaybackServiceMediaPlayer implements SharedPreferences.OnSharedPre } /** - * Sets the playback speed. + * Sets the playback volume. * This method is executed on the caller's thread. */ private void setVolumeSync(float volumeLeft, float volumeRight) { @@ -946,15 +946,16 @@ public class PlaybackServiceMediaPlayer implements SharedPreferences.OnSharedPre if (pausedBecauseOfTransientAudiofocusLoss) { // we paused => play now resume(); } else { // we ducked => raise audio level back - audioManager.adjustStreamVolume(AudioManager.STREAM_MUSIC, - AudioManager.ADJUST_RAISE, 0); + setVolumeSync(UserPreferences.getLeftVolume(), + UserPreferences.getRightVolume()); } } else if (focusChange == AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK) { if (playerStatus == PlayerStatus.PLAYING) { if (!UserPreferences.shouldPauseForFocusLoss()) { Log.d(TAG, "Lost audio focus temporarily. Ducking..."); - audioManager.adjustStreamVolume(AudioManager.STREAM_MUSIC, - AudioManager.ADJUST_LOWER, 0); + final float DUCK_FACTOR = 0.25f; + setVolumeSync(DUCK_FACTOR * UserPreferences.getLeftVolume(), + DUCK_FACTOR * UserPreferences.getRightVolume()); pausedBecauseOfTransientAudiofocusLoss = false; } else { Log.d(TAG, "Lost audio focus temporarily. Could duck, but won't, pausing..."); diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/DateUtils.java b/core/src/main/java/de/danoeh/antennapod/core/util/DateUtils.java index 6b0f423df..155ef519b 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/util/DateUtils.java +++ b/core/src/main/java/de/danoeh/antennapod/core/util/DateUtils.java @@ -19,14 +19,8 @@ public class DateUtils { private static final String TAG = "DateUtils"; - private static final SimpleDateFormat parser = new SimpleDateFormat("", Locale.US); private static final TimeZone defaultTimezone = TimeZone.getTimeZone("GMT"); - static { - parser.setLenient(false); - parser.setTimeZone(defaultTimezone); - } - public static Date parse(final String input) { if(input == null) { throw new IllegalArgumentException("Date must not be null"); @@ -86,6 +80,10 @@ public class DateUtils { "yyyy-MM-dd" }; + SimpleDateFormat parser = new SimpleDateFormat("", Locale.US); + parser.setLenient(false); + parser.setTimeZone(defaultTimezone); + ParsePosition pos = new ParsePosition(0); for(String pattern : patterns) { parser.applyPattern(pattern); 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..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,26 +36,32 @@ 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, context.getResources() - .getDisplayMetrics() + pageMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, + context.getResources().getDisplayMetrics() ); } @@ -82,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 @@ -95,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); @@ -125,8 +150,7 @@ public class Timeline { element.html(buffer.toString()); } } - - Log.i(TAG, "Out: " + document.toString()); + return document.toString(); } 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> diff --git a/core/src/main/res/values/styles.xml b/core/src/main/res/values/styles.xml index c4a731a53..d79ba6b45 100644 --- a/core/src/main/res/values/styles.xml +++ b/core/src/main/res/values/styles.xml @@ -63,6 +63,7 @@ <style name="Theme.AntennaPod.Dark" parent="Theme.AppCompat"> <item name="colorAccent">@color/holo_blue_dark</item> + <item name="colorControlNormal">@color/white</item> <item name="buttonStyle">@style/Widget.AntennaPod.Button</item> <item name="progressBarTheme">@style/ProgressBarDark</item> <item name="alertDialogTheme">@style/AntennaPod.Dialog.Dark</item> @@ -186,6 +187,7 @@ <item name="windowActionModeOverlay">true</item> <item name="progressBarTheme">@style/ProgressBarDark</item> <item name="colorAccent">@color/holo_blue_dark</item> + <item name="colorControlNormal">@color/white</item> <item name="buttonStyle">@style/Widget.AntennaPod.Button</item> <item name="alertDialogTheme">@style/AntennaPod.Dialog.Dark</item> <item name="attr/action_about">@drawable/ic_info_white_24dp</item> |