[u] new conditions for the parameter

This commit is contained in:
Grisha 2024-11-16 02:41:28 +03:00
parent 7ec45197ec
commit 892e6e7768
3 changed files with 24 additions and 6 deletions

View file

@ -57,10 +57,16 @@ public final class DownloaderImpl extends Downloader {
App.getApp().getString(R.string.proxy_address_key), "192.168.1.1"); App.getApp().getString(R.string.proxy_address_key), "192.168.1.1");
final String proxyPortStr = sharedPreferences.getString( final String proxyPortStr = sharedPreferences.getString(
App.getApp().getString(R.string.proxy_port_key), "1080"); App.getApp().getString(R.string.proxy_port_key), "1080");
final String proxyTypeStr = sharedPreferences.getString(
App.getApp().getString(R.string.proxy_type_key), "socks");
final Proxy.Type proxyType = "http".equalsIgnoreCase(proxyTypeStr)
? Proxy.Type.HTTP
: Proxy.Type.SOCKS;
final int proxyPort = Integer.parseInt(proxyPortStr); final int proxyPort = Integer.parseInt(proxyPortStr);
Log.d("DownloaderImpl_ProxySettings", Log.d("DownloaderImpl_ProxySettings",
"Proxy enabled with address: " + proxyAddress + " and port: " + proxyPort); "Proxy enabled with address: " + proxyAddress
final Proxy proxy = new Proxy(Proxy.Type.SOCKS, + " and port: " + proxyPort + ", type: " + proxyType);
final Proxy proxy = new Proxy(proxyType,
new InetSocketAddress(proxyAddress, proxyPort)); new InetSocketAddress(proxyAddress, proxyPort));
this.client = builder this.client = builder
.proxy(proxy) .proxy(proxy)

View file

@ -736,10 +736,16 @@ public final class YoutubeHttpDataSource extends BaseDataSource implements HttpD
App.getApp().getString(R.string.proxy_address_key), "192.168.1.1"); App.getApp().getString(R.string.proxy_address_key), "192.168.1.1");
final String proxyPortStr = sharedPreferences.getString( final String proxyPortStr = sharedPreferences.getString(
App.getApp().getString(R.string.proxy_port_key), "1080"); App.getApp().getString(R.string.proxy_port_key), "1080");
final String proxyTypeStr = sharedPreferences.getString(
App.getApp().getString(R.string.proxy_type_key), "socks");
final Proxy.Type proxyType = "http".equalsIgnoreCase(proxyTypeStr)
? Proxy.Type.HTTP
: Proxy.Type.SOCKS;
final int proxyPort = Integer.parseInt(proxyPortStr); final int proxyPort = Integer.parseInt(proxyPortStr);
android.util.Log.d("YoutubeHttpDataSource_ProxySettings", android.util.Log.d("YoutubeHttpDataSource_ProxySettings",
"Proxy enabled with address: " + proxyAddress + " and port: " + proxyPort); "Proxy enabled with address: "
final Proxy proxy = new Proxy(Proxy.Type.SOCKS, + proxyAddress + " and port: " + proxyPort + ", type: " + proxyType);
final Proxy proxy = new Proxy(proxyType,
new InetSocketAddress(proxyAddress, proxyPort)); new InetSocketAddress(proxyAddress, proxyPort));
connection = (HttpURLConnection) url.openConnection(proxy); connection = (HttpURLConnection) url.openConnection(proxy);
} else { } else {

View file

@ -68,10 +68,16 @@ public final class PicassoHelper {
context.getString(R.string.proxy_address_key), "192.168.1.1"); context.getString(R.string.proxy_address_key), "192.168.1.1");
final String proxyPortStr = sharedPreferences.getString( final String proxyPortStr = sharedPreferences.getString(
context.getString(R.string.proxy_port_key), "1080"); context.getString(R.string.proxy_port_key), "1080");
final String proxyTypeStr = sharedPreferences.getString(
context.getString(R.string.proxy_type_key), "socks");
final Proxy.Type proxyType = "http".equalsIgnoreCase(proxyTypeStr)
? Proxy.Type.HTTP
: Proxy.Type.SOCKS;
final int proxyPort = Integer.parseInt(proxyPortStr); final int proxyPort = Integer.parseInt(proxyPortStr);
Log.d("PicassoHelper_ProxySettings", Log.d("PicassoHelper_ProxySettings",
"Proxy enabled with address: " + proxyAddress + " and port: " + proxyPort); "Proxy enabled with address: "
proxySet = new Proxy(Proxy.Type.SOCKS, new InetSocketAddress(proxyAddress, proxyPort)); + proxyAddress + " and port: " + proxyPort + ", type: " + proxyType);
proxySet = new Proxy(proxyType, new InetSocketAddress(proxyAddress, proxyPort));
} else { } else {
Log.d("PicassoHelper_ProxySettings", Log.d("PicassoHelper_ProxySettings",
"Update called. proxy_enabled_key off: " + isProxyEnabled); "Update called. proxy_enabled_key off: " + isProxyEnabled);