From 13fd4c9f8459d2c8a3d7b4e8f7cb39865200826c Mon Sep 17 00:00:00 2001 From: n8fr8 Date: Tue, 3 Jul 2018 16:08:17 -0400 Subject: [PATCH] begin work on a background camera using overlay from the service --- .../main/sensors/motion/MotionDetector.java | 4 ++ .../main/service/BackgroundCamera.java | 43 +++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 src/main/java/org/havenapp/main/service/BackgroundCamera.java diff --git a/src/main/java/org/havenapp/main/sensors/motion/MotionDetector.java b/src/main/java/org/havenapp/main/sensors/motion/MotionDetector.java index 068b211f..f2f8a1f1 100644 --- a/src/main/java/org/havenapp/main/sensors/motion/MotionDetector.java +++ b/src/main/java/org/havenapp/main/sensors/motion/MotionDetector.java @@ -157,6 +157,10 @@ public void detect() { }); } + else + { + + } } diff --git a/src/main/java/org/havenapp/main/service/BackgroundCamera.java b/src/main/java/org/havenapp/main/service/BackgroundCamera.java new file mode 100644 index 00000000..3638bcb4 --- /dev/null +++ b/src/main/java/org/havenapp/main/service/BackgroundCamera.java @@ -0,0 +1,43 @@ +package org.havenapp.main.service; + +import android.content.Context; +import android.graphics.PixelFormat; +import android.view.Gravity; +import android.view.SurfaceHolder; +import android.view.SurfaceView; +import android.view.WindowManager; + +public class BackgroundCamera { + + private void startCamera (Context context) + { + + // Create new SurfaceView, set its size to 1x1, move it to the top left corner and set this service as a callback + WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); + SurfaceView surfaceView = new SurfaceView(context); + WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams( + 1, 1, + WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY, + WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH, + PixelFormat.TRANSLUCENT + ); + layoutParams.gravity = Gravity.LEFT | Gravity.TOP; + windowManager.addView(surfaceView, layoutParams); + surfaceView.getHolder().addCallback(new SurfaceHolder.Callback() { + @Override + public void surfaceCreated(SurfaceHolder surfaceHolder) { + + } + + @Override + public void surfaceChanged(SurfaceHolder surfaceHolder, int i, int i1, int i2) { + + } + + @Override + public void surfaceDestroyed(SurfaceHolder surfaceHolder) { + + } + }); + } +}