[
  {
    "path": ".gitignore",
    "content": "## Adopted from https://github.com/github/gitignore/blob/master/Android.gitignore\n\n# Built application files\n*.apk\n*.ap_\n\n# Files for the Dalvik VM\n*.dex\n\n# Java class files\n*.class\n\n# Generated files\nbin/\ngen/\n\n# Local configuration file (sdk path, etc)\nlocal.properties\n# Our Custom properties file\nconfig.properties\n\n# Eclipse generated files\n.classpath\n.project\n.directory\n.settings/\n.metadata/\n\n# Idea generated files\n*.iml\n.idea\nout\n\n# Netbeans generated files\nprivate\nnbandroid\n\n# MacOSX files\n.DS_Store\n\n# Maven\ntarget\ngen-external-apklibs\n"
  },
  {
    "path": "README.md",
    "content": "ATTENTION!\n==========\n\nThis project will no longer be maintained. Moving forward, I am going to spend my time on development of this project here: https://github.com/dm77/barcodescanner\n\n--------------------------------------------------------------------------------------\n\nThis is an Android library project that simplifies the usage of ZBar Android SDK (http://sourceforge.net/projects/zbar/files/AndroidSDK/) for scanning bar codes from within your Android application.\n\n### How to use?\n\n1. Download this project and add it as a library project to your existing Android app.\n2. Open the AndroidManifest.xml file in your project and add these lines under the manifest element:\n<pre>\n&lt;uses-permission android:name=\"android.permission.CAMERA\"/&gt;\n&lt;uses-feature android:name=\"android.hardware.camera\" /&gt;\n</pre>\n3. Within the application element, add the activity declaration:\n<pre>\n&lt;activity android:name=\"com.dm.zbar.android.scanner.ZBarScannerActivity\"\n            android:screenOrientation=\"landscape\"\n            android:label=\"@string/app_name\" /&gt;\n</pre>\n4. Now from inside your Android application, you can launch the ZBarScanner from any activity using this intent:\n\n```java\nIntent intent = new Intent(this, ZBarScannerActivity.class);\nstartActivityForResult(intent, ZBAR_SCANNER_REQUEST);\n```\n\nTo receive the results of the SCAN, add this method to your activity:\n\n```java\n@Override\nprotected void onActivityResult(int requestCode, int resultCode, Intent data)\n{    \n    if (resultCode == RESULT_OK) \n    {\n        // Scan result is available by making a call to data.getStringExtra(ZBarConstants.SCAN_RESULT)\n        // Type of the scan result is available by making a call to data.getStringExtra(ZBarConstants.SCAN_RESULT_TYPE)\n        Toast.makeText(this, \"Scan Result = \" + data.getStringExtra(ZBarConstants.SCAN_RESULT), Toast.LENGTH_SHORT).show();\n        Toast.makeText(this, \"Scan Result Type = \" + data.getIntExtra(ZBarConstants.SCAN_RESULT_TYPE, 0), Toast.LENGTH_SHORT).show();\n        // The value of type indicates one of the symbols listed in Advanced Options below.\n    } else if(resultCode == RESULT_CANCELED) {\n        Toast.makeText(this, \"Camera unavailable\", Toast.LENGTH_SHORT).show();\n    }\n}\n```  \n\n### Advanced Options\nIf you are interested in scanning only QR codes, you can specify the SCAN mode in the intent as shown below:\n```java\nIntent intent = new Intent(this, ZBarScannerActivity.class);\nintent.putExtra(ZBarConstants.SCAN_MODES, new int[]{Symbol.QRCODE});\nstartActivityForResult(intent, ZBAR_SCANNER_REQUEST);\n```\n\nYou can pass an array or integers for SCAN_MODES. The exact values are specified in net.sourceforge.zbar.Symbol class:\n```java\npublic static final int NONE = 0;\npublic static final int PARTIAL = 1;\npublic static final int EAN8 = 8;\npublic static final int UPCE = 9;\npublic static final int ISBN10 = 10;\npublic static final int UPCA = 12;\npublic static final int EAN13 = 13;\npublic static final int ISBN13 = 14;\npublic static final int I25 = 25;\npublic static final int DATABAR = 34;\npublic static final int DATABAR_EXP = 35;\npublic static final int CODABAR = 38;\npublic static final int CODE39 = 39;\npublic static final int PDF417 = 57;\npublic static final int QRCODE = 64;\npublic static final int CODE93 = 93;\npublic static final int CODE128 = 128;\n```\n\nIf you do not specify scan_modes, the scanner processes all the above listed types.\n\nBut if you are interested in QRCodes and ISBN, you would setup the intent as follows:\n```java\nIntent intent = new Intent(this, ZBarScannerActivity.class);\nintent.putExtra(ZBarConstants.SCAN_MODES, new int[]{Symbol.QRCODE, Symbol.ISBN10, Symbol.ISBN13});\nstartActivityForResult(intent, ZBAR_SCANNER_REQUEST);\n```\n\n### Example app\nThere is a ZBarScannerDemo app in the examples folder which demonstrates the use of this library.\n\n### Tests\nI have tested the scanner functionality on these devices without any issues so far:\n* Motorola Droid running Android 2.2.3\n* HTC Thunderbolt running Android 2.3.4\n* Samsung Galaxy Nexus running Android 4.0.4\n\n###Credits\nAlmost all of the code for this library project has been taken from these two places:\n\n1. CameraPreview app from Android SDK APIDemos \n2. The ZBar Android SDK: http://sourceforge.net/projects/zbar/files/AndroidSDK/\n\n###License\nMIT\n\n--------------------------------------------------------------------------------------\n\nATTENTION!\n==========\n\nThis project will no longer be maintained. Moving forward, I am going to spend my time on development of this project here: https://github.com/dm77/barcodescanner\n"
  },
  {
    "path": "ZBarScannerLibrary/AndroidManifest.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n      package=\"com.dm.zbar.android.scanner\"\n      android:versionCode=\"1\"\n      android:versionName=\"1.0\">\n\n    <uses-permission android:name=\"android.permission.CAMERA\"/>\n    <uses-feature android:name=\"android.hardware.camera\" />\n    <uses-sdk android:minSdkVersion=\"8\" />\n\n    <application android:label=\"@string/app_name\" android:icon=\"@drawable/ic_launcher\">\n        <activity android:name=\"ZBarScannerActivity\"\n                  android:screenOrientation=\"landscape\"\n                  android:label=\"@string/app_name\" />\n    </application>\n</manifest>\n"
  },
  {
    "path": "ZBarScannerLibrary/ant.properties",
    "content": "# This file is used to override default values used by the Ant build system.\n#\n# This file must be checked into Version Control Systems, as it is\n# integral to the build system of your project.\n\n# This file is only used by the Ant script.\n\n# You can use this to override default values such as\n#  'source.dir' for the location of your java source folder and\n#  'out.dir' for the location of your output folder.\n\n# You can also use it define how the release builds are signed by declaring\n# the following properties:\n#  'key.store' for the location of your keystore and\n#  'key.alias' for the name of the key to use.\n# The password will be asked during the build when you use the 'release' target.\n\n"
  },
  {
    "path": "ZBarScannerLibrary/build.properties",
    "content": ""
  },
  {
    "path": "ZBarScannerLibrary/build.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project name=\"ZBarScanner\" default=\"help\">\n\n    <!-- The local.properties file is created and updated by the 'android' tool.\n         It contains the path to the SDK. It should *NOT* be checked into\n         Version Control Systems. -->\n    <property file=\"local.properties\" />\n\n    <!-- The ant.properties file can be created by you. It is only edited by the\n         'android' tool to add properties to it.\n         This is the place to change some Ant specific build properties.\n         Here are some properties you may want to change/update:\n\n         source.dir\n             The name of the source directory. Default is 'src'.\n         out.dir\n             The name of the output directory. Default is 'bin'.\n\n         For other overridable properties, look at the beginning of the rules\n         files in the SDK, at tools/ant/build.xml\n\n         Properties related to the SDK location or the project target should\n         be updated using the 'android' tool with the 'update' action.\n\n         This file is an integral part of the build system for your\n         application and should be checked into Version Control Systems.\n\n         -->\n    <property file=\"ant.properties\" />\n\n    <!-- if sdk.dir was not set from one of the property file, then\n         get it from the ANDROID_HOME env var.\n         This must be done before we load project.properties since\n         the proguard config can use sdk.dir -->\n    <property environment=\"env\" />\n    <condition property=\"sdk.dir\" value=\"${env.ANDROID_HOME}\">\n        <isset property=\"env.ANDROID_HOME\" />\n    </condition>\n\n    <!-- The project.properties file is created and updated by the 'android'\n         tool, as well as ADT.\n\n         This contains project specific properties such as project target, and library\n         dependencies. Lower level build properties are stored in ant.properties\n         (or in .classpath for Eclipse projects).\n\n         This file is an integral part of the build system for your\n         application and should be checked into Version Control Systems. -->\n    <loadproperties srcFile=\"project.properties\" />\n\n    <!-- quick check on sdk.dir -->\n    <fail\n            message=\"sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through the ANDROID_HOME environment variable.\"\n            unless=\"sdk.dir\"\n    />\n\n    <!--\n        Import per project custom build rules if present at the root of the project.\n        This is the place to put custom intermediary targets such as:\n            -pre-build\n            -pre-compile\n            -post-compile (This is typically used for code obfuscation.\n                           Compiled code location: ${out.classes.absolute.dir}\n                           If this is not done in place, override ${out.dex.input.absolute.dir})\n            -post-package\n            -post-build\n            -pre-clean\n    -->\n    <import file=\"custom_rules.xml\" optional=\"true\" />\n\n    <!-- Import the actual build file.\n\n         To customize existing targets, there are two options:\n         - Customize only one target:\n             - copy/paste the target into this file, *before* the\n               <import> task.\n             - customize it to your needs.\n         - Customize the whole content of build.xml\n             - copy/paste the content of the rules files (minus the top node)\n               into this file, replacing the <import> task.\n             - customize to your needs.\n\n         ***********************\n         ****** IMPORTANT ******\n         ***********************\n         In all cases you must update the value of version-tag below to read 'custom' instead of an integer,\n         in order to avoid having your file be overridden by tools such as \"android update project\"\n    -->\n    <!-- version-tag: 1 -->\n    <import file=\"${sdk.dir}/tools/ant/build.xml\" />\n\n</project>\n"
  },
  {
    "path": "ZBarScannerLibrary/default.properties",
    "content": ""
  },
  {
    "path": "ZBarScannerLibrary/proguard-project.txt",
    "content": "# To enable ProGuard in your project, edit project.properties\n# to define the proguard.config property as described in that file.\n#\n# Add project specific ProGuard rules here.\n# By default, the flags in this file are appended to flags specified\n# in ${sdk.dir}/tools/proguard/proguard-android.txt\n# You can edit the include path and order by changing the ProGuard\n# include property in project.properties.\n#\n# For more details, see\n#   http://developer.android.com/guide/developing/tools/proguard.html\n\n# Add any project specific keep options here:\n\n# If your project uses WebView with JS, uncomment the following\n# and specify the fully qualified class name to the JavaScript interface\n# class:\n#-keepclassmembers class fqcn.of.javascript.interface.for.webview {\n#   public *;\n#}\n"
  },
  {
    "path": "ZBarScannerLibrary/project.properties",
    "content": "# This file is automatically generated by Android Tools.\n# Do not modify this file -- YOUR CHANGES WILL BE ERASED!\n#\n# This file must be checked in Version Control Systems.\n#\n# To customize properties used by the Ant build system edit\n# \"ant.properties\", and override values to adapt the script to your\n# project structure.\n#\n# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):\n#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt\n\n# Project target.\ntarget=android-16\nandroid.library=true\n"
  },
  {
    "path": "ZBarScannerLibrary/res/values/strings.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n    <string name=\"app_name\">ZBar Scanner</string>\n</resources>\n"
  },
  {
    "path": "ZBarScannerLibrary/src/com/dm/zbar/android/scanner/CameraPreview.java",
    "content": "package com.dm.zbar.android.scanner;\n\nimport android.content.Context;\nimport android.hardware.Camera;\nimport android.hardware.Camera.AutoFocusCallback;\nimport android.hardware.Camera.PreviewCallback;\nimport android.hardware.Camera.Size;\nimport android.util.Log;\nimport android.view.SurfaceHolder;\nimport android.view.SurfaceView;\nimport android.view.View;\nimport android.view.ViewGroup;\nimport java.io.IOException;\nimport java.util.List;\n\nclass CameraPreview extends ViewGroup implements SurfaceHolder.Callback {\n    private final String TAG = \"CameraPreview\";\n\n    SurfaceView mSurfaceView;\n    SurfaceHolder mHolder;\n    Size mPreviewSize;\n    List<Size> mSupportedPreviewSizes;\n    Camera mCamera;\n    PreviewCallback mPreviewCallback;\n    AutoFocusCallback mAutoFocusCallback;\n\n    CameraPreview(Context context, PreviewCallback previewCallback, AutoFocusCallback autoFocusCb) {\n        super(context);\n\n        mPreviewCallback = previewCallback;\n        mAutoFocusCallback = autoFocusCb;\n        mSurfaceView = new SurfaceView(context);\n        addView(mSurfaceView);\n\n        // Install a SurfaceHolder.Callback so we get notified when the\n        // underlying surface is created and destroyed.\n        mHolder = mSurfaceView.getHolder();\n        mHolder.addCallback(this);\n        mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);\n    }\n\n    public void setCamera(Camera camera) {\n        mCamera = camera;\n        if (mCamera != null) {\n            mSupportedPreviewSizes = mCamera.getParameters().getSupportedPreviewSizes();\n            requestLayout();\n        }\n    }\n\n    @Override\n    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {\n        // We purposely disregard child measurements because act as a\n        // wrapper to a SurfaceView that centers the camera preview instead\n        // of stretching it.\n        final int width = resolveSize(getSuggestedMinimumWidth(), widthMeasureSpec);\n        final int height = resolveSize(getSuggestedMinimumHeight(), heightMeasureSpec);\n        setMeasuredDimension(width, height);\n\n        if (mSupportedPreviewSizes != null) {\n            mPreviewSize = getOptimalPreviewSize(mSupportedPreviewSizes, width, height);\n        }\n    }\n\n    @Override\n    protected void onLayout(boolean changed, int l, int t, int r, int b) {\n        if (changed && getChildCount() > 0) {\n            final View child = getChildAt(0);\n\n            final int width = r - l;\n            final int height = b - t;\n\n            int previewWidth = width;\n            int previewHeight = height;\n            if (mPreviewSize != null) {\n                previewWidth = mPreviewSize.width;\n                previewHeight = mPreviewSize.height;\n            }\n\n            // Center the child SurfaceView within the parent.\n            if (width * previewHeight > height * previewWidth) {\n                final int scaledChildWidth = previewWidth * height / previewHeight;\n                child.layout((width - scaledChildWidth) / 2, 0,\n                        (width + scaledChildWidth) / 2, height);\n            } else {\n                final int scaledChildHeight = previewHeight * width / previewWidth;\n                child.layout(0, (height - scaledChildHeight) / 2,\n                        width, (height + scaledChildHeight) / 2);\n            }\n        }\n    }\n\n    public void hideSurfaceView() {\n        mSurfaceView.setVisibility(View.INVISIBLE);\n    }\n\n    public void showSurfaceView() {\n        mSurfaceView.setVisibility(View.VISIBLE);\n    }\n\n    public void surfaceCreated(SurfaceHolder holder) {\n        // The Surface has been created, acquire the camera and tell it where\n        // to draw.\n        try {\n            if (mCamera != null) {\n                mCamera.setPreviewDisplay(holder);\n            }\n        } catch (IOException exception) {\n            Log.e(TAG, \"IOException caused by setPreviewDisplay()\", exception);\n        }\n    }\n\n    public void surfaceDestroyed(SurfaceHolder holder) {\n        // Surface will be destroyed when we return, so stop the preview.\n        if (mCamera != null) {\n            mCamera.cancelAutoFocus();\n            mCamera.stopPreview();\n        }\n    }\n\n\n    private Size getOptimalPreviewSize(List<Size> sizes, int w, int h) {\n        final double ASPECT_TOLERANCE = 0.1;\n        double targetRatio = (double) w / h;\n        if (sizes == null) return null;\n\n        Size optimalSize = null;\n        double minDiff = Double.MAX_VALUE;\n\n        int targetHeight = h;\n\n        // Try to find an size match aspect ratio and size\n        for (Size size : sizes) {\n            double ratio = (double) size.width / size.height;\n            if (Math.abs(ratio - targetRatio) > ASPECT_TOLERANCE) continue;\n            if (Math.abs(size.height - targetHeight) < minDiff) {\n                optimalSize = size;\n                minDiff = Math.abs(size.height - targetHeight);\n            }\n        }\n\n        // Cannot find the one match the aspect ratio, ignore the requirement\n        if (optimalSize == null) {\n            minDiff = Double.MAX_VALUE;\n            for (Size size : sizes) {\n                if (Math.abs(size.height - targetHeight) < minDiff) {\n                    optimalSize = size;\n                    minDiff = Math.abs(size.height - targetHeight);\n                }\n            }\n        }\n        return optimalSize;\n    }\n\n    public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {\n        if (holder.getSurface() == null){\n          // preview surface does not exist\n          return;\n        }\n\n        if (mCamera != null) {\n            // Now that the size is known, set up the camera parameters and begin\n            // the preview.\n            Camera.Parameters parameters = mCamera.getParameters();\n            parameters.setPreviewSize(mPreviewSize.width, mPreviewSize.height);\n            requestLayout();\n\n            mCamera.setParameters(parameters);\n            mCamera.setPreviewCallback(mPreviewCallback);\n            mCamera.startPreview();\n            mCamera.autoFocus(mAutoFocusCallback);\n        }\n    }\n\n}\n"
  },
  {
    "path": "ZBarScannerLibrary/src/com/dm/zbar/android/scanner/ZBarConstants.java",
    "content": "package com.dm.zbar.android.scanner;\n\npublic interface ZBarConstants {\n    public static final String SCAN_MODES = \"SCAN_MODES\";\n    public static final String SCAN_RESULT = \"SCAN_RESULT\";\n    public static final String SCAN_RESULT_TYPE = \"SCAN_RESULT_TYPE\";\n    public static final String ERROR_INFO = \"ERROR_INFO\";\n}\n"
  },
  {
    "path": "ZBarScannerLibrary/src/com/dm/zbar/android/scanner/ZBarScannerActivity.java",
    "content": "package com.dm.zbar.android.scanner;\n\nimport android.app.Activity;\nimport android.content.Intent;\nimport android.content.pm.PackageManager;\nimport android.hardware.Camera;\nimport android.os.Bundle;\nimport android.os.Handler;\nimport android.text.TextUtils;\nimport android.view.Window;\nimport android.view.WindowManager;\nimport net.sourceforge.zbar.Config;\nimport net.sourceforge.zbar.Image;\nimport net.sourceforge.zbar.ImageScanner;\nimport net.sourceforge.zbar.Symbol;\nimport net.sourceforge.zbar.SymbolSet;\n\npublic class ZBarScannerActivity extends Activity implements Camera.PreviewCallback, ZBarConstants {\n\n    private static final String TAG = \"ZBarScannerActivity\";\n    private CameraPreview mPreview;\n    private Camera mCamera;\n    private ImageScanner mScanner;\n    private Handler mAutoFocusHandler;\n    private boolean mPreviewing = true;\n\n    static {\n        System.loadLibrary(\"iconv\");\n    }\n\n    @Override\n    protected void onCreate(Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n\n        if(!isCameraAvailable()) {\n            // Cancel request if there is no rear-facing camera.\n            cancelRequest();\n            return;\n        }\n\n        // Hide the window title.\n        requestWindowFeature(Window.FEATURE_NO_TITLE);\n        getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);\n\n        mAutoFocusHandler = new Handler();\n\n        // Create and configure the ImageScanner;\n        setupScanner();\n\n        // Create a RelativeLayout container that will hold a SurfaceView,\n        // and set it as the content of our activity.\n        mPreview = new CameraPreview(this, this, autoFocusCB);\n        setContentView(mPreview);\n    }\n\n    public void setupScanner() {\n        mScanner = new ImageScanner();\n        mScanner.setConfig(0, Config.X_DENSITY, 3);\n        mScanner.setConfig(0, Config.Y_DENSITY, 3);\n\n        int[] symbols = getIntent().getIntArrayExtra(SCAN_MODES);\n        if (symbols != null) {\n            mScanner.setConfig(Symbol.NONE, Config.ENABLE, 0);\n            for (int symbol : symbols) {\n                mScanner.setConfig(symbol, Config.ENABLE, 1);\n            }\n        }\n    }\n\n    @Override\n    protected void onResume() {\n        super.onResume();\n\n        // Open the default i.e. the first rear facing camera.\n        mCamera = Camera.open();\n        if(mCamera == null) {\n            // Cancel request if mCamera is null.\n            cancelRequest();\n            return;\n        }\n\n        mPreview.setCamera(mCamera);\n        mPreview.showSurfaceView();\n\n        mPreviewing = true;\n    }\n\n    @Override\n    protected void onPause() {\n        super.onPause();\n\n        // Because the Camera object is a shared resource, it's very\n        // important to release it when the activity is paused.\n        if (mCamera != null) {\n            mPreview.setCamera(null);\n            mCamera.cancelAutoFocus();\n            mCamera.setPreviewCallback(null);\n            mCamera.stopPreview();\n            mCamera.release();\n\n            // According to Jason Kuang on http://stackoverflow.com/questions/6519120/how-to-recover-camera-preview-from-sleep,\n            // there might be surface recreation problems when the device goes to sleep. So lets just hide it and\n            // recreate on resume\n            mPreview.hideSurfaceView();\n\n            mPreviewing = false;\n            mCamera = null;\n        }\n    }\n\n    public boolean isCameraAvailable() {\n        PackageManager pm = getPackageManager();\n        return pm.hasSystemFeature(PackageManager.FEATURE_CAMERA);\n    }\n\n    public void cancelRequest() {\n        Intent dataIntent = new Intent();\n        dataIntent.putExtra(ERROR_INFO, \"Camera unavailable\");\n        setResult(Activity.RESULT_CANCELED, dataIntent);\n        finish();\n    }\n\n    public void onPreviewFrame(byte[] data, Camera camera) {\n        Camera.Parameters parameters = camera.getParameters();\n        Camera.Size size = parameters.getPreviewSize();\n\n        Image barcode = new Image(size.width, size.height, \"Y800\");\n        barcode.setData(data);\n\n        int result = mScanner.scanImage(barcode);\n\n        if (result != 0) {\n            mCamera.cancelAutoFocus();\n            mCamera.setPreviewCallback(null);\n            mCamera.stopPreview();\n            mPreviewing = false;\n            SymbolSet syms = mScanner.getResults();\n            for (Symbol sym : syms) {\n                String symData = sym.getData();\n                if (!TextUtils.isEmpty(symData)) {\n                    Intent dataIntent = new Intent();\n                    dataIntent.putExtra(SCAN_RESULT, symData);\n                    dataIntent.putExtra(SCAN_RESULT_TYPE, sym.getType());\n                    setResult(Activity.RESULT_OK, dataIntent);\n                    finish();\n                    break;\n                }\n            }\n        }\n    }\n    private Runnable doAutoFocus = new Runnable() {\n        public void run() {\n            if(mCamera != null && mPreviewing) {\n                mCamera.autoFocus(autoFocusCB);\n            }\n        }\n    };\n\n    // Mimic continuous auto-focusing\n    Camera.AutoFocusCallback autoFocusCB = new Camera.AutoFocusCallback() {\n        public void onAutoFocus(boolean success, Camera camera) {\n            mAutoFocusHandler.postDelayed(doAutoFocus, 1000);\n        }\n    };\n}\n"
  },
  {
    "path": "examples/ZBarScannerDemo/AndroidManifest.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n      package=\"com.dm.zbar.android.examples\"\n      android:versionCode=\"1\"\n      android:versionName=\"1.0\">\n\n    <uses-permission android:name=\"android.permission.CAMERA\"/>\n    <uses-feature android:name=\"android.hardware.camera\" android:required=\"false\"/>\n    <uses-sdk android:minSdkVersion=\"8\" />\n\n    <application android:label=\"@string/app_name\" android:icon=\"@drawable/ic_launcher\">\n        <activity android:name=\"MainActivity\"\n                  android:label=\"@string/app_name\">\n            <intent-filter>\n                <action android:name=\"android.intent.action.MAIN\" />\n                <category android:name=\"android.intent.category.LAUNCHER\" />\n            </intent-filter>\n        </activity>\n\n        <activity android:name=\"com.dm.zbar.android.scanner.ZBarScannerActivity\"\n                  android:screenOrientation=\"landscape\"\n                  android:label=\"@string/app_name\" />\n    </application>\n</manifest>\n"
  },
  {
    "path": "examples/ZBarScannerDemo/ant.properties",
    "content": "# This file is used to override default values used by the Ant build system.\n#\n# This file must be checked into Version Control Systems, as it is\n# integral to the build system of your project.\n\n# This file is only used by the Ant script.\n\n# You can use this to override default values such as\n#  'source.dir' for the location of your java source folder and\n#  'out.dir' for the location of your output folder.\n\n# You can also use it define how the release builds are signed by declaring\n# the following properties:\n#  'key.store' for the location of your keystore and\n#  'key.alias' for the name of the key to use.\n# The password will be asked during the build when you use the 'release' target.\n\n"
  },
  {
    "path": "examples/ZBarScannerDemo/build.properties",
    "content": ""
  },
  {
    "path": "examples/ZBarScannerDemo/build.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project name=\"ZBarScannerDemo\" default=\"help\">\n\n    <!-- The local.properties file is created and updated by the 'android' tool.\n         It contains the path to the SDK. It should *NOT* be checked into\n         Version Control Systems. -->\n    <property file=\"local.properties\" />\n\n    <!-- The ant.properties file can be created by you. It is only edited by the\n         'android' tool to add properties to it.\n         This is the place to change some Ant specific build properties.\n         Here are some properties you may want to change/update:\n\n         source.dir\n             The name of the source directory. Default is 'src'.\n         out.dir\n             The name of the output directory. Default is 'bin'.\n\n         For other overridable properties, look at the beginning of the rules\n         files in the SDK, at tools/ant/build.xml\n\n         Properties related to the SDK location or the project target should\n         be updated using the 'android' tool with the 'update' action.\n\n         This file is an integral part of the build system for your\n         application and should be checked into Version Control Systems.\n\n         -->\n    <property file=\"ant.properties\" />\n\n    <!-- if sdk.dir was not set from one of the property file, then\n         get it from the ANDROID_HOME env var.\n         This must be done before we load project.properties since\n         the proguard config can use sdk.dir -->\n    <property environment=\"env\" />\n    <condition property=\"sdk.dir\" value=\"${env.ANDROID_HOME}\">\n        <isset property=\"env.ANDROID_HOME\" />\n    </condition>\n\n    <!-- The project.properties file is created and updated by the 'android'\n         tool, as well as ADT.\n\n         This contains project specific properties such as project target, and library\n         dependencies. Lower level build properties are stored in ant.properties\n         (or in .classpath for Eclipse projects).\n\n         This file is an integral part of the build system for your\n         application and should be checked into Version Control Systems. -->\n    <loadproperties srcFile=\"project.properties\" />\n\n    <!-- quick check on sdk.dir -->\n    <fail\n            message=\"sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through the ANDROID_HOME environment variable.\"\n            unless=\"sdk.dir\"\n    />\n\n    <!--\n        Import per project custom build rules if present at the root of the project.\n        This is the place to put custom intermediary targets such as:\n            -pre-build\n            -pre-compile\n            -post-compile (This is typically used for code obfuscation.\n                           Compiled code location: ${out.classes.absolute.dir}\n                           If this is not done in place, override ${out.dex.input.absolute.dir})\n            -post-package\n            -post-build\n            -pre-clean\n    -->\n    <import file=\"custom_rules.xml\" optional=\"true\" />\n\n    <!-- Import the actual build file.\n\n         To customize existing targets, there are two options:\n         - Customize only one target:\n             - copy/paste the target into this file, *before* the\n               <import> task.\n             - customize it to your needs.\n         - Customize the whole content of build.xml\n             - copy/paste the content of the rules files (minus the top node)\n               into this file, replacing the <import> task.\n             - customize to your needs.\n\n         ***********************\n         ****** IMPORTANT ******\n         ***********************\n         In all cases you must update the value of version-tag below to read 'custom' instead of an integer,\n         in order to avoid having your file be overridden by tools such as \"android update project\"\n    -->\n    <!-- version-tag: 1 -->\n    <import file=\"${sdk.dir}/tools/ant/build.xml\" />\n\n</project>\n"
  },
  {
    "path": "examples/ZBarScannerDemo/default.properties",
    "content": ""
  },
  {
    "path": "examples/ZBarScannerDemo/proguard-project.txt",
    "content": "# To enable ProGuard in your project, edit project.properties\n# to define the proguard.config property as described in that file.\n#\n# Add project specific ProGuard rules here.\n# By default, the flags in this file are appended to flags specified\n# in ${sdk.dir}/tools/proguard/proguard-android.txt\n# You can edit the include path and order by changing the ProGuard\n# include property in project.properties.\n#\n# For more details, see\n#   http://developer.android.com/guide/developing/tools/proguard.html\n\n# Add any project specific keep options here:\n\n# If your project uses WebView with JS, uncomment the following\n# and specify the fully qualified class name to the JavaScript interface\n# class:\n#-keepclassmembers class fqcn.of.javascript.interface.for.webview {\n#   public *;\n#}\n"
  },
  {
    "path": "examples/ZBarScannerDemo/project.properties",
    "content": "# This file is automatically generated by Android Tools.\n# Do not modify this file -- YOUR CHANGES WILL BE ERASED!\n#\n# This file must be checked in Version Control Systems.\n#\n# To customize properties used by the Ant build system edit\n# \"ant.properties\", and override values to adapt the script to your\n# project structure.\n#\n# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):\n#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt\n\n# Project target.\ntarget=android-16\nandroid.library.reference.1=../../ZBarScannerLibrary\n"
  },
  {
    "path": "examples/ZBarScannerDemo/res/layout/main.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    android:orientation=\"vertical\"\n    android:padding=\"5dp\"\n    android:gravity=\"center\"\n    android:layout_width=\"fill_parent\"\n    android:layout_height=\"fill_parent\">\n    <Button\n        android:id=\"@+id/scan_btn\"\n        android:layout_height=\"wrap_content\"\n        android:layout_width=\"fill_parent\"\n        android:onClick=\"launchScanner\"\n        android:text=\"@string/scan\" />\n\n    <Button\n        android:id=\"@+id/qrscan_btn\"\n        android:layout_height=\"wrap_content\"\n        android:layout_width=\"fill_parent\"\n        android:onClick=\"launchQRScanner\"\n        android:text=\"@string/scan_only_qr_codes\" />\n</LinearLayout>\n\n"
  },
  {
    "path": "examples/ZBarScannerDemo/res/values/strings.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n    <string name=\"app_name\">ZBar Scanner Demo</string>\n    <string name=\"scan\">Scan</string>\n    <string name=\"scan_only_qr_codes\">Scan only QR Codes</string>\n</resources>\n"
  },
  {
    "path": "examples/ZBarScannerDemo/src/com/dm/zbar/android/examples/MainActivity.java",
    "content": "package com.dm.zbar.android.examples;\n\nimport android.app.Activity;\nimport android.content.Intent;\nimport android.content.pm.PackageManager;\nimport android.os.Bundle;\nimport android.text.TextUtils;\nimport android.view.View;\nimport android.widget.Toast;\nimport com.dm.zbar.android.scanner.ZBarConstants;\nimport com.dm.zbar.android.scanner.ZBarScannerActivity;\nimport net.sourceforge.zbar.Symbol;\n\npublic class MainActivity extends Activity {\n\n    private static final int ZBAR_SCANNER_REQUEST = 0;\n    private static final int ZBAR_QR_SCANNER_REQUEST = 1;\n\n    @Override\n    public void onCreate(Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n        setContentView(R.layout.main);\n    }\n\n    public void launchScanner(View v) {\n        if (isCameraAvailable()) {\n            Intent intent = new Intent(this, ZBarScannerActivity.class);\n            startActivityForResult(intent, ZBAR_SCANNER_REQUEST);\n        } else {\n            Toast.makeText(this, \"Rear Facing Camera Unavailable\", Toast.LENGTH_SHORT).show();\n        }\n    }\n\n    public void launchQRScanner(View v) {\n        if (isCameraAvailable()) {\n            Intent intent = new Intent(this, ZBarScannerActivity.class);\n            intent.putExtra(ZBarConstants.SCAN_MODES, new int[]{Symbol.QRCODE});\n            startActivityForResult(intent, ZBAR_SCANNER_REQUEST);\n        } else {\n            Toast.makeText(this, \"Rear Facing Camera Unavailable\", Toast.LENGTH_SHORT).show();\n        }\n    }\n\n    public boolean isCameraAvailable() {\n        PackageManager pm = getPackageManager();\n        return pm.hasSystemFeature(PackageManager.FEATURE_CAMERA);\n    }\n\n    @Override\n    protected void onActivityResult(int requestCode, int resultCode, Intent data) {\n        switch (requestCode) {\n            case ZBAR_SCANNER_REQUEST:\n            case ZBAR_QR_SCANNER_REQUEST:\n                if (resultCode == RESULT_OK) {\n                    Toast.makeText(this, \"Scan Result = \" + data.getStringExtra(ZBarConstants.SCAN_RESULT), Toast.LENGTH_SHORT).show();\n                } else if(resultCode == RESULT_CANCELED && data != null) {\n                    String error = data.getStringExtra(ZBarConstants.ERROR_INFO);\n                    if(!TextUtils.isEmpty(error)) {\n                        Toast.makeText(this, error, Toast.LENGTH_SHORT).show();\n                    }\n                }\n                break;\n        }\n    }\n}\n"
  }
]