Notify user if proxy is not ready when they try to load a URL
This commit is contained in:
parent
6e8da9f6d3
commit
a5a20eebbd
@ -650,6 +650,20 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isProxyReady() {
|
||||||
|
if (mPreferences.getProxyChoice() == 2) {
|
||||||
|
if (!mI2PHelper.isI2PAndroidRunning()) {
|
||||||
|
Utils.showToast(this, getString(R.string.i2p_not_running));
|
||||||
|
return false;
|
||||||
|
} else if (!mI2PHelper.areTunnelsActive()) {
|
||||||
|
Utils.showToast(this, getString(R.string.i2p_tunnels_not_ready));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
private boolean isTablet() {
|
private boolean isTablet() {
|
||||||
return (getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_XLARGE;
|
return (getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_XLARGE;
|
||||||
}
|
}
|
||||||
|
@ -54,5 +54,7 @@ public interface BrowserController {
|
|||||||
|
|
||||||
boolean isIncognito();
|
boolean isIncognito();
|
||||||
|
|
||||||
|
boolean isProxyReady();
|
||||||
|
|
||||||
int getMenu();
|
int getMenu();
|
||||||
}
|
}
|
||||||
|
@ -526,6 +526,12 @@ public class LightningView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void reload() {
|
public synchronized void reload() {
|
||||||
|
// Check if configured proxy is available
|
||||||
|
if (!mBrowserController.isProxyReady()) {
|
||||||
|
// User has been notified
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (mWebView != null) {
|
if (mWebView != null) {
|
||||||
mWebView.reload();
|
mWebView.reload();
|
||||||
}
|
}
|
||||||
@ -611,6 +617,12 @@ public class LightningView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void loadUrl(String url) {
|
public synchronized void loadUrl(String url) {
|
||||||
|
// Check if configured proxy is available
|
||||||
|
if (!mBrowserController.isProxyReady()) {
|
||||||
|
// User has been notified
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (mWebView != null) {
|
if (mWebView != null) {
|
||||||
mWebView.loadUrl(url);
|
mWebView.loadUrl(url);
|
||||||
}
|
}
|
||||||
@ -815,6 +827,12 @@ public class LightningView {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
||||||
|
// Check if configured proxy is available
|
||||||
|
if (!mBrowserController.isProxyReady()) {
|
||||||
|
// User has been notified
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (mBrowserController.isIncognito()) {
|
if (mBrowserController.isIncognito()) {
|
||||||
return super.shouldOverrideUrlLoading(view, url);
|
return super.shouldOverrideUrlLoading(view, url);
|
||||||
}
|
}
|
||||||
|
@ -167,6 +167,8 @@
|
|||||||
<string name="use_tor_prompt">It looks like you have Orbot installed. Do you want to use Tor?</string>
|
<string name="use_tor_prompt">It looks like you have Orbot installed. Do you want to use Tor?</string>
|
||||||
<string name="use_i2p_prompt">It looks like you have I2P installed. Do you want to use I2P?</string>
|
<string name="use_i2p_prompt">It looks like you have I2P installed. Do you want to use I2P?</string>
|
||||||
<string name="install_orbot">Please install Orbot in order to proxy with Tor.</string>
|
<string name="install_orbot">Please install Orbot in order to proxy with Tor.</string>
|
||||||
|
<string name="i2p_not_running">I2P is not running.</string>
|
||||||
|
<string name="i2p_tunnels_not_ready">I2P tunnels are not ready yet.</string>
|
||||||
<string name="yes">Yes</string>
|
<string name="yes">Yes</string>
|
||||||
<string name="no">No</string>
|
<string name="no">No</string>
|
||||||
<string name="clear_cookies_exit">Clear cookies on exit</string>
|
<string name="clear_cookies_exit">Clear cookies on exit</string>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user