Coder Social home page Coder Social logo

goyalzz / qrmodule Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ydcool/qrmodule

0.0 1.0 0.0 5.07 MB

Android Qr Scan and generate module.Based on Google Zxing library.

Home Page: http://ydcool.github.io/QrModule/

License: Apache License 2.0

Java 100.00%

qrmodule's Introduction

Android QR Module

Download Build Status

  • Thanks to Ryan_Tang.本项目基于他blog上的项目优化改进。
  • Feel free to fork and pr.

Features

  • Qr Scan
  • Qr Generate
QR Scan

Demo APK download or scan

Usage

1 Add gradle dependence:

    compile 'me.ydcool.lib:qrmodule:latest.integration'

2 Add QrScannerActivity to your AndroidManifest.xml

    <activity android:name="me.ydcool.lib.qrmodule.activity.QrScannerActivity"/>

3 Add permissions

    <uses-permission android:name="android.permission.CAMERA"/>
    <uses-permission android:name="android.permission.FLASHLIGHT"/>
    <uses-permission android:name="android.permission.VIBRATE"/>

4 Start QrScannerActivity in your activity.

    Intent intent = new Intent(MainActivity.this, QrScannerActivity.class);
    startActivityForResult(intent, QrScannerActivity.QR_REQUEST_CODE);

5 And receive scanner activity result in your activity.

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == QrScannerActivity.QR_REQUEST_CODE) {
            Log.d(TAG, resultCode == RESULT_OK
                            ? data.getExtras().getString(QrScannerActivity.QR_RESULT_STR)
                            : "Scanned Nothing!");
        }
    }

See more details in Demo MainActivity.

QR Generate

Usage
  • Generate qr code with QrGenerator.
   Bitmap qrCode = new QrGenerator.Builder()
       .content("https://github.com/Ydcool/QrModule")
       .qrSize(300)
       .margin(2)
       .color(Color.BLACK)
       .bgColor(Color.WHITE)
       .ecc(ErrorCorrectionLevel.H)
       .overlay(getContext(),R.mipmap.ic_launcher)
       .overlaySize(100)
       .overlayAlpha(255)
       .overlayXfermode(PortBuff.Mode.SRC_ATOP)
       .encode();

    mImageView.setImageBitmap(qrCode);
Method Description
content(String content) content of qr code.
qrSize(int size) qr code image size.
margin(int margin) default is 2.See more about EncodeHintType.MARGIN
color(int color) qr code foreground color.
color(Context c, @ColorRes int color) set foreground color with color resource.
bgColor(int color) set the background color.
bgColor(Context c,@ColorRes int color) set the background color with color resource.
ecc(ErrorCorrectionLevel e) error correction level , default is L (~7%).See more about ErrorCorrectionLevel.
overlay(Bitmap overlay) overlay image on qr code, usually set with logo. NOTICE: once you set overlay image,you'd better set ecc to H.
overlay(Context c,@DrawableRes int overlay) set overlay with drawable resource.
overlaySize(int size) overlay image size in qr code.
overlayAlpha(int alpha) set overlay image alpha, range [0,255], default is 255(opaque).
overlayXfermode(PorterDuff.Mode m) set xfermode for overlay bitmap,default is SRC,see more about PorterDuff.Mode.
footNote(String s) This feature is under develop .
encode() return a encoded qrCode bitmap.

TODO

  • Custom pattern support.

License

Apache License. See the LICENSE for more info.

qrmodule's People

Contributors

ydcool avatar

Watchers

Ankush Goyal avatar

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.