Fixes some crashes
This commit is contained in:
parent
b103f661a9
commit
feb45c5f93
|
@ -135,7 +135,8 @@ public class ProxyActivity extends BaseActivity {
|
||||||
String proxy_passwordVal = proxy_password.getText().toString().trim();
|
String proxy_passwordVal = proxy_password.getText().toString().trim();
|
||||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||||
editor.putString(Helper.SET_PROXY_HOST, hostVal);
|
editor.putString(Helper.SET_PROXY_HOST, hostVal);
|
||||||
editor.putInt(Helper.SET_PROXY_PORT, Integer.parseInt(portVal));
|
if( portVal.matches("\\d+") )
|
||||||
|
editor.putInt(Helper.SET_PROXY_PORT, Integer.parseInt(portVal));
|
||||||
editor.putString(Helper.SET_PROXY_LOGIN, proxy_loginVal);
|
editor.putString(Helper.SET_PROXY_LOGIN, proxy_loginVal);
|
||||||
editor.putString(Helper.SET_PROXY_PASSWORD, proxy_passwordVal);
|
editor.putString(Helper.SET_PROXY_PASSWORD, proxy_passwordVal);
|
||||||
editor.apply();
|
editor.apply();
|
||||||
|
|
|
@ -106,24 +106,29 @@ public class LiveNotificationService extends Service {
|
||||||
int type = sharedpreferences.getInt(Helper.SET_PROXY_TYPE, 0);
|
int type = sharedpreferences.getInt(Helper.SET_PROXY_TYPE, 0);
|
||||||
proxy = null;
|
proxy = null;
|
||||||
if( proxyEnabled ){
|
if( proxyEnabled ){
|
||||||
String host = sharedpreferences.getString(Helper.SET_PROXY_HOST, "127.0.0.1");
|
try{
|
||||||
int port = sharedpreferences.getInt(Helper.SET_PROXY_PORT, 8118);
|
String host = sharedpreferences.getString(Helper.SET_PROXY_HOST, "127.0.0.1");
|
||||||
if( type == 0 )
|
int port = sharedpreferences.getInt(Helper.SET_PROXY_PORT, 8118);
|
||||||
proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(host, port));
|
if( type == 0 )
|
||||||
else
|
proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(host, port));
|
||||||
proxy = new Proxy(Proxy.Type.SOCKS, new InetSocketAddress(host, port));
|
else
|
||||||
final String login = sharedpreferences.getString(Helper.SET_PROXY_LOGIN, null);
|
proxy = new Proxy(Proxy.Type.SOCKS, new InetSocketAddress(host, port));
|
||||||
final String pwd = sharedpreferences.getString(Helper.SET_PROXY_PASSWORD, null);
|
final String login = sharedpreferences.getString(Helper.SET_PROXY_LOGIN, null);
|
||||||
if( login != null) {
|
final String pwd = sharedpreferences.getString(Helper.SET_PROXY_PASSWORD, null);
|
||||||
Authenticator authenticator = new Authenticator() {
|
if( login != null) {
|
||||||
public PasswordAuthentication getPasswordAuthentication() {
|
Authenticator authenticator = new Authenticator() {
|
||||||
assert pwd != null;
|
public PasswordAuthentication getPasswordAuthentication() {
|
||||||
return (new PasswordAuthentication(login,
|
assert pwd != null;
|
||||||
pwd.toCharArray()));
|
return (new PasswordAuthentication(login,
|
||||||
}
|
pwd.toCharArray()));
|
||||||
};
|
}
|
||||||
Authenticator.setDefault(authenticator);
|
};
|
||||||
|
Authenticator.setDefault(authenticator);
|
||||||
|
}
|
||||||
|
}catch (Exception e){
|
||||||
|
proxy = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if( intent == null || intent.getBooleanExtra("stop", false) ) {
|
if( intent == null || intent.getBooleanExtra("stop", false) ) {
|
||||||
stop = true;
|
stop = true;
|
||||||
|
|
Loading…
Reference in New Issue