Skip to content

Commit d3564e3

Browse files
author
Jenkins
committed
8.1.306
1 parent 6866c96 commit d3564e3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+3931
-4250
lines changed

.dart_tool/package_config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@
158158
"languageVersion": "3.1"
159159
}
160160
],
161-
"generated": "2025-06-05T13:05:01.191685Z",
161+
"generated": "2025-06-18T15:00:23.898723Z",
162162
"generator": "pub",
163163
"generatorVersion": "3.7.2",
164164
"flutterRoot": "file:///Users/administratorregula/development/flutter",

android/build.gradle

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,34 @@
1+
rootProject.allprojects {
2+
repositories {
3+
google()
4+
mavenCentral()
5+
maven {
6+
url "https://maven.regulaforensics.com/RegulaDocumentReader"
7+
}
8+
}
9+
}
10+
111
apply plugin: 'com.android.library'
212
apply plugin: 'kotlin-android'
313

414
android {
5-
// Conditional for compatibility with AGP <4.2.
6-
if (project.android.hasProperty("namespace")) {
7-
namespace 'io.flutter.plugins.regula.documentreader.flutter_document_reader_api'
15+
namespace 'com.regula.plugin.documentreader'
16+
compileSdk 34
17+
18+
defaultConfig {
19+
minSdk 21
820
}
921

1022
compileOptions {
11-
sourceCompatibility = JavaVersion.VERSION_21
12-
targetCompatibility = JavaVersion.VERSION_21
23+
sourceCompatibility = JavaVersion.VERSION_11
24+
targetCompatibility = JavaVersion.VERSION_11
1325
}
14-
15-
compileSdk 34
16-
17-
defaultConfig {
18-
minSdk 21
26+
kotlinOptions {
27+
jvmTarget = '11'
1928
}
2029

2130
dependencies {
22-
implementation('com.regula.documentreader:api:7.7.11452') {
31+
implementation('com.regula.documentreader:api:8.1.11551') {
2332
transitive = true
2433
}
2534

@@ -43,13 +52,3 @@ android {
4352
}
4453
}
4554
}
46-
47-
rootProject.allprojects {
48-
repositories {
49-
google()
50-
mavenCentral()
51-
maven {
52-
url "https://maven.regulaforensics.com/RegulaDocumentReader"
53-
}
54-
}
55-
}

android/gradle/wrapper/gradle-wrapper.properties

Lines changed: 0 additions & 5 deletions
This file was deleted.
Lines changed: 20 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,4 @@
1-
//
2-
// BluetoothUtil.kt
3-
// DocumentReader
4-
//
5-
// Created by Pavel Masiuk on 21.09.2023.
6-
// Copyright © 2023 Regula. All rights reserved.
7-
//
8-
@file:SuppressLint("MissingPermission")
9-
10-
package io.flutter.plugins.regula.documentreader.flutter_document_reader_api
1+
package com.regula.plugin.documentreader
112

123
import android.Manifest.permission.ACCESS_FINE_LOCATION
134
import android.Manifest.permission.BLUETOOTH_CONNECT
@@ -22,6 +13,7 @@ import android.content.pm.PackageManager.PERMISSION_GRANTED
2213
import android.os.Build
2314
import android.os.IBinder
2415
import android.provider.Settings
16+
import android.util.Log
2517
import androidx.core.content.ContextCompat.checkSelfPermission
2618
import com.regula.common.ble.BLEWrapper
2719
import com.regula.common.ble.BleWrapperCallback
@@ -38,45 +30,41 @@ const val INTENT_REQUEST_ENABLE_LOCATION = 196
3830
const val INTENT_REQUEST_ENABLE_BLUETOOTH = 197
3931

4032
@SuppressLint("StaticFieldLeak")
41-
lateinit var bluetooth: BLEWrapper
33+
var bluetooth: BLEWrapper? = null
4234
lateinit var savedCallbackForPermissionResult: Callback
43-
var deviceConnected = false
4435

4536
fun connectBluetoothDevice(callback: Callback) {
46-
// return if already connected
47-
if (deviceConnected) return
37+
if (bluetooth?.isConnected == true) {
38+
Log.e("REGULA", "Bluetooth device already connected, returning false")
39+
callback(false)
40+
return
41+
}
4842

49-
// If some of the bluetooth permissions/settings don't match the requirements,
50-
// save callback for later and request the permissions/settings.
51-
// Callback will then be used in onRequestPermissionsResult for permission requests
52-
// and in onActivityResult for settings change requests.
5343
if (!isBluetoothSettingsReady(activity)) {
5444
savedCallbackForPermissionResult = callback
5545
return
5646
}
5747

58-
// set searching timeout
59-
val timer = object : TimerTask() {
48+
val timeout = object : TimerTask() {
6049
override fun run() {
61-
callback.success(false)
62-
bluetooth.stopDeviceScan()
63-
bluetooth.disconnect()
50+
callback(false)
51+
bluetooth?.stopDeviceScan()
52+
bluetooth?.disconnect()
6453
}
6554
}
66-
Timer().schedule(timer, SEARCHING_TIMEOUT)
55+
Timer().schedule(timeout, SEARCHING_TIMEOUT)
6756

68-
// start searching devices
6957
val bleIntent = Intent(context, RegulaBleService::class.java)
7058
context.startService(bleIntent)
7159
context.bindService(bleIntent, object : ServiceConnection {
7260
override fun onServiceConnected(name: ComponentName, service: IBinder) {
7361
bluetooth = (service as RegulaBleService.LocalBinder).service.bleManager
74-
bluetooth.addCallback(object : BleWrapperCallback() {
62+
if (bluetooth!!.isConnected) callback(true)
63+
else bluetooth!!.addCallback(object : BleWrapperCallback() {
7564
override fun onDeviceReady() {
76-
timer.cancel()
77-
bluetooth.removeCallback(this)
78-
deviceConnected = true
79-
callback.success(true)
65+
timeout.cancel()
66+
bluetooth!!.removeCallback(this)
67+
callback(true)
8068
}
8169
})
8270
}
@@ -92,7 +80,7 @@ fun onRequestPermissionsResult(
9280
): Boolean {
9381
if (requestCode != BLE_ACCESS_PERMISSION || permissions.isEmpty()) return false
9482
if (grantResults.isEmpty() || grantResults[0] != PERMISSION_GRANTED) {
95-
savedCallbackForPermissionResult.success(false)
83+
savedCallbackForPermissionResult(false)
9684
return true
9785
}
9886
connectBluetoothDevice(savedCallbackForPermissionResult)
@@ -109,7 +97,7 @@ fun onActivityResult(requestCode: Int, rc: Int, @Suppress("UNUSED_PARAMETER") da
10997
if (resultCode == Activity.RESULT_OK)
11098
connectBluetoothDevice(savedCallbackForPermissionResult)
11199
else
112-
savedCallbackForPermissionResult.success(false)
100+
savedCallbackForPermissionResult(false)
113101
return true
114102
}
115103
return false

0 commit comments

Comments
 (0)