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

Allow more customization of the UI and allow portrait mode scanning. #18

Closed

Conversation

hansreichenbach-okta
Copy link

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.

…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
@rkistner
Copy link
Member

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.

@lkv1988
Copy link

lkv1988 commented Oct 31, 2014

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."

@hansreichenbach-okta
Copy link
Author

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
Software Engineer | Oktahttps://www.okta.com
e: [email protected]:[email protected]

[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]>
Reply-To: embarkmobile/zxing-android-minimal <[email protected]mailto:[email protected]>
Date: Thursday, October 30, 2014 at 11:28 PM
To: embarkmobile/zxing-android-minimal <[email protected]mailto:[email protected]>
Cc: Hans Reichenbach <[email protected]mailto:[email protected]>
Subject: Re: [zxing-android-minimal] Allow more customization of the UI and allow portrait mode scanning. (#18)

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.

@lkv1988
Copy link

lkv1988 commented Nov 3, 2014

@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.

@hansreichenbach-okta
Copy link
Author

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
Software Engineer | Oktahttps://www.okta.com
e: [email protected]:[email protected]

[Description: https://lh6.googleusercontent.com/7IuXyDjrRWhSMCaf21d6-8DzMimRWdIBmklcy-jnU2yV_5ScngwPebTEREVp4lNRQfSDIhSQrtlDuyLgcqCV2nF0Q_pAToYlhmGCnHKLKf7DfAT7A_TnTkkNW4G1r3Sp5Q]http:https://www.okta.com/

From: Kevin Liu <[email protected]mailto:[email protected]>
Reply-To: embarkmobile/zxing-android-minimal <[email protected]mailto:[email protected]>
Date: Sunday, November 2, 2014 at 8:04 PM
To: embarkmobile/zxing-android-minimal <[email protected]mailto:[email protected]>
Cc: Hans Reichenbach <[email protected]mailto:[email protected]>
Subject: Re: [zxing-android-minimal] Allow more customization of the UI and allow portrait mode scanning. (#18)

@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.

@lkv1988
Copy link

lkv1988 commented Nov 4, 2014

@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
Copy link
Member

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).

@rkistner
Copy link
Member

I started testing this now. Initial comments:

  1. The files from src-orig and res-orig are copied directly from the upstream ZXing project, and should not be modified. Instead, move it to the src and res folders.
  2. The "Custom Layout" in the sample app crashes with the "java.lang.IllegalArgumentException: Crop rectangle does not fit within image data." error. It looks like the rectangle is drawn in the wrong place. It seems to be triggered because of the setWide() call, rather than because of the custom layout. The logic should perhaps be moved to the activity instead of the IntentIntegrator.

@hansreichenbach-okta
Copy link
Author

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.

@rkistner
Copy link
Member

rkistner commented May 3, 2015

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).

@rkistner rkistner closed this May 3, 2015
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

3 participants