Use constants for proxy choices, part 2

This commit is contained in:
str4d 2015-05-26 12:52:11 +00:00
parent a0b2197d8f
commit 810483ec74
2 changed files with 11 additions and 5 deletions

View File

@ -588,11 +588,12 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
public void onClick(DialogInterface dialog, int which) {
switch (which) {
case DialogInterface.BUTTON_POSITIVE:
mPreferences.setProxyChoice(orbotInstalled ? 1 : 2);
mPreferences.setProxyChoice(orbotInstalled ?
Constants.PROXY_ORBOT : Constants.PROXY_I2P);
initializeProxy();
break;
case DialogInterface.BUTTON_NEGATIVE:
mPreferences.setProxyChoice(0);
mPreferences.setProxyChoice(Constants.NO_PROXY);
break;
}
}

View File

@ -233,7 +233,7 @@ public class PreferenceManager {
}
public int getProxyChoice() {
return mPrefs.getInt(Name.PROXY_CHOICE, 0);
return mPrefs.getInt(Name.PROXY_CHOICE, Constants.NO_PROXY);
}
public int getUserAgentChoice() {
@ -409,12 +409,17 @@ public class PreferenceManager {
}
/**
* 0: None. 1: Orbot. 2: I2P.
* Valid choices:
* <ul>
* <li>{@link Constants#NO_PROXY}</li>
* <li>{@link Constants#PROXY_ORBOT}</li>
* <li>{@link Constants#PROXY_I2P}</li>
* </ul>
*
* @param choice the proxy to use.
*/
public void setProxyChoice(int choice) {
putBoolean(Name.USE_PROXY, choice != 0);
putBoolean(Name.USE_PROXY, choice != Constants.NO_PROXY);
putInt(Name.PROXY_CHOICE, choice);
}