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

Android wrapper improvements #659

Merged
merged 24 commits into from Nov 14, 2023

Conversation

markusfisch
Copy link
Contributor

And finally some improvements we haven't taked about yet:

And allocate the Result object(s) on the C++ side, and only if
something was found.
Except `version` and `GTIN`, as requested.

`version` is about to be deprecated.
Now you can run this to publish the the library in your local
Maven repository:

	$ ./gradlew publishToMavenLocal

Then you can include the library in any project (on your machine)
by adding this to `dependencies` in `app/build.gradle`:

	implementation 'com.zxingcpp:zxingcpp:2.1.0'

Of course, for this to work you need to add `mavelLocal()` to your
`repositories` in your top level `build.gradle`:

	repositories {
		mavenLocal()
		…
	}

To publish the library in a public remote Maven repository, we
need to add the corresponding credentials.
Because the term "ZXingCpp" is more clear and there will probably be
write support some day, too.
Instead of an object field. This makes the API a little bit more
clear about side effects and also a bit more consistent.
Because ZXingCpp doesn't have any fields anymore. This way,
ZXingCpp is more clear to the user about possible side effects.
As we use the term "DecodeHints" in other wrappers and because
"Options" is a very general term. "DecodeHints" is more precise,
and it's immediately clear for what these options are.
With Android Studio for the latest style changes.
To use tabs for indentation like the sample app does.

There's no point in using a different indentation here.
Replace CR/LF by just LF, to match the rest of this project.
Add a space between slash and the first word like it's the
case with every other comment around here.
If that blank line between the immutable and mutable fields
is supposed to mean anything, `beeper` belongs to the first
group as it is immutable.
So DecodeHints can be reused between scans and does not need
to be allocated again.

This is of advantage when using `read()` with a video stream
because it avoids allocation in the hot path.
Can be generalized by using an additional function.
Copy link
Collaborator

@axxel axxel left a comment

Choose a reason for hiding this comment

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

@markusfisch thank you very much for your time spent on this.

@benjohnde If you have an opinion on the two comments I made regarding the use of optional types, please let us know.

Since there is `returnErrors` in `DecodeHints`, the `Result`
should contain a corresponding `error` member.
These members can never be null.
`time` and `position` can never be null now.
To also know the error type on the JVM.
If the result is not valid.

Also make `sequenceId` nullable, too.
Instead of returning null when no barcodes could be found.

While this change makes it easier to deal with a reading result,
it has the downside of needlessly allocating an empty ArrayList.
@axxel axxel merged commit ea74708 into zxing-cpp:master Nov 14, 2023
9 of 10 checks passed
@axxel
Copy link
Collaborator

axxel commented Nov 14, 2023

Progress. Awesome. :)

@markusfisch markusfisch deleted the android_wrapper_improvements branch February 27, 2024 10:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants