Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kroegerama/barcode-kaiteki
AndroidX and Camera2 based library for easy barcode scanning. Includes BarcodeView and different ready to use dialogs.
https://github.com/kroegerama/barcode-kaiteki
Last synced: about 1 month ago
JSON representation
AndroidX and Camera2 based library for easy barcode scanning. Includes BarcodeView and different ready to use dialogs.
- Host: GitHub
- URL: https://github.com/kroegerama/barcode-kaiteki
- Owner: kroegerama
- License: apache-2.0
- Created: 2019-08-04T07:25:34.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2021-05-13T09:19:40.000Z (over 3 years ago)
- Last Synced: 2023-11-07T15:24:53.986Z (about 1 year ago)
- Language: Kotlin
- Size: 2.8 MB
- Stars: 124
- Watchers: 6
- Forks: 18
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
![Publish](https://github.com/kroegerama/barcode-kaiteki/workflows/Publish/badge.svg)
![License](https://img.shields.io/github/license/kroegerama/barcode-kaiteki)| Artifact | Version |
|:-|:-:|
| com.kroegerama:barcode-kaiteki | [![Maven Central](https://img.shields.io/maven-central/v/com.kroegerama/barcode-kaiteki)](https://search.maven.org/artifact/com.kroegerama/barcode-kaiteki) |## Barcode-Kaiteki
An easy to use library for barcode detection. Based on the new **AndroidX** **Camera2** api. Uses the **zxing** barcode detection library.
Comes with a **BarcodeView**, which combines a camera preview and an automatic overlay for detected barcodes.
#### Also contains three differend ready to use dialogs:
* **BarcodeDialog** *(DialogFragment)*
* **BarcodeBottomSheet** *(BottomSheetDialogFragment)*
* **BarcodeAlertDialog** *(AlertDialog)*
* **BarcodeFragment** *(Fragment)*
#### Features
* camera permission handling
* customize the displayed result points
* customize the barcode type (can be a list)
* allows scanning of inverted barcodes (white barcode on black background)#### Add library dependency
barcode-kaiteki is distributed via MavenCentral. Just add it a as a dependency:
```gradle
dependencies {
implementation("com.kroegerama:barcode-kaiteki:")
}
```#### Usage
##### BarcodeDialog
Just let your Activity/Fragment implement **BarcodeResultListener**.
```kotlin
class MainActivity : AppCompatActivity(), BarcodeResultListener {//...
override fun onBarcodeResult(result: Result): Boolean {
Log.d(TAG, "Result: $result")//return false to not automatically close the dialog
return false
}
}```
Then it is as easy as showing one of the provided dialogs.
```kotlin
//show a Barcode FragmentDialog (with swipe to dismiss)
BarcodeDialog.show(
childFragmentManager,
formats = listOf(BarcodeFormat.QR_CODE),
barcodeInverted = false
)//show a Barcode BottomSheet
BarcodeBottomSheet.show(
childFragmentManager,
formats = listOf(BarcodeFormat.QR_CODE),
barcodeInverted = false
)//show an AlertDialog from activity
showBarcodeAlertDialog(
owner = this,
listener = this,
formats = listOf(BarcodeFormat.QR_CODE),
barcodeInverted = false
)
//or from a Fragment
requireContext().showBarcodeAlertDialog(
owner = this,
listener = this,
formats = listOf(BarcodeFormat.QR_CODE),
barcodeInverted = false
)//show a Barcode Fragment
val barcodeFragment = BarcodeFragment.makeInstance(
formats = listOf(BarcodeFormat.QR_CODE),
barcodeInverted = false
)
supportFragmentManager.beginTransaction()
.replace(R.id.container, barcodeFragment)
.commit()
```##### BarcodeView
You can also use the **BarcodeView** directly in your Layout.
```xml
```
Then add in your *onCreate/onViewCreated*: ```bcode.bindToLifecycle(this)``` and in your *onStop*: ```bcode.unbind()```.
```kotlin
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
bcode.setFormats(listOf(BarcodeFormat.QR_CODE, BarcodeFormat.AZTEC))
bcode.setBarcodeResultListener(this)
bcode.bindToLifecycle(this)
}override fun onStop() {
super.onStop()
bcode.unbind()
}
```