Skip to content

Commit

Permalink
add README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
kroegerama committed Aug 4, 2019
1 parent d668429 commit c2d49b7
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 0 deletions.
108 changes: 108 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
[![Release](https://jitpack.io/v/kroegerama/barcode-kaiteki.svg)](https://jitpack.io/#com.kroegerama/barcode-kaiteki)
[![Build Status](https://travis-ci.org/kroegerama/barcode-kaiteki.svg?branch=master)](https://travis-ci.org/kroegerama/barcode-kaiteki)

## Barcode-Kaiteki

<img width="200" src="art/qr-code.png">

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)*

<img width="200" src="art/screen-dialogfragment.png">&emsp;<img width="200" src="art/screen-bottomsheet.png">&emsp;<img width="200" src="art/screen-alertdialog.png">

#### Features

* camera permission handling
* customize the displayed result points
* customize the barcode type (can be a list)

#### Add library dependency

Add jitpack to your toplevel gradle file (if not already present):

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

Add barcode-kaiteki as dependency:

```gradle
dependencies {
implementation 'com.kroegerama:barcode-kaiteki:<version>'
}
```

#### 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(supportFragmentManager, listOf(BarcodeFormat.QR_CODE))

//show a Barcode BottomSheet
BarcodeBottomSheet.show(supportFragmentManager, listOf(BarcodeFormat.QR_CODE))

//or show an AlertDialog
showBarcodeAlertDialog(this, this, listOf(BarcodeFormat.QR_CODE))
```

##### BarcodeView

You can also use the **BarcodeView** directly in your Layout.

```xml
<com.kroegerama.kaiteki.bcode.views.BarcodeView
android:id="@+id/bcode"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:resultPointColor="#09E85E"
app:resultPointSize="8dp"
app:showResultPoints="true" />
```

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()
}
```
Binary file added art/screen-alertdialog.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added art/screen-bottomsheet.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added art/screen-dialogfragment.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit c2d49b7

Please sign in to comment.