Skip to content

Commit

Permalink
Keep LED on until image is available
Browse files Browse the repository at this point in the history
  • Loading branch information
jeisfeld committed Jul 7, 2017
1 parent 1e77769 commit 156ac29
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,9 @@ else if (SystemUtil.isAppInstalled(Application.getResourceString(R.string.packag
PreferenceUtil.setAllHints(!showTips);
// always show tips for first use
PreferenceUtil.setSharedPreferenceBoolean(R.string.key_tip_firstuse, false);
// always show hint on max volume for external LED
PreferenceUtil.setSharedPreferenceBoolean(R.string.key_tip_external_flash, false);

PreferenceUtil.setSharedPreferenceBoolean(R.string.key_internal_initialized_hints, true);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ public static AudioTrack generateTone(final double freqHz, final int durationMs)
public static AudioTrack generateHighFreqTone(final int durationMs) {
int count = (int) (BITRATE * 2.0 * (durationMs / MILLIS_IN_SECOND)) & ~1;
short[] samples = new short[count];
for (int i = 0; i < count; i += 2) {
short sample = TONE_MAP[(i / 2) % 4]; // MAGIC_NUMBER
for (int i = 0; i < count; i += 2) { // MAGIC_NUMBER
short sample = TONE_MAP[(i / 4) % 4]; // MAGIC_NUMBER
samples[i] = sample;
samples[i + 1] = sample;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ public final void takePicture() {
}
}

mCamera.takePicture(mShutterCallback, null, mPhotoCallback);
mCamera.takePicture(mShutterCallback, mRawCallback, mPhotoCallback);
}

/**
Expand Down Expand Up @@ -432,10 +432,19 @@ public void onPictureTaken(final byte[] data, final Camera photoCamera) {
private final ShutterCallback mShutterCallback = new ShutterCallback() {
@Override
public void onShutter() {
mCameraCallback.onTakingPicture();
}
};

/**
* The callback called when pictures are taken.
*/
private final PictureCallback mRawCallback = new PictureCallback() {
@Override
public void onPictureTaken(final byte[] data, final Camera photoCamera) {
if (mUseExternalFlash && mExternalFlashBeep != null) {
mExternalFlashBeep.stop();
}
mCameraCallback.onTakingPicture();
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,10 @@ public void onError(@NonNull final CameraDevice cameraDevice, final int error) {
private final ImageReader.OnImageAvailableListener mOnImageAvailableListener = new ImageReader.OnImageAvailableListener() {
@Override
public void onImageAvailable(@NonNull final ImageReader reader) {
if (mUseExternalFlash && mExternalFlashBeep != null) {
mExternalFlashBeep.stop();
}

Image image = reader.acquireNextImage();
ByteBuffer buffer = image.getPlanes()[0].getBuffer();
byte[] data = new byte[buffer.remaining()];
Expand Down Expand Up @@ -352,9 +356,6 @@ else if (CaptureResult.CONTROL_AF_STATE_FOCUSED_LOCKED == afState
}
break;
case STATE_TAKING_PICTURE_END:
if (mUseExternalFlash && mExternalFlashBeep != null) {
mExternalFlashBeep.stop();
}
mCameraCallback.onTakingPicture();
mState = CameraState.STATE_PICTURE_TAKEN;
break;
Expand Down

0 comments on commit 156ac29

Please sign in to comment.