Merge "Start Effects Recording only after preview loads" into ics-mr1
diff --git a/src/com/android/camera/EffectsRecorder.java b/src/com/android/camera/EffectsRecorder.java
index ea7ce39..390efa6 100644
--- a/src/com/android/camera/EffectsRecorder.java
+++ b/src/com/android/camera/EffectsRecorder.java
@@ -71,6 +71,7 @@
     public static final int  EFFECT_MSG_SWITCHING_EFFECT = 2;
     public static final int  EFFECT_MSG_EFFECTS_STOPPED  = 3;
     public static final int  EFFECT_MSG_RECORDING_DONE   = 4;
+    public static final int  EFFECT_MSG_PREVIEW_RUNNING  = 5;
 
     private Context mContext;
     private Handler mHandler;
@@ -607,6 +608,9 @@
                 mState = STATE_PREVIEW;
 
                 if (mLogVerbose) Log.v(TAG, "Start preview/effect switch complete");
+
+                // Sending a message to listener that preview is complete
+                sendMessage(mCurrentEffect, EFFECT_MSG_PREVIEW_RUNNING);
             }
         }
     };
diff --git a/src/com/android/camera/VideoCamera.java b/src/com/android/camera/VideoCamera.java
index 004c36a..1e90544 100755
--- a/src/com/android/camera/VideoCamera.java
+++ b/src/com/android/camera/VideoCamera.java
@@ -432,6 +432,16 @@
         mShutterButton.setOnShutterButtonListener(this);
         mShutterButton.requestFocus();
 
+        // Disable the shutter button if effects are ON since it might take
+        // a little more time for the effects preview to be ready. We do not
+        // want to allow recording before that happens. The shutter button
+        // will be enabled when we get the message from effectsrecorder that
+        // the preview is running. This becomes critical when the camera is
+        // swapped.
+        if (effectsActive()) {
+            mShutterButton.setEnabled(false);
+        }
+
         mRecordingTimeView = (TextView) findViewById(R.id.recording_time);
         mRecordingTimeRect = (RotateLayout) findViewById(R.id.recording_time_rect);
         mOrientationListener = new MyOrientationEventListener(this);
@@ -641,6 +651,7 @@
     @Override
     public void onShutterButtonClick() {
         if (collapseCameraControls()) return;
+
         boolean stop = mMediaRecorderRecording;
 
         if (stop) {
@@ -1997,6 +2008,9 @@
                 }
             }
             mEffectsDisplayResult = false;
+        } else if (effectMsg == EffectsRecorder.EFFECT_MSG_PREVIEW_RUNNING) {
+            // Enable the shutter button once the preview is complete.
+            mShutterButton.setEnabled(true);
         } else if (effectId == EffectsRecorder.EFFECT_BACKDROPPER) {
             switch (effectMsg) {
                 case EffectsRecorder.EFFECT_MSG_STARTED_LEARNING: