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

Scanning Window Size Issue #130

Closed
isaacbdawson opened this issue Jul 29, 2014 · 33 comments
Closed

Scanning Window Size Issue #130

isaacbdawson opened this issue Jul 29, 2014 · 33 comments

Comments

@isaacbdawson
Copy link

The scan window on the galaxy s5 is just ridiculous.
Any ideas how to fix this?

screenshot_2014-07-29-14-47-58

@teo-sk
Copy link

teo-sk commented Jul 30, 2014

This is a real issue for larger screens. I guess it's a problem deeper, i.e. in the zxing library, so don't know what could be done here.. But maybe there is some configuration available I don't know about? I would love to see a solution for this.

@Dbuggerx
Copy link

I guess that changing the "MAX_FRAME_WIDTH" and "MAX_FRAME_HEIGHT" in "CameraManager.java" (lines 44 and 45 - https://github.com/wildabeast/BarcodeScanner/blob/master/src/android/LibraryProject/src/com/google/zxing/client/android/camera/CameraManager.java) should solve this one.

@isaacbdawson
Copy link
Author

Just wanted to say thanks!
That did indeed work, I doubled the max values and was even able to scan a test vin barcode (I'll try it on an actual vehicle tomorrow).
I'm curious if there is a reason not just shove the max values way up, or if that causes other issues.

@Dbuggerx
Copy link

@isaacbdawson I'm glad I was able to help!

@teo-sk
Copy link

teo-sk commented Jul 31, 2014

It's probably a stupid question, but how can I rebuild the zxing dependency? I changed the values in my fork of this plugin, re-added the plugin, but the frame is still 600x400. Thanks in advance.

@isaacbdawson
Copy link
Author

Not a stupid question. I had the same issue, as I had never built (or re-built) a library project before.

So assuming you have the Android SDK and tools (ie: ant) then what you need to do is go to the directory:

yourpoject\plugins\com.phonegap.plugins.barcodescanner\src\android\LibraryProject

you'll need to put a local.properties file in this folder, or make one, it only needs one line:
sdk.dir=path/to/your/android/sdk

then assuming you have all the correct build tools and api packages (i did not, had to open my sdk manager and install build tools 19.1 and api 17) you would just need to run:
ant release

which will build the executable jar, which for me showed up as:
yourpoject\plugins\com.phonegap.plugins.barcodescanner\src\android\LibraryProject\bin\classes.jar

so rename it to: com.google.zxing.client.android.captureactivity.jar
and put it under: yourpoject\plugins\com.phonegap.plugins.barcodescanner\src\android\

also, to avoid removing/re-adding the platform (to redeploy the plugin) i also copied the file to:
yourproject\platforms\android\libs\com.google.zxing.client.android.captureactivity.jar

then just built the project.

just fyi, i'm using cordova (cli) on a windows machine, your steps might vary.

@Dbuggerx
Copy link

I used another approach.
I created an Android Studio project from the "Library Project".
Then I compiled a ".aar" file, and extracted the jar file from it.
Here's some reference: http://geekgarage.dad3zero.net/create-a-standalone-library-with-android-studio/

@teo-sk
Copy link

teo-sk commented Aug 4, 2014

Thank you very much, it worked.

@ralfery
Copy link

ralfery commented Aug 11, 2014

@isaacbdawson could you nicely share the .jar file you have built? Forgive my being a layman of this. (:

@isaacbdawson
Copy link
Author

Sure.

http://bit.ly/1svcyzC

@zonetti
Copy link

zonetti commented Aug 11, 2014

@isaacbdawson thank you. It worked :)

@ralfery
Copy link

ralfery commented Aug 11, 2014

Thanks isaacbdawson. I tried and built with your jar file.
Strangely the scan window doesn't seem to enlarge.

I also struggled to compile a version by my own (first time in my life to build a java) with following setup, but unluckily with still the small scan window.

CameraManager.java:
private static final int MIN_FRAME_WIDTH = 480;
private static final int MIN_FRAME_HEIGHT = 480;
private static final int MAX_FRAME_WIDTH = 1000;
private static final int MAX_FRAME_HEIGHT = 750;

@isaacbdawson
Copy link
Author

The only other thing I can think of to try would be to manually copy the jar file to:
yourproject\platforms\android\libs
then build

@ralfery
Copy link

ralfery commented Aug 11, 2014

@isaacbdawson Tried overwriting without any change. Then i performed
project-dir>cordova platform remove android
project-dir>cordova platform add android
project-dir>cordova run
and haha it works. High-five there!

@GTGeek88
Copy link

@isaacbdawson Could the .jar file work with PhoneGap Build? It appears there are solutions to the orientation issue and the scan area size, but they have not been implemented in the plugin for PhoneGap Build.

@isaacbdawson
Copy link
Author

@GTGeek88 I have not tried it myself, but you could certainly give it a shot.

@GTGeek88
Copy link

No, I can't, actually. The plugins used in PhoneGap Build are not controlled by developers. They are picked, approved, and implemented into the PhoneGap Build process by the PhoneGap folks, not you or me.

@isaacbdawson
Copy link
Author

Apologies, I thought you were referring to: https://github.com/phonegap-build/BarcodeScanner

@radumvlad
Copy link

Is it any update on this issue regarding PhoneGap Build applications?

As I can see now Adobe even put a subscription over those who want to upload a plugin, so what I was thinking(uploading the library after changing the limits and building the jar) won't work unless I pay them(why would you pay for helping them have more plugins?)

@quape
Copy link

quape commented Nov 7, 2014

Crazy. Docs are crap. Support is crap. And now they want money for plugins?

@radumvlad
Copy link

also...why is this marked as closed? I mean, there is a way to do it, but you have to change the freakin' plugin...

i don't get it, why is it so hard to change from pixels to percents so it would work on every device?

@isaacbdawson
Copy link
Author

This is marked as closed because I opened the issue, and the solution resolved the issue for me, so I closed it. In my case I am using Cordova, so the PhoneGap Build issues would be a separate issue altogether.

@radumvlad
Copy link

yes, but that doesn't solve the plugin itself, it's just a fix in which you just have to rebuild the plugin with the sources...

@jrameriz
Copy link

jrameriz commented Jan 6, 2015

they have been increased but not for phonegap build plugin

@jrameriz
Copy link

I've changed CameraManager.java to:
private static final int MIN_FRAME_WIDTH = 480;
private static final int MIN_FRAME_HEIGHT = 480;
private static final int MAX_FRAME_WIDTH = 1000;
private static final int MAX_FRAME_HEIGHT = 750;
after i go and use the run command locally on android device but the window is still small. any ideas?
this was a fresh install, added plugin (edited the cameramanager.java), and than run and small little window again!

@radumvlad
Copy link

i think you need to rebuild the android library after changing this values

it would be nice to control this values from PhoneGap :)

@48design
Copy link

It would be realy nice if it were possible to set this via an option in the config.xml when building with PhoneGap Build. We don't use the CLI at the moment, so we're not able to modify and recompile the library.

@jrameriz
Copy link

@radumvlad I deleted the the android library than ran it! and nothing changed!
@48design I'm in the same boat, frustration!

@heberfabiano
Copy link

Guys, too late for a question?

I tried the solution that @isaacbdawson provided but I'm getting Multiple dex files error when trying to run "ionic build android".

[dx] UNEXPECTED TOP-LEVEL EXCEPTION:
   [dx] com.android.dex.DexException: Multiple dex files define Lcom/squareup/okhttp/Address;
   [dx]     at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
   [dx]     at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
   [dx]     at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
   [dx]     at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
   [dx]     at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
   [dx]     at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454)
   [dx]     at com.android.dx.command.dexer.Main.runMonoDex(Main.java:303)
   [dx]     at com.android.dx.command.dexer.Main.run(Main.java:246)
   [dx]     at com.android.dx.command.dexer.Main.main(Main.java:215)

Any idea about what I'm doing wrong?

Thank you!

@phpprousa
Copy link

For those of us creating an HTML5 app, then wrapping with PhoneGap build, any easy way to add this support for larger scan windows?

@itsmebhavin
Copy link

You can include .jar file which I have created with bigger viewfinder area.
https://github.com/bapatel1/zxing-barcode-scanner-bigger-viewfinder

@eramirez1983
Copy link

I change the size from CameraManager.java and later I cleaned both proyects and I found a problem with the size of the screen, I Just wanna take all size, but when I'm testing I found which I put the cellphone on landscape take the correct size but if I put to the horizontal position not work correctly, this is because take the size of the screen before to invoke camera scanner, I made a little change like this...

    Display display = getWindowManager().getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    int width = size.x;
    int height = size.y;

    // go to fullscreen scan
    Intent intent = new Intent("com.google.zxing.client.android.SCAN");
    intent.putExtra("SCAN_WIDTH", height);
    intent.putExtra("SCAN_HEIGHT", width);
    intent.putExtra("PROMPT_MESSAGE", "Enfoque un código de barras en el interior del el lector para escanearlo.");
    intent.putExtra("SCAN_MODE", "ONE_D_MODE");//ONE_D_MODE
    startActivityForResult(intent, SCANNER_REQUEST_CODE);

I only invert the values of width and height, I made this because this is real size if you want take all size from the screen, when you invoke scanner always starts on landscape position, I hope this helps, regards.

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

No branches or pull requests