From 1c7a6e05e15b3fc0f3243c36c6646e0bc992640e Mon Sep 17 00:00:00 2001 From: tebalink Date: Mon, 15 Jul 2024 15:09:54 +0300 Subject: [PATCH 01/32] fix v android 14 --- .../com/codingdevs/thermal_printer/ThermalPrinterPlugin.kt | 2 +- example/android/app/build.gradle | 2 +- example/pubspec.yaml | 2 +- pubspec.yaml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/android/src/main/kotlin/com/codingdevs/thermal_printer/ThermalPrinterPlugin.kt b/android/src/main/kotlin/com/codingdevs/thermal_printer/ThermalPrinterPlugin.kt index 9a4b344..68a0551 100644 --- a/android/src/main/kotlin/com/codingdevs/thermal_printer/ThermalPrinterPlugin.kt +++ b/android/src/main/kotlin/com/codingdevs/thermal_printer/ThermalPrinterPlugin.kt @@ -53,7 +53,7 @@ class ThermalPrinterPlugin : FlutterPlugin, MethodCallHandler, PluginRegistry.Re private var isBle: Boolean = false private var isScan: Boolean = false lateinit var adapter: USBPrinterService - private lateinit var bluetoothService: BluetoothService + private var bluetoothService: BluetoothService private val usbHandler = object : Handler(Looper.getMainLooper()) { diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index 6cd1658..97ff440 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -44,7 +44,7 @@ android { defaultConfig { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId "com.codingdevs.thermal_printer_example" - minSdkVersion 19 + minSdkVersion flutter.minSdkVersion targetSdkVersion 33 versionCode flutterVersionCode.toInteger() versionName flutterVersionName diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 17e411f..4f1ae97 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -6,7 +6,7 @@ description: Demonstrates how to use the thermal_printer plugin. publish_to: 'none' # Remove this line if you wish to publish to pub.dev environment: - sdk: '>=2.18.4 <3.3.10' + sdk: '>=3.4.1 <4.0.0' # Dependencies specify other packages that your package needs in order to work. # To automatically upgrade your package dependencies to the latest versions diff --git a/pubspec.yaml b/pubspec.yaml index 75bf575..cf3e678 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -10,7 +10,7 @@ platforms: windows: environment: - sdk: '>=2.18.4 <4.0.0' + sdk: '>=3.4.1 <4.0.0' flutter: ">=1.20.0" dependencies: From d4492efc1a774523c3f0b314afcaa0be8e79231e Mon Sep 17 00:00:00 2001 From: hussein Date: Thu, 15 Aug 2024 12:51:42 +0100 Subject: [PATCH 02/32] capabilities added --- lib/resources/capabilities.json | 251 ++++++++++++++++++++++++++++++++ 1 file changed, 251 insertions(+) diff --git a/lib/resources/capabilities.json b/lib/resources/capabilities.json index 1a9ec0d..d2c161b 100644 --- a/lib/resources/capabilities.json +++ b/lib/resources/capabilities.json @@ -221,5 +221,256 @@ "model": "TP806L", "description": "" } + }, + "Star_TSP100": { + "codePages": { + "0": "CP437", + "1": "CP932", + "2": "CP850", + "3": "CP860", + "4": "CP863", + "5": "CP865", + "6": "CP1252", + "7": "CP866", + "8": "CP852", + "9": "CP858", + "10": "CP874", + "11": "ISO_8859-1", + "12": "ISO_8859-2", + "13": "ISO_8859-3", + "14": "ISO_8859-4", + "15": "ISO_8859-5", + "16": "ISO_8859-6", + "17": "ISO_8859-7", + "18": "ISO_8859-8", + "19": "ISO_8859-9", + "20": "ISO_8859-10", + "21": "ISO_8859-11", + "22": "ISO_8859-12", + "23": "ISO_8859-13", + "24": "ISO_8859-14", + "25": "ISO_8859-15", + "26": "ISO_8859-16", + "27": "CP1250", + "28": "CP1251", + "29": "CP1253", + "30": "CP1254", + "31": "CP1255", + "32": "CP1256", + "33": "CP1257", + "34": "CP1258", + "35": "CP866" + }, + "vendor": "Star Micronics", + "model": "TSP100", + "description": "Star TSP100 ESC/POS thermal receipt printer" + }, + "T1N": { + "codePages": { + "0": "CP437", + "1": "CP850", + "2": "CP860", + "3": "CP863", + "4": "CP865", + "5": "CP932", + "6": "CP1252", + "7": "CP866", + "8": "CP852", + "9": "CP858", + "10": "CP864", + "11": "CP775", + "12": "CP1250", + "13": "CP1251", + "14": "CP1253", + "15": "CP1254", + "16": "CP1255", + "17": "CP1256", + "18": "CP1257", + "19": "CP1258", + "20": "ISO_8859-1", + "21": "ISO_8859-2", + "22": "ISO_8859-3", + "23": "ISO_8859-4", + "24": "ISO_8859-5", + "25": "ISO_8859-6", + "26": "ISO_8859-7", + "27": "ISO_8859-8", + "28": "ISO_8859-9", + "29": "ISO_8859-15", + "30": "Unknown", + "31": "Unknown", + "32": "Unknown", + "255": "Unknown" + }, + "vendor": "T1N", + "model": "Virtual Bluetooth Thermal Printer", + "description": "T1N Virtual Bluetooth Thermal Printer profile for ESC/POS commands" + }, + "Epson_TM-T88V": { + "codePages": { + "0": "CP437", + "1": "CP932", + "2": "CP850", + "3": "CP860", + "4": "CP863", + "5": "CP865", + "6": "CP1252", + "7": "CP866", + "8": "CP852", + "9": "CP858", + "10": "CP874" + }, + "vendor": "Epson", + "model": "TM-T88V", + "description": "High-performance thermal receipt printer for retail and hospitality." + }, + "Bixolon_SRP-350III": { + "codePages": { + "0": "CP437", + "1": "CP850", + "2": "CP860", + "3": "CP863", + "4": "CP865", + "5": "CP1252", + "6": "CP866", + "7": "CP852", + "8": "CP858", + "9": "CP874" + }, + "vendor": "Bixolon", + "model": "SRP-350III", + "description": "Reliable and versatile thermal printer for POS environments." + }, + "Zebra_ZQ510": { + "codePages": { + "0": "CP437", + "1": "CP850", + "2": "CP860", + "3": "CP863", + "4": "CP865", + "5": "CP1252", + "6": "CP866", + "7": "CP852", + "8": "CP858" + }, + "vendor": "Zebra", + "model": "ZQ510", + "description": "Rugged mobile printer ideal for field service and logistics." + }, + "Star_TSP654II": { + "codePages": { + "0": "CP437", + "1": "CP932", + "2": "CP850", + "3": "CP860", + "4": "CP863", + "5": "CP865", + "6": "CP1252", + "7": "CP866", + "8": "CP852", + "9": "CP858" + }, + "vendor": "Star Micronics", + "model": "TSP654II", + "description": "Compact and fast thermal printer for retail and hospitality." + }, + "Citizen_CT-S310II": { + "codePages": { + "0": "CP437", + "1": "CP850", + "2": "CP860", + "3": "CP863", + "4": "CP865", + "5": "CP1252", + "6": "CP866", + "7": "CP852", + "8": "CP858", + "9": "CP874" + }, + "vendor": "Citizen", + "model": "CT-S310II", + "description": "Eco-friendly thermal printer with high-speed printing." + }, + "POS-X_EVO_HiSpeed": { + "codePages": { + "0": "CP437", + "1": "CP850", + "2": "CP860", + "3": "CP863", + "4": "CP865", + "5": "CP1252", + "6": "CP866", + "7": "CP852", + "8": "CP858", + "9": "CP874" + }, + "vendor": "POS-X", + "model": "EVO HiSpeed", + "description": "High-speed thermal receipt printer for POS applications." + }, + "Toshiba_B-FV4D": { + "codePages": { + "0": "CP437", + "1": "CP850", + "2": "CP860", + "3": "CP863", + "4": "CP865", + "5": "CP1252", + "6": "CP866", + "7": "CP852", + "8": "CP858" + }, + "vendor": "Toshiba", + "model": "B-FV4D", + "description": "Compact desktop printer for retail and healthcare." + }, + "Sewoo_LK-P24": { + "codePages": { + "0": "CP437", + "1": "CP850", + "2": "CP860", + "3": "CP863", + "4": "CP865", + "5": "CP1252", + "6": "CP866", + "7": "CP852", + "8": "CP858" + }, + "vendor": "Sewoo", + "model": "LK-P24", + "description": "Portable thermal printer for mobile point-of-sale." + }, + "NCR_RealPOS_7198": { + "codePages": { + "0": "CP437", + "1": "CP850", + "2": "CP860", + "3": "CP863", + "4": "CP865", + "5": "CP1252", + "6": "CP866", + "7": "CP852", + "8": "CP858", + "9": "CP874" + }, + "vendor": "NCR", + "model": "RealPOS 7198", + "description": "High-speed thermal printer for retail environments." + }, + "Honeywell_PC42t": { + "codePages": { + "0": "CP437", + "1": "CP850", + "2": "CP860", + "3": "CP863", + "4": "CP865", + "5": "CP1252", + "6": "CP866", + "7": "CP852", + "8": "CP858" + }, + "vendor": "Honeywell", + "model": "PC42t", + "description": "Versatile desktop label printer for retail and manufacturing." } } From 723206a20b9d4c21940e63ba04a5786258b76785 Mon Sep 17 00:00:00 2001 From: hussein Date: Thu, 15 Aug 2024 12:52:28 +0100 Subject: [PATCH 03/32] fixing with lateinit initialization --- .../com/codingdevs/thermal_printer/ThermalPrinterPlugin.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/src/main/kotlin/com/codingdevs/thermal_printer/ThermalPrinterPlugin.kt b/android/src/main/kotlin/com/codingdevs/thermal_printer/ThermalPrinterPlugin.kt index 68a0551..a048667 100644 --- a/android/src/main/kotlin/com/codingdevs/thermal_printer/ThermalPrinterPlugin.kt +++ b/android/src/main/kotlin/com/codingdevs/thermal_printer/ThermalPrinterPlugin.kt @@ -53,7 +53,7 @@ class ThermalPrinterPlugin : FlutterPlugin, MethodCallHandler, PluginRegistry.Re private var isBle: Boolean = false private var isScan: Boolean = false lateinit var adapter: USBPrinterService - private var bluetoothService: BluetoothService + lateinit var bluetoothService: BluetoothService private val usbHandler = object : Handler(Looper.getMainLooper()) { From 75c9893e23971a8f5471d1571447acc9bef3db28 Mon Sep 17 00:00:00 2001 From: hussein Date: Thu, 15 Aug 2024 12:55:11 +0100 Subject: [PATCH 04/32] capabilities --- lib/resources/capabilities.json | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib/resources/capabilities.json b/lib/resources/capabilities.json index d2c161b..4ebf8b6 100644 --- a/lib/resources/capabilities.json +++ b/lib/resources/capabilities.json @@ -69,7 +69,6 @@ "model": "Default", "description": "Default ESC/POS profile" }, - "XP-N160I": { "codePages": { "0": "CP437", @@ -144,7 +143,6 @@ "model": "XP-N160I", "description": "" }, - "RP80USE": { "codePages": { "0": "CP437", @@ -195,7 +193,6 @@ "model": "RP80USE", "description": "" }, - "TP806L": { "codePages": { "0": "PC437", From 4723c1674291c48d31af6a8d4a351e3a8fa138a0 Mon Sep 17 00:00:00 2001 From: hussein Date: Thu, 15 Aug 2024 15:05:49 +0100 Subject: [PATCH 05/32] fixed build issue with android with recent flutter. changing down kotlin version build impacted by multidex and sdk versions. - ext.kotlin_version = '1.7.21' - minSdkVersion 24 - targetSdkVersion 34 --- README.md | 4 ++-- android/build.gradle | 8 ++++---- example/android/app/build.gradle | 4 ++-- example/android/build.gradle | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index acaf1b4..60924de 100644 --- a/README.md +++ b/README.md @@ -57,8 +57,8 @@ In build.gradle set ``` defaultConfig { ... - minSdkVersion 19 - targetSdkVersion 33 + minSdkVersion 24 + targetSdkVersion 34 ... ``` diff --git a/android/build.gradle b/android/build.gradle index 909ce0a..49f2944 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -2,14 +2,14 @@ group 'com.codingdevs.thermal_printer' version '1.0-SNAPSHOT' buildscript { - ext.kotlin_version = '1.9.10' + ext.kotlin_version = '1.7.21' repositories { google() mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:7.4.0' + classpath 'com.android.tools.build:gradle:7.4.2' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } @@ -41,8 +41,8 @@ android { } defaultConfig { - minSdkVersion 19 - targetSdkVersion 33 + minSdkVersion 24 + targetSdkVersion 34 } } diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index 97ff440..26fa40c 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -44,8 +44,8 @@ android { defaultConfig { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId "com.codingdevs.thermal_printer_example" - minSdkVersion flutter.minSdkVersion - targetSdkVersion 33 + minSdkVersion 24 + targetSdkVersion 34 versionCode flutterVersionCode.toInteger() versionName flutterVersionName } diff --git a/example/android/build.gradle b/example/android/build.gradle index 92546c1..954fa1c 100644 --- a/example/android/build.gradle +++ b/example/android/build.gradle @@ -1,12 +1,12 @@ buildscript { - ext.kotlin_version = '1.9.10' + ext.kotlin_version = '1.7.21' repositories { google() mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:7.4.0' + classpath 'com.android.tools.build:gradle:7.4.2' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } From 4064f310a4782ae6adc89cd4ceb8cb382baec451 Mon Sep 17 00:00:00 2001 From: Marcos Rodriguez Date: Tue, 7 Jan 2025 15:17:38 -0500 Subject: [PATCH 06/32] UPDATE DEPENDENCIES. --- example/pubspec.yaml | 2 +- pubspec.yaml | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 17e411f..a0778ce 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -6,7 +6,7 @@ description: Demonstrates how to use the thermal_printer plugin. publish_to: 'none' # Remove this line if you wish to publish to pub.dev environment: - sdk: '>=2.18.4 <3.3.10' + sdk: '>=2.18.4 <4.0.0' # Dependencies specify other packages that your package needs in order to work. # To automatically upgrade your package dependencies to the latest versions diff --git a/pubspec.yaml b/pubspec.yaml index 75bf575..79aff4a 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -18,11 +18,11 @@ dependencies: sdk: flutter enum_to_string: ^2.0.1 - image: ^4.1.3 + image: ^4.5.2 - network_info_plus: ^4.1.0 + network_info_plus: ^6.1.2 ping_discover_network_forked: ^0.0.1 - rxdart: ^0.27.7 + rxdart: ^0.28.0 gbk_codec: ^0.4.0 hex: ^0.2.0 dart_ping: ^9.0.1 From ff14215d7cc57f7ed898a00ed749dc56275c8449 Mon Sep 17 00:00:00 2001 From: Marcos Rodriguez Date: Tue, 7 Jan 2025 15:38:58 -0500 Subject: [PATCH 07/32] Add namespace. --- android/build.gradle | 1 + 1 file changed, 1 insertion(+) diff --git a/android/build.gradle b/android/build.gradle index 909ce0a..23a16b8 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -25,6 +25,7 @@ apply plugin: 'com.android.library' apply plugin: 'kotlin-android' android { + namespace "com.codingdevs.thermal_printer" compileSdkVersion 33 compileOptions { From 6d878648d6c1436b70de6b0a09da8880d365c053 Mon Sep 17 00:00:00 2001 From: Marcos Rodriguez Date: Tue, 7 Jan 2025 15:39:20 -0500 Subject: [PATCH 08/32] Bump version. --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index 79aff4a..7f7aae3 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: thermal_printer description: A flutter plugin that prints esc commands to printers in different platforms such as android, ios, windows and different interfaces Bluetooth and BLE, TCP and USB -version: 1.0.5 +version: 1.0.6 homepage: https://github.com/codingdevs/thermal_printer # This package supports all platforms listed below. From 73972bd1887fc4cb0c2ec64f9b5169c810df3cef Mon Sep 17 00:00:00 2001 From: nasibudesign Date: Mon, 13 Jan 2025 13:37:03 +0100 Subject: [PATCH 09/32] Update README.md --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index acaf1b4..f585971 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,6 @@ -# thermal_printer +# thermal_printer_forked +As the original has not received any update this one is meant to resolve issues by merging every solution contributed. +I love this package, I work with this package but the maintenance of it is suffering from the OG. [![Pub Version](https://img.shields.io/badge/pub-v1.0.5-green)](https://pub.dev/packages/thermal_printer) From 055661efc8e7842acb60c0bb5f2db8461d645a37 Mon Sep 17 00:00:00 2001 From: hussein Date: Mon, 13 Jan 2025 13:56:54 +0100 Subject: [PATCH 10/32] fix android 14 sdk 34 --- .../thermal_printer/adapter/USBPrinterAdapter.kt | 12 +++++++++--- .../thermal_printer/usb/USBPrinterService.kt | 12 +++++++++--- .../codingdevs/thermal_printer/usb/UsbReceiver.kt | 7 ++++--- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/android/src/main/kotlin/com/codingdevs/thermal_printer/adapter/USBPrinterAdapter.kt b/android/src/main/kotlin/com/codingdevs/thermal_printer/adapter/USBPrinterAdapter.kt index dc93fb5..8b0333b 100644 --- a/android/src/main/kotlin/com/codingdevs/thermal_printer/adapter/USBPrinterAdapter.kt +++ b/android/src/main/kotlin/com/codingdevs/thermal_printer/adapter/USBPrinterAdapter.kt @@ -27,14 +27,20 @@ class USBPrinterAdapter private constructor() { fun init(reactContext: Context?) { mContext = reactContext mUSBManager = mContext!!.getSystemService(Context.USB_SERVICE) as UsbManager + val explicitIntent = Intent(ACTION_USB_PERMISSION); + explicitIntent.setPackage(mContext?.packageName); mPermissionIndent = if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.S) { - PendingIntent.getBroadcast(mContext, 0, Intent(ACTION_USB_PERMISSION), PendingIntent.FLAG_MUTABLE) + PendingIntent.getBroadcast(mContext, 0, explicitIntent, PendingIntent.FLAG_MUTABLE) } else { - PendingIntent.getBroadcast(mContext, 0, Intent(ACTION_USB_PERMISSION), 0) + PendingIntent.getBroadcast(mContext, 0, explicitIntent, 0) } val filter = IntentFilter(ACTION_USB_PERMISSION) filter.addAction(UsbManager.ACTION_USB_DEVICE_DETACHED) - mContext!!.registerReceiver(mUsbDeviceReceiver, filter) + if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.TIRAMISU) { + mContext!!.registerReceiver(mUsbDeviceReceiver, filter, Context.RECEIVER_NOT_EXPORTED); + } else { + mContext!!.registerReceiver(mUsbDeviceReceiver, filter); + } Log.v(LOG_TAG, "ESC/POS Printer initialized") } diff --git a/android/src/main/kotlin/com/codingdevs/thermal_printer/usb/USBPrinterService.kt b/android/src/main/kotlin/com/codingdevs/thermal_printer/usb/USBPrinterService.kt index a9c3499..9d79ae5 100644 --- a/android/src/main/kotlin/com/codingdevs/thermal_printer/usb/USBPrinterService.kt +++ b/android/src/main/kotlin/com/codingdevs/thermal_printer/usb/USBPrinterService.kt @@ -70,14 +70,20 @@ class USBPrinterService private constructor(private var mHandler: Handler?) { fun init(reactContext: Context?) { mContext = reactContext mUSBManager = mContext!!.getSystemService(Context.USB_SERVICE) as UsbManager + val explicitIntent = Intent(ACTION_USB_PERMISSION); + explicitIntent.setPackage(mContext?.packageName); mPermissionIndent = if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.S) { - PendingIntent.getBroadcast(mContext, 0, Intent(ACTION_USB_PERMISSION), PendingIntent.FLAG_MUTABLE) + PendingIntent.getBroadcast(mContext, 0, explicitIntent, PendingIntent.FLAG_MUTABLE) } else { - PendingIntent.getBroadcast(mContext, 0, Intent(ACTION_USB_PERMISSION), 0) + PendingIntent.getBroadcast(mContext, 0, explicitIntent, 0) } val filter = IntentFilter(ACTION_USB_PERMISSION) filter.addAction(UsbManager.ACTION_USB_DEVICE_DETACHED) - mContext!!.registerReceiver(mUsbDeviceReceiver, filter) + if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.TIRAMISU) { + mContext!!.registerReceiver(mUsbDeviceReceiver, filter, Context.RECEIVER_NOT_EXPORTED); + } else { + mContext!!.registerReceiver(mUsbDeviceReceiver, filter); + } Log.v(LOG_TAG, "ESC/POS Printer initialized") } diff --git a/android/src/main/kotlin/com/codingdevs/thermal_printer/usb/UsbReceiver.kt b/android/src/main/kotlin/com/codingdevs/thermal_printer/usb/UsbReceiver.kt index e1faf75..0d538f1 100644 --- a/android/src/main/kotlin/com/codingdevs/thermal_printer/usb/UsbReceiver.kt +++ b/android/src/main/kotlin/com/codingdevs/thermal_printer/usb/UsbReceiver.kt @@ -16,11 +16,12 @@ class UsbReceiver : BroadcastReceiver() { if (UsbManager.ACTION_USB_DEVICE_ATTACHED == action) { val usbDevice: UsbDevice? = intent.getParcelableExtra(UsbManager.EXTRA_DEVICE) - + val explicitIntent = Intent("com.flutter_pos_printer.USB_PERMISSION"); + explicitIntent.setPackage(context?.packageName); val mPermissionIndent = if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.S) { - PendingIntent.getBroadcast(context, 0, Intent("com.flutter_pos_printer.USB_PERMISSION"), PendingIntent.FLAG_MUTABLE) + PendingIntent.getBroadcast(context, 0, explicitIntent, PendingIntent.FLAG_MUTABLE) } else { - PendingIntent.getBroadcast(context, 0, Intent("com.flutter_pos_printer.USB_PERMISSION"), 0) + PendingIntent.getBroadcast(context, 0, explicitIntent, 0) } val mUSBManager = context?.getSystemService(Context.USB_SERVICE) as UsbManager? mUSBManager?.requestPermission(usbDevice, mPermissionIndent) From 28fa2d2cbb82a34d7631ed37484535f86a78c752 Mon Sep 17 00:00:00 2001 From: hussein Date: Mon, 13 Jan 2025 14:28:37 +0100 Subject: [PATCH 11/32] fixing name space and updating to the flutter version 3.27.1 --- android/build.gradle | 9 +++++---- android/src/main/AndroidManifest.xml | 3 +-- example/android/app/build.gradle | 3 ++- example/android/build.gradle | 4 ++-- example/android/gradle/wrapper/gradle-wrapper.properties | 2 +- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index 49f2944..3ffba4b 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -2,14 +2,14 @@ group 'com.codingdevs.thermal_printer' version '1.0-SNAPSHOT' buildscript { - ext.kotlin_version = '1.7.21' + ext.kotlin_version = '1.9.10' repositories { google() mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:7.4.2' + classpath 'com.android.tools.build:gradle:8.1.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } @@ -25,7 +25,8 @@ apply plugin: 'com.android.library' apply plugin: 'kotlin-android' android { - compileSdkVersion 33 + namespace 'com.codingdevs.thermal_printer' + compileSdkVersion 35 compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 @@ -42,7 +43,7 @@ android { defaultConfig { minSdkVersion 24 - targetSdkVersion 34 + targetSdkVersion 35 } } diff --git a/android/src/main/AndroidManifest.xml b/android/src/main/AndroidManifest.xml index e0ae8f2..500bb71 100644 --- a/android/src/main/AndroidManifest.xml +++ b/android/src/main/AndroidManifest.xml @@ -1,5 +1,4 @@ - + Date: Mon, 13 Jan 2025 15:02:03 +0100 Subject: [PATCH 12/32] version: 1.0.6 --- CHANGELOG.md | 5 +++++ pubspec.yaml | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2e067c1..8c9ad12 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## 1.0.6 +#### FORKED PROJECT +* fixed Bt discovery issue with android 14 version +* fix issue building android version + ## 1.0.5 * fixed windows build diff --git a/pubspec.yaml b/pubspec.yaml index cf3e678..d3bd297 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: thermal_printer description: A flutter plugin that prints esc commands to printers in different platforms such as android, ios, windows and different interfaces Bluetooth and BLE, TCP and USB -version: 1.0.5 -homepage: https://github.com/codingdevs/thermal_printer +version: 1.0.6 +homepage: https://github.com/nasibudesign/thermal_printer/ # This package supports all platforms listed below. platforms: From 46a74c77aff351c1634e38f6cfbbebd1d56774ba Mon Sep 17 00:00:00 2001 From: hussein Date: Mon, 13 Jan 2025 15:25:05 +0100 Subject: [PATCH 13/32] name: thermal_printer_plus --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index d3bd297..7159162 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,4 +1,4 @@ -name: thermal_printer +name: thermal_printer_plus description: A flutter plugin that prints esc commands to printers in different platforms such as android, ios, windows and different interfaces Bluetooth and BLE, TCP and USB version: 1.0.6 homepage: https://github.com/nasibudesign/thermal_printer/ From 0be785a6d77b2ed63b26bbe25283063d0ab13f53 Mon Sep 17 00:00:00 2001 From: hussein Date: Mon, 13 Jan 2025 15:29:14 +0100 Subject: [PATCH 14/32] name: thermal_printer_plus --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2bef3a9..d9f965d 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# thermal_printer_forked +# thermal_printer_plus As the original has not received any update this one is meant to resolve issues by merging every solution contributed. I love this package, I work with this package but the maintenance of it is suffering from the OG. From ea2365991c1703150e511263eda03c132f7b07d1 Mon Sep 17 00:00:00 2001 From: hussein Date: Mon, 13 Jan 2025 16:32:27 +0100 Subject: [PATCH 15/32] updating plugin name changes --- example/lib/main.dart | 4 ++-- example/pubspec.yaml | 2 +- example/windows/flutter/generated_plugin_registrant.cc | 2 +- example/windows/flutter/generated_plugins.cmake | 2 +- lib/src/connectors/bluetooth.dart | 4 ++-- lib/src/connectors/tcp.dart | 6 +++--- lib/src/connectors/usb.dart | 4 ++-- lib/src/printer_manager.dart | 2 +- lib/src/printers/escpos.dart | 4 ++-- lib/src/printers/star.dart | 2 +- lib/src/printers/tspl.dart | 2 +- pubspec.yaml | 1 - 12 files changed, 17 insertions(+), 18 deletions(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index f40a1a3..822c4ee 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -3,8 +3,8 @@ import 'dart:developer'; import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; -import 'package:thermal_printer/esc_pos_utils_platform/esc_pos_utils_platform.dart'; -import 'package:thermal_printer/thermal_printer.dart'; +import 'package:thermal_printer_plus/esc_pos_utils_platform/esc_pos_utils_platform.dart'; +import 'package:thermal_printer_plus/thermal_printer.dart'; import 'package:image/image.dart' as img; import 'package:dart_ping_ios/dart_ping_ios.dart'; import 'image_utils.dart'; diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 4f1ae97..73b19b3 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -18,7 +18,7 @@ dependencies: flutter: sdk: flutter - thermal_printer: + thermal_printer_plus: # When depending on this package from a real application you should use: # thermal_printer: ^x.y.z # See https://dart.dev/tools/pub/dependencies#version-constraints diff --git a/example/windows/flutter/generated_plugin_registrant.cc b/example/windows/flutter/generated_plugin_registrant.cc index 5840272..f66dff6 100644 --- a/example/windows/flutter/generated_plugin_registrant.cc +++ b/example/windows/flutter/generated_plugin_registrant.cc @@ -6,7 +6,7 @@ #include "generated_plugin_registrant.h" -#include +#include void RegisterPlugins(flutter::PluginRegistry* registry) { ThermalPrinterPluginRegisterWithRegistrar( diff --git a/example/windows/flutter/generated_plugins.cmake b/example/windows/flutter/generated_plugins.cmake index 3454c74..9960d99 100644 --- a/example/windows/flutter/generated_plugins.cmake +++ b/example/windows/flutter/generated_plugins.cmake @@ -3,7 +3,7 @@ # list(APPEND FLUTTER_PLUGIN_LIST - thermal_printer + thermal_printer_plus ) list(APPEND FLUTTER_FFI_PLUGIN_LIST diff --git a/lib/src/connectors/bluetooth.dart b/lib/src/connectors/bluetooth.dart index 7b4808b..4cfbeca 100644 --- a/lib/src/connectors/bluetooth.dart +++ b/lib/src/connectors/bluetooth.dart @@ -2,8 +2,8 @@ import 'dart:async'; import 'dart:io'; import 'package:flutter/services.dart'; -import 'package:thermal_printer/discovery.dart'; -import 'package:thermal_printer/thermal_printer.dart'; +import 'package:thermal_printer_plus/discovery.dart'; +import 'package:thermal_printer_plus/thermal_printer.dart'; import 'package:rxdart/rxdart.dart'; class BluetoothPrinterInput extends BasePrinterInput { diff --git a/lib/src/connectors/tcp.dart b/lib/src/connectors/tcp.dart index c33532c..95e6531 100644 --- a/lib/src/connectors/tcp.dart +++ b/lib/src/connectors/tcp.dart @@ -3,10 +3,10 @@ import 'dart:io'; import 'dart:typed_data'; import 'package:dart_ping/dart_ping.dart'; import 'package:flutter/material.dart'; -import 'package:thermal_printer/src/models/printer_device.dart'; +import 'package:thermal_printer_plus/src/models/printer_device.dart'; import 'package:network_info_plus/network_info_plus.dart'; -import 'package:thermal_printer/discovery.dart'; -import 'package:thermal_printer/printer.dart'; +import 'package:thermal_printer_plus/discovery.dart'; +import 'package:thermal_printer_plus/printer.dart'; import 'package:ping_discover_network_forked/ping_discover_network_forked.dart'; class TcpPrinterInput extends BasePrinterInput { diff --git a/lib/src/connectors/usb.dart b/lib/src/connectors/usb.dart index 44312ac..a0f811f 100644 --- a/lib/src/connectors/usb.dart +++ b/lib/src/connectors/usb.dart @@ -2,8 +2,8 @@ import 'dart:async'; import 'dart:io'; import 'dart:typed_data'; -import 'package:thermal_printer/discovery.dart'; -import 'package:thermal_printer/thermal_printer.dart'; +import 'package:thermal_printer_plus/discovery.dart'; +import 'package:thermal_printer_plus/thermal_printer.dart'; class UsbPrinterInput extends BasePrinterInput { final String? name; diff --git a/lib/src/printer_manager.dart b/lib/src/printer_manager.dart index a149b50..00e7e22 100644 --- a/lib/src/printer_manager.dart +++ b/lib/src/printer_manager.dart @@ -1,6 +1,6 @@ import 'dart:io'; -import 'package:thermal_printer/thermal_printer.dart'; +import 'package:thermal_printer_plus/thermal_printer.dart'; enum PrinterType { bluetooth, usb, network } diff --git a/lib/src/printers/escpos.dart b/lib/src/printers/escpos.dart index 0cf157c..c010741 100644 --- a/lib/src/printers/escpos.dart +++ b/lib/src/printers/escpos.dart @@ -1,7 +1,7 @@ import 'dart:typed_data'; -import 'package:thermal_printer/printer.dart'; -import 'package:thermal_printer/src/utils.dart'; +import 'package:thermal_printer_plus/printer.dart'; +import 'package:thermal_printer_plus/src/utils.dart'; import 'package:image/image.dart' as img; class EscPosPrinter extends GenericPrinter { diff --git a/lib/src/printers/star.dart b/lib/src/printers/star.dart index 4b7cb66..cd3b659 100644 --- a/lib/src/printers/star.dart +++ b/lib/src/printers/star.dart @@ -1,7 +1,7 @@ import 'dart:typed_data'; import 'package:enum_to_string/enum_to_string.dart'; -import 'package:thermal_printer/printer.dart'; +import 'package:thermal_printer_plus/printer.dart'; // import 'package:flutter_star_prnt/flutter_star_prnt.dart'; enum StarEmulation { StarPRNT, StarLine, StarGraphic } diff --git a/lib/src/printers/tspl.dart b/lib/src/printers/tspl.dart index 74fc8ef..35ad4e5 100644 --- a/lib/src/printers/tspl.dart +++ b/lib/src/printers/tspl.dart @@ -1,6 +1,6 @@ import 'dart:core'; import 'dart:typed_data'; -import 'package:thermal_printer/printer.dart'; +import 'package:thermal_printer_plus/printer.dart'; import 'package:image/image.dart' as img; import '../utils.dart'; diff --git a/pubspec.yaml b/pubspec.yaml index 7159162..d9ae566 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -52,7 +52,6 @@ flutter: assets: - assets/resources/capabilities.json - - packages/thermal_printer/resources/capabilities.json # To add assets to your plugin package, add an assets section, like this: # assets: From bd0c0b38772debebe12933f70af28f4469a4bc20 Mon Sep 17 00:00:00 2001 From: hussein Date: Mon, 13 Jan 2025 19:33:51 +0100 Subject: [PATCH 16/32] fixing ios and adding capabilities --- assets/resources/capabilities.json | 254 +++++++++++++++++- example/ios/Flutter/AppFrameworkInfo.plist | 2 +- example/ios/Podfile | 2 +- example/ios/Podfile.lock | 30 +-- example/ios/Runner.xcodeproj/project.pbxproj | 14 +- .../xcshareddata/xcschemes/Runner.xcscheme | 2 +- example/ios/Runner/AppDelegate.swift | 2 +- example/ios/Runner/Info.plist | 15 +- ...r.podspec => thermal_printer_plus.podspec} | 6 +- .../src/capability_profile.dart | 2 +- pubspec.yaml | 1 + 11 files changed, 296 insertions(+), 34 deletions(-) rename ios/{thermal_printer.podspec => thermal_printer_plus.podspec} (90%) diff --git a/assets/resources/capabilities.json b/assets/resources/capabilities.json index 1a9ec0d..4ebf8b6 100644 --- a/assets/resources/capabilities.json +++ b/assets/resources/capabilities.json @@ -69,7 +69,6 @@ "model": "Default", "description": "Default ESC/POS profile" }, - "XP-N160I": { "codePages": { "0": "CP437", @@ -144,7 +143,6 @@ "model": "XP-N160I", "description": "" }, - "RP80USE": { "codePages": { "0": "CP437", @@ -195,7 +193,6 @@ "model": "RP80USE", "description": "" }, - "TP806L": { "codePages": { "0": "PC437", @@ -221,5 +218,256 @@ "model": "TP806L", "description": "" } + }, + "Star_TSP100": { + "codePages": { + "0": "CP437", + "1": "CP932", + "2": "CP850", + "3": "CP860", + "4": "CP863", + "5": "CP865", + "6": "CP1252", + "7": "CP866", + "8": "CP852", + "9": "CP858", + "10": "CP874", + "11": "ISO_8859-1", + "12": "ISO_8859-2", + "13": "ISO_8859-3", + "14": "ISO_8859-4", + "15": "ISO_8859-5", + "16": "ISO_8859-6", + "17": "ISO_8859-7", + "18": "ISO_8859-8", + "19": "ISO_8859-9", + "20": "ISO_8859-10", + "21": "ISO_8859-11", + "22": "ISO_8859-12", + "23": "ISO_8859-13", + "24": "ISO_8859-14", + "25": "ISO_8859-15", + "26": "ISO_8859-16", + "27": "CP1250", + "28": "CP1251", + "29": "CP1253", + "30": "CP1254", + "31": "CP1255", + "32": "CP1256", + "33": "CP1257", + "34": "CP1258", + "35": "CP866" + }, + "vendor": "Star Micronics", + "model": "TSP100", + "description": "Star TSP100 ESC/POS thermal receipt printer" + }, + "T1N": { + "codePages": { + "0": "CP437", + "1": "CP850", + "2": "CP860", + "3": "CP863", + "4": "CP865", + "5": "CP932", + "6": "CP1252", + "7": "CP866", + "8": "CP852", + "9": "CP858", + "10": "CP864", + "11": "CP775", + "12": "CP1250", + "13": "CP1251", + "14": "CP1253", + "15": "CP1254", + "16": "CP1255", + "17": "CP1256", + "18": "CP1257", + "19": "CP1258", + "20": "ISO_8859-1", + "21": "ISO_8859-2", + "22": "ISO_8859-3", + "23": "ISO_8859-4", + "24": "ISO_8859-5", + "25": "ISO_8859-6", + "26": "ISO_8859-7", + "27": "ISO_8859-8", + "28": "ISO_8859-9", + "29": "ISO_8859-15", + "30": "Unknown", + "31": "Unknown", + "32": "Unknown", + "255": "Unknown" + }, + "vendor": "T1N", + "model": "Virtual Bluetooth Thermal Printer", + "description": "T1N Virtual Bluetooth Thermal Printer profile for ESC/POS commands" + }, + "Epson_TM-T88V": { + "codePages": { + "0": "CP437", + "1": "CP932", + "2": "CP850", + "3": "CP860", + "4": "CP863", + "5": "CP865", + "6": "CP1252", + "7": "CP866", + "8": "CP852", + "9": "CP858", + "10": "CP874" + }, + "vendor": "Epson", + "model": "TM-T88V", + "description": "High-performance thermal receipt printer for retail and hospitality." + }, + "Bixolon_SRP-350III": { + "codePages": { + "0": "CP437", + "1": "CP850", + "2": "CP860", + "3": "CP863", + "4": "CP865", + "5": "CP1252", + "6": "CP866", + "7": "CP852", + "8": "CP858", + "9": "CP874" + }, + "vendor": "Bixolon", + "model": "SRP-350III", + "description": "Reliable and versatile thermal printer for POS environments." + }, + "Zebra_ZQ510": { + "codePages": { + "0": "CP437", + "1": "CP850", + "2": "CP860", + "3": "CP863", + "4": "CP865", + "5": "CP1252", + "6": "CP866", + "7": "CP852", + "8": "CP858" + }, + "vendor": "Zebra", + "model": "ZQ510", + "description": "Rugged mobile printer ideal for field service and logistics." + }, + "Star_TSP654II": { + "codePages": { + "0": "CP437", + "1": "CP932", + "2": "CP850", + "3": "CP860", + "4": "CP863", + "5": "CP865", + "6": "CP1252", + "7": "CP866", + "8": "CP852", + "9": "CP858" + }, + "vendor": "Star Micronics", + "model": "TSP654II", + "description": "Compact and fast thermal printer for retail and hospitality." + }, + "Citizen_CT-S310II": { + "codePages": { + "0": "CP437", + "1": "CP850", + "2": "CP860", + "3": "CP863", + "4": "CP865", + "5": "CP1252", + "6": "CP866", + "7": "CP852", + "8": "CP858", + "9": "CP874" + }, + "vendor": "Citizen", + "model": "CT-S310II", + "description": "Eco-friendly thermal printer with high-speed printing." + }, + "POS-X_EVO_HiSpeed": { + "codePages": { + "0": "CP437", + "1": "CP850", + "2": "CP860", + "3": "CP863", + "4": "CP865", + "5": "CP1252", + "6": "CP866", + "7": "CP852", + "8": "CP858", + "9": "CP874" + }, + "vendor": "POS-X", + "model": "EVO HiSpeed", + "description": "High-speed thermal receipt printer for POS applications." + }, + "Toshiba_B-FV4D": { + "codePages": { + "0": "CP437", + "1": "CP850", + "2": "CP860", + "3": "CP863", + "4": "CP865", + "5": "CP1252", + "6": "CP866", + "7": "CP852", + "8": "CP858" + }, + "vendor": "Toshiba", + "model": "B-FV4D", + "description": "Compact desktop printer for retail and healthcare." + }, + "Sewoo_LK-P24": { + "codePages": { + "0": "CP437", + "1": "CP850", + "2": "CP860", + "3": "CP863", + "4": "CP865", + "5": "CP1252", + "6": "CP866", + "7": "CP852", + "8": "CP858" + }, + "vendor": "Sewoo", + "model": "LK-P24", + "description": "Portable thermal printer for mobile point-of-sale." + }, + "NCR_RealPOS_7198": { + "codePages": { + "0": "CP437", + "1": "CP850", + "2": "CP860", + "3": "CP863", + "4": "CP865", + "5": "CP1252", + "6": "CP866", + "7": "CP852", + "8": "CP858", + "9": "CP874" + }, + "vendor": "NCR", + "model": "RealPOS 7198", + "description": "High-speed thermal printer for retail environments." + }, + "Honeywell_PC42t": { + "codePages": { + "0": "CP437", + "1": "CP850", + "2": "CP860", + "3": "CP863", + "4": "CP865", + "5": "CP1252", + "6": "CP866", + "7": "CP852", + "8": "CP858" + }, + "vendor": "Honeywell", + "model": "PC42t", + "description": "Versatile desktop label printer for retail and manufacturing." } } diff --git a/example/ios/Flutter/AppFrameworkInfo.plist b/example/ios/Flutter/AppFrameworkInfo.plist index 8d4492f..7c56964 100644 --- a/example/ios/Flutter/AppFrameworkInfo.plist +++ b/example/ios/Flutter/AppFrameworkInfo.plist @@ -21,6 +21,6 @@ CFBundleVersion 1.0 MinimumOSVersion - 9.0 + 12.0 diff --git a/example/ios/Podfile b/example/ios/Podfile index 1e8c3c9..2c068c4 100644 --- a/example/ios/Podfile +++ b/example/ios/Podfile @@ -1,5 +1,5 @@ # Uncomment this line to define a global platform for your project -# platform :ios, '9.0' +platform :ios, '12.0' # CocoaPods analytics sends network stats synchronously affecting flutter build latency. ENV['COCOAPODS_DISABLE_STATS'] = 'true' diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index fcaf980..dfd92ca 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -1,34 +1,34 @@ PODS: - Flutter (1.0.0) - - thermal_printer (0.0.1): - - Flutter - - flutter_star_prnt (0.0.1): + - flutter_icmp_ping (0.0.1): - Flutter - network_info_plus (0.0.1): - Flutter + - thermal_printer_plus (1.0.6): + - Flutter DEPENDENCIES: - Flutter (from `Flutter`) - - thermal_printer (from `.symlinks/plugins/thermal_printer/ios`) - - flutter_star_prnt (from `.symlinks/plugins/flutter_star_prnt/ios`) + - flutter_icmp_ping (from `.symlinks/plugins/flutter_icmp_ping/ios`) - network_info_plus (from `.symlinks/plugins/network_info_plus/ios`) + - thermal_printer_plus (from `.symlinks/plugins/thermal_printer_plus/ios`) EXTERNAL SOURCES: Flutter: :path: Flutter - thermal_printer: - :path: ".symlinks/plugins/thermal_printer/ios" - flutter_star_prnt: - :path: ".symlinks/plugins/flutter_star_prnt/ios" + flutter_icmp_ping: + :path: ".symlinks/plugins/flutter_icmp_ping/ios" network_info_plus: :path: ".symlinks/plugins/network_info_plus/ios" + thermal_printer_plus: + :path: ".symlinks/plugins/thermal_printer_plus/ios" SPEC CHECKSUMS: - Flutter: 50d75fe2f02b26cc09d224853bb45737f8b3214a - thermal_printer: 72176df8340825c736b5768fce1591e8884e456e - flutter_star_prnt: c4ea89b6b9ccb708624f5830c9d34b7ee1165999 - network_info_plus: b78876159360f5580608c2cea620d6ceffabd0ad + Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7 + flutter_icmp_ping: 2b159955eee0c487c766ad83fec224ae35e7c935 + network_info_plus: 6d0c3eb8367b8164fa3fb0c19875e3f59d49697f + thermal_printer_plus: cbb9818595ad92174d0972828ee0dd3e6ccd1b99 -PODFILE CHECKSUM: aafe91acc616949ddb318b77800a7f51bffa2a4c +PODFILE CHECKSUM: 4e8f8b2be68aeea4c0d5beb6ff1e79fface1d048 -COCOAPODS: 1.11.3 +COCOAPODS: 1.15.2 diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj index 7360c87..037fe52 100644 --- a/example/ios/Runner.xcodeproj/project.pbxproj +++ b/example/ios/Runner.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 50; + objectVersion = 54; objects = { /* Begin PBXBuildFile section */ @@ -68,7 +68,6 @@ E0E3FD80E0B79A8ABC11BBC1 /* Pods-Runner.release.xcconfig */, 1C58FBFFA0E12ED58F12B1CB /* Pods-Runner.profile.xcconfig */, ); - name = Pods; path = Pods; sourceTree = ""; }; @@ -156,7 +155,7 @@ 97C146E61CF9000F007C117D /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 1300; + LastUpgradeCheck = 1510; ORGANIZATIONNAME = ""; TargetAttributes = { 97C146ED1CF9000F007C117D = { @@ -200,10 +199,12 @@ /* Begin PBXShellScriptBuildPhase section */ 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; buildActionMask = 2147483647; files = ( ); inputPaths = ( + "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}", ); name = "Thin Binary"; outputPaths = ( @@ -236,6 +237,7 @@ }; 9740EEB61CF901F6004384FC /* Run Script */ = { isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; buildActionMask = 2147483647; files = ( ); @@ -340,7 +342,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos; @@ -417,7 +419,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -466,7 +468,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos; diff --git a/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index c87d15a..5e31d3d 100644 --- a/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -1,6 +1,6 @@ + CADisableMinimumFrameDurationOnPhone + CFBundleDevelopmentRegion $(DEVELOPMENT_LANGUAGE) CFBundleDisplayName @@ -24,6 +26,13 @@ $(FLUTTER_BUILD_NUMBER) LSRequiresIPhoneOS + UIApplicationSupportsIndirectInputEvents + + UIBackgroundModes + + bluetooth-central + fetch + UILaunchStoryboardName LaunchScreen UIMainStoryboardFile @@ -43,7 +52,9 @@ UIViewControllerBasedStatusBarAppearance - CADisableMinimumFrameDurationOnPhone - + NSBluetoothAlwaysUsageDescription + We need Bluetooth to connect to devices. + NSBluetoothPeripheralUsageDescription + We need Bluetooth to connect to peripherals. diff --git a/ios/thermal_printer.podspec b/ios/thermal_printer_plus.podspec similarity index 90% rename from ios/thermal_printer.podspec rename to ios/thermal_printer_plus.podspec index d4bee84..22de263 100644 --- a/ios/thermal_printer.podspec +++ b/ios/thermal_printer_plus.podspec @@ -3,8 +3,8 @@ # Run `pod lib lint thermal_printer.podspec` to validate before publishing. # Pod::Spec.new do |s| - s.name = 'thermal_printer' - s.version = '1.0.0' + s.name = 'thermal_printer_plus' + s.version = '1.0.6' s.summary = 'A new Flutter plugin project.' s.description = <<-DESC A new Flutter plugin project. @@ -17,7 +17,7 @@ A new Flutter plugin project. s.public_header_files = 'Classes/**/*.h' s.static_framework = true s.dependency 'Flutter' - s.platform = :ios, '9.0' + s.platform = :ios, '12.0' # Import all * .a libraries in the Classes folder s.frameworks = ["SystemConfiguration", "CoreTelephony","WebKit"] diff --git a/lib/esc_pos_utils_platform/src/capability_profile.dart b/lib/esc_pos_utils_platform/src/capability_profile.dart index 68a75e8..4ffb595 100644 --- a/lib/esc_pos_utils_platform/src/capability_profile.dart +++ b/lib/esc_pos_utils_platform/src/capability_profile.dart @@ -20,7 +20,7 @@ class CapabilityProfile { /// Public factory static Future load({String name = 'default'}) async { - final content = await rootBundle.loadString('packages/thermal_printer/resources/capabilities.json'); + final content = await rootBundle.loadString('packages/thermal_printer_plus/resources/capabilities.json'); Map capabilities = json.decode(content); var profile = capabilities['profiles'][name]; diff --git a/pubspec.yaml b/pubspec.yaml index d9ae566..e990b08 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -52,6 +52,7 @@ flutter: assets: - assets/resources/capabilities.json + - packages/thermal_printer_plus/resources/capabilities.json # To add assets to your plugin package, add an assets section, like this: # assets: From f89d40f92dafdc99996bee04cc770e48ef36389e Mon Sep 17 00:00:00 2001 From: hussein Date: Mon, 13 Jan 2025 19:39:54 +0100 Subject: [PATCH 17/32] version: 1.0.7 --- CHANGELOG.md | 5 +++++ pubspec.yaml | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8c9ad12..c8e4eeb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## 1.0.7 + +* fixed iOS build +* added some capabilities for printers + ## 1.0.6 #### FORKED PROJECT * fixed Bt discovery issue with android 14 version diff --git a/pubspec.yaml b/pubspec.yaml index e990b08..5afd57f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: thermal_printer_plus description: A flutter plugin that prints esc commands to printers in different platforms such as android, ios, windows and different interfaces Bluetooth and BLE, TCP and USB -version: 1.0.6 +version: 1.0.7 homepage: https://github.com/nasibudesign/thermal_printer/ # This package supports all platforms listed below. From e5dbfd117cbfc48293ac61be801b7eea7554b0c8 Mon Sep 17 00:00:00 2001 From: hussein Date: Mon, 13 Jan 2025 19:58:38 +0100 Subject: [PATCH 18/32] lowering android minSdkVersion to 21 --- android/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/build.gradle b/android/build.gradle index 3ffba4b..cf6a5c6 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -42,7 +42,7 @@ android { } defaultConfig { - minSdkVersion 24 + minSdkVersion 21 targetSdkVersion 35 } } From 9665b52973db5620cb20f903ffc9740e6cd2fa69 Mon Sep 17 00:00:00 2001 From: hussein Date: Mon, 13 Jan 2025 19:59:53 +0100 Subject: [PATCH 19/32] version: 1.0.8 --- CHANGELOG.md | 4 ++++ pubspec.yaml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c8e4eeb..93852f5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.0.8 + +* android minSdkVersion to 21 + ## 1.0.7 * fixed iOS build diff --git a/pubspec.yaml b/pubspec.yaml index 5afd57f..eba5aee 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: thermal_printer_plus description: A flutter plugin that prints esc commands to printers in different platforms such as android, ios, windows and different interfaces Bluetooth and BLE, TCP and USB -version: 1.0.7 +version: 1.0.8 homepage: https://github.com/nasibudesign/thermal_printer/ # This package supports all platforms listed below. From 1d00e7e8e8005492dcfb566149eb8ef54ef7f362 Mon Sep 17 00:00:00 2001 From: Marcos Rodriguez Date: Sat, 18 Jan 2025 15:53:02 -0500 Subject: [PATCH 20/32] Fix On detach from Engine. --- .../codingdevs/thermal_printer/ThermalPrinterPlugin.kt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/android/src/main/kotlin/com/codingdevs/thermal_printer/ThermalPrinterPlugin.kt b/android/src/main/kotlin/com/codingdevs/thermal_printer/ThermalPrinterPlugin.kt index 9a4b344..e9586a1 100644 --- a/android/src/main/kotlin/com/codingdevs/thermal_printer/ThermalPrinterPlugin.kt +++ b/android/src/main/kotlin/com/codingdevs/thermal_printer/ThermalPrinterPlugin.kt @@ -164,8 +164,13 @@ class ThermalPrinterPlugin : FlutterPlugin, MethodCallHandler, PluginRegistry.Re messageChannel = null messageUSBChannel = null - bluetoothService.setHandler(null) - adapter.setHandler(null) + if (::bluetoothService.isInitialized) { + bluetoothService.setHandler(null) + } + + if (::adapter.isInitialized) { + adapter.setHandler(null) + } } override fun onAttachedToEngine(@NonNull flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) { From 06e19d2524054aca6a34473732cf363adcd0e4f7 Mon Sep 17 00:00:00 2001 From: Marcos Rodriguez Date: Sat, 18 Jan 2025 16:02:41 -0500 Subject: [PATCH 21/32] bumped version updated network_info_plus dependency --- pubspec.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pubspec.yaml b/pubspec.yaml index 7f7aae3..6a18729 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: thermal_printer description: A flutter plugin that prints esc commands to printers in different platforms such as android, ios, windows and different interfaces Bluetooth and BLE, TCP and USB -version: 1.0.6 +version: 1.0.7 homepage: https://github.com/codingdevs/thermal_printer # This package supports all platforms listed below. @@ -20,7 +20,7 @@ dependencies: enum_to_string: ^2.0.1 image: ^4.5.2 - network_info_plus: ^6.1.2 + network_info_plus: ^6.1.3 ping_discover_network_forked: ^0.0.1 rxdart: ^0.28.0 gbk_codec: ^0.4.0 From c5580b58bf6e410eee36efe480c83f6e09d5ee0a Mon Sep 17 00:00:00 2001 From: Marcos Rodriguez Date: Wed, 12 Feb 2025 23:02:04 -0500 Subject: [PATCH 22/32] Rename project to `thermal_printer_plus` and update plugin name to `thermal_printer_plus_plugin`. On Windows --- windows/CMakeLists.txt | 6 +++--- .../thermal_printer_plus_plugin.h} | 0 ...l_printer_plugin.cpp => thermal_printer_plus_plugin.cpp} | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) rename windows/include/{thermal_printer/thermal_printer_plugin.h => thermal_printer_plus/thermal_printer_plus_plugin.h} (100%) rename windows/{thermal_printer_plugin.cpp => thermal_printer_plus_plugin.cpp} (98%) diff --git a/windows/CMakeLists.txt b/windows/CMakeLists.txt index 2b836de..d94d41b 100644 --- a/windows/CMakeLists.txt +++ b/windows/CMakeLists.txt @@ -1,15 +1,15 @@ cmake_minimum_required(VERSION 3.15) -set(PROJECT_NAME "thermal_printer") +set(PROJECT_NAME "thermal_printer_plus") project(${PROJECT_NAME} LANGUAGES CXX) # This value is used when generating builds using this plugin, so it must # not be changed -set(PLUGIN_NAME "thermal_printer_plugin") +set(PLUGIN_NAME "thermal_printer_plus_plugin") add_definitions(-D_CRT_SECURE_NO_WARNINGS) add_library(${PLUGIN_NAME} SHARED - "thermal_printer_plugin.cpp" + "thermal_printer_plus_plugin.cpp" "include/printer.cpp" "include/printer.h" "include/utils.hpp" diff --git a/windows/include/thermal_printer/thermal_printer_plugin.h b/windows/include/thermal_printer_plus/thermal_printer_plus_plugin.h similarity index 100% rename from windows/include/thermal_printer/thermal_printer_plugin.h rename to windows/include/thermal_printer_plus/thermal_printer_plus_plugin.h diff --git a/windows/thermal_printer_plugin.cpp b/windows/thermal_printer_plus_plugin.cpp similarity index 98% rename from windows/thermal_printer_plugin.cpp rename to windows/thermal_printer_plus_plugin.cpp index fbaa30a..e2ef000 100644 --- a/windows/thermal_printer_plugin.cpp +++ b/windows/thermal_printer_plus_plugin.cpp @@ -1,4 +1,4 @@ -#include "include/thermal_printer/thermal_printer_plugin.h" +#include "include/thermal_printer_plus/thermal_printer_plus_plugin.h" // This must be included before many other Windows headers. #include From 6ef5fe8755b9c4c29c670a4554050c13f05f0dfc Mon Sep 17 00:00:00 2001 From: Marcos Rodriguez Date: Wed, 12 Feb 2025 23:05:55 -0500 Subject: [PATCH 23/32] Bump Version. --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index f5f622e..c84618d 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: thermal_printer_plus description: A flutter plugin that prints esc commands to printers in different platforms such as android, ios, windows and different interfaces Bluetooth and BLE, TCP and USB -version: 1.0.8 +version: 1.0.9 homepage: https://github.com/nasibudesign/thermal_printer/ # This package supports all platforms listed below. From 4247b18355357a20728f0684edbbc81f5a2d28da Mon Sep 17 00:00:00 2001 From: Marcos Rodriguez Date: Wed, 12 Feb 2025 23:25:03 -0500 Subject: [PATCH 24/32] ``` rename `thermal_printer_plus_plugin.h` to `thermal_printer_plugin.h` ``` --- pubspec.yaml | 2 +- .../{thermal_printer_plus_plugin.h => thermal_printer_plugin.h} | 0 windows/thermal_printer_plus_plugin.cpp | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) rename windows/include/thermal_printer_plus/{thermal_printer_plus_plugin.h => thermal_printer_plugin.h} (100%) diff --git a/pubspec.yaml b/pubspec.yaml index c84618d..5cd7749 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: thermal_printer_plus description: A flutter plugin that prints esc commands to printers in different platforms such as android, ios, windows and different interfaces Bluetooth and BLE, TCP and USB -version: 1.0.9 +version: 1.0.10 homepage: https://github.com/nasibudesign/thermal_printer/ # This package supports all platforms listed below. diff --git a/windows/include/thermal_printer_plus/thermal_printer_plus_plugin.h b/windows/include/thermal_printer_plus/thermal_printer_plugin.h similarity index 100% rename from windows/include/thermal_printer_plus/thermal_printer_plus_plugin.h rename to windows/include/thermal_printer_plus/thermal_printer_plugin.h diff --git a/windows/thermal_printer_plus_plugin.cpp b/windows/thermal_printer_plus_plugin.cpp index e2ef000..c095ad0 100644 --- a/windows/thermal_printer_plus_plugin.cpp +++ b/windows/thermal_printer_plus_plugin.cpp @@ -1,4 +1,4 @@ -#include "include/thermal_printer_plus/thermal_printer_plus_plugin.h" +#include "include/thermal_printer_plus/thermal_printer_plugin.h" // This must be included before many other Windows headers. #include From 1eaf0f0a4fddda2304ffaf7d8d677317bec84067 Mon Sep 17 00:00:00 2001 From: hussein nasibu Date: Thu, 13 Feb 2025 16:25:58 +0100 Subject: [PATCH 25/32] version: 1.0.11 --- CHANGELOG.md | 4 ++++ README.md | 24 +++++++++++++++++++++--- ios/thermal_printer_plus.podspec | 2 +- pubspec.yaml | 2 +- 4 files changed, 27 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 93852f5..34bb300 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.0.9 + +* fixed windows build + ## 1.0.8 * android minSdkVersion to 21 diff --git a/README.md b/README.md index d9f965d..8d6dfab 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # thermal_printer_plus -As the original has not received any update this one is meant to resolve issues by merging every solution contributed. -I love this package, I work with this package but the maintenance of it is suffering from the OG. +As the original [thermal_printer](https://pub.dev/packages/thermal_printer) has not received any update this one is meant to resolve issues by merging every solution contributed. +I love this package, I work with this package but the maintenance of it is suffering from the OG, Any PR are welcome. -[![Pub Version](https://img.shields.io/badge/pub-v1.0.5-green)](https://pub.dev/packages/thermal_printer) +[![Pub Version](https://img.shields.io/badge/pub-v1.0.11-green)](https://pub.dev/packages/thermal_printer_plus) A library to discover printers, and send printer commands. @@ -89,6 +89,24 @@ put the following code in AndroidManifest ## iOS Allow to connect bluetooth (BLE) and network devices +Add in Info.plist +```xml + NSBluetoothAlwaysUsageDescription + We need Bluetooth to connect to devices printer and print receipt. + NSBluetoothPeripheralUsageDescription + We need Bluetooth to connect and print receipt. +``` + +To discover network print don't forget to register dartPing at before runApp method + +```dart +// Register DartPingIOS + if (Platform.isIOS) { + DartPingIOS.register(); + } +``` + + ## Windows Allow to connect USB and network devices To network devices is necessary to set ipAddress diff --git a/ios/thermal_printer_plus.podspec b/ios/thermal_printer_plus.podspec index 22de263..086fcbf 100644 --- a/ios/thermal_printer_plus.podspec +++ b/ios/thermal_printer_plus.podspec @@ -4,7 +4,7 @@ # Pod::Spec.new do |s| s.name = 'thermal_printer_plus' - s.version = '1.0.6' + s.version = '1.0.11' s.summary = 'A new Flutter plugin project.' s.description = <<-DESC A new Flutter plugin project. diff --git a/pubspec.yaml b/pubspec.yaml index 5cd7749..9b6cbc2 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: thermal_printer_plus description: A flutter plugin that prints esc commands to printers in different platforms such as android, ios, windows and different interfaces Bluetooth and BLE, TCP and USB -version: 1.0.10 +version: 1.0.11 homepage: https://github.com/nasibudesign/thermal_printer/ # This package supports all platforms listed below. From c62d5ba07e0a27504ba30fc8b7b77122283ace60 Mon Sep 17 00:00:00 2001 From: hussein Date: Thu, 13 Feb 2025 16:40:45 +0100 Subject: [PATCH 26/32] version: 1.0.11 CHANGELOG --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 34bb300..e56f416 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -## 1.0.9 +## 1.0.11 * fixed windows build From 856a2adaff85f56556ae284c339cd8cae2553809 Mon Sep 17 00:00:00 2001 From: Marcos Rodriguez Date: Sat, 8 Mar 2025 15:04:04 -0500 Subject: [PATCH 27/32] Refactor: Improved Bluetooth and Location Permission Handling - Added more robust permission checking for Bluetooth and Location. - Prevents infinite permission request loops when permissions are permanently denied. - Displays a Toast message when permissions are permanently denied. - Requests only necessary permissions based on the current status. - Corrected handling of `BLUETOOTH_SCAN` and `BLUETOOTH_CONNECT` for newer Android versions. - Commented out unused legacy `BLUETOOTH` and `BLUETOOTH_ADMIN` permissions. --- .../thermal_printer/ThermalPrinterPlugin.kt | 52 +++++++++++++++---- 1 file changed, 43 insertions(+), 9 deletions(-) diff --git a/android/src/main/kotlin/com/codingdevs/thermal_printer/ThermalPrinterPlugin.kt b/android/src/main/kotlin/com/codingdevs/thermal_printer/ThermalPrinterPlugin.kt index e844e24..2277ac0 100644 --- a/android/src/main/kotlin/com/codingdevs/thermal_printer/ThermalPrinterPlugin.kt +++ b/android/src/main/kotlin/com/codingdevs/thermal_printer/ThermalPrinterPlugin.kt @@ -373,23 +373,57 @@ class ThermalPrinterPlugin : FlutterPlugin, MethodCallHandler, PluginRegistry.Re result.success(true) } + /** + * Checks for required Bluetooth/Location permissions. If missing, requests them. + * + * This method also prevents the infinite loop by NOT calling requestPermissions again + * if the user has denied permanently ("Don’t ask again"). + */ private fun checkPermissions(): Boolean { - val permissions = mutableListOf( - Manifest.permission.ACCESS_FINE_LOCATION, -// Manifest.permission.BLUETOOTH, -// Manifest.permission.BLUETOOTH_ADMIN, + val requiredPermissions = mutableListOf( + Manifest.permission.ACCESS_FINE_LOCATION + // Commented out for newer Android versions, but you can re-enable if needed: + // Manifest.permission.BLUETOOTH, + // Manifest.permission.BLUETOOTH_ADMIN, ) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { - permissions.add(Manifest.permission.BLUETOOTH_SCAN) - permissions.add(Manifest.permission.BLUETOOTH_CONNECT) + requiredPermissions.add(Manifest.permission.BLUETOOTH_SCAN) + requiredPermissions.add(Manifest.permission.BLUETOOTH_CONNECT) + } + + // 1) If all permissions are already granted, return true. + if (hasPermissions(context, *requiredPermissions.toTypedArray())) { + return true + } + + // 2) Identify which permissions we can request again + val permissionsToRequest = mutableListOf() + for (permission in requiredPermissions) { + val granted = ActivityCompat.checkSelfPermission(context!!, permission) == PackageManager.PERMISSION_GRANTED + val canAskAgain = ActivityCompat.shouldShowRequestPermissionRationale(currentActivity!!, permission) + + if (!granted) { + // If not granted, check if we can still ask for it again + if (canAskAgain) { + // We'll add this permission to request + permissionsToRequest.add(permission) + } else { + // The user checked "Don't ask again" or the system policy prohibits asking + Toast.makeText(context, "Permission is permanently denied. Please enable it in Settings.", Toast.LENGTH_LONG).show() + return false + } + } } - if (!hasPermissions(context, *permissions.toTypedArray())) { - ActivityCompat.requestPermissions(currentActivity!!, permissions.toTypedArray(), PERMISSION_ALL) + // 3) If there's no permission left to request, it means everything's either granted or permanently denied + if (permissionsToRequest.isEmpty()) { return false } - return true + + // 4) Request all the missing permissions + ActivityCompat.requestPermissions(currentActivity!!, permissionsToRequest.toTypedArray(), PERMISSION_ALL) + return false } private fun hasPermissions(context: Context?, vararg permissions: String?): Boolean { From 0540e10417b87faf3aefc8b530fbf17a167f2dd5 Mon Sep 17 00:00:00 2001 From: Marcos Rodriguez Date: Sat, 8 Mar 2025 15:06:03 -0500 Subject: [PATCH 28/32] Bump Version. --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index 9b6cbc2..0b538c6 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: thermal_printer_plus description: A flutter plugin that prints esc commands to printers in different platforms such as android, ios, windows and different interfaces Bluetooth and BLE, TCP and USB -version: 1.0.11 +version: 1.0.12 homepage: https://github.com/nasibudesign/thermal_printer/ # This package supports all platforms listed below. From f3e385b4cccc84d415757544fabc87ebcacf5133 Mon Sep 17 00:00:00 2001 From: Marcos Rodriguez Date: Thu, 3 Apr 2025 23:11:54 -0400 Subject: [PATCH 29/32] Roolback NetworkInfoPlus check https://github.com/fluttercommunity/plus_plugins/pull/3408#issuecomment-2777451912 --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index 0b538c6..834b8c8 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -20,7 +20,7 @@ dependencies: enum_to_string: ^2.0.1 image: ^4.5.2 - network_info_plus: ^6.1.3 + network_info_plus: 6.1.2 ping_discover_network_forked: ^0.0.1 rxdart: ^0.28.0 gbk_codec: ^0.4.0 From 58e24b60d5538b2110d7e5f0ae19a583021c5ba5 Mon Sep 17 00:00:00 2001 From: hussein Date: Wed, 16 Jul 2025 13:23:01 +0100 Subject: [PATCH 30/32] Migrate to new Flutter/Gradle system and other fixes --- android/build.gradle | 2 +- .../gradle/wrapper/gradle-wrapper.properties | 2 +- example/android/app/build.gradle | 18 +++++------ example/android/build.gradle | 13 -------- .../gradle/wrapper/gradle-wrapper.properties | 2 +- example/android/settings.gradle | 31 ++++++++++++++----- 6 files changed, 33 insertions(+), 35 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index 3ffba4b..6aec723 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -9,7 +9,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:8.1.0' + classpath 'com.android.tools.build:gradle:8.3.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 2ec77e5..fce403e 100644 --- a/android/gradle/wrapper/gradle-wrapper.properties +++ b/android/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index 6d57c8d..ecd8045 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -1,3 +1,9 @@ +plugins { + id "com.android.application" + id "kotlin-android" + id "dev.flutter.flutter-gradle-plugin" +} + def localProperties = new Properties() def localPropertiesFile = rootProject.file('local.properties') if (localPropertiesFile.exists()) { @@ -6,11 +12,6 @@ if (localPropertiesFile.exists()) { } } -def flutterRoot = localProperties.getProperty('flutter.sdk') -if (flutterRoot == null) { - throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") -} - def flutterVersionCode = localProperties.getProperty('flutter.versionCode') if (flutterVersionCode == null) { flutterVersionCode = '1' @@ -21,13 +22,9 @@ if (flutterVersionName == null) { flutterVersionName = '1.0' } -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' -apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" - android { namespace 'com.codingdevs.thermal_printer_example' - compileSdkVersion flutter.compileSdkVersion + compileSdkVersion 35 compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 @@ -65,5 +62,4 @@ flutter { } dependencies { - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" } diff --git a/example/android/build.gradle b/example/android/build.gradle index 070b4ff..bc157bd 100644 --- a/example/android/build.gradle +++ b/example/android/build.gradle @@ -1,16 +1,3 @@ -buildscript { - ext.kotlin_version = '1.9.10' - repositories { - google() - mavenCentral() - } - - dependencies { - classpath 'com.android.tools.build:gradle:8.1.0' - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - } -} - allprojects { repositories { google() diff --git a/example/android/gradle/wrapper/gradle-wrapper.properties b/example/android/gradle/wrapper/gradle-wrapper.properties index d07c7fc..fb5eb59 100644 --- a/example/android/gradle/wrapper/gradle-wrapper.properties +++ b/example/android/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-all.zip diff --git a/example/android/settings.gradle b/example/android/settings.gradle index 44e62bc..32c78c5 100644 --- a/example/android/settings.gradle +++ b/example/android/settings.gradle @@ -1,11 +1,26 @@ -include ':app' +pluginManagement { + def flutterSdkPath = { + def properties = new Properties() + file("local.properties").withInputStream { properties.load(it) } + def flutterSdkPath = properties.getProperty("flutter.sdk") + assert flutterSdkPath != null, "flutter.sdk not set in local.properties" + return flutterSdkPath + }() -def localPropertiesFile = new File(rootProject.projectDir, "local.properties") -def properties = new Properties() + includeBuild("$flutterSdkPath/packages/flutter_tools/gradle") -assert localPropertiesFile.exists() -localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } + repositories { + google() + mavenCentral() + gradlePluginPortal() + } +} -def flutterSdkPath = properties.getProperty("flutter.sdk") -assert flutterSdkPath != null, "flutter.sdk not set in local.properties" -apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" +plugins { + id "dev.flutter.flutter-plugin-loader" version "1.0.0" + id "com.android.application" version "8.3.0" apply false + id "org.jetbrains.kotlin.android" version "1.9.10" apply false +} + + +include ':app' \ No newline at end of file From f24c70babd7e6a6a7216cccead7396aa51cad2e8 Mon Sep 17 00:00:00 2001 From: hussein Date: Fri, 19 Dec 2025 14:19:17 +0100 Subject: [PATCH 31/32] Enhance Bluetooth Connection Management - Added checks to ensure BLEConnecter and its characteristics are initialized before writing data, preventing potential crashes. - Improved peripheral connection handling by ensuring existing connections are properly closed before establishing new ones. - Updated scanning and closing methods to handle BLEConnecter lifecycle more robustly, preventing delegate crashes. --- ios/Classes/ConnecterManager.m | 52 ++++++++++++++++++++++++++---- ios/Classes/ThermalPrinterPlugin.m | 8 +++++ 2 files changed, 54 insertions(+), 6 deletions(-) diff --git a/ios/Classes/ConnecterManager.m b/ios/Classes/ConnecterManager.m index d50e31b..fc6a072 100644 --- a/ios/Classes/ConnecterManager.m +++ b/ios/Classes/ConnecterManager.m @@ -30,6 +30,12 @@ +(instancetype)sharedInstance { * @param discover 发现的设备 */ -(void)scanForPeripheralsWithServices:(nullable NSArray *)serviceUUIDs options:(nullable NSDictionary *)options discover:(void(^_Nullable)(CBPeripheral *_Nullable peripheral,NSDictionary *_Nullable advertisementData,NSNumber *_Nullable RSSI))discover{ + // Ensure BLEConnecter exists - recreate only if it was never created + // (we don't deallocate it on disconnect to prevent delegate crashes) + if (_bleConnecter == nil) { + currentConnMethod = BLUETOOTH; + [self initConnecter:currentConnMethod]; + } [_bleConnecter scanForPeripheralsWithServices:serviceUUIDs options:options discover:discover]; } @@ -60,13 +66,27 @@ -(void)initConnecter:(ConnectMethod)connectMethod { * 方法说明:停止扫描 */ -(void)stopScan { - [_bleConnecter stopScan]; + if (_bleConnecter != nil) { + [_bleConnecter stopScan]; + } } /** * 连接 */ -(void)connectPeripheral:(CBPeripheral *)peripheral options:(nullable NSDictionary *)options timeout:(NSUInteger)timeout connectBlack:(void(^_Nullable)(ConnectState state)) connectState{ + // Ensure BLEConnecter exists - recreate only if it was never created + // (we don't deallocate it on disconnect to prevent delegate crashes) + if (_bleConnecter == nil) { + currentConnMethod = BLUETOOTH; + [self initConnecter:currentConnMethod]; + } + + // If there's an existing connection, disconnect it first + if (_bleConnecter.connPeripheral != nil && _bleConnecter.connPeripheral != peripheral) { + [_bleConnecter closePeripheral:_bleConnecter.connPeripheral]; + } + [_bleConnecter connectPeripheral:peripheral options:options timeout:timeout connectBlack:connectState]; } @@ -90,19 +110,39 @@ -(void)write:(NSData *)data { #ifdef DEBUG NSLog(@"[ConnecterManager] write:"); #endif + + // Guard: Check if characteristic exists before writing + if (_bleConnecter != nil && _bleConnecter.transparentDataWriteChar == nil) { + NSLog(@"[ConnecterManager] ERROR: Cannot write - transparentDataWriteChar is nil. Characteristics may not be discovered yet."); + return; // Prevent crash by returning early + } + _bleConnecter.writeProgress = nil; [_connecter write:data]; } -(void)close { + // Stop scanning first to prevent new delegate callbacks + if (_bleConnecter != nil) { + [_bleConnecter stopScan]; + } + + // Properly disconnect the peripheral if connected + if (_bleConnecter != nil && _bleConnecter.connPeripheral != nil) { + [_bleConnecter closePeripheral:_bleConnecter.connPeripheral]; + } + + // Close the connecter (this should handle delegate cleanup) if (_connecter) { [_connecter close]; } - switch (currentConnMethod) { - case BLUETOOTH: - _bleConnecter = nil; - break; - } + + // IMPORTANT: Do NOT set _bleConnecter = nil here! + // Core Bluetooth retains a reference to BLEConnecter as a delegate, + // and can call delegate methods (like centralManagerDidUpdateState:) at any time. + // If we deallocate BLEConnecter, Core Bluetooth will crash when trying to call these methods. + // Instead, keep BLEConnecter alive - it can be reused for new connections. + // The BLEConnecter will handle being disconnected and can accept new connections. } @end diff --git a/ios/Classes/ThermalPrinterPlugin.m b/ios/Classes/ThermalPrinterPlugin.m index abe96d7..d32831a 100644 --- a/ios/Classes/ThermalPrinterPlugin.m +++ b/ios/Classes/ThermalPrinterPlugin.m @@ -111,6 +111,14 @@ - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result { } NSData *data2 = [NSData dataWithBytes:cArray length:sizeof(cArray)]; // NSLog(@"bytes in hex: %@", [data2 description]); + + // Guard: Check if characteristic exists before writing + if (Manager.bleConnecter != nil && Manager.bleConnecter.transparentDataWriteChar == nil) { + NSLog(@"[ThermalPrinterPlugin] ERROR: Cannot write - transparentDataWriteChar is nil. Characteristics may not be discovered yet."); + result(nil); + return; // Prevent crash by returning early + } + [Manager write:data2]; result(nil); } @catch(FlutterError *e) { From 4b1f350ac74b24947e405eaf07cccb1488b3696e Mon Sep 17 00:00:00 2001 From: hussein Date: Fri, 19 Dec 2025 14:27:11 +0100 Subject: [PATCH 32/32] Update iOS Deployment Target and Permissions Handling - Increased iOS deployment target from 12.0 to 13.0 across multiple files. - Enhanced permission checks in ThermalPrinterPlugin to include necessary Bluetooth permissions for Android versions below S. - Updated Podfile.lock to reflect the new version of thermal_printer_plus (1.0.11) and CocoaPods version (1.16.2). - Modified app title in main.dart for clarity. --- .../thermal_printer/ThermalPrinterPlugin.kt | 9 +++++---- example/ios/Flutter/AppFrameworkInfo.plist | 2 +- example/ios/Podfile | 2 +- example/ios/Podfile.lock | 14 +++++++------- example/ios/Runner.xcodeproj/project.pbxproj | 9 ++++++--- .../xcshareddata/xcschemes/Runner.xcscheme | 3 +++ example/lib/main.dart | 2 +- 7 files changed, 24 insertions(+), 17 deletions(-) diff --git a/android/src/main/kotlin/com/codingdevs/thermal_printer/ThermalPrinterPlugin.kt b/android/src/main/kotlin/com/codingdevs/thermal_printer/ThermalPrinterPlugin.kt index 2277ac0..803249b 100644 --- a/android/src/main/kotlin/com/codingdevs/thermal_printer/ThermalPrinterPlugin.kt +++ b/android/src/main/kotlin/com/codingdevs/thermal_printer/ThermalPrinterPlugin.kt @@ -381,15 +381,16 @@ class ThermalPrinterPlugin : FlutterPlugin, MethodCallHandler, PluginRegistry.Re */ private fun checkPermissions(): Boolean { val requiredPermissions = mutableListOf( - Manifest.permission.ACCESS_FINE_LOCATION - // Commented out for newer Android versions, but you can re-enable if needed: - // Manifest.permission.BLUETOOTH, - // Manifest.permission.BLUETOOTH_ADMIN, + Manifest.permission.ACCESS_FINE_LOCATION, + Manifest.permission.ACCESS_COARSE_LOCATION ) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { requiredPermissions.add(Manifest.permission.BLUETOOTH_SCAN) requiredPermissions.add(Manifest.permission.BLUETOOTH_CONNECT) + } else { + requiredPermissions.add(Manifest.permission.BLUETOOTH) + requiredPermissions.add(Manifest.permission.BLUETOOTH_ADMIN) } // 1) If all permissions are already granted, return true. diff --git a/example/ios/Flutter/AppFrameworkInfo.plist b/example/ios/Flutter/AppFrameworkInfo.plist index 7c56964..1dc6cf7 100644 --- a/example/ios/Flutter/AppFrameworkInfo.plist +++ b/example/ios/Flutter/AppFrameworkInfo.plist @@ -21,6 +21,6 @@ CFBundleVersion 1.0 MinimumOSVersion - 12.0 + 13.0 diff --git a/example/ios/Podfile b/example/ios/Podfile index 2c068c4..10f3c9b 100644 --- a/example/ios/Podfile +++ b/example/ios/Podfile @@ -1,5 +1,5 @@ # Uncomment this line to define a global platform for your project -platform :ios, '12.0' +platform :ios, '13.0' # CocoaPods analytics sends network stats synchronously affecting flutter build latency. ENV['COCOAPODS_DISABLE_STATS'] = 'true' diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index dfd92ca..977759e 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -4,7 +4,7 @@ PODS: - Flutter - network_info_plus (0.0.1): - Flutter - - thermal_printer_plus (1.0.6): + - thermal_printer_plus (1.0.11): - Flutter DEPENDENCIES: @@ -24,11 +24,11 @@ EXTERNAL SOURCES: :path: ".symlinks/plugins/thermal_printer_plus/ios" SPEC CHECKSUMS: - Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7 - flutter_icmp_ping: 2b159955eee0c487c766ad83fec224ae35e7c935 - network_info_plus: 6d0c3eb8367b8164fa3fb0c19875e3f59d49697f - thermal_printer_plus: cbb9818595ad92174d0972828ee0dd3e6ccd1b99 + Flutter: cabc95a1d2626b1b06e7179b784ebcf0c0cde467 + flutter_icmp_ping: 47c1df3440c18ddd39fc457e607bb3b42d4a339f + network_info_plus: cf61925ab5205dce05a4f0895989afdb6aade5fc + thermal_printer_plus: ad9ed77574c9da74de2d4fc89f1f773e52c41a0f -PODFILE CHECKSUM: 4e8f8b2be68aeea4c0d5beb6ff1e79fface1d048 +PODFILE CHECKSUM: cc1f88378b4bfcf93a6ce00d2c587857c6008d3b -COCOAPODS: 1.15.2 +COCOAPODS: 1.16.2 diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj index 037fe52..f194241 100644 --- a/example/ios/Runner.xcodeproj/project.pbxproj +++ b/example/ios/Runner.xcodeproj/project.pbxproj @@ -342,7 +342,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos; @@ -358,6 +358,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + DEVELOPMENT_TEAM = XSQ379TX3B; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( @@ -419,7 +420,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -468,7 +469,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos; @@ -486,6 +487,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + DEVELOPMENT_TEAM = XSQ379TX3B; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( @@ -508,6 +510,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + DEVELOPMENT_TEAM = XSQ379TX3B; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( diff --git a/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index 5e31d3d..9c12df5 100644 --- a/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -26,6 +26,7 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + customLLDBInitFile = "$(SRCROOT)/Flutter/ephemeral/flutter_lldbinit" shouldUseLaunchSchemeArgsEnv = "YES"> diff --git a/example/lib/main.dart b/example/lib/main.dart index 822c4ee..3ccb907 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -302,7 +302,7 @@ class _MyAppState extends State { return MaterialApp( home: Scaffold( appBar: AppBar( - title: const Text('Flutter Pos Plugin Platform example app'), + title: const Text('Thermal Printer Plus example app'), ), body: Center( child: Container(