From 9d08519585c7cb050e1c4e2def7a30cd2968785e Mon Sep 17 00:00:00 2001 From: Rahul Dev Garg <34365102+rahuldevgarg@users.noreply.github.com> Date: Wed, 22 Nov 2023 19:20:03 +0530 Subject: [PATCH] Revert "Fixes for new flutter verion" --- .whitesource | 14 -- android/build.gradle | 4 +- .../gradle/wrapper/gradle-wrapper.properties | 2 +- .../BluetoothThermalPrinterPlugin.kt | 49 +---- example/android/app/build.gradle | 4 +- .../android/app/src/main/AndroidManifest.xml | 6 +- example/android/build.gradle | 6 +- .../gradle/wrapper/gradle-wrapper.properties | 2 +- example/lib/main.dart | 12 +- example/pubspec.lock | 195 +++++++----------- example/pubspec.yaml | 4 +- example/test/widget_test.dart | 2 +- lib/bluetooth_thermal_printer.dart | 11 - 13 files changed, 100 insertions(+), 211 deletions(-) delete mode 100644 .whitesource diff --git a/.whitesource b/.whitesource deleted file mode 100644 index 9c7ae90..0000000 --- a/.whitesource +++ /dev/null @@ -1,14 +0,0 @@ -{ - "scanSettings": { - "baseBranches": [] - }, - "checkRunSettings": { - "vulnerableCheckRunConclusionLevel": "failure", - "displayMode": "diff", - "useMendCheckNames": true - }, - "issueSettings": { - "minSeverityLevel": "LOW", - "issueType": "DEPENDENCY" - } -} \ No newline at end of file diff --git a/android/build.gradle b/android/build.gradle index 87ce24c..04118cb 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -2,14 +2,14 @@ group 'com.peoplewareinnovations.bluetooth_thermal_printer' version '1.0-SNAPSHOT' buildscript { - ext.kotlin_version = '1.5.20' + ext.kotlin_version = '1.3.50' repositories { google() jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:7.3.0' + classpath 'com.android.tools.build:gradle:3.5.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties index 3c472b9..01a286e 100644 --- a/android/gradle/wrapper/gradle-wrapper.properties +++ b/android/gradle/wrapper/gradle-wrapper.properties @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip diff --git a/android/src/main/kotlin/com/peoplewareinnovations/bluetooth_thermal_printer/BluetoothThermalPrinterPlugin.kt b/android/src/main/kotlin/com/peoplewareinnovations/bluetooth_thermal_printer/BluetoothThermalPrinterPlugin.kt index 6660895..ca45f8d 100644 --- a/android/src/main/kotlin/com/peoplewareinnovations/bluetooth_thermal_printer/BluetoothThermalPrinterPlugin.kt +++ b/android/src/main/kotlin/com/peoplewareinnovations/bluetooth_thermal_printer/BluetoothThermalPrinterPlugin.kt @@ -101,19 +101,7 @@ class BluetoothThermalPrinterPlugin: FlutterPlugin, MethodCallHandler{ } } } - }else if (call.method == "disconnectPrinter") { - GlobalScope.launch(Dispatchers.Main) { - if(outputStream != null) { - outputStream = disconnect()?.also { - //result.success("true") - //Toast.makeText(this@MainActivity, "Connected to printer", Toast.LENGTH_SHORT).show() - }.apply { - result.success("true") - //Log.d(TAG, "finished: Connection state:$state") - } - } - } - } else if (call.method == "writeBytes") { + }else if (call.method == "writeBytes") { var lista: List = call.arguments as List var bytes: ByteArray = "\n".toByteArray() @@ -242,40 +230,6 @@ class BluetoothThermalPrinterPlugin: FlutterPlugin, MethodCallHandler{ } } - private suspend fun disconnect(): OutputStream? { - state = "false" - return withContext(Dispatchers.IO) { - var outputStream: OutputStream? = outputStream - val bluetoothAdapter = BluetoothAdapter.getDefaultAdapter() - if (bluetoothAdapter != null && bluetoothAdapter.isEnabled) { - try { - if(mac.length>0) { - val bluetoothAddress = mac - val bluetoothDevice = bluetoothAdapter.getRemoteDevice(bluetoothAddress) - var bluetoothSocket = bluetoothDevice.createRfcommSocketToServiceRecord( - UUID.fromString("00001101-0000-1000-8000-00805F9B34FB") - ) - bluetoothSocket.close() - //bluetoothSocket=null - } - Log.d(TAG, "Disconnected: ") - outputStream?.close() - outputStream=null - } catch (e: Exception){ - state = "false" - var code:Int = e.hashCode() //1535159 off // - Log.d(TAG, "connect: ${e.message} code $code") - outputStream?.close() - } - }else{ - state = "false" - outputStream=null - Log.d(TAG, "Adapter problem") - } - outputStream - } - } - private fun getLinkedDevices():List{ val listItems: MutableList = mutableListOf() @@ -373,3 +327,4 @@ class BluetoothThermalPrinterPlugin: FlutterPlugin, MethodCallHandler{ channel.setMethodCallHandler(null) } } + diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index 567e8c5..bc4a051 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -26,7 +26,7 @@ apply plugin: 'kotlin-android' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" android { - compileSdkVersion 31 + compileSdkVersion 29 sourceSets { main.java.srcDirs += 'src/main/kotlin' @@ -40,7 +40,7 @@ android { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId "com.peoplewareinnovations.bluetooth_thermal_printer_example" minSdkVersion 16 - targetSdkVersion 31 + targetSdkVersion 29 versionCode flutterVersionCode.toInteger() versionName flutterVersionName } diff --git a/example/android/app/src/main/AndroidManifest.xml b/example/android/app/src/main/AndroidManifest.xml index 4273542..defbdf5 100644 --- a/example/android/app/src/main/AndroidManifest.xml +++ b/example/android/app/src/main/AndroidManifest.xml @@ -5,9 +5,8 @@ In most cases you can leave this as-is, but you if you want to provide additional functionality it is fine to subclass or reimplement FlutterApplication and put your custom class here. --> - - + android:windowSoftInputMode="adjustResize"> new feature - static Future disconnect() async { - String? result = "false"; - try { - result = await _channel.invokeMethod('disconnectPrinter'); - } on PlatformException catch (e) { - print("Failed to disconnect: '${e.message}'."); - } - return result; - } - ///Printes the [bytes] using bluetooth printer. static Future writeBytes(List bytes) async {