diff options
author | Angus Kong <shkong@google.com> | 2013-01-31 18:22:44 -0800 |
---|---|---|
committer | Angus Kong <shkong@google.com> | 2013-01-31 18:30:27 -0800 |
commit | 52fe00244742dbae0072d15f73dab54a55271b56 (patch) | |
tree | 310a20ee8f55fa1b7cde427d8c9f76d3917c3831 /src/com/android/camera/CameraActivity.java | |
parent | 346a15d3c7452927b3088a2c70410b90dfc36180 (diff) | |
download | android_packages_apps_Gallery2-52fe00244742dbae0072d15f73dab54a55271b56.tar.gz android_packages_apps_Gallery2-52fe00244742dbae0072d15f73dab54a55271b56.tar.bz2 android_packages_apps_Gallery2-52fe00244742dbae0072d15f73dab54a55271b56.zip |
Make video snapshot save images in the background.
bug:8114662
Change-Id: I4e96269bd7723dd9a82d2905a01f736c8982c4ed
Diffstat (limited to 'src/com/android/camera/CameraActivity.java')
-rw-r--r-- | src/com/android/camera/CameraActivity.java | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/com/android/camera/CameraActivity.java b/src/com/android/camera/CameraActivity.java index 9f9f1b652..bf1ec2483 100644 --- a/src/com/android/camera/CameraActivity.java +++ b/src/com/android/camera/CameraActivity.java @@ -20,10 +20,13 @@ import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.ObjectAnimator; import android.content.Context; +import android.content.ComponentName; import android.content.Intent; +import android.content.ServiceConnection; import android.content.res.Configuration; import android.graphics.drawable.Drawable; import android.os.Bundle; +import android.os.IBinder; import android.provider.MediaStore; import android.view.KeyEvent; import android.view.LayoutInflater; @@ -59,6 +62,18 @@ public class CameraActivity extends ActivityBase // The degrees of the device rotated clockwise from its natural orientation. private int mLastRawOrientation = OrientationEventListener.ORIENTATION_UNKNOWN; + private MediaSaveService mMediaSaveService; + private ServiceConnection mConnection = new ServiceConnection() { + @Override + public void onServiceConnected(ComponentName className, IBinder b) { + mMediaSaveService = ((MediaSaveService.LocalBinder) b).getService(); + mCurrentModule.onMediaSaveServiceConnected(mMediaSaveService); + } + @Override + public void onServiceDisconnected(ComponentName className) { + mMediaSaveService = null; + }}; + private static final String TAG = "CAM_activity"; private static final int[] DRAW_IDS = { @@ -89,6 +104,7 @@ public class CameraActivity extends ActivityBase mCurrentModule.init(this, mFrame, true); mSwitcher.setCurrentIndex(mCurrentModuleIndex); mOrientationListener = new MyOrientationEventListener(this); + bindMediaSaveService(); } public void init() { @@ -118,6 +134,12 @@ public class CameraActivity extends ActivityBase mSwitcher.setCurrentIndex(mCurrentModuleIndex); } + @Override + public void onDestroy() { + unbindMediaSaveService(); + super.onDestroy(); + } + private class MyOrientationEventListener extends OrientationEventListener { public MyOrientationEventListener(Context context) { @@ -184,6 +206,9 @@ public class CameraActivity extends ActivityBase } openModule(mCurrentModule, canReuse); mCurrentModule.onOrientationChanged(mLastRawOrientation); + if (mMediaSaveService != null) { + mCurrentModule.onMediaSaveServiceConnected(mMediaSaveService); + } getCameraScreenNail().setAlpha(0f); getCameraScreenNail().setOnFrameDrawnOneShot(mOnFrameDrawn); } @@ -298,6 +323,18 @@ public class CameraActivity extends ActivityBase mCurrentModule.onResumeAfterSuper(); } + private void bindMediaSaveService() { + Intent intent = new Intent(this, MediaSaveService.class); + startService(intent); // start service before binding it so the + // service won't be killed if we unbind it. + bindService(intent, mConnection, Context.BIND_AUTO_CREATE); + } + + private void unbindMediaSaveService() { + mMediaSaveService.setListener(null); + unbindService(mConnection); + } + @Override protected void onFullScreenChanged(boolean full) { if (full) { @@ -481,4 +518,8 @@ public class CameraActivity extends ActivityBase public CameraScreenNail getCameraScreenNail() { return (CameraScreenNail) mCameraScreenNail; } + + public MediaSaveService getMediaSaveService() { + return mMediaSaveService; + } } |