mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 10:49:06 +01:00
Merge branch '331-viewfinder' into 'master'
Reinitialise viewfinder when camera view is shown Thanks to @str4d for finding the cause of the bug. Closes #331. See merge request !165
This commit is contained in:
@@ -44,20 +44,19 @@ public class CameraView extends SurfaceView implements SurfaceHolder.Callback,
|
||||
|
||||
public CameraView(Context context) {
|
||||
super(context);
|
||||
initialize();
|
||||
}
|
||||
|
||||
public CameraView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
initialize();
|
||||
}
|
||||
|
||||
public CameraView(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
initialize();
|
||||
}
|
||||
|
||||
private void initialize() {
|
||||
@Override
|
||||
protected void onAttachedToWindow() {
|
||||
super.onAttachedToWindow();
|
||||
setKeepScreenOn(true);
|
||||
SurfaceHolder holder = getHolder();
|
||||
if (Build.VERSION.SDK_INT < 11)
|
||||
@@ -65,6 +64,13 @@ public class CameraView extends SurfaceView implements SurfaceHolder.Callback,
|
||||
holder.addCallback(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow();
|
||||
setKeepScreenOn(false);
|
||||
getHolder().removeCallback(this);
|
||||
}
|
||||
|
||||
public void start(Camera camera, PreviewConsumer previewConsumer,
|
||||
int rotationDegrees) {
|
||||
this.camera = camera;
|
||||
@@ -93,9 +99,7 @@ public class CameraView extends SurfaceView implements SurfaceHolder.Callback,
|
||||
camera.startPreview();
|
||||
if (autoFocus) camera.autoFocus(this);
|
||||
previewConsumer.start(camera);
|
||||
} catch (IOException e) {
|
||||
LOG.log(WARNING, "Error starting camera preview", e);
|
||||
} catch (RuntimeException e) {
|
||||
} catch (IOException | RuntimeException e) {
|
||||
LOG.log(WARNING, "Error starting camera preview", e);
|
||||
}
|
||||
}
|
||||
@@ -246,7 +250,6 @@ public class CameraView extends SurfaceView implements SurfaceHolder.Callback,
|
||||
public void surfaceDestroyed(SurfaceHolder holder) {
|
||||
LOG.info("Surface destroyed");
|
||||
surfaceExists = false;
|
||||
holder.removeCallback(this);
|
||||
}
|
||||
|
||||
public void onAutoFocus(boolean success, final Camera camera) {
|
||||
|
||||
Reference in New Issue
Block a user