Loading app/src/main/java/net/sourceforge/opencamera/cameracontroller/CameraController2.java +29 −7 Original line number Diff line number Diff line Loading @@ -44,6 +44,7 @@ import android.view.Display; import android.view.Surface; import android.view.SurfaceHolder; import android.view.TextureView; import android.widget.Toast; import androidx.annotation.NonNull; import androidx.annotation.RequiresApi; Loading @@ -65,6 +66,8 @@ import java.util.Locale; import java.util.Queue; import java.util.concurrent.Executor; import foundation.e.camera.R; /** Provides support using Android 5's Camera 2 API * android.hardware.camera2.*. */ Loading Loading @@ -100,6 +103,8 @@ public class CameraController2 extends CameraController { private long min_exposure_time; private long max_exposure_time; private int toastCounter = 0; private final static int tonemap_log_max_curve_points_c = 64; private final static float [] jtvideo_values_base = new float[] { 0.00f, 0.00f, Loading Loading @@ -180,7 +185,7 @@ public class CameraController2 extends CameraController { private boolean previewIsVideoMode; private AutoFocusCallback autofocus_cb; private long autofocus_time_ms = -1; // time we set autofocus_cb to non-null private static final long autofocus_timeout_c = 250; // timeout for calling autofocus_cb (applies for both auto and continuous focus) private static final long autofocus_timeout_c = 500; // timeout for calling autofocus_cb (applies for both auto and continuous focus) private boolean capture_follows_autofocus_hint; private boolean ready_for_capture; private FaceDetectionListener face_detection_listener; Loading Loading @@ -8195,15 +8200,18 @@ public class CameraController2 extends CameraController { // need to check af_state != null, I received Google Play crash in 1.33 where it was null boolean focus_success = af_state != null && ( af_state == CaptureResult.CONTROL_AF_STATE_FOCUSED_LOCKED || af_state == CaptureResult.CONTROL_AF_STATE_PASSIVE_FOCUSED ); if( MyDebug.LOG ) { if( focus_success ) if( focus_success ) { Log.d(TAG, "autofocus success"); else } else { Log.d(TAG, "autofocus failed"); if( af_state == null ) onFocusFailed(); } if( af_state == null ) { Log.e(TAG, "continuous focus mode but af_state is null"); else } else { Log.d(TAG, "af_state: " + af_state); } } if( af_state == null ) { test_af_state_null_focus++; } Loading Loading @@ -8255,10 +8263,12 @@ public class CameraController2 extends CameraController { ) { boolean focus_success = af_state == CaptureResult.CONTROL_AF_STATE_FOCUSED_LOCKED || af_state == CaptureResult.CONTROL_AF_STATE_PASSIVE_FOCUSED; if( MyDebug.LOG ) { if( focus_success ) if( focus_success ) { Log.d(TAG, "onCaptureCompleted: autofocus success"); else } else { Log.d(TAG, "onCaptureCompleted: autofocus failed"); onFocusFailed(); } Log.d(TAG, "af_state: " + af_state); } state = STATE_NORMAL; Loading Loading @@ -8448,6 +8458,18 @@ public class CameraController2 extends CameraController { } } private void onFocusFailed() { // Show only if focus failed twice. if (toastCounter == 1) { Toast.makeText(context, R.string.preference_failed_focus_mode_message, Toast.LENGTH_SHORT).show(); toastCounter = 0; } else { toastCounter++; } } private void handleContinuousFocusMove(CaptureResult result) { Integer af_state = result.get(CaptureResult.CONTROL_AF_STATE); if( af_state != null && af_state == CaptureResult.CONTROL_AF_STATE_PASSIVE_SCAN && af_state != last_af_state ) { Loading app/src/main/res/values/strings.xml +1 −0 Original line number Diff line number Diff line Loading @@ -783,6 +783,7 @@ <string name="exposure_unlock">Unlock exposure</string> <string name="preference_nr_mode_low_light_message">Low light mode: please hold the camera steady</string> <string name="preference_failed_focus_mode_message">Please hold the camera steady for better photos.</string> <string name="photo_mode_panorama">Pano</string> <!-- keep short, as this shows in the popup menu; probably shouldn't be translated? --> <string name="photo_mode_panorama_full">Panorama</string> Loading Loading
app/src/main/java/net/sourceforge/opencamera/cameracontroller/CameraController2.java +29 −7 Original line number Diff line number Diff line Loading @@ -44,6 +44,7 @@ import android.view.Display; import android.view.Surface; import android.view.SurfaceHolder; import android.view.TextureView; import android.widget.Toast; import androidx.annotation.NonNull; import androidx.annotation.RequiresApi; Loading @@ -65,6 +66,8 @@ import java.util.Locale; import java.util.Queue; import java.util.concurrent.Executor; import foundation.e.camera.R; /** Provides support using Android 5's Camera 2 API * android.hardware.camera2.*. */ Loading Loading @@ -100,6 +103,8 @@ public class CameraController2 extends CameraController { private long min_exposure_time; private long max_exposure_time; private int toastCounter = 0; private final static int tonemap_log_max_curve_points_c = 64; private final static float [] jtvideo_values_base = new float[] { 0.00f, 0.00f, Loading Loading @@ -180,7 +185,7 @@ public class CameraController2 extends CameraController { private boolean previewIsVideoMode; private AutoFocusCallback autofocus_cb; private long autofocus_time_ms = -1; // time we set autofocus_cb to non-null private static final long autofocus_timeout_c = 250; // timeout for calling autofocus_cb (applies for both auto and continuous focus) private static final long autofocus_timeout_c = 500; // timeout for calling autofocus_cb (applies for both auto and continuous focus) private boolean capture_follows_autofocus_hint; private boolean ready_for_capture; private FaceDetectionListener face_detection_listener; Loading Loading @@ -8195,15 +8200,18 @@ public class CameraController2 extends CameraController { // need to check af_state != null, I received Google Play crash in 1.33 where it was null boolean focus_success = af_state != null && ( af_state == CaptureResult.CONTROL_AF_STATE_FOCUSED_LOCKED || af_state == CaptureResult.CONTROL_AF_STATE_PASSIVE_FOCUSED ); if( MyDebug.LOG ) { if( focus_success ) if( focus_success ) { Log.d(TAG, "autofocus success"); else } else { Log.d(TAG, "autofocus failed"); if( af_state == null ) onFocusFailed(); } if( af_state == null ) { Log.e(TAG, "continuous focus mode but af_state is null"); else } else { Log.d(TAG, "af_state: " + af_state); } } if( af_state == null ) { test_af_state_null_focus++; } Loading Loading @@ -8255,10 +8263,12 @@ public class CameraController2 extends CameraController { ) { boolean focus_success = af_state == CaptureResult.CONTROL_AF_STATE_FOCUSED_LOCKED || af_state == CaptureResult.CONTROL_AF_STATE_PASSIVE_FOCUSED; if( MyDebug.LOG ) { if( focus_success ) if( focus_success ) { Log.d(TAG, "onCaptureCompleted: autofocus success"); else } else { Log.d(TAG, "onCaptureCompleted: autofocus failed"); onFocusFailed(); } Log.d(TAG, "af_state: " + af_state); } state = STATE_NORMAL; Loading Loading @@ -8448,6 +8458,18 @@ public class CameraController2 extends CameraController { } } private void onFocusFailed() { // Show only if focus failed twice. if (toastCounter == 1) { Toast.makeText(context, R.string.preference_failed_focus_mode_message, Toast.LENGTH_SHORT).show(); toastCounter = 0; } else { toastCounter++; } } private void handleContinuousFocusMove(CaptureResult result) { Integer af_state = result.get(CaptureResult.CONTROL_AF_STATE); if( af_state != null && af_state == CaptureResult.CONTROL_AF_STATE_PASSIVE_SCAN && af_state != last_af_state ) { Loading
app/src/main/res/values/strings.xml +1 −0 Original line number Diff line number Diff line Loading @@ -783,6 +783,7 @@ <string name="exposure_unlock">Unlock exposure</string> <string name="preference_nr_mode_low_light_message">Low light mode: please hold the camera steady</string> <string name="preference_failed_focus_mode_message">Please hold the camera steady for better photos.</string> <string name="photo_mode_panorama">Pano</string> <!-- keep short, as this shows in the popup menu; probably shouldn't be translated? --> <string name="photo_mode_panorama_full">Panorama</string> Loading