OpenNoteScanner icon indicating copy to clipboard operation
OpenNoteScanner copied to clipboard

crash when writing camera settings

Open JLOrwell opened this issue 7 years ago • 1 comments

your project is specifically setting the camera to FOCUS_MODE_CONTINUOUS_PICTURE, without a check to see if the camera allows it. We are using Galaxy tab Es and they don't support that. This causes an exception when trying to set camera settings. I suggest this code change:

 PackageManager pm = getPackageManager();
       if (pm.hasSystemFeature(PackageManager.FEATURE_CAMERA_AUTOFOCUS)) {
           //following code prevents crash on newer tablets -jdl
           List<String> focusModes = param.getSupportedFocusModes();
           if (focusModes.contains("auto"))
               param.setFocusMode(Camera.Parameters.FOCUS_MODE_AUTO);
           else if (focusModes.contains("continuous-picture"))
               param.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE);
           Log.d(TAG, "enabling autofocus");
       } else {
           mFocused = true;
           Log.d(TAG, "autofocus not available");
       }
    

JLOrwell avatar Aug 10 '18 20:08 JLOrwell

Hi @JLOrwell , thank you for your interest on Open Note Scanner.

Can you do a pull request with this change over the current head code? I will accept it right after the CI test.

Best regards, Claudemir

allgood avatar Sep 21 '18 23:09 allgood