Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

[camera] android-rework part 4: Android flash and zoom features #3798

Merged

Conversation

mvanbeusekom
Copy link
Contributor

Adds flash and zoom features containing the implementation to handle flash and zoom via the Android Camera2 API.

This is the forth PR in a series of pull-requests which will gradually introduce changes from PR #3651, making it easier to review the code (as discussed with @stuartmorgan).

If you had to change anything in the flutter/tests repo, include a link to the migration guide as per the breaking change policy.

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide and the C++, Objective-C, Java style guides.
  • I signed the CLA.
  • The title of the PR starts with the name of the plugin surrounded by square brackets, e.g. [shared_preferences]
  • I listed at least one issue that this PR fixes in the description above.
  • I updated pubspec.yaml with an appropriate new version according to the pub versioning philosophy.
    • Since this will be a series of pull-requests I will update the version in the last PR of the series.
  • I updated CHANGELOG.md to add a description of the change.
    • Since this will be a series of pull-requests I will update the version in the last PR of the series.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test exempt.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@google-cla
Copy link

google-cla bot commented Apr 8, 2021

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

@acoutts
Copy link
Contributor

acoutts commented Apr 8, 2021

@googlebot I consent.

@google-cla google-cla bot added cla: yes and removed cla: no labels Apr 8, 2021
@mvanbeusekom mvanbeusekom force-pushed the camera-android/flash_zoom_features branch from 6868a50 to 3402d95 Compare April 20, 2021 11:48
import androidx.annotation.Nullable;
import androidx.core.math.MathUtils;

public final class CameraZoom {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Javadoc for the class itself and its public members.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

I have renamed this class to ZoomUtils and made it package private. Also I simplified the class moving all state into the ZoomLevelFeature class where it belongs.

This reduces method chains and makes the whole design a lot simpler.

}

this.maxZoom =
((maxZoom == null) || (maxZoom < DEFAULT_ZOOM_FACTOR)) ? DEFAULT_ZOOM_FACTOR : maxZoom;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does the default change the max, rather than the max changing the default?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This statement is part of the constructor where one can pass in a parameter specifying the maximum zoom level. However if the specified maximum zoom level if not specified or below the minimum zoom level (which is named incorrectly and something I will fix), the maximum zoom level will be set equal to the minimum zoom level.

return null;
}

final float newZoom = MathUtils.clamp(zoom, DEFAULT_ZOOM_FACTOR, this.maxZoom);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the default a minimum?

Copy link
Contributor Author

@mvanbeusekom mvanbeusekom May 19, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The constant DEFAULT_ZOOM_FACTOR is named incorrect and should have been named MIN_ZOOM_LEVEL. This is something I will correct.

import io.flutter.plugins.camera.CameraProperties;
import io.flutter.plugins.camera.features.CameraFeature;

/** Exposure offset makes the image brighter or darker. */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like copypasta from another class.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed and documented the other public members in this class.

@mvanbeusekom
Copy link
Contributor Author

@stuartmorgan I have gone through your feedback and applied the necessary changes. I would appreciate it if you could have another look.

Copy link
Contributor

@stuartmorgan-g stuartmorgan-g left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with one comment nit.

}

/**
* Gets the maximum supported zoom level.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docs on these two methods are swapped.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent catch, I swapped the documentation around so they match the correct method.

@mvanbeusekom mvanbeusekom merged commit 2576d6b into flutter:master May 25, 2021
@mvanbeusekom mvanbeusekom deleted the camera-android/flash_zoom_features branch May 25, 2021 19:03
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request May 25, 2021
fotiDim pushed a commit to fotiDim/plugins that referenced this pull request Sep 13, 2021
…ter#3798)

* Base classes to support Android camera features

Co-authored-by: Andrew Coutts <[email protected]>

* Fixed formatting

* Applied feedback from PR

* Added Android Flash and Zoom features

Co-authored-by: Andrew Coutts <[email protected]>

* Use mockito-inline

* Fix formatting issue

* Processed feedback on pull request.

* Fixed formatting

* Fixed formatting

* Swap docs to match correct methods

Co-authored-by: Andrew Coutts <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants