Skip to content

Commit

Permalink
Fix continuous auto-focus
Browse files Browse the repository at this point in the history
When autoFocus is called in continuous modes, the camera focuses only once
and continuous focus does not work until auto focus is cancelled.

This could help with kloener#9 and definietly fixes focusing only once in
continuous mode.
  • Loading branch information
morckx committed Oct 10, 2020
1 parent 62a9c03 commit 2b6425b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/src/main/java/de/visorapp/visor/VisorActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ public void onStartTrackingTouch(SeekBar seekBar) {

@Override
public void onStopTrackingTouch(SeekBar seekBar) {

mVisorView.autoFocusCamera(); // will not be applied in continuous modes
}
};
/**
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/java/de/visorapp/visor/VisorSurface.java
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,6 @@ public void enableCamera() {
toggleCameraPreview();
}

autoFocusCamera();
if (mSharedPreferences.getBoolean(getResources().getString(R.string.key_preference_auto_torch), false)) {
turnFlashlightOn();
}
Expand Down Expand Up @@ -712,7 +711,7 @@ public void playActionSoundShutter() {
* It will autofocus just a single time.
*/
public void autoFocusCamera() {
if (mState != STATE_PREVIEW) return;
if (mState != STATE_PREVIEW || mCamera.getParameters().getFocusMode().contains("continuous")) return;

try {
mCamera.cancelAutoFocus();
Expand Down Expand Up @@ -790,6 +789,8 @@ public void toggleAutoFocusMode() {
if (currentMode.equals(FOCUS_MODE_AUTO)) {
Toast.makeText(VisorSurface.this.getContext(), R.string.text_autofocus_enabled, Toast.LENGTH_SHORT).show();
cameraParameters.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE);
// make sure that no focusing is in progress or CONTINUOUS mode will not work
mCamera.cancelAutoFocus();
} else {
Toast.makeText(VisorSurface.this.getContext(), R.string.text_autofocus_disabled, Toast.LENGTH_SHORT).show();
cameraParameters.setFocusMode(FOCUS_MODE_AUTO);
Expand Down

0 comments on commit 2b6425b

Please sign in to comment.