Giter Club home page Giter Club logo

android-barcode's Introduction

Barcode - Android

Purpose

This library provides Android wrappers for the Zebra Crossing (zxing) Library. If you only need to scan barcodes and are only distributing on Google Play enabled devices, check out the new Google Mobile Vision libraries. The scanning component works fine, but was more or less included because it had already been built for other purposes.

Components

  • BarcodeDemo - Project that demonstrates usage of barcode scanning and generation.
  • Generation
    • BarcodeView - Extends ImageView and will attempt to fill itself with the barcode type specified
      • Required Custom Attributes:
        • barcode_format - Enumeration of supported barcode formats e.g. "qr_code". Must be either specified in layout or provided via setBarcodeFormat method on the view instance.
        • barcode_text - Value to be encoded. Must be either specified in layout or provided via setBarcodeText.
      • Optional Custom Attributes
        • barcode_character_set - If unspecified will default to "UTF-8".
        • barcode_foreground_color - Android color value for the "black" part of the barcode.
        • barcode_background_color - Android color value for the "white" part of the barcode.
    • BarcodeRequest - Create an object that specifies a desired barcode image size/format/text/etc created with the BarcodeRequestBuilder inside it.
    • BarcodeBitmapGenerator - Create a barcode bitmap synchronously from a BarcodeRequest
    • AsyncBarcodeBitmapGenerator - Create a barcode bitmap asynchronously with a weak reference to the callback.
      • Constructor can be set to either single operation mode or multiple operation mode. In single operation mode any currently running request will be cancelled before the next is started.
  • Detection
    • ZXingFacade - Provides an easier to manage interface to ZXing's camera based barcode scanning operations. Check out the BarcodeDemo ScanningActivity. You provide it with a SurfaceView for the preview, a callback listener for detected barcodes and pass it onCreate/Pause/Resume Activity lifecycle events.

Usage

Include the library in your project with the compile directive in your dependencies section of your build.gradle.

    ...

    dependencies {
        ...
        compile ('com.bottlerocketstudios:barcode:1.0.3@aar') {
            transitive = true;
        }
    }

Standard Generator Operation

Add the app XML namespace to the root element of your layout.

    xmlns:app="http://schemas.android.com/apk/res-auto"

Now add the BarcodeView somewhere in your layout.

    <com.bottlerocketstudios.barcode.generation.ui.BarcodeView
        android:id="@+id/generation_barcode_image"
        app:barcode_format="qr_code"
        android:layout_width="match_parent"
        android:layout_height="300dp"
        android:layout_marginTop="20dp"/>

The layout width and height cannot be wrap_content as that doesn't have a real meaning for a barcode. There is no intrinsic size of most barcodes and the ImageView's bitmap has not been set to be measured until the barcode is created.

Standard Detector Operation

The BarcodeDemo project's ScanningActivity is the best source for an example implementation. Clone this repo or browse the source to look at that Activity. Be sure to pay attention to the manifest permissions.

Build

This project must be built with gradle.

  • Version Numbering - The version name should end with "-SNAPSHOT" for non release builds. This will cause the resulting binary, source, and javadoc files to be uploaded to the snapshot repository in Maven as a snapshot build. Removing snapshot from the version name will publish the build on jcenter. If that version is already published, it will not overwrite it.
  • Execution - To build this libarary, associated tasks are dynamically generated by Android build tools in conjunction with Gradle. Example command for the production flavor of the release build type:
    • Build and upload: ./gradlew --refresh-dependencies clean lint uploadToMaven
    • Build only: ./gradlew --refresh-dependencies clean lint assembleRelease

android-barcode's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.