Haven is for people who need a way to protect their personal spaces and possessions without compromising their own privacy, through an Android app and on-device sensors
don't stop camera when surface/fragment is paused - keep it going!
n8fr86b20f29b30f3
diff --git a/src/main/java/org/havenapp/main/sensors/motion/Preview.java b/src/main/java/org/havenapp/main/sensors/motion/Preview.javaindex 524ccb6..71856a2 100644--- a/src/main/java/org/havenapp/main/sensors/motion/Preview.java+++ b/src/main/java/org/havenapp/main/sensors/motion/Preview.java@@ -118,7 +118,15 @@ public class Preview extends SurfaceView implements SurfaceHolder.Callback {prefs = new PreferenceManager(context);motionSensitivity = prefs.getCameraSensitivity();- }+++ /*+ * We bind to the alert service+ */+ context.bindService(new Intent(context,+ MonitorService.class), mConnection, Context.BIND_ABOVE_CLIENT);++ }public void setMotionSensitivity (int motionSensitivity){@@ -137,13 +145,7 @@ public class Preview extends SurfaceView implements SurfaceHolder.Callback {* in order to minimize CPU usage*/public void surfaceCreated(SurfaceHolder holder) {-- /*- * We bind to the alert service- */- context.bindService(new Intent(context,- MonitorService.class), mConnection, Context.BIND_ABOVE_CLIENT);-+/** The Surface has been created, acquire the camera and tell it where* to draw.@@ -336,17 +338,22 @@ public class Preview extends SurfaceView implements SurfaceHolder.Callback {public void surfaceDestroyed(SurfaceHolder holder) {- if (camera != null) {- // Surface will be destroyed when we return, so stop the preview.- // Because the CameraDevice object is not a shared resource, it's very- // important to release it when the activity is paused.- context.unbindService(mConnection);- camera.setPreviewCallback(null);- camera.stopPreview();- camera.release();- }+}+ public void stopCamera ()+ {+ if (camera != null) {+ // Surface will be destroyed when we return, so stop the preview.+ // Because the CameraDevice object is not a shared resource, it's very+ // important to release it when the activity is paused.+ context.unbindService(mConnection);+ camera.setPreviewCallback(null);+ camera.stopPreview();+ camera.release();+ }+ }+public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {if (camera != null) {diff --git a/src/main/java/org/havenapp/main/ui/CameraFragment.java b/src/main/java/org/havenapp/main/ui/CameraFragment.javaindex 6579beb..5ac2b59 100644--- a/src/main/java/org/havenapp/main/ui/CameraFragment.java+++ b/src/main/java/org/havenapp/main/ui/CameraFragment.java@@ -101,6 +101,14 @@ public final class CameraFragment extends Fragment {}}}++ @Override+ public void onDestroy() {+ super.onDestroy();++ preview.stopCamera();+ }+public void onSensorChanged(SensorEvent event) {}diff --git a/src/main/java/org/havenapp/main/ui/MicrophoneConfigureActivity.java b/src/main/java/org/havenapp/main/ui/MicrophoneConfigureActivity.javaindex 0422cd9..7000d3e 100644--- a/src/main/java/org/havenapp/main/ui/MicrophoneConfigureActivity.java+++ b/src/main/java/org/havenapp/main/ui/MicrophoneConfigureActivity.java@@ -57,6 +57,7 @@ public class MicrophoneConfigureActivity extends AppCompatActivity implements MimNumberTrigger.setMinValue(0);mNumberTrigger.setMaxValue(MAX_SLIDER_VALUE);+if (!mPrefManager.getMicrophoneSensitivity().equals(PreferenceManager.MEDIUM))mNumberTrigger.setValue(Integer.parseInt(mPrefManager.getMicrophoneSensitivity()));else@@ -68,8 +69,6 @@ public class MicrophoneConfigureActivity extends AppCompatActivity implements Mi});--initWave();startMic();}