-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Allow more customization of the UI and allow portrait mode scanning. #18
Allow more customization of the UI and allow portrait mode scanning. #18
Conversation
…rious things like the scanner line and frame and also allows for portrait layout styles. Add toggles to the IntentIntegrator covering scanner line, beep, frame, successful decode overlay, and layout orientation. Extensive modifications to allow layouts to gracefully work in portrait mode. Added a custom class for the preview SurfaceView that will center the preview images instead of scaling them to weird proportions. Also broke up CaptureActivity some because it was FAR too monolithic and confusing.
…threading Fix the overlay result points so that they match up in portrait mode
…d fix a few little formatting things.
Thanks for all this work. From my first impression it looks good, but I'll need some time to check it through and test it properly. |
How to use it? I just set setOrientation(ScannerOptions.ORIENTATION_PORTRAIT) and got error "java.lang.IllegalArgumentException: Crop rectangle does not fit within image data." |
I'll need some more information. A code snippet of the layout you're passing in and what options your passing IntentIntegrator would be very helpful. I'm going to guess that you're either passing in a custom frame size that doesn't match up with your actual image size, or your preview image frame is super small. It could very well be my code as well, though. Hans Reichenbach [Description: https://lh6.googleusercontent.com/7IuXyDjrRWhSMCaf21d6-8DzMimRWdIBmklcy-jnU2yV_5ScngwPebTEREVp4lNRQfSDIhSQrtlDuyLgcqCV2nF0Q_pAToYlhmGCnHKLKf7DfAT7A_TnTkkNW4G1r3Sp5Q]http:https://www.okta.com/ [Description: https://www.okta.com/_media/email/Oktane14-banner_500.png]http:https://www.oktane14.com/ From: Kevin Liu <[email protected]mailto:[email protected]> How to use it? I just set setOrientation(ScannerOptions.ORIENTATION_PORTRAIT) and got error "java.lang.IllegalArgumentException: Crop rectangle does not fit within image data." Reply to this email directly or view it on GitHubhttps://github.com//pull/18#issuecomment-61223830. |
@hansreichenbach-okta Yes, I used a custom(/legacy) layout which is in zxing-android-minimal and only add one new code 'setOrientation'. BTW, could you just give me a example? I'll try to follow your example because I'm a new in zxing. |
Ahhh ok. Yeah I don't have any legacy devices to play with so wasn't able to test that side of things, it's very likely I broke something on accident. Do you have to use legacy? Pre 4.0 is only like 10% of the market now and falling fast. I'll work on getting you an example, I can't share my actual code because it's confidential. Hans Reichenbach [Description: https://lh6.googleusercontent.com/7IuXyDjrRWhSMCaf21d6-8DzMimRWdIBmklcy-jnU2yV_5ScngwPebTEREVp4lNRQfSDIhSQrtlDuyLgcqCV2nF0Q_pAToYlhmGCnHKLKf7DfAT7A_TnTkkNW4G1r3Sp5Q]http:https://www.okta.com/ From: Kevin Liu <[email protected]mailto:[email protected]> @hansreichenbach-oktahttps://github.com/hansreichenbach-okta Yes, I used a custom(/legacy) layout which is in zxing-android-minimal and only add one new code 'setOrientation'. BTW, could you just give me a example? I'll try to follow your example because I'm a new in zxing. Reply to this email directly or view it on GitHubhttps://github.com//pull/18#issuecomment-61436472. |
@hansreichenbach-okta My device is Nexus5, but yes, I include the legacy-lib in build.gradle. |
@@ -357,7 +468,7 @@ public final void initiateScan() { | |||
*/ | |||
public Intent createScanIntent() { | |||
Intent intentScan = new Intent(activity, getCaptureActivity()); | |||
intentScan.setAction("com.google.zxing.client.android.SCAN"); | |||
intentScan.setAction("com.google.zxing.client.android.SCAN"); //TODO is this secure? Might be vulnerable to attack |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The intent is specifically initialized with the capture activity, so it shouldn't be vulnerable. The action is required somewhere in CaptureActivity (legacy from official ZXing code).
I started testing this now. Initial comments:
|
Ok, I'll move the changed files over no problem. And good catch with the setWide thing, I didn't even notice that method when I was working on this before. It doesn't make any sense to do those calculations there and it makes bad assumptions because of the old method of everything being basically hardcoded on working in full-screen layout mode only. I'll work on moving them to a better spot. |
Thanks for the work. The ability to set the orientation is now partially available in the 2.3 release, as well as in the 3.x branch (in a different form). |
There are a few more things that I want to fix and a few things that I haven't fully tested but this is a very workable version so I figured I would go ahead and make an initial PR to get some thoughts and opinions. It is a rather large set of changes, so it's better to get multiple eyes on this sort of thing.