mirror of
https://github.com/nuclearfog/Shitter.git
synced 2025-01-30 19:05:02 +01:00
fixed crash, bug fix
This commit is contained in:
parent
4c37aee5bd
commit
42fffe957b
@ -397,6 +397,17 @@ public class AppSettings extends AppCompatActivity implements OnClickListener, O
|
||||
String errMsg = getString(R.string.error_empty_port);
|
||||
proxyPort.setError(errMsg);
|
||||
success = false;
|
||||
} else if (editPort.length() > 5) {
|
||||
String errMsg = getString(R.string.error_invalid_port);
|
||||
proxyPort.setError(errMsg);
|
||||
success = false;
|
||||
} else {
|
||||
int port = Integer.parseInt(editPort.toString());
|
||||
if (port < 0 || port > 65535) {
|
||||
String errMsg = getString(R.string.error_invalid_port);
|
||||
proxyPort.setError(errMsg);
|
||||
success = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (editUser != null && editUser.length() > 0) {
|
||||
|
@ -65,8 +65,10 @@ abstract class ProxySetup {
|
||||
int proxyPort = settings.getProxyPortNumber();
|
||||
InetSocketAddress socket = new InetSocketAddress(proxyHost, proxyPort);
|
||||
Proxy httpsProxy = new Proxy(Proxy.Type.HTTP, socket);
|
||||
proxyList = new ArrayList<>(1);
|
||||
Proxy socksProxy = new Proxy(Proxy.Type.SOCKS, socket);
|
||||
proxyList = new ArrayList<>(2);
|
||||
proxyList.add(httpsProxy);
|
||||
proxyList.add(socksProxy);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -76,6 +78,7 @@ abstract class ProxySetup {
|
||||
|
||||
@Override
|
||||
public void connectFailed(URI uri, SocketAddress sa, IOException ioe) {
|
||||
// ignore to force using proxy and avoid data leak
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -79,7 +79,7 @@ public class TwitterEngine {
|
||||
// Twitter4J has its own proxy settings
|
||||
if (settings.isProxyServerSet()) {
|
||||
builder.setHttpProxyHost(settings.getProxyHost());
|
||||
builder.setHttpProxyPort(Integer.parseInt(settings.getProxyPort()));
|
||||
builder.setHttpProxyPort(settings.getProxyPortNumber());
|
||||
if (settings.isProxyLoginSet()) {
|
||||
builder.setHttpProxyUser(settings.getProxyUser());
|
||||
builder.setHttpProxyPassword(settings.getProxyPass());
|
||||
|
@ -300,7 +300,7 @@ public class GlobalSettings {
|
||||
* @return proxy port integer
|
||||
*/
|
||||
public int getProxyPortNumber() {
|
||||
if (proxyPort.isEmpty())
|
||||
if (proxyPort.isEmpty() || proxyPort.length() > 5)
|
||||
return 0;
|
||||
return Integer.parseInt(proxyPort);
|
||||
}
|
||||
|
@ -148,4 +148,5 @@
|
||||
<string name="error_image_loading">Bild konnte nicht geladen werden!</string>
|
||||
<string name="item_image_save">Bild speichern</string>
|
||||
<string name="error_cant_load_video">Video kann nicht abgespielt werden!</string>
|
||||
<string name="error_invalid_port">Ungültiger Port!</string>
|
||||
</resources>
|
@ -151,4 +151,5 @@
|
||||
<string name="error_image_loading">Could not load image!</string>
|
||||
<string name="item_image_save">save image</string>
|
||||
<string name="error_cant_load_video">Could not play video!</string>
|
||||
<string name="error_invalid_port">Invalid port!</string>
|
||||
</resources>
|
Loading…
x
Reference in New Issue
Block a user