Skip to content

Commit

Permalink
Dev
Browse files Browse the repository at this point in the history
  • Loading branch information
yuriy-budiyev committed May 24, 2022
1 parent 1b0575d commit 2999ed5
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 18 deletions.
57 changes: 41 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Code scanner library for [Android](https://developer.android.com), based on [ZXi
### Usage ([sample](https://github.com/yuriy-budiyev/lib-demo-app))

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

```gradle
allprojects {
Expand All @@ -39,6 +40,7 @@ allprojects {
```

or in settings.gradle file:

```gradle
dependencyResolutionManagement {
Expand All @@ -50,47 +52,69 @@ dependencyResolutionManagement {
```

Step 2. Add dependency:

```gradle
dependencies {
implementation 'com.github.yuriy-budiyev:code-scanner:2.3.0'
implementation 'com.github.yuriy-budiyev:code-scanner:2.3.1'
}
```

Add camera permission and hardware feature to AndroidManifest.xml (Don't forget about dynamic permissions on API >= 23):

```xml
<uses-permission android:name="android.permission.CAMERA"/>

<uses-feature
android:name="android.hardware.camera"
android:required="false"/>
```

Define a view in your layout file:

```xml
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">

<com.budiyev.android.codescanner.CodeScannerView
android:id="@+id/scanner_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:autoFocusButtonColor="@android:color/white"
app:autoFocusButtonVisible="true"
app:flashButtonColor="@android:color/white"
app:flashButtonVisible="true"
app:frameColor="@android:color/white"
app:frameCornersSize="50dp"
app:frameCornersRadius="0dp"
app:frameAspectRatioWidth="1"
app:frameAspectRatioHeight="1"
app:frameSize="0.75"
app:frameThickness="2dp"
app:frameVerticalBias="0.5"
app:maskColor="#77000000"/>
android:layout_height="match_parent"/>
</FrameLayout>
```

You can use XML attributes to set view parameters:

```
maskColor
maskVisible
frameColor
frameVisible
frameThickness
frameCornersSize
frameCornersRadius
frameAspectRatioWidth
frameAspectRatioHeight
frameSize
frameVerticalBias
autoFocusButtonColor
autoFocusButtonVisible
autoFocusButtonPaddingHorizontal
autoFocusButtonPaddingVertical
autoFocusButtonOnIcon
autoFocusButtonOffIcon
autoFocusButtonPosition
flashButtonColor
flashButtonVisible
flashButtonPaddingHorizontal
flashButtonPaddingVertical
flashButtonOnIcon
flashButtonOffIcon
flashButtonPosition
```

And add following code to your activity:

Kotlin
Expand Down Expand Up @@ -145,6 +169,7 @@ class MainActivity : AppCompatActivity() {
```

Java

```java
public class MainActivity extends AppCompatActivity {
private CodeScanner mCodeScanner;
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ apply plugin: 'com.android.library'
apply plugin: 'maven-publish'

ext {
libraryVersion = '2.3.0'
libraryVersion = '2.3.1'
publishedGroupId = 'com.budiyev.android'
}

Expand All @@ -41,7 +41,7 @@ android {
defaultConfig {
minSdkVersion 19
targetSdkVersion 32
versionCode 61
versionCode 62
versionName libraryVersion
}

Expand Down

0 comments on commit 2999ed5

Please sign in to comment.