proxy bug fix, cleanup

This commit is contained in:
NudeDude 2019-06-16 09:47:24 +02:00
parent 5cfbb16f0b
commit e50f257a7e
9 changed files with 45 additions and 20 deletions

View File

@ -25,6 +25,7 @@ public class ImageLoader extends AsyncTask<String, Void, Bitmap[]> {
ONLINE,
STORAGE
}
private WeakReference<MediaViewer> ui;
private ImageAdapter imageAdapter;
private Mode mode;

View File

@ -40,6 +40,7 @@ public class ProfileEditor extends AsyncTask<Void, Void, TwitterUser> {
READ_DATA,
WRITE_DATA
}
private final Mode mode;
private WeakReference<ProfileEdit> ui;
private WeakReference<Dialog> popup;

View File

@ -44,6 +44,7 @@ public class ProfileLoader extends AsyncTask<Long, TwitterUser, TwitterUser> {
ACTION_BLOCK,
ACTION_MUTE
}
private final Mode mode;
private WeakReference<UserProfile> ui;
private TwitterEngine mTwitter;

View File

@ -53,6 +53,7 @@ public class StatusLoader extends AsyncTask<Long, Tweet, Tweet> {
FAVORITE,
DELETE
}
private final Mode mode;
private WeakReference<TweetDetail> ui;
private TwitterEngine mTwitter;

View File

@ -32,7 +32,7 @@ public class GlobalSettings {
private int woeIdPos;
private long userId;
private String proxyAddress, proxyPort;
private String proxyHost, proxyPort;
private String proxyUser, proxyPass;
private GlobalSettings(Context context) {
@ -51,7 +51,7 @@ public class GlobalSettings {
key1 = settings.getString("key1", "");
key2 = settings.getString("key2", "");
userId = settings.getLong("userID", -1L);
proxyAddress = settings.getString("proxy_addr", "");
proxyHost = settings.getString("proxy_addr", "");
proxyPort = settings.getString("proxy_port", "");
proxyUser = settings.getString("proxy_user", "");
proxyPass = settings.getString("proxy_pass", "");
@ -288,19 +288,19 @@ public class GlobalSettings {
*
* @return proxy address
*/
public String getProxyAddress() {
return proxyAddress;
public String getProxyHost() {
return proxyHost;
}
/**
* set proxy address
*
* @param proxyAddress address of proxy
* @param proxyHost address of proxy
*/
public void setProxyAddress(String proxyAddress) {
this.proxyAddress = proxyAddress;
public void setProxyHost(String proxyHost) {
this.proxyHost = proxyHost;
Editor edit = settings.edit();
edit.putString("proxy_addr", proxyAddress);
edit.putString("proxy_addr", proxyHost);
edit.apply();
}
@ -436,11 +436,26 @@ public class GlobalSettings {
}
/**
* set proxy
* set JAVA VM proxy
*/
public void setProxy() {
System.setProperty("https.proxyHost", proxyAddress);
try {
if (proxyHost.trim().isEmpty()) {
System.clearProperty("https.proxyHost");
} else {
System.setProperty("https.proxyHost", proxyHost);
}
if (proxyPort.trim().isEmpty()) {
System.clearProperty("https.proxyPort");
} else {
System.setProperty("https.proxyPort", proxyPort);
}
if (proxyUser.trim().isEmpty()) {
System.clearProperty("https.proxyUser");
}
if (proxyPass.trim().isEmpty()) {
System.clearProperty("https.proxyPassword");
}
Authenticator.setDefault(new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
@ -449,6 +464,9 @@ public class GlobalSettings {
return new PasswordAuthentication(proxyUser, proxyPass.toCharArray());
}
});
} catch (SecurityException sErr) {
sErr.printStackTrace();
}
}
/**

View File

@ -29,6 +29,7 @@ public class MessageLoader extends AsyncTask<Long, Void, List<Message>> {
LOAD,
DEL
}
private Mode mode;
private WeakReference<View> ui;
private TwitterEngine mTwitter;

View File

@ -33,6 +33,7 @@ public class TweetLoader extends AsyncTask<Object, Void, List<Tweet>> {
DB_ANS,
TWEET_SEARCH
}
private Mode mode;
private WeakReference<View> ui;
private TweetAdapter adapter;

View File

@ -29,6 +29,7 @@ public class UserLoader extends AsyncTask<Object, Void, List<TwitterUser>> {
FAVORIT,
SEARCH
}
private Mode mode;
private WeakReference<View> ui;
private TwitterEngine mTwitter;

View File

@ -122,7 +122,7 @@ public class AppSettings extends AppCompatActivity implements OnClickListener,
colorButton2.setBackgroundColor(settings.getFontColor());
colorButton3.setBackgroundColor(settings.getPopupColor());
colorButton4.setBackgroundColor(settings.getHighlightColor());
proxyAddr.setText(settings.getProxyAddress());
proxyAddr.setText(settings.getProxyHost());
proxyPort.setText(settings.getProxyPort());
proxyUser.setText(settings.getProxyUser());
proxyPass.setText(settings.getProxyPass());
@ -136,7 +136,7 @@ public class AppSettings extends AppCompatActivity implements OnClickListener,
@Override
public void onBackPressed() {
settings.setProxyAddress(proxyAddr.getText().toString());
settings.setProxyHost(proxyAddr.getText().toString());
settings.setProxyPort(proxyPort.getText().toString());
settings.setProxyUser(proxyUser.getText().toString());
settings.setProxyPass(proxyPass.getText().toString());