Giter Site home page Giter Site logo

brightec / kbarcode Goto Github PK

View Code? Open in Web Editor NEW
99.0 10.0 16.0 7.05 MB

A library to help implement barcode scanning

License: MIT License

Shell 1.27% Kotlin 96.77% Java 1.96%
barcode-libraries barcode-scanning camera2 firebase android android-development android-barcode

kbarcode's Introduction

KBarcode


⚠️ Signing key revoked

The key used to sign the maven central distributions for this library has been revoked. If you have issues importing them, we suggest either migrating to CameraX (see deprecation notice below) or importing the source code of this library directly into you project.


⚠️ Deprecated: This library is no longer maintained

This library was written before the first stable release of the CameraX library. It was intended to provide a thorough and high quality implementation of the camera2 APIs. Since the launch of CameraX and it's ongoing development, we would recommend using that library for a barcode scanning use case.

To help you migrate we already have an example of a CameraX implementation within the demo app included in this repo. See also CameraX section of our wiki





Maven Central

A library to help implement barcode scanning.





Why?

Another barcode library. Yawn.

We can understand why you may think that, but there are some key reasons we decided to write a new barcode library.

  • Quality We want this library to be a high quality production ready library.
  • Camera2 Many barcode libraries still use camera1 API's. These are now deprecated and although unlikely to be removed, you can get better performance and stability from camera2. You are also safe in the knowledge that Android will work to fix issues, and the library will have more longevity.
  • MLKit This library uses Google MLKit to process the frames and return barcodes. The Google team are committed to these API's and continue to work to improve them.
  • Tested We want this library to have tests. It's surprising how many don't.
  • Simple We want the implementation to be simple, but not try to hide away too much of the complexity of the task.

Download

implementation 'uk.co.brightec.kbarcode:kbarcode:$version'

Releases

See the releases section for details about each release and any migration steps required.

Releases requiring migration: 1.0.2, 1.0.3, 1.3.0

Releases with behaviour changes: 1.1.0, 1.2.3

Wiki

For a detailed look at the library and a full get started guide checkout the wiki

Community

We welcome community involvement with this library. We want this library to be useful for others, and of a high production quality.

Issues

Please do raise issues if you find problems with the library, sample or its documentation. We have provided a template to use.

Pull Requests

If you find an issue, why not try to fix it and create a pull request. We run CI checks on every pull request which must pass. To run these locally

./gradlew check connectedAndroidTest

This will run our code standards checks, lint, tests and instrumented tests.

If you're keen to help, why not fix someone else's issue.

Feature Requests

You can submit feature requests as issues. As mentioned above we want this library to be simple, high quality and production ready. We therefore may be selective about which features we wish to include in order to achieve these goals.

Before fully coding a feature, why not raise an issue to start a discussion with us.

License

See license

Author

Alistair Sykes - Github Medium Twitter

This library is maintained by the Brightec team

kbarcode's People

Contributors

alistairsykes avatar chrisleversuch avatar nickholcombe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

kbarcode's Issues

Crash on back

When I press the back button the app crashes.

I'm using jetpack navigation.

  1. Fragment A open fragment B (this is the fragment with the barcode viewer)
  2. from fragment B I press back button,

Expected behavior
the app back to fragment A, but it close, I can't see any log on logcat, it just crash with no reason and no messages
this is the only log I found but I'm not sure it's releated:


2021-10-28 17:20:29.917 3144-4100/swaix.dev.xxxxxxx E/BufferQueueProducer: [ImageReader-4000x3000f23m3-3144-1](id:c4800000001,api:4,p:1129,c:3144) dequeueBuffer: BufferQueue has been abandoned
    
    --------- beginning of crash
2021-10-28 17:20:29.917 3144-3918/swaix.dev.xxxxxxx A/libc: Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x7bbc626f2d in tid 3918 (pool-3-thread-1), pid 3144 (dev.xxxxxxx )
2021-10-28 17:20:29.997 3144-3166/swaix.dev.xxxxxxx  E/BufferQueueProducer: [ImageReader-4000x3000f23m3-3144-1](id:c4800000001,api:4,p:1129,c:3144) queueBuffer: BufferQueue has been abandoned
2021-10-28 17:20:30.031 3144-3144/swaix.dev.xxxxxxx E/BufferQueueProducer: [ImageReader-4000x3000f23m3-3144-1](id:c4800000001,api:4,p:1129,c:3144) cancelBuffer: BufferQueue has been abandoned
2021-10-28 17:20:30.032 3144-3144/swaix.dev.xxxxxxx E/BufferQueueProducer: [ImageReader-4000x3000f23m3-3144-1](id:c4800000001,api:4,p:1129,c:3144) cancelBuffer: BufferQueue has been abandoned
2021-10-28 17:20:30.226 3144-3144/swaix.dev.xxxxxxx E/BarcodeImageProcessor: Barcode processing error
    kotlinx.coroutines.JobCancellationException: StandaloneCoroutine was cancelled; job=StandaloneCoroutine{Cancelling}@d2bd765
2021-10-28 17:20:31.148 3144-3144/swaix.dev.xxxxxxx E/BarcodeReaderFragment: *****---- ON PAUSE BARCODE

it looks like it crashes after on pause.

Smartphone (please complete the following information):

  • Device: Pixel 2xl, Samsung a50
  • OS: Android 11

Additional context
it works fine on emulator :|

[FEATURE] Black screen when Camera permission denied.

Thank you for providing awesome library 😃
Is your feature request related to a problem? Please describe.
When I cleared data and reinstalled an app using Barcode view,it kept black screen without any warning and error. So,it took a lot of time to solve.
Though it was stupid error due to no Camera Permission, but sometimes we forget:cry:

Describe the solution you'd like
Throw a Exception when it has no camera permission.

[BUG] Crash on VisionImageProcessorSingleBase$startDetection$2.onComplete()

Lib leads to a crash on uk.co.brightec.kbarcode.processor.base.VisionImageProcessorSingleBase$startDetection$2.onComplete(VisionImageProcessorSingleBase.java:4)

Tested on Huawei Honor 8X

To Reproduce
Steps to reproduce the behavior:
Adding the BarcodeView in kotlin code:

        this?.activity?.let {
        val barcodeView = BarcodeView(it)
        barcodeView.apply {
            setOptions(
                Options.Builder()
                    .cameraFacing(CameraCharacteristics.LENS_FACING_BACK)
                    .barcodeFormats(
                        intArrayOf(
                            Barcode.FORMAT_CODE_128,
                            Barcode.FORMAT_CODE_39,
                            Barcode.FORMAT_CODE_93
                        )
                    )
                    .barcodesSort(null)
                    .scaleType(BarcodeView.CENTER_CROP)
                    .build()
            )
            this.layoutParams =
                FrameLayout.LayoutParams(
                    FrameLayout.LayoutParams.MATCH_PARENT,
                    FrameLayout.LayoutParams.MATCH_PARENT
                )
            layout.addView(this)
            lifecycle.addObserver(this)
        }
        }

Expected behavior
Showing the camera canvas

Smartphone:

  • Device: Huawei Honor 8X

Additional context
This is the crashlytics message:

Fatal Exception: x.b
at uk.co.brightec.kbarcode.processor.base.VisionImageProcessorSingleBase$startDetection$2.onComplete(VisionImageProcessorSingleBase.java:4)
at com.google.android.gms.tasks.zzj.run(zzj.java:6)
at android.os.Handler.handleCallback(Handler.java:907)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:216)
at android.app.ActivityThread.main(ActivityThread.java:7625)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:987)

[BUG] App crash when returning to it

Describe the bug
After just having used the scanning functionality, then closing the app, and the re-opening the app, I encountered the following exception:

java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:503)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: java.lang.reflect.InvocationTargetException        at java.lang.reflect.Method.invoke(Method.java:-2)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: android.hardware.camera2.CameraAccessException: CAMERA_DISCONNECTED (2): checkPidStatus:1708: The camera device has been disconnected
        at android.hardware.camera2.CameraManager.throwAsPublicException(CameraManager.java:728)
        at android.hardware.camera2.impl.ICameraDeviceUserWrapper.waitUntilIdle(ICameraDeviceUserWrapper.java:179)
        at android.hardware.camera2.impl.CameraDeviceImpl.waitUntilIdle(CameraDeviceImpl.java:1135)
        at android.hardware.camera2.impl.CameraDeviceImpl.configureStreamsChecked(CameraDeviceImpl.java:436)
        at android.hardware.camera2.impl.CameraDeviceImpl.createCaptureSessionInternal(CameraDeviceImpl.java:662)
        at android.hardware.camera2.impl.CameraDeviceImpl.createCaptureSession(CameraDeviceImpl.java:510)
        at uk.co.brightec.kbarcode.camera.Camera2Source.createCaptureSession$kbarcode_release(Camera2Source.kt:121)
        at uk.co.brightec.kbarcode.camera.Camera2Source$start$1.onOpened(Camera2Source.kt:55)
        at android.hardware.camera2.impl.CameraDeviceImpl$1.run(CameraDeviceImpl.java:143)
        at android.os.Handler.handleCallback(Handler.java:873)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:193)
        at android.app.ActivityThread.main(ActivityThread.java:6718)
        at java.lang.reflect.Method.invoke(Method.java:-2)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: android.os.ServiceSpecificException: checkPidStatus:1708: The camera device has been disconnected
        at android.os.Parcel.createException(Parcel.java:1964)
        at android.os.Parcel.readException(Parcel.java:1918)
        at android.os.Parcel.readException(Parcel.java:1868)
        at android.hardware.camera2.ICameraDeviceUser$Stub$Proxy.waitUntilIdle(ICameraDeviceUser.java:599)
        at android.hardware.camera2.impl.ICameraDeviceUserWrapper.waitUntilIdle(ICameraDeviceUserWrapper.java:177)
        at android.hardware.camera2.impl.CameraDeviceImpl.waitUntilIdle(CameraDeviceImpl.java:1135)
        at android.hardware.camera2.impl.CameraDeviceImpl.configureStreamsChecked(CameraDeviceImpl.java:436)
        at android.hardware.camera2.impl.CameraDeviceImpl.createCaptureSessionInternal(CameraDeviceImpl.java:662)
        at android.hardware.camera2.impl.CameraDeviceImpl.createCaptureSession(CameraDeviceImpl.java:510)
        at uk.co.brightec.kbarcode.camera.Camera2Source.createCaptureSession$kbarcode_release(Camera2Source.kt:121)
        at uk.co.brightec.kbarcode.camera.Camera2Source$start$1.onOpened(Camera2Source.kt:55)
        at android.hardware.camera2.impl.CameraDeviceImpl$1.run(CameraDeviceImpl.java:143)
        at android.os.Handler.handleCallback(Handler.java:873)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:193)
        at android.app.ActivityThread.main(ActivityThread.java:6718)
        at java.lang.reflect.Method.invoke(Method.java:-2)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

I believe this is rather rare though, but it might be good if you handled this some better way that doesn't cause the app to crash.

To Reproduce
Steps to reproduce the behavior:
Close app, and then re-open it. Doesn't happen all the time though.

Expected behavior
I expected the app to re-open with the camera view and the scanning started as normal. This is what happens most of the time, except this one time when I got the exception.

Screenshots
N/A

Smartphone (please complete the following information):

  • Device: Google Pixel 2 XL
  • OS: Android 9, API 28

Additional context
None

[FEATURE] Barcodes Filter

Is your feature request related to a problem? Please describe.
No problem

Describe the solution you'd like
Similar to the already implemented sort feature, it would be great to add a filter, which would enable functionality such as only returning barcodes within a certain area (i.e. viewfinder).

It would be great to provide a base class (similar to BarcodeComparator.kt) which can provide the FrameMetadata, in order to enable more functionality.

Describe alternatives you've considered
This can be done manually within the implementation listener, but would be simpler if it was integrated into the library.

Additional context
None

[BUG] Manifest forces "uses-feature"

In the android manifest the "uses-feature" forces the application that uses this library to use them.
An app could have the barcode scanning as optional feature, but by forcing these feature, the app cannot be installed because google play filters devices not matching.

A possible solution could be a change of:
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />

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

Originally posted by @falkontre in #1 (comment)

[FEATURE] FirebaseVisionBarcode is deprecated, migrate to ML Kit SDK

Describe the solution you'd like

The FirebaseVisionBarcode class is deprecated. Google states:

The standalone ML Kit SDK replaces this API. For more information, refer to the migration guide.

Do you have plans to migrate your very well designed library?

Describe alternatives you've considered

I have considered the following alternatives if Brightec does not plan to do this migration.

  • Updating the library myself.
  • Using the ML Kit SDK instead of the KBarcode library.

[BUG] Mocking Barcode.class

Describe the bug
Mockito is unable to mock class uk.co.brightec.kbarcode.Barcode.

Caused by: java.lang.ClassNotFoundException: com.google.firebase.ml.vision.barcode.FirebaseVisionBarcode

To Reproduce
Steps to reproduce the behavior:

  • Attempt to mock a Barcode in a unit test

Expected behavior
Barcode should be mockable

Screenshots
N/A

Smartphone (please complete the following information):
N/A

Additional context
None

[FEATURE] Ui test

Is your feature request related to a problem? Please describe.

Reading documentation i don't see any topic on how to use this view with UI testing (like Espresso).

Have you any tip that you can provide, so it's easy to do a test that request to scan a barcode?

Describe the solution you'd like

On test method:

activity.findViewById<KBarcodeView>(R.id.barcodeScanner).doScan(mockBarcode)

Surface had no valid native window. on barcodeView.start()

Once I grant the CAMERA permissions barcodeView.start() throws an error

On Android Marshmallow is not needed call to start but on Android Pie

I want to know if there is a way to know if the barcode is already started to avoid calling .start()

E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.centinal.ivs.internal.debug, PID: 17159
java.lang.IllegalArgumentException: Surface was abandoned
at android.hardware.camera2.utils.SurfaceUtils.getSurfaceSize(SurfaceUtils.java:70)
at android.hardware.camera2.params.OutputConfiguration.(OutputConfiguration.java:97)
at android.hardware.camera2.params.OutputConfiguration.(OutputConfiguration.java:71)
at android.hardware.camera2.impl.CameraDeviceImpl.createCaptureSession(CameraDeviceImpl.java:474)
at uk.co.brightec.kbarcode.camera.Camera2Source.createCaptureSession$kbarcode_release(Camera2Source.kt:121)
at uk.co.brightec.kbarcode.camera.Camera2Source$start$1.onOpened(Camera2Source.kt:55)
at android.hardware.camera2.impl.CameraDeviceImpl$1.run(CameraDeviceImpl.java:134)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: android.hardware.camera2.legacy.LegacyExceptionUtils$BufferQueueAbandonedException
at android.hardware.camera2.legacy.LegacyExceptionUtils.throwOnError(LegacyExceptionUtils.java:64)
at android.hardware.camera2.legacy.LegacyCameraDevice.getSurfaceSize(LegacyCameraDevice.java:540)
at android.hardware.camera2.utils.SurfaceUtils.getSurfaceSize(SurfaceUtils.java:68)
at android.hardware.camera2.params.OutputConfiguration.(OutputConfiguration.java:97) 
at android.hardware.camera2.params.OutputConfiguration.(OutputConfiguration.java:71) 
at android.hardware.camera2.impl.CameraDeviceImpl.createCaptureSession(CameraDeviceImpl.java:474) 
at uk.co.brightec.kbarcode.camera.Camera2Source.createCaptureSession$kbarcode_release(Camera2Source.kt:121) 
at uk.co.brightec.kbarcode.camera.Camera2Source$start$1.onOpened(Camera2Source.kt:55) 
at android.hardware.camera2.impl.CameraDeviceImpl$1.run(CameraDeviceImpl.java:134) 
at android.os.Handler.handleCallback(Handler.java:739) 
at android.os.Handler.dispatchMessage(Handler.java:95) 
at android.os.Looper.loop(Looper.java:148) 
at android.app.ActivityThread.main(ActivityThread.java:5417) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 

[QUESTION] - minSDK

TnQ for this great lib.
however when i want to add this lib it gives me this build failure:

Manifest merger failed : uses-sdk:minSdkVersion 18 cannot be smaller than version 21 declared in library [uk.co.brightec.kbarcode:kbarcode:1.0.3] C:\Users\satari-s\.gradle\caches\transforms-2\files-2.1\a77019e964680a36c49ac5f39ad6b767\AndroidManifest.xml as the library might be using APIs not available in 18
	Suggestion: use a compatible library with a minSdk of at most 18,
		or increase this project's minSdk version to at least 21,
		or use tools:overrideLibrary="uk.co.brightec.kbarcode" to force usage (may lead to runtime failures)

Is it possible to decrease the min sdk version?

[BUG] Library doesn't work at all

Describe the bug
Current version of library doesnt work because it uses old dependecies that will throw exception on build

Duplicate class com.google.android.gms.internal.vision.zze found in modules jetified-play-services-vision-20.0.0-runtime (com.google.android.gms:play-services-vision:20.0.0) and jetified-play-services-vision-common-19.1.0-runtime (com.google.android.gms:play-services-vision-common:19.1.0)
Duplicate class com.google.android.gms.internal.vision.zzf found in modules jetified-play-services-vision-20.0.0-runtime (com.google.android.gms:play-services-vision:20.0.0) and jetified-play-services-vision-common-19.1.0-runtime (com.google.android.gms:play-services-vision-common:19.1.0)
Duplicate class com.google.android.gms.internal.vision.zzg found in modules jetified-play-services-vision-20.0.0-runtime (com.google.android.gms:play-services-vision:20.0.0) and jetified-play-services-vision-common-19.1.0-runtime (com.google.android.gms:play-services-vision-common:19.1.0)
Duplicate class com.google.android.gms.internal.vision.zzh found in modules jetified-play-services-vision-20.0.0-runtime (com.google.android.gms:play-services-vision:20.0.0) and jetified-play-services-vision-common-19.1.0-runtime (com.google.android.gms:play-services-vision-common:19.1.0)
Duplicate class com.google.android.gms.internal.vision.zzi found in modules jetified-play-services-vision-20.0.0-runtime (com.google.android.gms:play-services-vision:20.0.0) and jetified-play-services-vision-common-19.1.0-runtime (com.google.android.gms:play-services-vision-common:19.1.0)
Duplicate class com.google.android.gms.internal.vision.zzv found in modules jetified-play-services-vision-20.0.0-runtime (com.google.android.gms:play-services-vision:20.0.0) and jetified-play-services-vision-common-19.1.0-runtime (com.google.android.gms:play-services-vision-common:19.1.0)
Duplicate class com.google.android.gms.internal.vision.zzw found in modules jetified-play-services-vision-20.0.0-runtime (com.google.android.gms:play-services-vision:20.0.0) and jetified-play-services-vision-common-19.1.0-runtime (com.google.android.gms:play-services-vision-common:19.1.0)

Go to the documentation to learn how to Fix dependency resolution errors.

If you manually add newest version of play-services-vision then you will get runtime crash on library init

E/AndroidRuntime: FATAL EXCEPTION: FirebaseMLHandler
    Process: com.p1ng2win.gabiapplication, PID: 7373
    java.lang.VerifyError: Superclass com.google.firebase.ml.vision.barcode.internal.zzj of com.google.firebase.ml.vision.barcode.BarcodeDetectorCreator is declared final (declaration of 'com.google.firebase.ml.vision.barcode.BarcodeDetectorCreator' appears in /data/app/com.p1ng2win.gabiapplication-KiY0_DnxVctfCKFLF5qfYg==/base.apk!classes2.dex)
        at java.lang.VMClassLoader.findLoadedClass(Native Method)
        at java.lang.ClassLoader.findLoadedClass(ClassLoader.java:738)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:363)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
        at com.google.android.gms.dynamite.DynamiteModule.instantiate(com.google.android.gms:play-services-basement@@17.3.0:257)
        at com.google.firebase.ml.vision.barcode.internal.zzc.zzqu(com.google.firebase:firebase-ml-vision@@24.1.0:25)
        at com.google.firebase.ml.vision.barcode.internal.zzc.zzow(com.google.firebase:firebase-ml-vision@@24.1.0:10)
        at com.google.android.gms.internal.firebase_ml.zzqz.zzf(com.google.firebase:firebase-ml-common@@22.1.2:53)
        at com.google.android.gms.internal.firebase_ml.zzqz$zza.zzoz(com.google.firebase:firebase-ml-common@@22.1.2:7)
        at com.google.android.gms.internal.firebase_ml.zzqz$zza.call(com.google.firebase:firebase-ml-common@@22.1.2:24)
        at com.google.android.gms.internal.firebase_ml.zzqf.zza(com.google.firebase:firebase-ml-common@@22.1.2:32)
        at com.google.android.gms.internal.firebase_ml.zzqe.run(Unknown Source:4)
        at android.os.Handler.handleCallback(Handler.java:883)
        at android.os.Handler.dispatchMessage(Handler.java:100)
        at android.os.Looper.loop(Looper.java:224)
        at android.os.HandlerThread.run(HandlerThread.java:67)

To Reproduce
Steps to reproduce the behavior:
Literally try to use library

My gradle



apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'io.sentry.android.gradle'
apply plugin: 'com.google.firebase.crashlytics'
apply plugin: 'com.google.firebase.firebase-perf'
apply plugin: "androidx.navigation.safeargs.kotlin"

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.3"
    defaultConfig {
        applicationId "com.p1ng2win.gabiapplication"
        minSdkVersion 21
        targetSdkVersion 29
        versionCode 68 //56
        versionName "1.820" //1.81
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            shrinkResources false

            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        coreLibraryDesugaringEnabled true

        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = "1.8"
    }

    packagingOptions {
        exclude 'META-INF/atomicfu.kotlin_module'
    }
}

androidExtensions {
    experimental = true
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'androidx.core:core-ktx:1.3.2'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
    implementation 'com.google.android.material:material:1.2.1'
    implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0"
    implementation 'com.android.support:multidex:1.0.3'
    implementation 'androidx.preference:preference-ktx:1.1.1'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'

    coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.1'

    //arch
    implementation "androidx.lifecycle:lifecycle-runtime-ktx:$ktx_version"
    implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$ktx_version"
    implementation "androidx.lifecycle:lifecycle-livedata-ktx:$ktx_version"
    implementation "androidx.fragment:fragment-ktx:1.2.5"

    //navigation
    implementation "androidx.navigation:navigation-fragment-ktx:$nav_version"
    implementation "androidx.navigation:navigation-ui-ktx:$nav_version"

    //testing
    testImplementation 'junit:junit:4.13.1'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'

    //GooglePlay
    implementation 'com.google.android.play:core:1.8.3'
    implementation 'com.google.android.play:core-ktx:1.8.1'
    implementation 'com.google.android.gms:play-services-vision:20.1.2'

    //Firebase
    implementation platform('com.google.firebase:firebase-bom:26.1.0')
    implementation 'com.google.firebase:firebase-analytics-ktx'
    implementation 'com.google.firebase:firebase-crashlytics-ktx'
    implementation 'com.google.firebase:firebase-messaging-ktx'
    implementation 'com.google.firebase:firebase-perf-ktx'

    //LiveData, ViewModel
    implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"
    implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version"
    implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"
    implementation "androidx.lifecycle:lifecycle-common-java8:$lifecycle_version"

    //Sentry (crash analytics)
    implementation 'io.sentry:sentry-android:3.1.0'

    //Retrofit
    implementation 'com.squareup.retrofit2:retrofit:2.9.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
    implementation 'com.squareup.retrofit2:converter-scalars:2.9.0'
    implementation 'com.squareup.okhttp3:logging-interceptor:4.9.0'

    //Glide
    implementation 'com.github.bumptech.glide:glide:4.11.0'
    kapt 'com.github.bumptech.glide:compiler:4.11.0'

    //BarcodeScanner
    implementation 'uk.co.brightec.kbarcode:kbarcode:1.2.2'
    implementation('com.journeyapps:zxing-android-embedded:4.1.0') { transitive = false }
    implementation 'com.google.zxing:core:3.3.0'

    //LeakCanary
    debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.2'

    //WebSocket
    implementation 'tech.gusavila92:java-android-websocket-client:1.2.2'

    //Grant Runtime Permission
    implementation 'com.androidisland.ezpermission:ezpermission:0.1.4'

    //SegmentedControl Button
    implementation 'com.github.trinnguyen:Android-SegmentView:master-SNAPSHOT'

    //Notification Builder
    implementation "io.karn:notify:1.3.0"

    implementation "androidx.room:room-runtime:$room_version"
    implementation "androidx.room:room-ktx:$room_version"
    kapt "androidx.room:room-compiler:$room_version"

    //KotlinX DateTime
    implementation "org.jetbrains.kotlinx:kotlinx-datetime:0.1.0"

    //Timber (logs)
    implementation 'com.jakewharton.timber:timber:4.7.1'

    //AdapterDelegates
    implementation 'com.hannesdorfmann:adapterdelegates4-kotlin-dsl:4.3.0'
    implementation 'com.hannesdorfmann:adapterdelegates4-kotlin-dsl-layoutcontainer:4.3.0'

}

Smartphone (please complete the following information):

  • Device: Xiaomi mi 9t
  • OS: MIUI 11
  • Version kbarcode:1.2.2

Additional context
I think you should migrate to google ml kit because firebase ml kit was deprecated

[BUG] Screen Lag every second

Describe the bug
First of TnQ for this great lib. its simple and completely a clean solution.
However There i an annoying bug. When camera shows up screen lags periodically every second. I think the problem is that you are processing bitmap on the main thread and when the device config is weak this bug happens.

To Reproduce
Run this lib on the mid level devices

Expected behavior
Camera must work without lag and calculating and processing must be in background thread

Smartphone (please complete the following information):

  • Device: [Samsung Galaxy J5]
  • OS: [Android 28]
  • Version [1.0.3]

[FEATURE] Toggle flash on/off

For low-light situations I was thinking of implementing a button to turn the flash on/off but I couldn't find a way to do it in the library. And from what I know, I can't turn the flash on separately if there's already a camera instance running. So, having this feature built into it could've really helped.

[FEATURE] Add a way to pause the camera preview, or clear the list of scanned barcodes.

Right now, calling barcodeView.start() or lifecycle.addObserver(barcodeView) starts the camera preview. Calling barcodeView.pause() does pause the barcode scanning, but not the preview. In order to actually pause the view, I have to call barcodeView.release(). This kinda works, but when starting the barcode view again, the onBarcodeListener gets called with the previous scanned value instantly.

Describe the solution you'd like
It would be great to have a way to stop the preview and barcode scanning altogether, and restart it later, without it firing the onBarcodeListener when resuming.

That would be possible through a pausePreview() and resumePreview method I suppose.

[BUG] Detection stops working when toggling flash

Describe the bug
The barcode detection stops working when i toggle the flash via setCameraFlashMode(). This is what i see in the error logs:

2022-10-15 12:20:57.008 23489-23489/hu.egis.greta E/BarcodeImageProcessor: Barcode processing error
    com.google.mlkit.common.MlKitException: This detector is already closed!
        at com.google.mlkit.vision.common.internal.MobileVisionBase.processBase(com.google.mlkit:vision-common@@16.3.0:3)
        at com.google.mlkit.vision.barcode.internal.BarcodeScannerImpl.process(com.google.android.gms:play-services-mlkit-barcode-scanning@@16.1.5:1)
        at uk.co.brightec.kbarcode.processor.BarcodeImageProcessor.detectInImage$kbarcode_release(BarcodeImageProcessor.kt:1)
        at uk.co.brightec.kbarcode.processor.base.ImageProcessorBase.startDetection$kbarcode_release(ImageProcessorBase.kt:30)
        at uk.co.brightec.kbarcode.processor.base.ImageProcessorBase$startDetection$1.invokeSuspend(Unknown Source:12)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
        at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
        at android.os.Handler.handleCallback(Handler.java:938)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loopOnce(Looper.java:226)
        at android.os.Looper.loop(Looper.java:313)
        at android.app.ActivityThread.main(ActivityThread.java:8669)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135)

I went through your code and i saw that the updateCameraFeature closes the BarcodeScanner, and it is not recreated. I saw that if i call setBarcodeFormats() then it will trigger a createScanner() so the barcode detection continues, but with this solution sometimes i get a crash:

2022-10-15 12:32:53.847 3210-26680/? E/DropBoxUtil: [AppErrors] null InputStream [CONTEXT service_id=254 ]
    java.io.IOException: null InputStream
        at bupm.c(:com.google.android.gms@[email protected] (190408-480654083):23)
        at buno.apply(:com.google.android.gms@[email protected] (190408-480654083):5)
        at jxy.apply(:com.google.android.gms@[email protected] (190408-480654083):0)
        at jym.apply(:com.google.android.gms@[email protected] (190408-480654083):5)
        at clsc.a(:com.google.android.gms@[email protected] (190408-480654083):0)
        at ctwm.a(:com.google.android.gms@[email protected] (190408-480654083):2)
        at cztz.d(:com.google.android.gms@[email protected] (190408-480654083):2)
        at czub.run(:com.google.android.gms@[email protected] (190408-480654083):9)
        at czvl.execute(:com.google.android.gms@[email protected] (190408-480654083):0)
        at cztx.q(:com.google.android.gms@[email protected] (190408-480654083):1)
        at cztx.gn(:com.google.android.gms@[email protected] (190408-480654083):4)
        at czub.g(:com.google.android.gms@[email protected] (190408-480654083):0)
        at clro.a(:com.google.android.gms@[email protected] (190408-480654083):4)
        at ctwk.a(:com.google.android.gms@[email protected] (190408-480654083):2)
        at czvr.a(:com.google.android.gms@[email protected] (190408-480654083):4)
        at czxt.a(:com.google.android.gms@[email protected] (190408-480654083):2)
        at czwu.run(:com.google.android.gms@[email protected] (190408-480654083):3)
        at czxv.run(:com.google.android.gms@[email protected] (190408-480654083):0)
        at czvt.run(:com.google.android.gms@[email protected] (190408-480654083):7)
        at czvl.execute(:com.google.android.gms@[email protected] (190408-480654083):0)
        at czvt.execute(:com.google.android.gms@[email protected] (190408-480654083):9)
        at cztx.q(:com.google.android.gms@[email protected] (190408-480654083):1)
        at cztx.gn(:com.google.android.gms@[email protected] (190408-480654083):4)
        at czvv.c(:com.google.android.gms@[email protected] (190408-480654083):5)
        at clrt.h(:com.google.android.gms@[email protected] (190408-480654083):4)
        at clsd.a(:com.google.android.gms@[email protected] (190408-480654083):0)
        at ctwm.a(:com.google.android.gms@[email protected] (190408-480654083):2)
        at cztz.d(:com.google.android.gms@[email protected] (190408-480654083):2)
        at czub.run(:com.google.android.gms@[email protected] (190408-480654083):9)
        at czvl.execute(:com.google.android.gms@[email protected] (190408-480654083):0)
        at cztx.q(:com.google.android.gms@[email protected] (190408-480654083):1)
        at cztx.gn(:com.google.android.gms@[email protected] (190408-480654083):4)
        at czub.g(:com.google.android.gms@[email protected] (190408-480654083):0)
        at clsa.a(:com.google.android.gms@[email protected] (190408-480654083):4)
        at ctwk.a(:com.google.android.gms@[email protected] (190408-480654083):2)
        at czvr.a(:com.google.android.gms@[email protected] (190408-480654083):4)
        at czxt.a(:com.google.android.gms@[email protected] (190408-480654083):2)
        at czwu.run(:com.google.android.gms@[email protected] (190408-480654083):3)
        at czxv.run(:com.google.android.gms@[email protected] (190408-480654083):0)
        at czvt.run(:com.google.android.gms@[email protected] (190408-480654083):7)
        at czvl.execute(:com.google.android.gms@[email protected] (190408-480654083):0)
        at czvt.execute(:com.google.android.gms@[email protected] (190408-480654083):9)
        at cztx.q(:com.google.android.gms@[email protected] (190408-480654083):1)
        at cztx.gn(:com.google.android.gms@[email protected] (190408-480654083):4)
        at czvv.c(:com.google.android.gms@[email protected] (190408-480654083):5)
        at clsi.c(:com.google.android.gms@[email protected] (190408-480654083):5)
        at clsi.b(:com.google.android.gms@[email protected] (190408-480654083):2)
        at com.google.android.gms.stats.service.DropBoxEntryAddedChimeraService.a(:com.google.android.gms@[email protected] (190408-480654083):32)
2022-10-15 12:32:53.847 3210-26680/? E/DropBoxUtil:     at com.google.android.gms.framework.tracing.wrapper.TracingIntentService.onHandleIntent(:com.google.android.gms@[email protected] (190408-480654083):1)
        at gjl.handleMessage(:com.google.android.gms@[email protected] (190408-480654083):0)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loopOnce(Looper.java:226)
        at android.os.Looper.loop(Looper.java:313)
        at android.os.HandlerThread.run(HandlerThread.java:67)

[FEATURE] Click to focus in barcode view

Is your feature request related to a problem? Please describe.
No problem.

Describe the solution you'd like
Rather than relying autofocus, it would be nice to allow the user to click within the view to focus.

Describe alternatives you've considered
None really..

Additional context
None

[BUG] Empty CameraIdList

Describe the bug
CameraManager.cameraIdList could hypothetically be an empty list.

To Reproduce
Unknown exactly how to make this occur

Expected behavior
Report the error to the caller using the OnCameraReadyListener

Screenshots
N/A

Smartphone (please complete the following information):
Unknown

Additional context
None

Dim light

very low light when the camera opens any solution?

[BUG] Surface destroyed

Describe the bug
If the surface was prematurely destroyed, not caused by lifecycle then the camera source will still be trying to access it.
If caused by lifecycle it is handled by the KBarcode.release() method.

To Reproduce
Unknown

Expected behavior
Within SurfaceHolder.Callback.surfaceDestroyed in BarcodeView we should call barcodeScanner.release(). This might involve a slight refactor of how we have setup the SurfaceHolder.Callback in order to make this scenario a bit more clear.

Screenshots
N/A

Smartphone (please complete the following information):
Unknown

Additional context
None

[BUG] Samsung Galaxy S9

Describe the bug

On Samsung Galaxy S9 device, camera is not even started and activity gets stuck

To Reproduce
Steps to reproduce the behavior:

  1. Implement on Galaxy S9

Expected behavior
Camera preview is shown and able to scan

Screenshots
If applicable, add screenshots to help explain your problem.

Smartphone (please complete the following information):

  • Device: Samsung Galaxy S9
  • OS: Android 9
  • Version 1.0.3

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.