|
| 1 | +# ZXing Fragment Library |
| 2 | + |
| 3 | +This library allows you to embed a Barcode scanner as a Fragment. |
| 4 | + |
| 5 | +Most of the code was taken from the official [ZXing repository](https://code.google.com/p/zxing/), this is basically a re-implementation of CaptureActivity.java. |
| 6 | + |
| 7 | +This was also inspired by another similar library, [barcodefragmentlib](https://code.google.com/p/barcodefragmentlib/). |
| 8 | + |
| 9 | +## WARNING |
| 10 | + |
| 11 | +I'm currently updating this library, I've updated the original ZXing sources to the latest version and there might be some incompatibilities with older versions of Android. |
| 12 | + |
| 13 | +Please browse the ```before-rebuild``` branch to get the previous version. |
| 14 | + |
| 15 | +There are some bugs that prevent the scanning in portrait mode (especially with 1D codes, QR and others should be ok). |
| 16 | + |
| 17 | +## Goals |
| 18 | + |
| 19 | +Here are the basic guidelines for this project. As always, suggestions are appreciated :) |
| 20 | + |
| 21 | +* Provide a simple library to scan codes using ZXing's core library. |
| 22 | +* Be compatible with Android 2.1 and up. |
| 23 | +* Work out of the box (or almost). |
| 24 | +* Facilitate customization and/or configuration. |
| 25 | + |
| 26 | +## Usage |
| 27 | + |
| 28 | +1. Add the library as a module dependency to your app. |
| 29 | +2. Add the ZXing core library (the jar is included in libs/zxing-core-2.3.jar) |
| 30 | +3. Add the following permissions to your AndroidManifest.xml |
| 31 | +```xml |
| 32 | + <uses-permission android:name="android.permission.CAMERA" /> |
| 33 | + <uses-feature android:name="android.hardware.camera" /> |
| 34 | + <uses-feature android:name="android.hardware.camera.autofocus" /> |
| 35 | + <uses-feature android:name="android.hardware.camera.flash" /> |
| 36 | +``` |
| 37 | + |
| 38 | +4. Extend the BarCodeScannerFragment class and add a callback somewhere: |
| 39 | + |
| 40 | + ```java |
| 41 | + this.setmCallBack(new BarCodeScannerFragment.IResultCallback() { |
| 42 | + @Override |
| 43 | + public void result(Result lastResult) { |
| 44 | + Log.v("zxingfragmentlib", lastResult.toString()); |
| 45 | + } |
| 46 | + }); |
| 47 | + ``` |
| 48 | +5. Enjoy! |
| 49 | + |
| 50 | +A sample activity is included, look at SampleActivity.java, SampleFragment.java and sample_activity.xml to get an idea. |
| 51 | + |
| 52 | + |
| 53 | +## Contributing |
| 54 | + |
| 55 | +Any code improvements and bug reports are appreciated, just submit a pull request or open an issue. |
| 56 | + |
| 57 | +## TODO |
| 58 | + |
| 59 | +* Add a LICENSE file (Apache 2.0 ?) |
| 60 | +* Remove unused XMLs |
| 61 | +* Remove PreferencesActivity |
| 62 | +* ~~Add a gradle build file~~ |
| 63 | +* Add front-camera selector |
| 64 | +* Add compiler jar/aar file. |
| 65 | + |
| 66 | +## Author |
| 67 | + |
| 68 | +Jaime Oyarzun <jaime@welcu.com> |
| 69 | + |
| 70 | +The original ZXing project is at https://github.com/zxing/zxing |
0 commit comments