Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable macro mode #4

Open
ghost opened this issue Sep 15, 2015 · 3 comments
Open

Enable macro mode #4

ghost opened this issue Sep 15, 2015 · 3 comments

Comments

@ghost
Copy link

ghost commented Sep 15, 2015

Hello

on the S3 jellybean detection does not work because camera can not focus close enough.

Here I added a checkbox in the main view after Seekbar

    <CheckBox
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Macro"
        android:id="@+id/btnMacro"
        android:layout_above="@+id/CameraZoomControls"
        android:layout_centerHorizontal="true" />

Then I added code in CameraView to handle the checkbox

    public void setMacroControl(CheckBox macroControl)
    {
        _macroControl = macroControl;
        _macroControl.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                Camera.Parameters params = mCamera.getParameters();
                List<String> FocusModes = params.getSupportedFocusModes();
                if (isChecked) {
                    if (FocusModes != null && FocusModes.contains(Camera.Parameters.FOCUS_MODE_MACRO)) {
                        params.setFocusMode(Camera.Parameters.FOCUS_MODE_MACRO);
                    }
                } else {
                    if (FocusModes != null && FocusModes.contains(Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO)) {
                        params.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO);
                    } else if (FocusModes != null && FocusModes.contains(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE)) {
                        params.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE);
                    }

                }
                mCamera.setParameters(params);
            }
        });
    }

it is enabled in main activity with:

_resistorCameraView.setMacroControl((CheckBox) findViewById(R.id.btnMacro));

It will be very useful.

@thegouger
Copy link
Owner

Nice! If you make a pull request, I can merge these changes in.

@ghost
Copy link
Author

ghost commented Sep 15, 2015

you can also use some old fashioned copy-paste! I dont want to fork and all for
10 code lines :)

This code just has to be added, there is nothing to remove.

@thegouger
Copy link
Owner

Heh, touché

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant