Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proper support for java apps #37

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
6 changes: 6 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 35 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 25 additions & 3 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 0 additions & 12 deletions .idea/runConfigurations.xml

This file was deleted.

53 changes: 50 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ renderOption.setEcl(ErrorCorrectionLevel.M); // (optional) specify an error corr
renderOption.setPatternScale(0.35f); // (optional) specify a scale for patterns
renderOption.setRoundedPatterns(true); // (optional) if true, blocks will be drawn as dots instead
renderOption.setClearBorder(true); // if set to true, the background will NOT be drawn on the border area
renderOption.setColor(color); // set a color palette for the QR code
renderOption.setcolorQR(color); // set a color palette for the QR code
renderOption.setBackground(background); // set a background, keep reading to find more about it
renderOption.setLogo(logo); // set a logo, keep reading to find more about it
```
Expand Down Expand Up @@ -155,7 +155,7 @@ color.auto = false // set to true to automatically pick out colors from the back
```java
// Java

Color color = new Color();
ColorQR color = new Color();
color.setLight(0xFFFFFFFF); // for blank spaces
color.setDark(0xFFFF8C8C); // for non-blank spaces
color.setBackground(0xFFFFFFFF); // for the background (will be overriden by background images, if set)
Expand Down Expand Up @@ -188,7 +188,34 @@ logo.setScale(0.3f); // scale for the logo in the QR code
logo.setClippingRect(new Rect(0, 0, 200, 200)); // crop the logo image before applying it to the QR code
```

### 5. Render!
### 5 Hey! I want QrCode different Versions (say version 6) and I want Customized Positions

```kotlin
var renderOption = RenderOption()
// version
renderOption.qrCodeVersion = 6 // or set the version you need
// rounded position
renderOption.isCustomPositions = true
val color = Color()
color.light = -0x1
color.dark = -0x1000000
color.background = -0x1
color.auto = false

color.topLeftColor = ResourcesCompat.getColor(this.resources, R.color.top_left, null)
color.topRigntColor = ResourcesCompat.getColor(this.resources, R.color.top_right, null)
color.bottomLeftColor = ResourcesCompat.getColor(this.resources, R.color.bottom_left, null)

renderOption.color = color
```

output:

<img src="art/custom-qrcode-v6.jpg" width="400">

Please see [fun buildNiceQrCode(link: String)](https://github.com/fahimfarhan/AwesomeQRCode/blob/6e1132f8c683d4d9f0c2c13ac1fc8cf7714b8fd0/qrcodedemo/src/main/java/app/soumicslab/qrcodedemo/StartActivity.kt#L131) for the complete code.

### 6. Render!

Meet the magical renderer.

Expand Down Expand Up @@ -237,6 +264,26 @@ try {
}
```

```java
// Java
try {
RenderResult render = AwesomeQrRenderer.render(renderOption);
if (render.getBitmap() != null) {
// play with the bitmap
} else if (render.getType() == RenderResult.OutputType.GIF){
// If your Background is a GifBackground, the image
// will be saved to the output file set in GifBackground
// instead of being returned here. As a result, the
// result.bitmap will be null.
}
else {
// Oops, something gone wrong.
}
} catch (Exception e) {
e.printStackTrace();
}
```

## Changelog

#### Version 1.2.0
Expand Down
Binary file added art/custom-qrcode-v6.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 3 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.2.70'
ext.kotlin_version = '1.5.10'
repositories {
google()
jcenter()
maven { url "http://dl.bintray.com/waynejo/maven" }
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0'
classpath "com.android.tools.build:gradle:7.1.0-alpha01"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

// NOTE: Do not place your application dependencies here; they belong
Expand Down
2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@
systemProp.http.proxyHost=127.0.0.1
org.gradle.jvmargs=-Xmx1536m
systemProp.http.proxyPort=8123
android.useAndroidX=true
android.enableJetifier=true
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.8-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-bin.zip
13 changes: 6 additions & 7 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@ apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'

android {
compileSdkVersion 28
buildToolsVersion '28.0.2'
compileSdkVersion 30

defaultConfig {
minSdkVersion 14
targetSdkVersion 28
targetSdkVersion 30
versionCode 10
versionName "1.2.0"

Expand All @@ -32,10 +31,10 @@ dependencies {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.google.zxing:core:3.2.1'
implementation 'com.waynejo:androidndkgif:0.3.3'
testImplementation 'junit:junit:4.12'
implementation 'com.google.zxing:core:3.4.1'
implementation ('io.github.waynejo:androidndkgif:1.0.1')
testImplementation 'junit:junit:4.13.2'
}
repositories {
mavenCentral()
maven { url 'https://repo1.maven.org/maven2' }
}
Loading