diff options
Diffstat (limited to 'core')
10 files changed, 83 insertions, 8 deletions
diff --git a/core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java b/core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java index 6d614f039..a06047229 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java +++ b/core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java @@ -2,6 +2,7 @@ package de.danoeh.antennapod.core.preferences; import android.content.Context; import android.content.SharedPreferences; +import android.content.res.Configuration; import android.preference.PreferenceManager; import android.support.annotation.IntRange; import android.support.annotation.NonNull; @@ -164,7 +165,7 @@ public class UserPreferences { * @return R.style.Theme_AntennaPod_Light or R.style.Theme_AntennaPod_Dark */ public static int getTheme() { - return readThemeValue(prefs.getString(PREF_THEME, "0")); + return readThemeValue(prefs.getString(PREF_THEME, "system")); } public static int getNoTitleTheme() { @@ -672,14 +673,18 @@ public class UserPreferences { } private static int readThemeValue(String valueFromPrefs) { - switch (Integer.parseInt(valueFromPrefs)) { - case 0: + switch (valueFromPrefs) { + case "0": return R.style.Theme_AntennaPod_Light; - case 1: + case "1": return R.style.Theme_AntennaPod_Dark; - case 2: + case "2": return R.style.Theme_AntennaPod_TrueBlack; default: + int nightMode = context.getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK; + if (nightMode == Configuration.UI_MODE_NIGHT_YES) { + return R.style.Theme_AntennaPod_Dark; + } return R.style.Theme_AntennaPod_Light; } } diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/download/AntennapodHttpClient.java b/core/src/main/java/de/danoeh/antennapod/core/service/download/AntennapodHttpClient.java index 97007a214..04a6d5882 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/service/download/AntennapodHttpClient.java +++ b/core/src/main/java/de/danoeh/antennapod/core/service/download/AntennapodHttpClient.java @@ -16,7 +16,9 @@ import java.net.Socket; import java.net.SocketAddress; import java.security.GeneralSecurityException; import java.security.KeyStore; +import java.util.ArrayList; import java.util.Arrays; +import java.util.List; import java.util.concurrent.TimeUnit; import javax.net.ssl.SSLContext; @@ -28,6 +30,8 @@ import javax.net.ssl.X509TrustManager; import de.danoeh.antennapod.core.preferences.UserPreferences; import de.danoeh.antennapod.core.storage.DBWriter; +import okhttp3.CipherSuite; +import okhttp3.ConnectionSpec; import okhttp3.Credentials; import okhttp3.HttpUrl; import okhttp3.JavaNetCookieJar; @@ -138,9 +142,24 @@ public class AntennapodHttpClient { }); } } - if(16 <= Build.VERSION.SDK_INT && Build.VERSION.SDK_INT < 21) { + if (16 <= Build.VERSION.SDK_INT && Build.VERSION.SDK_INT < 21) { builder.sslSocketFactory(new CustomSslSocketFactory(), trustManager()); } + + if (Build.VERSION.SDK_INT < 21) { + // workaround for Android 4.x for certain web sites. + // see: https://github.com/square/okhttp/issues/4053#issuecomment-402579554 + List<CipherSuite> cipherSuites = new ArrayList<>(); + cipherSuites.addAll(ConnectionSpec.MODERN_TLS.cipherSuites()); + cipherSuites.add(CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA); + cipherSuites.add(CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA); + + ConnectionSpec legacyTls = new ConnectionSpec.Builder(ConnectionSpec.MODERN_TLS) + .cipherSuites(cipherSuites.toArray(new CipherSuite[0])) + .build(); + builder.connectionSpecs(Arrays.asList(legacyTls, ConnectionSpec.CLEARTEXT)); + } + return builder; } diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/playback/ExoPlayerWrapper.java b/core/src/main/java/de/danoeh/antennapod/core/service/playback/ExoPlayerWrapper.java index f20525f73..7af33f8f9 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/service/playback/ExoPlayerWrapper.java +++ b/core/src/main/java/de/danoeh/antennapod/core/service/playback/ExoPlayerWrapper.java @@ -2,6 +2,7 @@ package de.danoeh.antennapod.core.service.playback; import android.content.Context; import android.net.Uri; +import android.os.Handler; import android.view.SurfaceHolder; import com.google.android.exoplayer2.C; @@ -27,7 +28,6 @@ import com.google.android.exoplayer2.util.Util; import org.antennapod.audio.MediaPlayer; import de.danoeh.antennapod.core.util.playback.IPlayer; - public class ExoPlayerWrapper implements IPlayer { private final Context mContext; private SimpleExoPlayer mExoPlayer; @@ -35,15 +35,35 @@ public class ExoPlayerWrapper implements IPlayer { private MediaPlayer.OnSeekCompleteListener audioSeekCompleteListener; private MediaPlayer.OnCompletionListener audioCompletionListener; private MediaPlayer.OnErrorListener audioErrorListener; + private MediaPlayer.OnBufferingUpdateListener bufferingUpdateListener; + private boolean shouldCheckBufferingUpdates = true; + ExoPlayerWrapper(Context context) { mContext = context; mExoPlayer = createPlayer(); + + Handler handler = new Handler(); // Main thread + handler.postDelayed(new Runnable() { + @Override + public void run() { + if (bufferingUpdateListener != null) { + bufferingUpdateListener.onBufferingUpdate(null, mExoPlayer.getBufferedPercentage()); + } + if (shouldCheckBufferingUpdates) { + handler.postDelayed(this, 2000); + } + } + }, 2000); } private SimpleExoPlayer createPlayer() { + DefaultLoadControl.Builder loadControl = new DefaultLoadControl.Builder(); + loadControl.setBufferDurationsMs(30000, 120000, + DefaultLoadControl.DEFAULT_BUFFER_FOR_PLAYBACK_MS, + DefaultLoadControl.DEFAULT_BUFFER_FOR_PLAYBACK_AFTER_REBUFFER_MS); SimpleExoPlayer p = ExoPlayerFactory.newSimpleInstance(mContext, new DefaultRenderersFactory(mContext), - new DefaultTrackSelector(), new DefaultLoadControl()); + new DefaultTrackSelector(), loadControl.createDefaultLoadControl()); p.setSeekParameters(SeekParameters.PREVIOUS_SYNC); p.addListener(new Player.EventListener() { @Override @@ -148,12 +168,14 @@ public class ExoPlayerWrapper implements IPlayer { @Override public void release() { + shouldCheckBufferingUpdates = false; if (mExoPlayer != null) { mExoPlayer.release(); } audioSeekCompleteListener = null; audioCompletionListener = null; audioErrorListener = null; + bufferingUpdateListener = null; } @Override @@ -247,4 +269,8 @@ public class ExoPlayerWrapper implements IPlayer { } return mExoPlayer.getVideoFormat().height; } + + void setOnBufferingUpdateListener(MediaPlayer.OnBufferingUpdateListener bufferingUpdateListener) { + this.bufferingUpdateListener = bufferingUpdateListener; + } } diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/playback/LocalPSMP.java b/core/src/main/java/de/danoeh/antennapod/core/service/playback/LocalPSMP.java index 5177fa6be..9164f561f 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/service/playback/LocalPSMP.java +++ b/core/src/main/java/de/danoeh/antennapod/core/service/playback/LocalPSMP.java @@ -1025,6 +1025,7 @@ public class LocalPSMP extends PlaybackServiceMediaPlayer { ExoPlayerWrapper ap = (ExoPlayerWrapper) mp; ap.setOnCompletionListener(audioCompletionListener); ap.setOnSeekCompleteListener(audioSeekCompleteListener); + ap.setOnBufferingUpdateListener(audioBufferingUpdateListener); ap.setOnErrorListener(audioErrorListener); } else { Log.w(TAG, "Unknown media player: " + mp); diff --git a/core/src/main/res/drawable/ic_playback_speed_dark.xml b/core/src/main/res/drawable/ic_playback_speed_dark.xml new file mode 100644 index 000000000..7c7d1cf8c --- /dev/null +++ b/core/src/main/res/drawable/ic_playback_speed_dark.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="utf-8"?> +<vector xmlns:android="http://schemas.android.com/apk/res/android" + android:height="24dp" + android:width="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + <path android:fillColor="#FF757575" android:pathData="M 12,14.888154 A 2.2284437,2.2284437 0 0 1 9.7715563,12.659711 c 0,-0.831952 0.4531167,-1.559911 1.1142217,-1.938746 L 18.098507,6.5463469 13.990743,13.66251 C 13.619336,14.390469 12.869093,14.888154 12,14.888154 m 0,-9.6565888 c 1.344494,0 2.599851,0.3714073 3.691789,0.9805151 L 14.131878,7.110886 C 13.485629,6.858329 12.742815,6.7171943 12,6.7171943 A 5.9425165,5.9425165 0 0 0 6.0574835,12.659711 c 0,1.64162 0.661105,3.127249 1.7381861,4.196902 h 0.00743 c 0.2896977,0.289697 0.2896977,0.757671 0,1.047369 -0.2896977,0.289697 -0.7650991,0.289697 -1.0547967,0.0075 v 0 C 5.4038067,16.566915 4.5718544,14.709879 4.5718544,12.659711 A 7.4281456,7.4281456 0 0 1 12,5.2315652 m 7.428145,7.4281458 c 0,2.050168 -0.831952,3.907204 -2.176446,5.251699 v 0 c -0.289698,0.282269 -0.757671,0.282269 -1.047369,-0.0075 -0.289697,-0.289698 -0.289697,-0.757671 0,-1.047368 v 0 c 1.077082,-1.077082 1.738186,-2.555282 1.738186,-4.196902 0,-0.742815 -0.141134,-1.48563 -0.401119,-2.154163 l 0.898805,-1.5599106 c 0.616537,1.1142216 0.987943,2.3621496 0.987943,3.7140736 z" /> +</vector>
\ No newline at end of file diff --git a/core/src/main/res/drawable/ic_playback_speed_white.xml b/core/src/main/res/drawable/ic_playback_speed_white.xml new file mode 100644 index 000000000..cc6af0d55 --- /dev/null +++ b/core/src/main/res/drawable/ic_playback_speed_white.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="utf-8"?> +<vector xmlns:android="http://schemas.android.com/apk/res/android" + android:height="48dp" + android:width="48dp" + android:viewportWidth="24" + android:viewportHeight="24"> + <path android:fillColor="#ffffffff" android:pathData="M 12,14.888154 A 2.2284437,2.2284437 0 0 1 9.7715563,12.659711 c 0,-0.831952 0.4531167,-1.559911 1.1142217,-1.938746 L 18.098507,6.5463469 13.990743,13.66251 C 13.619336,14.390469 12.869093,14.888154 12,14.888154 m 0,-9.6565888 c 1.344494,0 2.599851,0.3714073 3.691789,0.9805151 L 14.131878,7.110886 C 13.485629,6.858329 12.742815,6.7171943 12,6.7171943 A 5.9425165,5.9425165 0 0 0 6.0574835,12.659711 c 0,1.64162 0.661105,3.127249 1.7381861,4.196902 h 0.00743 c 0.2896977,0.289697 0.2896977,0.757671 0,1.047369 -0.2896977,0.289697 -0.7650991,0.289697 -1.0547967,0.0075 v 0 C 5.4038067,16.566915 4.5718544,14.709879 4.5718544,12.659711 A 7.4281456,7.4281456 0 0 1 12,5.2315652 m 7.428145,7.4281458 c 0,2.050168 -0.831952,3.907204 -2.176446,5.251699 v 0 c -0.289698,0.282269 -0.757671,0.282269 -1.047369,-0.0075 -0.289697,-0.289698 -0.289697,-0.757671 0,-1.047368 v 0 c 1.077082,-1.077082 1.738186,-2.555282 1.738186,-4.196902 0,-0.742815 -0.141134,-1.48563 -0.401119,-2.154163 l 0.898805,-1.5599106 c 0.616537,1.1142216 0.987943,2.3621496 0.987943,3.7140736 z" /> +</vector>
\ No newline at end of file diff --git a/core/src/main/res/values/arrays.xml b/core/src/main/res/values/arrays.xml index 7c9811bc7..5e7eab1ea 100644 --- a/core/src/main/res/values/arrays.xml +++ b/core/src/main/res/values/arrays.xml @@ -157,11 +157,14 @@ </string-array> <string-array name="theme_options"> + <item>@string/pref_theme_title_use_system</item> <item>@string/pref_theme_title_light</item> <item>@string/pref_theme_title_dark</item> <item>@string/pref_theme_title_trueblack</item> </string-array> + <string-array name="theme_values"> + <item>system</item> <item>0</item> <item>1</item> <item>2</item> diff --git a/core/src/main/res/values/attrs.xml b/core/src/main/res/values/attrs.xml index d0419bb38..530b40d46 100644 --- a/core/src/main/res/values/attrs.xml +++ b/core/src/main/res/values/attrs.xml @@ -9,6 +9,7 @@ <attr name="av_fast_forward" format="reference"/> <attr name="av_pause" format="reference"/> <attr name="av_play" format="reference"/> + <attr name="av_speed" format="reference"/> <attr name="av_rewind" format="reference"/> <attr name="content_discard" format="reference"/> <attr name="content_new" format="reference"/> diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml index 517f4b81c..c7bd2d2a2 100644 --- a/core/src/main/res/values/strings.xml +++ b/core/src/main/res/values/strings.xml @@ -133,6 +133,7 @@ <string name="share_link_label">Share Episode URL</string> <string name="share_link_with_position_label">Share Episode URL with Position</string> <string name="share_file_label">Share File</string> + <string name="share_website_url_label">Share Website URL</string> <string name="share_feed_url_label">Share Feed URL</string> <string name="share_item_url_label">Share Media File URL</string> <string name="share_item_url_with_position_label">Share Media File URL with Position</string> @@ -398,6 +399,7 @@ <string name="pref_parallel_downloads_title">Parallel Downloads</string> <string name="pref_episode_cache_title">Episode Cache</string> <string name="pref_episode_cache_summary">Total number of downloaded episodes cached on the device. Automatic download will be suspended if this number is reached.</string> + <string name="pref_theme_title_use_system">Use system theme</string> <string name="pref_theme_title_light">Light</string> <string name="pref_theme_title_dark">Dark</string> <string name="pref_theme_title_trueblack">Black (AMOLED ready)</string> diff --git a/core/src/main/res/values/styles.xml b/core/src/main/res/values/styles.xml index b589d4f20..d2ba4bb50 100644 --- a/core/src/main/res/values/styles.xml +++ b/core/src/main/res/values/styles.xml @@ -23,6 +23,7 @@ <item name="av_fast_forward">@drawable/ic_fast_forward_grey600_24dp</item> <item name="av_pause">@drawable/ic_pause_grey600_24dp</item> <item name="av_play">@drawable/ic_play_arrow_grey600_24dp</item> + <item name="av_speed">@drawable/ic_playback_speed_dark</item> <item name="av_rewind">@drawable/ic_fast_rewind_grey600_24dp</item> <item name="content_discard">@drawable/ic_delete_grey600_24dp</item> <item name="content_new">@drawable/ic_add_grey600_24dp</item> @@ -108,6 +109,7 @@ <item name="av_fast_forward">@drawable/ic_fast_forward_white_24dp</item> <item name="av_pause">@drawable/ic_pause_white_24dp</item> <item name="av_play">@drawable/ic_play_arrow_white_24dp</item> + <item name="av_speed">@drawable/ic_playback_speed_white</item> <item name="av_rewind">@drawable/ic_fast_rewind_white_24dp</item> <item name="content_discard">@drawable/ic_delete_white_24dp</item> <item name="content_new">@drawable/ic_add_white_24dp</item> |