|
|
@ -62,21 +62,21 @@ public class ProxyUtils { |
|
|
|
if (orbotInstalled && i2pInstalled) { |
|
|
|
if (orbotInstalled && i2pInstalled) { |
|
|
|
String[] proxyChoices = activity.getResources().getStringArray(R.array.proxy_choices_array); |
|
|
|
String[] proxyChoices = activity.getResources().getStringArray(R.array.proxy_choices_array); |
|
|
|
builder.setTitle(activity.getResources().getString(R.string.http_proxy)) |
|
|
|
builder.setTitle(activity.getResources().getString(R.string.http_proxy)) |
|
|
|
.setSingleChoiceItems(proxyChoices, mPreferences.getProxyChoice(), |
|
|
|
.setSingleChoiceItems(proxyChoices, mPreferences.getProxyChoice(), |
|
|
|
new DialogInterface.OnClickListener() { |
|
|
|
new DialogInterface.OnClickListener() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void onClick(DialogInterface dialog, int which) { |
|
|
|
public void onClick(DialogInterface dialog, int which) { |
|
|
|
mPreferences.setProxyChoice(which); |
|
|
|
mPreferences.setProxyChoice(which); |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
.setPositiveButton(activity.getResources().getString(R.string.action_ok), |
|
|
|
.setPositiveButton(activity.getResources().getString(R.string.action_ok), |
|
|
|
new DialogInterface.OnClickListener() { |
|
|
|
new DialogInterface.OnClickListener() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void onClick(DialogInterface dialog, int which) { |
|
|
|
public void onClick(DialogInterface dialog, int which) { |
|
|
|
if (mPreferences.getUseProxy()) |
|
|
|
if (mPreferences.getUseProxy()) |
|
|
|
initializeProxy(activity); |
|
|
|
initializeProxy(activity); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() { |
|
|
|
DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
@ -84,7 +84,7 @@ public class ProxyUtils { |
|
|
|
switch (which) { |
|
|
|
switch (which) { |
|
|
|
case DialogInterface.BUTTON_POSITIVE: |
|
|
|
case DialogInterface.BUTTON_POSITIVE: |
|
|
|
mPreferences.setProxyChoice(orbotInstalled ? |
|
|
|
mPreferences.setProxyChoice(orbotInstalled ? |
|
|
|
Constants.PROXY_ORBOT : Constants.PROXY_I2P); |
|
|
|
Constants.PROXY_ORBOT : Constants.PROXY_I2P); |
|
|
|
initializeProxy(activity); |
|
|
|
initializeProxy(activity); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case DialogInterface.BUTTON_NEGATIVE: |
|
|
|
case DialogInterface.BUTTON_NEGATIVE: |
|
|
@ -95,8 +95,8 @@ public class ProxyUtils { |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
builder.setMessage(orbotInstalled ? R.string.use_tor_prompt : R.string.use_i2p_prompt) |
|
|
|
builder.setMessage(orbotInstalled ? R.string.use_tor_prompt : R.string.use_i2p_prompt) |
|
|
|
.setPositiveButton(R.string.yes, dialogClickListener) |
|
|
|
.setPositiveButton(R.string.yes, dialogClickListener) |
|
|
|
.setNegativeButton(R.string.no, dialogClickListener); |
|
|
|
.setNegativeButton(R.string.no, dialogClickListener); |
|
|
|
} |
|
|
|
} |
|
|
|
Dialog dialog = builder.show(); |
|
|
|
Dialog dialog = builder.show(); |
|
|
|
BrowserDialog.setDialogSize(activity, dialog); |
|
|
|
BrowserDialog.setDialogSize(activity, dialog); |
|
|
@ -114,14 +114,12 @@ public class ProxyUtils { |
|
|
|
case Constants.NO_PROXY: |
|
|
|
case Constants.NO_PROXY: |
|
|
|
// We shouldn't be here
|
|
|
|
// We shouldn't be here
|
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
case Constants.PROXY_ORBOT: |
|
|
|
case Constants.PROXY_ORBOT: |
|
|
|
if (!OrbotHelper.isOrbotRunning(activity)) |
|
|
|
if (!OrbotHelper.isOrbotRunning(activity)) |
|
|
|
OrbotHelper.requestStartTor(activity); |
|
|
|
OrbotHelper.requestStartTor(activity); |
|
|
|
host = "localhost"; |
|
|
|
host = "localhost"; |
|
|
|
port = 8118; |
|
|
|
port = 8118; |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case Constants.PROXY_I2P: |
|
|
|
case Constants.PROXY_I2P: |
|
|
|
mI2PProxyInitialized = true; |
|
|
|
mI2PProxyInitialized = true; |
|
|
|
if (mI2PHelperBound && !mI2PHelper.isI2PAndroidRunning()) { |
|
|
|
if (mI2PHelperBound && !mI2PHelper.isI2PAndroidRunning()) { |
|
|
@ -130,10 +128,14 @@ public class ProxyUtils { |
|
|
|
host = "localhost"; |
|
|
|
host = "localhost"; |
|
|
|
port = 4444; |
|
|
|
port = 4444; |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
default: |
|
|
|
default: |
|
|
|
host = mPreferences.getProxyHost(); |
|
|
|
host = mPreferences.getProxyHost(); |
|
|
|
port = mPreferences.getProxyPort(); |
|
|
|
port = mPreferences.getProxyPort(); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case Constants.PROXY_MANUAL: |
|
|
|
|
|
|
|
host = mPreferences.getProxyHost(); |
|
|
|
|
|
|
|
port = mPreferences.getProxyPort(); |
|
|
|
|
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
try { |
|
|
@ -191,6 +193,7 @@ public class ProxyUtils { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Constants.PROXY |
|
|
|
public static int setProxyChoice(int choice, @NonNull Activity activity) { |
|
|
|
public static int setProxyChoice(int choice, @NonNull Activity activity) { |
|
|
|
switch (choice) { |
|
|
|
switch (choice) { |
|
|
|
case Constants.PROXY_ORBOT: |
|
|
|
case Constants.PROXY_ORBOT: |
|
|
|