Skip to content
This repository has been archived by the owner on Jan 18, 2022. It is now read-only.

Commit

Permalink
v0.2.0; add burst support, default to 5;
Browse files Browse the repository at this point in the history
Signed-off-by: Jerry Chen <jerryc05@qq.com>
  • Loading branch information
Jerry Chen committed Jul 16, 2019
1 parent cdf520e commit 33a3a9f
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 50 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ android {
minSdkVersion 16
targetSdkVersion 29
versionCode 1
versionName "0.1.3"
versionName "0.2.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
resConfigs "xxhdpi"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,6 @@ private static void openCamera1(final Context context) {
mCamera = Camera.open(cameraID);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1)
mCamera.enableShutterSound(false);

// final Camera.Parameters mCameraParameters = mCamera.getParameters();
// final List<Camera.Size> sizes = mCameraParameters.getSupportedPictureSizes();
// final Camera.Size mSize = Collections.max(sizes, new Comparator<Camera.Size>() {
// @Override
// public int compare(Camera.Size prev, Camera.Size next) {
// final int width = prev.width - next.width;
// return width != 0 ? width
// : prev.height - next.height;
// }
// });
// mCameraParameters.setPictureSize(mSize.width, mSize.height);
// mCamera.setParameters(mCameraParameters);
} catch (Exception e) {
UserInterface.showExceptionToNotification(
e.toString(), "openCamera1()", context);
Expand All @@ -70,8 +57,12 @@ private static void captureCamera1(final Context context) {
try {
mCamera.setPreviewTexture(new SurfaceTexture(-1));
mCamera.startPreview();
mCamera.takePicture(null, null,
getJpegPictureCallback(context));

for (int i = 0; i < imageCount; i++) {
mCamera.takePicture(null, null,
getJpegPictureCallback(context));
Thread.sleep(100);
}

} catch (Exception e) {
closeCamera1(mCamera);
Expand All @@ -95,7 +86,7 @@ public void onPictureTaken(byte[] data, Camera camera) {

@SuppressWarnings("WeakerAccess")
static void closeCamera1(Camera camera) {
if(BuildConfig.DEBUG)
if (BuildConfig.DEBUG)
Log.d(TAG, "closeCamera1: ");

camera.stopPreview();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,12 @@ public void onConfigured(CameraCaptureSession cameraCaptureSession) {
Log.d(TAG, "mCaptureStillImageStateCallback#onConfigured: ");
try {
mCameraCaptureSession = cameraCaptureSession;
cameraCaptureSession.capture(getStillImageCaptureRequest(context),
getCaptureCallback(), null);

for (int i = 0; i < imageCount; i++) {
cameraCaptureSession.capture(getStillImageCaptureRequest(context),
getCaptureCallback(), null);
Thread.sleep(100);
}

} catch (final Exception e) {
UserInterface.showExceptionToNotification(e.toString(),
Expand Down Expand Up @@ -237,7 +241,7 @@ static CaptureRequest getStillImageCaptureRequest(final Context context)
((Activity) context).getWindowManager()
.getDefaultDisplay().getRotation()));
else
mCaptureRequestBuilder.set(CaptureRequest.JPEG_ORIENTATION,270);
mCaptureRequestBuilder.set(CaptureRequest.JPEG_ORIENTATION, 270);

return mCaptureRequestBuilder.build();
}
Expand Down Expand Up @@ -295,34 +299,6 @@ public void onCaptureCompleted(CameraCaptureSession session,
if (BuildConfig.DEBUG)
Log.d(TAG, "mCaptureCallback#onCaptureCompleted: ");

// final CaptureRequest.Builder mCaptureRequestBuilder;
// try {
// mCaptureRequestBuilder = mCameraDevice
// .createCaptureRequest(CameraDevice.TEMPLATE_MANUAL);
// mCaptureRequestBuilder.set(
// CaptureRequest.CONTROL_AE_MODE,
// CaptureRequest.CONTROL_AE_MODE_OFF
// );
// mCaptureRequestBuilder.set(
// CaptureRequest.CONTROL_AE_PRECAPTURE_TRIGGER,
// CaptureRequest.CONTROL_AE_PRECAPTURE_TRIGGER_IDLE
// );
// mCaptureRequestBuilder.set(
// CaptureRequest.CONTROL_AF_MODE,
// CameraMetadata.CONTROL_AF_MODE_OFF
// );
// mCaptureRequestBuilder.set(
// CaptureRequest.CONTROL_AF_TRIGGER,
// CameraMetadata.CONTROL_AF_TRIGGER_CANCEL
// );
//// mCaptureRequestBuilder.addTarget(getCaptureImageReader().getSurface());
// mCaptureRequestBuilder.addTarget(getPreviewImageReader().getSurface());
//
// session.capture(mCaptureRequestBuilder.build(),
// null, null);
// } catch (Exception e) {
// UserInterface.showExceptionToDialog(activity, e);
// }
closeCamera2();
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public abstract class CameraBaseAPIClass {
private static final boolean canUseCamera2 =
Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP;
public static boolean isFront = true;
static int imageCount = 5;

@SuppressWarnings("unused")
public static void getImageFromDefaultCamera(final Context context,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import jerryc05.unlockme.receivers.MyDeviceAdminReceiver;

import static jerryc05.unlockme.helpers.UserInterface.notifyToForegroundService;
import static jerryc05.unlockme.helpers.camera.CameraBaseAPIClass.getImageFromDefaultCamera;

public class ForegroundService extends Service {

Expand Down Expand Up @@ -57,9 +58,9 @@ public int onStartCommand(Intent intent, int flags, int startId) {
@Override
public void run() {
if (ACTION_UPDATE_NOTIFICATION.equals(intent.getAction()))
UserInterface.notifyToForegroundService(ForegroundService.this);
notifyToForegroundService(ForegroundService.this);
else
CameraBaseAPIClass.getImageFromDefaultCamera(
getImageFromDefaultCamera(
ForegroundService.this, true);
}
});
Expand Down

0 comments on commit 33a3a9f

Please sign in to comment.