Browse Source

Use constants for proxy choices

master
str4d 10 years ago
parent
commit
a0b2197d8f
  1. 10
      app/src/main/java/acr/browser/lightning/activity/BrowserActivity.java
  2. 8
      app/src/main/java/acr/browser/lightning/activity/SettingsActivity.java
  3. 5
      app/src/main/java/acr/browser/lightning/constant/Constants.java

10
app/src/main/java/acr/browser/lightning/activity/BrowserActivity.java

@ -614,11 +614,11 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll @@ -614,11 +614,11 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
int port;
switch (mPreferences.getProxyChoice()) {
case 0:
case Constants.NO_PROXY:
// We shouldn't be here
return;
case 1:
case Constants.PROXY_ORBOT:
OrbotHelper oh = new OrbotHelper(this);
if (!oh.isOrbotRunning()) {
oh.requestOrbotStart(this);
@ -627,7 +627,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll @@ -627,7 +627,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
port = 8118;
break;
case 2:
case Constants.PROXY_I2P:
mI2PProxyInitialized = true;
if (mI2PHelperBound && !mI2PHelper.isI2PAndroidRunning()) {
mI2PHelper.requestI2PAndroidStart(this);
@ -651,7 +651,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll @@ -651,7 +651,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
}
public boolean isProxyReady() {
if (mPreferences.getProxyChoice() == 2) {
if (mPreferences.getProxyChoice() == Constants.PROXY_I2P) {
if (!mI2PHelper.isI2PAndroidRunning()) {
Utils.showToast(this, getString(R.string.i2p_not_running));
return false;
@ -1501,7 +1501,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll @@ -1501,7 +1501,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
@Override
protected void onStart() {
super.onStart();
if (mPreferences.getProxyChoice() == 2) {
if (mPreferences.getProxyChoice() == Constants.PROXY_I2P) {
// Try to bind to I2P Android
mI2PHelper.bind(new I2PAndroidHelper.Callback() {
@Override

8
app/src/main/java/acr/browser/lightning/activity/SettingsActivity.java

@ -322,18 +322,18 @@ public class SettingsActivity extends ThemableSettingsActivity { @@ -322,18 +322,18 @@ public class SettingsActivity extends ThemableSettingsActivity {
private void setProxyChoice(int choice) {
switch (choice) {
case 1:
case Constants.PROXY_ORBOT:
OrbotHelper oh = new OrbotHelper(this);
if (!oh.isOrbotInstalled()) {
choice = 0;
choice = Constants.NO_PROXY;
Utils.showToast(mContext, getResources().getString(R.string.install_orbot));
}
break;
case 2:
case Constants.PROXY_I2P:
I2PAndroidHelper ih = new I2PAndroidHelper(this);
if (!ih.isI2PAndroidInstalled()) {
choice = 0;
choice = Constants.NO_PROXY;
ih.promptToInstall(this);
}
break;

5
app/src/main/java/acr/browser/lightning/constant/Constants.java

@ -38,4 +38,9 @@ public final class Constants { @@ -38,4 +38,9 @@ public final class Constants {
public static final String FILE = "file://";
public static final String FOLDER = "folder://";
public static final String TAG = "Lightning";
// These should match the order of @array/proxy_choices_array
public static final int NO_PROXY = 0;
public static final int PROXY_ORBOT = 1;
public static final int PROXY_I2P = 2;
}

Loading…
Cancel
Save