Improve 2237074: Make preview start earlier.

Change-Id: I9d7416cfd7c9cbaa3bc135ac8fd67776ec1c65e3
diff --git a/src/com/android/camera/Camera.java b/src/com/android/camera/Camera.java
index ddb6611..cdf8735 100644
--- a/src/com/android/camera/Camera.java
+++ b/src/com/android/camera/Camera.java
@@ -601,14 +601,25 @@
                 mJpegPictureCallbackTime - mRawPictureCallbackTime;
             Log.v(TAG, "mRawPictureAndJpegPictureCallbackTime = "
                     + mRawPictureAndJpegPictureCallbackTime + "ms");
-            mImageCapture.storeImage(jpegData, camera, mLocation);
 
             if (!mIsImageCaptureIntent) {
+                // We want to show the taken picture for a while, so we wait
+                // for at least 1.2 second before restarting the preview.
                 long delay = 1200 - (
                         System.currentTimeMillis() - mRawPictureCallbackTime);
-                mHandler.sendEmptyMessageDelayed(
-                        RESTART_PREVIEW, Math.max(delay, 0));
+                if (delay < 0) {
+                    restartPreview();
+                } else {
+                    mHandler.sendEmptyMessageDelayed(RESTART_PREVIEW, delay);
+                }
             }
+            mImageCapture.storeImage(jpegData, camera, mLocation);
+
+            // Calculate this in advance of each shot so we don't add to shutter
+            // latency. It's true that someone else could write to the SD card in
+            // the mean time and fill it, but that could have happened between the
+            // shutter press and saving the JPEG too.
+            calculatePicturesRemaining();
         }
     }
 
@@ -1538,12 +1549,6 @@
             showCameraErrorAndFinish();
             return;
         }
-
-        // Calculate this in advance of each shot so we don't add to shutter
-        // latency. It's true that someone else could write to the SD card in
-        // the mean time and fill it, but that could have happened between the
-        // shutter press and saving the JPEG too.
-        calculatePicturesRemaining();
     }
 
     private void setPreviewDisplay(SurfaceHolder holder) {
diff --git a/src/com/android/camera/MenuHelper.java b/src/com/android/camera/MenuHelper.java
index 453d629..0ab7612 100644
--- a/src/com/android/camera/MenuHelper.java
+++ b/src/com/android/camera/MenuHelper.java
@@ -1066,8 +1066,9 @@
                 String storageDirectory =
                         Environment.getExternalStorageDirectory().toString();
                 StatFs stat = new StatFs(storageDirectory);
+                final int PICTURE_BYTES = 1500000;
                 float remaining = ((float) stat.getAvailableBlocks()
-                        * (float) stat.getBlockSize()) / 400000F;
+                        * (float) stat.getBlockSize()) / PICTURE_BYTES;
                 return (int) remaining;
             }
         } catch (Exception ex) {