diff options
author | ByteHamster <info@bytehamster.com> | 2022-02-19 13:46:12 +0100 |
---|---|---|
committer | ByteHamster <info@bytehamster.com> | 2022-02-19 13:46:12 +0100 |
commit | acb384b128c00580878b55aeb8dfdede7e3dc0cc (patch) | |
tree | 9e1b9b774fcc0ac90bb24cc4ca6eda95d1943f02 /core/src/main/java/de/danoeh | |
parent | 6273dff85f4b9bba233ddf5d30ea36b617b09334 (diff) | |
parent | f4c90885d7e60089bfd94f10b09895a477f33187 (diff) | |
download | AntennaPod-acb384b128c00580878b55aeb8dfdede7e3dc0cc.zip |
Merge branch 'master' into develop
Diffstat (limited to 'core/src/main/java/de/danoeh')
4 files changed, 12 insertions, 34 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 08daf01e2..74f89a039 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 @@ -611,27 +611,22 @@ public class UserPreferences { public static void setProxyConfig(ProxyConfig config) { SharedPreferences.Editor editor = prefs.edit(); editor.putString(PREF_PROXY_TYPE, config.type.name()); - Proxy.Type type = Proxy.Type.valueOf(config.type.name()); - if (type == Proxy.Type.DIRECT) { - editor.apply(); - return; - } - if(TextUtils.isEmpty(config.host)) { + if (TextUtils.isEmpty(config.host)) { editor.remove(PREF_PROXY_HOST); } else { editor.putString(PREF_PROXY_HOST, config.host); } - if(config.port <= 0 || config.port > 65535) { + if (config.port <= 0 || config.port > 65535) { editor.remove(PREF_PROXY_PORT); } else { editor.putInt(PREF_PROXY_PORT, config.port); } - if(TextUtils.isEmpty(config.username)) { + if (TextUtils.isEmpty(config.username)) { editor.remove(PREF_PROXY_USER); } else { editor.putString(PREF_PROXY_USER, config.username); } - if(TextUtils.isEmpty(config.password)) { + if (TextUtils.isEmpty(config.password)) { editor.remove(PREF_PROXY_PASSWORD); } else { editor.putString(PREF_PROXY_PASSWORD, config.password); 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 bca3792b0..b26c57963 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 @@ -118,7 +118,7 @@ public class AntennapodHttpClient { builder.followSslRedirects(true); ProxyConfig config = UserPreferences.getProxyConfig(); - if (config.type != Proxy.Type.DIRECT) { + if (config.type != Proxy.Type.DIRECT && !TextUtils.isEmpty(config.host)) { int port = config.port > 0 ? config.port : ProxyConfig.DEFAULT_PORT; SocketAddress address = InetSocketAddress.createUnresolved(config.host, port); builder.proxy(new Proxy(config.type, address)); diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadService.java b/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadService.java index 982800b1c..1973c626b 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadService.java +++ b/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadService.java @@ -7,7 +7,6 @@ import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; -import android.os.Binder; import android.os.Build; import android.os.IBinder; import android.text.TextUtils; @@ -88,18 +87,11 @@ public class DownloadService extends Service { private ScheduledFuture<?> downloadPostFuture; private final ScheduledThreadPoolExecutor notificationUpdateExecutor; private static DownloaderFactory downloaderFactory = new DefaultDownloaderFactory(); - private final IBinder binder = new LocalBinder(); private ConnectionStateMonitor connectionMonitor; - private class LocalBinder extends Binder { - public DownloadService getService() { - return DownloadService.this; - } - } - @Override public IBinder onBind(Intent intent) { - return binder; + return null; } public DownloadService() { @@ -264,9 +256,9 @@ public class DownloadService extends Service { EventBus.getDefault().postSticky(DownloadEvent.refresh(Collections.emptyList())); cancelNotificationUpdater(); - downloadHandleExecutor.shutdown(); - downloadEnqueueExecutor.shutdown(); - notificationUpdateExecutor.shutdown(); + downloadEnqueueExecutor.shutdownNow(); + downloadHandleExecutor.shutdownNow(); + notificationUpdateExecutor.shutdownNow(); if (downloadPostFuture != null) { downloadPostFuture.cancel(true); } @@ -401,6 +393,9 @@ public class DownloadService extends Service { @Override public void onReceive(Context context, Intent intent) { Log.d(TAG, "cancelDownloadReceiver: " + intent.getAction()); + if (!isRunning) { + return; + } if (TextUtils.equals(intent.getAction(), ACTION_CANCEL_DOWNLOAD)) { String url = intent.getStringExtra(EXTRA_DOWNLOAD_URL); if (url == null) { diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/download/ProxyConfig.java b/core/src/main/java/de/danoeh/antennapod/core/service/download/ProxyConfig.java index 0d59a1b7e..797001e3a 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/service/download/ProxyConfig.java +++ b/core/src/main/java/de/danoeh/antennapod/core/service/download/ProxyConfig.java @@ -14,18 +14,6 @@ public class ProxyConfig { public static final int DEFAULT_PORT = 8080; - public static ProxyConfig direct() { - return new ProxyConfig(Proxy.Type.DIRECT, null, 0, null, null); - } - - public static ProxyConfig http(String host, int port, String username, String password) { - return new ProxyConfig(Proxy.Type.HTTP, host, port, username, password); - } - - public static ProxyConfig socks(String host, int port, String username, String password) { - return new ProxyConfig(Proxy.Type.SOCKS, host, port, username, password); - } - public ProxyConfig(Proxy.Type type, String host, int port, String username, String password) { this.type = type; this.host = host; |