diff options
author | Wu-cheng Li <wuchengli@google.com> | 2011-10-19 22:13:35 +0800 |
---|---|---|
committer | Wu-cheng Li <wuchengli@google.com> | 2011-10-20 11:11:03 +0800 |
commit | eeeea93f90ff788a3d86e1e3bb2bb4725adff9ee (patch) | |
tree | c076a368d00a396bb79a53dc1da5d8b667b6f504 /src | |
parent | f9f24d4c578a01cb09a7e5c4c66b75595d3669ee (diff) | |
download | LegacyCamera-eeeea93f90ff788a3d86e1e3bb2bb4725adff9ee.zip LegacyCamera-eeeea93f90ff788a3d86e1e3bb2bb4725adff9ee.tar.gz LegacyCamera-eeeea93f90ff788a3d86e1e3bb2bb4725adff9ee.tar.bz2 |
Reset the video effect when camcorder application starts.
On video recording, if a Background effect is applied,
it is strange to see the popup window the next time the camera app
is opened.
bug:5477191
To reproduce:
-Open camera;
-Select Video recorder;
-Select settings>Effects>Background;
-Activate a background effect;
-The pop-up ("Place your device...") comes out;
-Effect is active;
-Press Home;
-Select the Camera app again;
-The pop-up is triggered again. The app is in background effect mode.
Change-Id: Iea44d7ef2243df5dec961e5ecf67e85b5e971dcb
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/camera/MenuHelper.java | 3 | ||||
-rwxr-xr-x | src/com/android/camera/VideoCamera.java | 72 |
2 files changed, 46 insertions, 29 deletions
diff --git a/src/com/android/camera/MenuHelper.java b/src/com/android/camera/MenuHelper.java index 2e1ec28..07caeb2 100644 --- a/src/com/android/camera/MenuHelper.java +++ b/src/com/android/camera/MenuHelper.java @@ -138,8 +138,9 @@ public class MenuHelper { startCameraActivity(activity, new Intent(action), className); } - public static void gotoVideoMode(Activity activity) { + public static void gotoVideoMode(Activity activity, boolean resetEffect) { Intent intent = new Intent(MediaStore.INTENT_ACTION_VIDEO_CAMERA); + intent.putExtra(VideoCamera.RESET_EFFECT_EXTRA, resetEffect); startCameraActivity(activity, intent, VIDEO_CAMERA_CLASS); } diff --git a/src/com/android/camera/VideoCamera.java b/src/com/android/camera/VideoCamera.java index 8960311..7ea8542 100755 --- a/src/com/android/camera/VideoCamera.java +++ b/src/com/android/camera/VideoCamera.java @@ -183,6 +183,9 @@ public class VideoCamera extends ActivityBase private int mEffectType = EffectsRecorder.EFFECT_NONE; private Object mEffectParameter = null; private String mEffectUriFromGallery = null; + private String mPrefVideoEffectDefault; + private boolean mResetEffect = true; + public static final String RESET_EFFECT_EXTRA = "reset_effect"; private boolean mMediaRecorderRecording = false; private long mRecordingStartTime; @@ -353,6 +356,11 @@ public class VideoCamera extends ActivityBase CameraSettings.upgradeLocalPreferences(mPreferences.getLocal()); mNumberOfCameras = CameraHolder.instance().getNumberOfCameras(); + mPrefVideoEffectDefault = getString(R.string.pref_video_effect_default); + // Do not reset the effect if users are switching between back and front + // cameras. + mResetEffect = getIntent().getBooleanExtra(RESET_EFFECT_EXTRA, true); + resetEffect(); /* * To reduce startup time, we start the preview in another thread. @@ -705,33 +713,17 @@ public class VideoCamera extends ActivityBase mEffectType = CameraSettings.readEffectType(mPreferences); if (mEffectType != EffectsRecorder.EFFECT_NONE) { mEffectParameter = CameraSettings.readEffectParameter(mPreferences); - // When picking from gallery, mEffectParameter should have been - // initialized in onActivityResult. If not, fall back to no effect - if (mEffectType == EffectsRecorder.EFFECT_BACKDROPPER - && ((String) mEffectParameter).equals(EFFECT_BG_FROM_GALLERY) - && mEffectUriFromGallery == null) { - Log.w(TAG, "No URI from gallery, resetting to no effect"); - mEffectType = EffectsRecorder.EFFECT_NONE; - mEffectParameter = null; - writeDefaultEffectToPrefs(); - if (mIndicatorControlContainer != null) { - mIndicatorControlContainer.overrideSettings( + // Set quality to 480p for effects, unless intent is overriding it + if (!intent.hasExtra(MediaStore.EXTRA_VIDEO_QUALITY)) { + quality = CamcorderProfile.QUALITY_480P; + } + // On initial startup, can get here before indicator control is + // enabled. In that case, UI quality override handled in + // initializeIndicatorControl. + if (mIndicatorControlContainer != null) { + mIndicatorControlContainer.overrideSettings( CameraSettings.KEY_VIDEO_QUALITY, - null); - } - } else { - // Set quality to 480p for effects, unless intent is overriding it - if (!intent.hasExtra(MediaStore.EXTRA_VIDEO_QUALITY)) { - quality = CamcorderProfile.QUALITY_480P; - } - // On initial startup, can get here before indicator control is - // enabled. In that case, UI quality override handled in - // initializeIndicatorControl. - if (mIndicatorControlContainer != null) { - mIndicatorControlContainer.overrideSettings( - CameraSettings.KEY_VIDEO_QUALITY, - Integer.toString(CamcorderProfile.QUALITY_480P)); - } + Integer.toString(CamcorderProfile.QUALITY_480P)); } } else { mEffectParameter = null; @@ -805,6 +797,10 @@ public class VideoCamera extends ActivityBase // some time to get first orientation. mOrientationListener.enable(); if (!mPreviewing) { + if (resetEffect()) { + mBgLearningMessageFrame.setVisibility(View.GONE); + mIndicatorControlContainer.reloadPreferences(); + } try { mCameraDevice = Util.openCamera(this, mCameraId); readVideoPreferences(); @@ -1933,6 +1929,11 @@ public class VideoCamera extends ActivityBase // seen by startPreview from onResume() mEffectUriFromGallery = ((Uri) data.getData()).toString(); Log.v(TAG, "Received URI from gallery: " + mEffectUriFromGallery); + mResetEffect = false; + } else { + mEffectUriFromGallery = null; + Log.w(TAG, "No URI from gallery"); + mResetEffect = true; } break; default: @@ -2053,9 +2054,11 @@ public class VideoCamera extends ActivityBase // animation. if (mIsVideoCaptureIntent) { // If the intent is video capture, stay in video capture mode. - MenuHelper.gotoVideoMode(this, getIntent()); + Intent intent = getIntent(); + intent.putExtra(RESET_EFFECT_EXTRA, false); + MenuHelper.gotoVideoMode(this, intent); } else { - MenuHelper.gotoVideoMode(this); + MenuHelper.gotoVideoMode(this, false); } finish(); } else { @@ -2346,4 +2349,17 @@ public class VideoCamera extends ActivityBase Util.broadcastNewPicture(this, uri); } } + + private boolean resetEffect() { + if (mResetEffect) { + String value = mPreferences.getString(CameraSettings.KEY_VIDEO_EFFECT, + mPrefVideoEffectDefault); + if (!mPrefVideoEffectDefault.equals(value)) { + writeDefaultEffectToPrefs(); + return true; + } + } + mResetEffect = true; + return false; + } } |