mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-13 03:09:04 +01:00
Compare commits
9 Commits
beta-0.16.
...
beta-0.16.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
aafddcd0f0 | ||
|
|
69bfb72171 | ||
|
|
1aa33ec9b2 | ||
|
|
6702df1e22 | ||
|
|
c1748c9a86 | ||
|
|
9df624c62a | ||
|
|
0ee6197d7f | ||
|
|
b03a7dce3e | ||
|
|
6c59d7dd5f |
@@ -78,8 +78,8 @@ android {
|
|||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdkVersion 14
|
minSdkVersion 14
|
||||||
targetSdkVersion 22
|
targetSdkVersion 22
|
||||||
versionCode 1606
|
versionCode 1608
|
||||||
versionName "0.16.6"
|
versionName "0.16.8"
|
||||||
applicationId "org.briarproject.briar.beta"
|
applicationId "org.briarproject.briar.beta"
|
||||||
resValue "string", "app_package", "org.briarproject.briar.beta"
|
resValue "string", "app_package", "org.briarproject.briar.beta"
|
||||||
buildConfigField "String", "GitHash", "\"${getGitHash()}\""
|
buildConfigField "String", "GitHash", "\"${getGitHash()}\""
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import android.hardware.Camera.CameraInfo;
|
|||||||
import android.hardware.Camera.Parameters;
|
import android.hardware.Camera.Parameters;
|
||||||
import android.hardware.Camera.Size;
|
import android.hardware.Camera.Size;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
|
import android.support.annotation.Nullable;
|
||||||
import android.support.annotation.UiThread;
|
import android.support.annotation.UiThread;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.view.Surface;
|
import android.view.Surface;
|
||||||
@@ -43,6 +44,7 @@ public class CameraView extends SurfaceView implements SurfaceHolder.Callback,
|
|||||||
private static final Logger LOG =
|
private static final Logger LOG =
|
||||||
Logger.getLogger(CameraView.class.getName());
|
Logger.getLogger(CameraView.class.getName());
|
||||||
|
|
||||||
|
@Nullable
|
||||||
private Camera camera = null;
|
private Camera camera = null;
|
||||||
private PreviewConsumer previewConsumer = null;
|
private PreviewConsumer previewConsumer = null;
|
||||||
private Surface surface = null;
|
private Surface surface = null;
|
||||||
@@ -86,6 +88,8 @@ public class CameraView extends SurfaceView implements SurfaceHolder.Callback,
|
|||||||
try {
|
try {
|
||||||
LOG.info("Opening camera");
|
LOG.info("Opening camera");
|
||||||
camera = Camera.open();
|
camera = Camera.open();
|
||||||
|
if (camera == null)
|
||||||
|
throw new RuntimeException("No back-facing camera.");
|
||||||
} catch (RuntimeException e) {
|
} catch (RuntimeException e) {
|
||||||
LOG.log(WARNING, "Error opening camera", e);
|
LOG.log(WARNING, "Error opening camera", e);
|
||||||
return;
|
return;
|
||||||
@@ -129,6 +133,7 @@ public class CameraView extends SurfaceView implements SurfaceHolder.Callback,
|
|||||||
private void startPreview(SurfaceHolder holder) {
|
private void startPreview(SurfaceHolder holder) {
|
||||||
LOG.info("Starting preview");
|
LOG.info("Starting preview");
|
||||||
try {
|
try {
|
||||||
|
if (camera == null) throw new IOException("Camera is null.");
|
||||||
camera.setPreviewDisplay(holder);
|
camera.setPreviewDisplay(holder);
|
||||||
camera.startPreview();
|
camera.startPreview();
|
||||||
previewStarted = true;
|
previewStarted = true;
|
||||||
@@ -142,6 +147,7 @@ public class CameraView extends SurfaceView implements SurfaceHolder.Callback,
|
|||||||
private void stopPreview() {
|
private void stopPreview() {
|
||||||
LOG.info("Stopping preview");
|
LOG.info("Stopping preview");
|
||||||
try {
|
try {
|
||||||
|
if (camera == null) throw new RuntimeException("Camera is null.");
|
||||||
stopConsumer();
|
stopConsumer();
|
||||||
camera.stopPreview();
|
camera.stopPreview();
|
||||||
} catch (RuntimeException e) {
|
} catch (RuntimeException e) {
|
||||||
@@ -152,12 +158,14 @@ public class CameraView extends SurfaceView implements SurfaceHolder.Callback,
|
|||||||
|
|
||||||
@UiThread
|
@UiThread
|
||||||
private void startConsumer() {
|
private void startConsumer() {
|
||||||
|
if (camera == null) throw new RuntimeException("Camera is null");
|
||||||
if (autoFocus) camera.autoFocus(this);
|
if (autoFocus) camera.autoFocus(this);
|
||||||
previewConsumer.start(camera);
|
previewConsumer.start(camera);
|
||||||
}
|
}
|
||||||
|
|
||||||
@UiThread
|
@UiThread
|
||||||
private void stopConsumer() {
|
private void stopConsumer() {
|
||||||
|
if (camera == null) throw new RuntimeException("Camera is null");
|
||||||
if (autoFocus) camera.cancelAutoFocus();
|
if (autoFocus) camera.cancelAutoFocus();
|
||||||
previewConsumer.stop();
|
previewConsumer.stop();
|
||||||
}
|
}
|
||||||
@@ -176,6 +184,7 @@ public class CameraView extends SurfaceView implements SurfaceHolder.Callback,
|
|||||||
if (LOG.isLoggable(INFO))
|
if (LOG.isLoggable(INFO))
|
||||||
LOG.info("Display orientation " + orientation + " degrees");
|
LOG.info("Display orientation " + orientation + " degrees");
|
||||||
try {
|
try {
|
||||||
|
if (camera == null) throw new RuntimeException("Camera is null");
|
||||||
camera.setDisplayOrientation(orientation);
|
camera.setDisplayOrientation(orientation);
|
||||||
} catch (RuntimeException e) {
|
} catch (RuntimeException e) {
|
||||||
LOG.log(WARNING, "Error setting display orientation", e);
|
LOG.log(WARNING, "Error setting display orientation", e);
|
||||||
@@ -216,7 +225,11 @@ public class CameraView extends SurfaceView implements SurfaceHolder.Callback,
|
|||||||
setFocusMode(params);
|
setFocusMode(params);
|
||||||
params.setFlashMode(FLASH_MODE_OFF);
|
params.setFlashMode(FLASH_MODE_OFF);
|
||||||
setPreviewSize(params);
|
setPreviewSize(params);
|
||||||
camera.setParameters(params);
|
try {
|
||||||
|
camera.setParameters(params);
|
||||||
|
} catch (RuntimeException e) {
|
||||||
|
LOG.log(WARNING, "Error setting best camera parameters", e);
|
||||||
|
}
|
||||||
return camera.getParameters();
|
return camera.getParameters();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -287,7 +300,7 @@ public class CameraView extends SurfaceView implements SurfaceHolder.Callback,
|
|||||||
|
|
||||||
@UiThread
|
@UiThread
|
||||||
private void logCameraParameters() {
|
private void logCameraParameters() {
|
||||||
if (LOG.isLoggable(INFO)) {
|
if (camera != null && LOG.isLoggable(INFO)) {
|
||||||
Parameters params = camera.getParameters();
|
Parameters params = camera.getParameters();
|
||||||
if (Build.VERSION.SDK_INT >= 15) {
|
if (Build.VERSION.SDK_INT >= 15) {
|
||||||
LOG.info("Video stabilisation enabled: "
|
LOG.info("Video stabilisation enabled: "
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import org.briarproject.bramble.api.nullsafety.ParametersNotNullByDefault;
|
|||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import static java.util.logging.Level.INFO;
|
import static java.util.logging.Level.INFO;
|
||||||
|
import static java.util.logging.Level.WARNING;
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
@MethodsNotNullByDefault
|
@MethodsNotNullByDefault
|
||||||
@@ -60,8 +61,12 @@ class QrCodeDecoder implements PreviewConsumer, PreviewCallback {
|
|||||||
@Override
|
@Override
|
||||||
public void onPreviewFrame(byte[] data, Camera camera) {
|
public void onPreviewFrame(byte[] data, Camera camera) {
|
||||||
if (camera == this.camera) {
|
if (camera == this.camera) {
|
||||||
Size size = camera.getParameters().getPreviewSize();
|
try {
|
||||||
new DecoderTask(data, size.width, size.height).execute();
|
Size size = camera.getParameters().getPreviewSize();
|
||||||
|
new DecoderTask(data, size.width, size.height).execute();
|
||||||
|
} catch (RuntimeException e) {
|
||||||
|
LOG.log(WARNING, "Error getting camera parameters.", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,7 +75,7 @@ class QrCodeDecoder implements PreviewConsumer, PreviewCallback {
|
|||||||
private final byte[] data;
|
private final byte[] data;
|
||||||
private final int width, height;
|
private final int width, height;
|
||||||
|
|
||||||
DecoderTask(byte[] data, int width, int height) {
|
private DecoderTask(byte[] data, int width, int height) {
|
||||||
this.data = data;
|
this.data = data;
|
||||||
this.width = width;
|
this.width = width;
|
||||||
this.height = height;
|
this.height = height;
|
||||||
|
|||||||
@@ -218,7 +218,7 @@ public class ShowQrCodeFragment extends BaseEventFragment
|
|||||||
statusView.setVisibility(VISIBLE);
|
statusView.setVisibility(VISIBLE);
|
||||||
status.setText(R.string.connecting_to_device);
|
status.setText(R.string.connecting_to_device);
|
||||||
task.connectAndRunProtocol(remotePayload);
|
task.connectAndRunProtocol(remotePayload);
|
||||||
} catch (IOException e) {
|
} catch (IOException | IllegalArgumentException e) {
|
||||||
// TODO show failure
|
// TODO show failure
|
||||||
Toast.makeText(getActivity(), R.string.qr_code_invalid,
|
Toast.makeText(getActivity(), R.string.qr_code_invalid,
|
||||||
LENGTH_LONG).show();
|
LENGTH_LONG).show();
|
||||||
|
|||||||
Reference in New Issue
Block a user