Cleanup and smoother Bubble physics
diff --git a/src/com/savoirfairelinux/sflphone/model/BubbleModel.java b/src/com/savoirfairelinux/sflphone/model/BubbleModel.java
index 9d8f0e0..f59282f 100644
--- a/src/com/savoirfairelinux/sflphone/model/BubbleModel.java
+++ b/src/com/savoirfairelinux/sflphone/model/BubbleModel.java
@@ -10,7 +10,8 @@
 	public int width, height;
 	public ArrayList<Bubble> listBubbles = new ArrayList<Bubble>();
 
-	private static final float BUBBLE_SPEED = 4.f;
+	private static final double BUBBLE_RETURN_TIME_HALF_LIFE = .25;
+	private static final double BUBBLE_RETURN_TIME_LAMBDA = Math.log(2)/BUBBLE_RETURN_TIME_HALF_LIFE;
 
 	public void update()
 	{
@@ -20,7 +21,7 @@
 		if (lastUpdate > now)
 			return;
 
-		float dt = (float) Math.min((now - lastUpdate) / 1000000000.0, .2);
+		double dt = Math.min((now - lastUpdate) / 1000000000.0, .2);
 		lastUpdate = now;
 
 		//Log.w(TAG, "update dt="+dt);
@@ -31,11 +32,12 @@
 			Bubble b = listBubbles.get(i);
 			//Log.w(TAG, "update b");
 			if(!b.dragged && b.attractor != null) {
-				float bx=b.getPosX(), by=b.getPosY();
-				float dx = (b.attractor.x - bx) * dt * BUBBLE_SPEED;
-				float dy = (b.attractor.y - by) * dt * BUBBLE_SPEED;
+				double bx=b.getPosX(), by=b.getPosY();
+				double edt = -Math.expm1(-BUBBLE_RETURN_TIME_LAMBDA*dt);
+				double dx = (b.attractor.x - bx) * edt;
+				double dy = (b.attractor.y - by) * edt;
 				//Log.w(TAG, "update dx="+dt+" dy="+dy);
-				b.setPos(bx+dx, by+dy);
+				b.setPos((float)(bx+dx), (float)(by+dy));
 			}
 		}
 	}
diff --git a/src/com/savoirfairelinux/sflphone/model/BubblesView.java b/src/com/savoirfairelinux/sflphone/model/BubblesView.java
index 9853731..3ce9439 100644
--- a/src/com/savoirfairelinux/sflphone/model/BubblesView.java
+++ b/src/com/savoirfairelinux/sflphone/model/BubblesView.java
@@ -161,11 +161,11 @@
 				Canvas c = null;

 				try {

 					c = surfaceHolder.lockCanvas(null);

+

+					// for the case the surface is destroyed while already in the loop

+					if(c == null || model == null) continue;

+

 					synchronized (surfaceHolder) {

-

-						// for the case the surface is destroyed while already in the loop

-						if(c == null || model == null) continue;

-

 						//Log.w(TAG, "Thread doDraw");

 						model.update();

 						doDraw(c);

@@ -198,17 +198,6 @@
 			}

 		}

 

-		/*private void updatePhysics()

-		{

-			long now = System.currentTimeMillis();

-

-			// Do nothing if lastUpdate is in the future.

-			if (model.lastUpdate > now)

-				return;

-

-			double elapsed = (now - model.lastUpdate) / 1000.0;

-		}

-		 */

 		private void doDraw(Canvas canvas)

 		{

 			canvas.drawColor(Color.WHITE);