summaryrefslogtreecommitdiffstats
path: root/src/com/android/camera/CameraActivity.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/camera/CameraActivity.java')
-rw-r--r--src/com/android/camera/CameraActivity.java41
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;
+ }
}