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

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

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

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

@ -38,4 +38,9 @@ public final class Constants {
public static final String FILE = "file://"; public static final String FILE = "file://";
public static final String FOLDER = "folder://"; public static final String FOLDER = "folder://";
public static final String TAG = "Lightning"; 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