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, ONLINE,
STORAGE STORAGE
} }
private WeakReference<MediaViewer> ui; private WeakReference<MediaViewer> ui;
private ImageAdapter imageAdapter; private ImageAdapter imageAdapter;
private Mode mode; private Mode mode;

View File

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

View File

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

View File

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

View File

@ -32,7 +32,7 @@ public class GlobalSettings {
private int woeIdPos; private int woeIdPos;
private long userId; private long userId;
private String proxyAddress, proxyPort; private String proxyHost, proxyPort;
private String proxyUser, proxyPass; private String proxyUser, proxyPass;
private GlobalSettings(Context context) { private GlobalSettings(Context context) {
@ -51,7 +51,7 @@ public class GlobalSettings {
key1 = settings.getString("key1", ""); key1 = settings.getString("key1", "");
key2 = settings.getString("key2", ""); key2 = settings.getString("key2", "");
userId = settings.getLong("userID", -1L); userId = settings.getLong("userID", -1L);
proxyAddress = settings.getString("proxy_addr", ""); proxyHost = settings.getString("proxy_addr", "");
proxyPort = settings.getString("proxy_port", ""); proxyPort = settings.getString("proxy_port", "");
proxyUser = settings.getString("proxy_user", ""); proxyUser = settings.getString("proxy_user", "");
proxyPass = settings.getString("proxy_pass", ""); proxyPass = settings.getString("proxy_pass", "");
@ -288,19 +288,19 @@ public class GlobalSettings {
* *
* @return proxy address * @return proxy address
*/ */
public String getProxyAddress() { public String getProxyHost() {
return proxyAddress; return proxyHost;
} }
/** /**
* set proxy address * set proxy address
* *
* @param proxyAddress address of proxy * @param proxyHost address of proxy
*/ */
public void setProxyAddress(String proxyAddress) { public void setProxyHost(String proxyHost) {
this.proxyAddress = proxyAddress; this.proxyHost = proxyHost;
Editor edit = settings.edit(); Editor edit = settings.edit();
edit.putString("proxy_addr", proxyAddress); edit.putString("proxy_addr", proxyHost);
edit.apply(); edit.apply();
} }
@ -436,11 +436,26 @@ public class GlobalSettings {
} }
/** /**
* set proxy * set JAVA VM proxy
*/ */
public void setProxy() { 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); 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() { Authenticator.setDefault(new Authenticator() {
@Override @Override
protected PasswordAuthentication getPasswordAuthentication() { protected PasswordAuthentication getPasswordAuthentication() {
@ -449,6 +464,9 @@ public class GlobalSettings {
return new PasswordAuthentication(proxyUser, proxyPass.toCharArray()); 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, LOAD,
DEL DEL
} }
private Mode mode; private Mode mode;
private WeakReference<View> ui; private WeakReference<View> ui;
private TwitterEngine mTwitter; private TwitterEngine mTwitter;

View File

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

View File

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

View File

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