Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ch.ubique.android:qrscanner-compose

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ch.ubique.android:qrscanner-compose

Compose support for the Ubique QR code scanner library

  • 1.0.0-dev-6
  • Source
  • Maven
  • Socket score

Version published
Maintainers
1
Source

QR Code Scanner for Android

License: MPL 2.0

QR Code Scanner for Android built by Ubique based on AndroidX Camera2 with support for ZXing or MLKit decoding.

Download

This library is available on mavenCentral()

// Core library containing the camera view and image analysis use case
implementation 'ch.ubique.android:qrscanner-core:1.0.0'

// ZXing based image decoders
implementation 'ch.ubique.android:qrscanner-zxing:1.0.0'

// MLKit based image decoders
implementation 'ch.ubique.android:qrscanner-mlkit:1.0.0'

// Jetpack Compose support
implementation 'ch.ubique.android:qrscanner-compose:1.0.0'

Quick Start

Check out the example app included in this repository on how to use the library. Note: Camera permission handling is not handled by the library, it is the responsibility of the client app to request the permission.

Android View

Include the view in your layout:

<ch.ubique.qrscanner.view.QrScannerView
    android:id="@+id/qrScanner"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

Define the image decoders to be used to scan for QR codes:

qrScanner.setImageDecoders(
    MLKitImageDecoder(),            // Available with the qrscanner-mlkit dependency
	GlobalHistogramImageDecoder(),  // Available with the qrscanner-zxing dependency
    HybridImageDecoder(),           // Available with the qrscanner-zxing dependency
)

Set a callback for the decoding state:

qrScanner.setScannercallback { state ->
    when (state) {
		is DecodingState.NotFound -> {} // None of the image decoders could detect a QR code
		is DecodingState.Decoded -> {}  // state.content contains the decoded QR code content
		is DecodingState.Error -> {}    // state.errorCode indicates the type of error that occured during the decoding
	}
}

Optional settings:

qrScanner.setFlash(false) // Activate/Deactivate the camera flash
qrScanner.setLinearZoom(0f) // Set the camera zoom on a linear scale from 0f to 1f
qrScanner.setFocusOnTap(true) // Enable/disable camera focus on tap
qrScanner.setScanningMode(ScanningMode.PARALLEL) // Change the scanning behavior when using multiple image decoders

Jetpack Compose

Invoke the composable in your screen:

QrScanner(
    imageDecoders = listOf(
		MLKitImageDecoder(),            // Available with the qrscanner-mlkit dependency
		GlobalHistogramImageDecoder(),  // Available with the qrscanner-zxing dependency
		HybridImageDecoder(),           // Available with the qrscanner-zxing dependency
    ),
    scannerCallback = QrScannerCallback { state ->
		when (state) {
			is DecodingState.NotFound -> {} // None of the image decoders could detect a QR code
			is DecodingState.Decoded -> {}  // state.content contains the decoded QR code content
			is DecodingState.Error -> {}    // state.errorCode indicates the type of error that occured during the decoding
		}
    },
    modifier = Modifier.fillMaxSize(),
    scanningMode = ScanningMode.PARALLEL,
    isFlashEnabled = remember { mutableStateOf(false) },
    linearZoom = remember { mutableStateOf(0f) },
)

License

This project is licensed under the terms of the MPL 2 license. See the LICENSE file for details.

FAQs

Package last updated on 27 Apr 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc