Browse Source

Notify user if proxy is not ready when they try to load a URL

master
str4d 10 years ago
parent
commit
a5a20eebbd
  1. 14
      app/src/main/java/acr/browser/lightning/activity/BrowserActivity.java
  2. 2
      app/src/main/java/acr/browser/lightning/controller/BrowserController.java
  3. 18
      app/src/main/java/acr/browser/lightning/view/LightningView.java
  4. 2
      app/src/main/res/values/strings.xml

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

@ -650,6 +650,20 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll @@ -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() {
return (getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_XLARGE;
}

2
app/src/main/java/acr/browser/lightning/controller/BrowserController.java

@ -54,5 +54,7 @@ public interface BrowserController { @@ -54,5 +54,7 @@ public interface BrowserController {
boolean isIncognito();
boolean isProxyReady();
int getMenu();
}

18
app/src/main/java/acr/browser/lightning/view/LightningView.java

@ -526,6 +526,12 @@ public class LightningView { @@ -526,6 +526,12 @@ public class LightningView {
}
public synchronized void reload() {
// Check if configured proxy is available
if (!mBrowserController.isProxyReady()) {
// User has been notified
return;
}
if (mWebView != null) {
mWebView.reload();
}
@ -611,6 +617,12 @@ public class LightningView { @@ -611,6 +617,12 @@ public class LightningView {
}
public synchronized void loadUrl(String url) {
// Check if configured proxy is available
if (!mBrowserController.isProxyReady()) {
// User has been notified
return;
}
if (mWebView != null) {
mWebView.loadUrl(url);
}
@ -815,6 +827,12 @@ public class LightningView { @@ -815,6 +827,12 @@ public class LightningView {
@Override
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()) {
return super.shouldOverrideUrlLoading(view, url);
}

2
app/src/main/res/values/strings.xml

@ -167,6 +167,8 @@ @@ -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_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="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="no">No</string>
<string name="clear_cookies_exit">Clear cookies on exit</string>

Loading…
Cancel
Save