Git Product home page Git Product logo

qrgenerator's Introduction

QRGenerator

QR Generator Library and Saves the QR Code as Image

Featured In:

Android Arsenal

How to Import the Library:

Add it in your root build.gradle at the end of repositories:

allprojects {
  repositories {
    ...
    maven { url 'https://jitpack.io' }
  }
}

Gradle:

dependencies {
  implementation 'com.github.androidmads:QRGenerator:1.0.1'
}

Features:

  1. QR code color can be changed dynamically
  2. Android X support is included
  3. Minimum support from version 14 is included
  4. Margin of the QR code can be controlled

Permission:

Add This Permission for saving your generated code

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

How to use this Library:

After importing this library, use the following lines to use this library. The following lines are used to generated the QR Code

// Initializing the QR Encoder with your value to be encoded, type you required and Dimension
QRGEncoder qrgEncoder = new QRGEncoder(inputValue, null, QRGContents.Type.TEXT, smallerDimension);
qrgEncoder.setColorBlack(Color.RED);
qrgEncoder.setColorWhite(Color.BLUE);
try {
  // Getting QR-Code as Bitmap
  bitmap = qrgEncoder.getBitmap();
  // Setting Bitmap to ImageView
  qrImage.setImageBitmap(bitmap);
} catch (WriterException e) {
  Log.v(TAG, e.toString());
}

The following lines are used to generated the QR Code without margin/default border

// Initializing the QR Encoder with your value to be encoded, type you required and Dimension
QRGEncoder qrgEncoder = new QRGEncoder(inputValue, null, QRGContents.Type.TEXT, smallerDimension);
qrgEncoder.setColorBlack(Color.RED);
qrgEncoder.setColorWhite(Color.BLUE);
try {
  // Getting QR-Code as Bitmap
  bitmap = qrgEncoder.getBitmap(0);
  // Setting Bitmap to ImageView
  qrImage.setImageBitmap(bitmap);
} catch (WriterException e) {
  Log.v(TAG, e.toString());
}

Save QR Code as Image

// Save with location, value, bitmap returned and type of Image(JPG/PNG).
QRGSaver qrgSaver = new QRGSaver();
qrgSaver.save(savePath, edtValue.getText().toString().trim(), bitmap, QRGContents.ImageType.IMAGE_JPEG);

For more Details Click Here

License:

The MIT License (MIT)

Copyright (c) 2016 AndroidMad / Mushtaq M A

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

qrgenerator's People

Contributors

androidmads avatar guilucas07 avatar hannesa2 avatar tonyesna avatar vladimirjevtic95 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

qrgenerator's Issues

zxing is required in README

Would be nice you inform in README that zxing is required to run this project (internally QRGEncode use it).
I want to make the change and submit a pull request to contribute.

android:allowBackup="true"

Hello,

You're using in your lib: android:allowBackup="true"
This prevents apps using your lib to set it to false. Librry should not set this property. Can you please remove?

Colors in getBitmap() method

Hi,

in one of commit you changed colors used in method getBitmap(), but in getBitmap(int margin) method uses old colors order.
It broke expected QR displaying in my app, although it is not a problem, because I can inverse colors in the library's client side.
Is it either expected behavior or bug?

изображение

Moving the library to a Maven repository

I get a warning during building my app:
"Please remove usages of jcenter() Maven repository from your build scripts and migrate your build to other Maven repositories.
This repository is deprecated and it will be shut down in the future."
According to this, due to end of service provided by jcenter, can the library be moved to a maven repository?

Generate mixed language text

i wondered how can generate text that contains english and arabic characters as the example below:

JSONObject jsonBody = new JSONObject();
try {
jsonBody.put("firstName", "Houssem");
jsonBody.put("lastName", "حسام");
} catch (JSONException e) {
e.printStackTrace();
}
qrgEncoder = new QRGEncoder(jsonBody.toString(), null, QRGContents.Type.TEXT, dimen);

Remove border from QR-Code

Hi guys,

I am creating a QR-Code with a text and put it in a imageView. Here is my code:

 final String value = "Thats a test value";
 QRGEncoder qrgEncoder = new QRGEncoder(value, null, QRGContents.Type.TEXT, 1024);
 qrgEncoder.setColorBlack(Color.BLACK);
 qrgEncoder.setColorWhite(Color.WHITE);
 final Bitmap bitmap = qrgEncoder.getBitmap();
 ivQrCode.setImageBitmap(bitmap);

But my generated QR-Code has a border, in my case white. Can I remove this border?
I have already tried to set the color to transparent but then the ImageView still has exactly the same margin to the sides.
I need to remove the border before generating a bitmap.

See here:
image

Special Charaters are not working in QRcode.

I'm making QRcode of this string -> Code§%1$s§
Everything is perfect but when i scanned that barcode, the charater "Â" is missing from the string.
I thing special charaters are not working in it.
Can you please figure this out. I want to make my app live.
Waiting for your response
Thanks

encoding 0, what ever i pass

qrgEncoder = new QRGEncoder("test123", null, QRGContents.Type.TEXT, 800);
qrgEncoder.setColorBlack(Color.GREEN);
qrgEncoder.setColorWhite(Color.WHITE);
Log.v("sdasdasdd",""+user_details.account_id);
try {
// Getting QR-Code as Bitmap
bitmap = qrgEncoder.getBitmap();
// Setting Bitmap to ImageView
imageView.setImageBitmap(bitmap);
} catch (Exception e) {
Toast.makeText(getApplicationContext(),""+e.getMessage(),Toast.LENGTH_LONG).show();
Log.v("Sadsda",e.getMessage());
}
}

Support for NOT jCenter() repository

I have following issues:

Could not find androidmads.library.qrgenearator:QRGenearator:1.0.4.
     Searched in the following locations:
       - https://dl.google.com/dl/android/maven2/androidmads/library/qrgenearator/QRGenearator/1.0.4/QRGenearator-1.0.4.pom
       - https://repo.maven.apache.org/maven2/androidmads/library/qrgenearator/QRGenearator/1.0.4/QRGenearator-1.0.4.pom
       - https://jitpack.io/androidmads/library/qrgenearator/QRGenearator/1.0.4/QRGenearator-1.0.4.pom

It seems that this is related to lacking of jCenter() alternatives?

cann't read encoded text

J\å:ÁýDßë�x�òÝ�vã!13!Ü�î,TX§�0�(q·ádOÓû��½Ô

This is my encoded content.And added to your content place.Don't work

How to add new line?

Hi, I tried generating QR image with the following text newline:\nSymbols: @-+*/\\~!@#$%^&*()_+ but there was no new line inserted when I scanned the code.

How to add new line?

java.util.zip.ZipException: duplicate entry: com/google/zxing/BarcodeFormat.class

In my project, I use
compile 'com.google.android.gms:play-services-maps:11.0.1'
compile 'com.google.firebase:firebase-messaging:11.0.1'
compile 'com.google.firebase:firebase-core:11.0.1'

I got this error when I want to build signed apk!

Error:Execution failed for task ':app:transformClassesWithJarMergingForRelease'. > com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/zxing/aztec/AztecDetectorResult.class

JSON in qrCode

I am having issue passing json as string as inputValue in QR ecoding.
When I decode it I get apparently random numbers

Breaking Changes with new version

I was looking at the new commit and there was a breaking change to the public api specifically method encodeAsBitmap(). Was just wondering why the name change and removing the throw Writer exception.

The method now returns null instead of the exception which can cause NPE in the app if not handled correctly.
Was just curious on this change.

Thanks for the recent update to the AndroidX libraries!! @androidmads

QR Code storing content in a PDF

I Have tried every method to have the QR Generator generate a QR code, so that when it is decoded the inputted text is stored on a PDF document along with the QR code contents, e.g. QR code type, EC level etc. But I get errors up and down the class. How do I store the inputted text along with the QR code contents on a PDF

QrgSaver().save() not working

I tried to save the generated QR code to my phone's internal storage but the file is not getting saved.
I am attaching the code used to save below:

QRGSaver().save(folder.path, "$url_et $currentDateTimeString", bitmap, QRGContents.ImageType.IMAGE_PNG)

Error cannot resolve method

error: cannot find symbol
qrgEncoder.setColorBlack(Color.RED);
^
symbol: method setColorBlack(int)
location: variable qrgEncoder of type QRGEncoder

error: cannot find symbol
qrgEncoder.setColorWhite(Color.Blue);
^
symbol: method setColorWhite(int)
location: variable qrgEncoder of type QRGEncoder

Why don't we make colours WHITE and BLACK modifiable?

We can print black and white codes but we can also use other colours,
Now those colours are

private static final int WHITE = 0xFFFFFFFF; private static final int BLACK = 0xFF000000;

i don't see any reason why they can't be public non-final

What happened to version 1.0.4?

Version 1.0.4 existed in jCenter, https://mvnrepository.com/artifact/androidmads.library.qrgenearator/QRGenearator/1.0.4

I have had implemented tests based on this library which now fail, meaning that its functionality has been changed in the current 1.0.1 version on GitHub.

Edit: If someone else is looking for a direct replacement of jCenter's androidmads.library.qrgenearator:QRGenearator:1.0.4, Jitpack's com.github.smartdevelopers-ir:QRGenerator:1.0.4 can be used.

min api

Hi,

Does this really need a min API of 15? Is there any way this could be lowered to 14? What is the limiting factor here?

Thanks!

Update support library to Android X

Greetings, currently the project is using an android support library vs AndroidX. I want to make the change and submit a pull request to contribute.
However, it seems no one is maintaining this project anymore?

Any response from the @androidmads team is welcomed.

Thank you.

Angel

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.