]> www.average.org Git - WhereAmI.git/blobdiff - src/org/average/whereami/WhereAmI.java
handle preferences more precisely
[WhereAmI.git] / src / org / average / whereami / WhereAmI.java
index 1002b3aadb0fc7d6d3aa7c5ca110b89cf7e7e90f..94c0139f116211bb12e910a2d96d53acf6272751 100644 (file)
@@ -7,6 +7,7 @@ import org.average.whereami.LastLocation;
 
 import android.app.Activity;
 import android.net.wifi.WifiManager;
+import android.os.Build;
 import android.os.Bundle;
 import android.os.AsyncTask;
 import android.os.Handler;
@@ -65,7 +66,7 @@ public class WhereAmI extends Activity
                     Time tm = new Time();
                     tm.setToNow();
                     tvs.setText(R.string.lasttry);
-                    tvs.append(tm.format(" %d/%m/%Y %H:%M:%S"));
+                    tvs.append(tm.format(" %d/%m/%Y %H:%M"));
                 }
             }
 
@@ -167,7 +168,7 @@ public class WhereAmI extends Activity
                 Time tm = new Time();
                 tm.setToNow();
                 tvs.setText(R.string.failtry);
-                tvs.append(tm.format(" %d/%m/%Y %H:%M:%S"));
+                tvs.append(tm.format(" %d/%m/%Y %H:%M"));
             }
             if (managewifi) {
                 boolean wifion = wifiman.setWifiEnabled(false);
@@ -199,6 +200,14 @@ public class WhereAmI extends Activity
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
+        if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.FROYO) {
+            Log.v(TAG, "Disabling keepalive for build version " +
+                       Build.VERSION.SDK_INT);
+            System.setProperty("http.keepAlive", "false");
+        } else {
+            Log.v(TAG, "Post-Froyo version " +
+                        Build.VERSION.SDK_INT);
+       }
         prefs = PreferenceManager.getDefaultSharedPreferences(this);
         store = new PersistentStore(prefs);
         wifiman = (WifiManager)getSystemService(Context.WIFI_SERVICE);
@@ -211,17 +220,6 @@ public class WhereAmI extends Activity
         tvt = (TextView)findViewById(R.id.time);
         tvd = (TextView)findViewById(R.id.date);
         tvs = (TextView)findViewById(R.id.timestamp);
-       ut = new UpdateTarget[] {
-            new UpdateTarget((TextView)findViewById(R.id.location),
-                             new PhoneLog(res, store)),
-            new UpdateTarget((TextView)findViewById(R.id.phonecall),
-                             new LastLocation(res, store))
-        };
-        Log.v(TAG, "created UI, about to start update task");
-       mHandler.post(updateClock);
-       mHandler.post(updateCal);
-       mHandler.post(updateInfo);
-        Log.v(TAG, "created UI, update task created");
     }
 
     /** Called when reactivated */
@@ -241,6 +239,17 @@ public class WhereAmI extends Activity
         } else {
             getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
         }
+       ut = new UpdateTarget[] {
+            new UpdateTarget((TextView)findViewById(R.id.phonecall),
+                             new PhoneLog(res, store)),
+            new UpdateTarget((TextView)findViewById(R.id.location),
+                             new LastLocation(res, store))
+        };
+        Log.v(TAG, "created UI, about to start update tasks");
+       mHandler.post(updateClock);
+       mHandler.post(updateCal);
+       mHandler.post(updateInfo);
+        Log.v(TAG, "created UI, update tasks created");
     }
 
     /** Called when put to background */
@@ -248,6 +257,7 @@ public class WhereAmI extends Activity
     public void onPause() {
         super.onPause();
         Log.v(TAG, "going background");
+        resetInfo.run();
     }
 
     /** Called when the activity is destroyed. */