From 4b5420f51a15465544a1285e0a1be25f257cd4db Mon Sep 17 00:00:00 2001
From: zzz <zzz@mail.i2p>
Date: Thu, 23 Jun 2011 21:05:33 +0000
Subject: [PATCH] - Toast if no network - Update status faster - Update release
 notes

---
 res/raw/releasenotes_txt                      |  7 +++---
 .../router/activity/I2PWebViewClient.java     | 21 +++++++++++++++---
 .../android/router/activity/MainActivity.java | 22 ++++++++++++++-----
 3 files changed, 39 insertions(+), 11 deletions(-)

diff --git a/res/raw/releasenotes_txt b/res/raw/releasenotes_txt
index c20d3834f..136a333cd 100644
--- a/res/raw/releasenotes_txt
+++ b/res/raw/releasenotes_txt
@@ -12,7 +12,7 @@ The app runs on either WIFI or mobile networks. For now, the app is very low ban
 
 The app uses TCP only for router-router connections, with a maximum of 24 simultaneous. UDP is disabled.
 
-UPnP is enabled but it it doesn't appear to be working.
+UPnP is enabled but it doesn't appear to be working.
 
 NTP is disabled. If you have cell service, your phone or tablet should have the correct time. If you do not have cell service, ensure your device has accurate time.
 
@@ -29,6 +29,7 @@ The browser does not use the outproxy for regular web sites. Javascript is disab
 The following problems with eepsites are probably not fixable except on Android 3.0 (Honeycomb - i.e. tablets) due to API limitations. I don't have a tablet to test on, so I haven't made any effort to work on it. The workaround is to use Firefox Mobile 4 and the ProxMob plugin (see below).
   - No images
   - No CSS
+  - No POSTs to forms
 
 For eepsites, there are several other things to note:
   - No cookies
@@ -41,9 +42,9 @@ For eepsites, there are several other things to note:
 Using clients with the router
 -----------------------------
 
-The app stats an HTTP proxy at localhost port 4444 and a transparent IRC proxy at localhost port 6668. These are "shared clients" on the same tunnels. Once you see in and out client tunnels listed on the router status (several minutes after startup), you should be able to connect.
+The app starts an HTTP proxy at localhost port 4444 and a transparent IRC proxy at localhost port 6668. These are "shared clients" on the same tunnels. Once you see in and out client tunnels listed on the router status (several minutes after startup), you should be able to connect.
 
-The HTTP proxy is untested (other than with the news fetcher). It should work with Firefox 4 Mobile and the ProxyMob Firefox plugin, if you have at least 512 MB of RAM.
+The HTTP proxy should work with Firefox 4 Mobile and the ProxyMob Firefox plugin, if you have at least 512 MB of RAM. If it works it should avoid all the problems with the embedded web browser listed above. I can't test it as I have a 256 MB Droid.
 
 The IRC proxy destinations are irc.postman.i2p and irc.freshcoffee.i2p. It is tested with the "Android IRC Free" app.
 
diff --git a/src/net/i2p/android/router/activity/I2PWebViewClient.java b/src/net/i2p/android/router/activity/I2PWebViewClient.java
index dacfacc3c..11c0d81a9 100644
--- a/src/net/i2p/android/router/activity/I2PWebViewClient.java
+++ b/src/net/i2p/android/router/activity/I2PWebViewClient.java
@@ -4,6 +4,7 @@ import android.app.Dialog;
 import android.app.ProgressDialog;
 import android.content.DialogInterface;
 import android.os.AsyncTask;
+import android.view.Gravity;
 import android.webkit.WebView;
 import android.webkit.WebViewClient;
 import android.widget.Toast;
@@ -12,6 +13,7 @@ import java.net.URI;
 import java.net.URISyntaxException;
 
 import net.i2p.android.apps.EepGetFetcher;
+import net.i2p.android.router.util.Util;
 import net.i2p.util.EepGet;
 
 class I2PWebViewClient extends WebViewClient {
@@ -31,7 +33,8 @@ class I2PWebViewClient extends WebViewClient {
             URI uri = new URI(url);
             String s = uri.getScheme();
             if (s == null) {
-                Toast toast = Toast.makeText(view.getContext(), "Bad URL " + url, Toast.LENGTH_SHORT);
+                Toast toast = Toast.makeText(view.getContext(), "Bad URL " + url, Toast.LENGTH_LONG);
+                toast.setGravity(Gravity.CENTER, 0, 0);
                 toast.show();
                 return true;
             }
@@ -40,7 +43,15 @@ class I2PWebViewClient extends WebViewClient {
                 return false;
             String h = uri.getHost();
             if (h == null) {
-                Toast toast = Toast.makeText(view.getContext(), "Bad URL " + url, Toast.LENGTH_SHORT);
+                Toast toast = Toast.makeText(view.getContext(), "Bad URL " + url, Toast.LENGTH_LONG);
+                toast.setGravity(Gravity.CENTER, 0, 0);
+                toast.show();
+                return true;
+            }
+
+            if (!Util.isConnected(view.getContext())) {
+                Toast toast = Toast.makeText(view.getContext(), "No Internet connection is available", Toast.LENGTH_LONG);
+                toast.setGravity(Gravity.CENTER, 0, 0);
                 toast.show();
                 return true;
             }
@@ -48,10 +59,14 @@ class I2PWebViewClient extends WebViewClient {
             h = h.toLowerCase();
             if (h.endsWith(".i2p")) {
                 if (!s.equals("http")) {
-                    Toast toast = Toast.makeText(view.getContext(), "Bad URL " + url, Toast.LENGTH_SHORT);
+                    Toast toast = Toast.makeText(view.getContext(), "Bad URL " + url, Toast.LENGTH_LONG);
+                    toast.setGravity(Gravity.CENTER, 0, 0);
                     toast.show();
                     return true;
                 }
+
+                // TODO check that the router is up and we have client tunnels both ways
+
                 // strip trailing junk
                 int hash = url.indexOf("#");
                 if (hash > 0)
diff --git a/src/net/i2p/android/router/activity/MainActivity.java b/src/net/i2p/android/router/activity/MainActivity.java
index fc3bd53de..c07582a0c 100644
--- a/src/net/i2p/android/router/activity/MainActivity.java
+++ b/src/net/i2p/android/router/activity/MainActivity.java
@@ -23,6 +23,7 @@ public class MainActivity extends I2PActivityBase {
 
     private Handler _handler;
     private Runnable _updater;
+    private Runnable _oneShotUpdate;
     private String _savedStatus;
 
     protected static final String PROP_NEW_INSTALL = "i2p.newInstall";
@@ -111,7 +112,7 @@ public class MainActivity extends I2PActivityBase {
                 } else {
                     startRouter();
                 }
-                updateVisibility();
+                updateOneShot();
             }
         });
 
@@ -122,7 +123,7 @@ public class MainActivity extends I2PActivityBase {
                 if (svc != null && _isBound) {
                     setPref(PREF_AUTO_START, false);
                     svc.manualStop();
-                    updateVisibility();
+                    updateOneShot();
                 }
             }
         });
@@ -134,7 +135,7 @@ public class MainActivity extends I2PActivityBase {
                 if (svc != null && _isBound) {
                     setPref(PREF_AUTO_START, false);
                     svc.manualQuit();
-                    updateVisibility();
+                    updateOneShot();
                 }
             }
         });
@@ -148,6 +149,7 @@ public class MainActivity extends I2PActivityBase {
 
         _handler = new Handler();
         _updater = new Updater();
+        _oneShotUpdate = new OneShotUpdate();
     }
 
     @Override
@@ -174,8 +176,7 @@ public class MainActivity extends I2PActivityBase {
     public void onResume()
     {
         super.onResume();
-        updateVisibility();
-        updateStatus();
+        updateOneShot();
     }
 
     @Override
@@ -186,6 +187,17 @@ public class MainActivity extends I2PActivityBase {
         super.onSaveInstanceState(outState);
     }
 
+    private void updateOneShot() {
+        _handler.postDelayed(_oneShotUpdate, 100);
+    }
+
+    private class OneShotUpdate implements Runnable {
+        public void run() {
+            updateVisibility();
+            updateStatus();
+        }
+    }
+
     private class Updater implements Runnable {
         private int counter;
 
-- 
GitLab