Skip to content

Commit

Permalink
v4.3.0 and cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
rkistner committed Oct 25, 2021
1 parent a13ce2b commit cc12c10
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 30 deletions.
14 changes: 14 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
### 4.3.0 (2021-10-25)

* Minimum SDK version 19, but requires additional config (see readme) for < 24 compatibility.
* Add ScanOptions and ScanContract for use with `registerForActivityResult()`.
* Deprecates IntentIntegrator.
* Use minimal AndroidX libraries.

### 4.2.0 (2021-03-15)

* Fix MediaPlayer warnings (#587).
* Prevent CameraConfigurationUtils clash (#609).
* Add licenses to POM (#556).
* Bug: Crashes on SDK versions older than 21 (#645).

### 4.1.0 (2020-01-07)

* Ability to hide the laser in ViewfinderView (#503).
Expand Down
46 changes: 17 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,8 @@ repositories {
}
dependencies {
implementation 'com.journeyapps:zxing-android-embedded:4.2.0'
implementation 'com.journeyapps:zxing-android-embedded:4.3.0'
}
android {
buildToolsVersion '28.0.3' // Older versions may give compile errors
}
```

## Older SDK versions
Expand All @@ -51,16 +46,12 @@ repositories {
}
dependencies {
implementation('com.journeyapps:zxing-android-embedded:4.2.0') { transitive = false }
implementation('com.journeyapps:zxing-android-embedded:4.3.0') { transitive = false }
implementation 'com.google.zxing:core:3.3.0'
}
android {
buildToolsVersion '28.0.3'
}
```

### Option 2: Desugaring
### Option 2: Desugaring (Advanced)

This option does not require changing library versions, but may complicate the build process.

Expand Down Expand Up @@ -108,23 +99,20 @@ See for details: https://developer.android.com/training/basics/intents/result
`startActivityForResult` can still be used via `IntentIntegrator`, but that is not recommended anymore.

```java
// Note: startActivityForResult is deprecated, so this example uses registerForActivityResult instead.
// See for details: https://developer.android.com/training/basics/intents/result

// Register the launcher and result handler
private final ActivityResultLauncher<ScanOptions> barcodeLauncher = registerForActivityResult(new ScanContract(),
result -> {
if(result.getContents() == null) {
Toast.makeText(MyActivity.this, "Cancelled", Toast.LENGTH_LONG).show();
} else {
Toast.makeText(MyActivity.this, "Scanned: " + result.getContents(), Toast.LENGTH_LONG).show();
}
});

// Launch
public void onButtonClick(View view) {
barcodeLauncher.launch(new ScanOptions());
}
// Register the launcher and result handler
private final ActivityResultLauncher<ScanOptions> barcodeLauncher = registerForActivityResult(new ScanContract(),
result -> {
if(result.getContents() == null) {
Toast.makeText(MyActivity.this, "Cancelled", Toast.LENGTH_LONG).show();
} else {
Toast.makeText(MyActivity.this, "Scanned: " + result.getContents(), Toast.LENGTH_LONG).show();
}
});

// Launch
public void onButtonClick(View view) {
barcodeLauncher.launch(new ScanOptions());
}
```

Customize options:
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ subprojects {
mavenCentral()
}

version = '4.2.0'
version = '4.3.0'
group = 'com.journeyapps'

ext.androidTargetSdk = 30
Expand Down
1 change: 1 addition & 0 deletions zxing-android-embedded/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ android {
// We test with primitives such as Rect, and rely on their default behaviour working.
unitTests.returnDefaultValues = true
}

defaultConfig {
minSdkVersion 19
}
Expand Down

0 comments on commit cc12c10

Please sign in to comment.