diff --git a/android/build.gradle b/android/build.gradle index 909ce0a..b3ef618 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 = '2.2.20' repositories { google() mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:7.4.0' + classpath 'com.android.tools.build:gradle:8.13.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } @@ -25,15 +25,16 @@ apply plugin: 'com.android.library' apply plugin: 'kotlin-android' android { - compileSdkVersion 33 + namespace = "com.codingdevs.thermal_printer" + compileSdkVersion 36 compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 + sourceCompatibility JavaVersion.VERSION_11 + targetCompatibility JavaVersion.VERSION_11 } kotlinOptions { - jvmTarget = '1.8' + jvmTarget = '11' } sourceSets { @@ -42,10 +43,10 @@ android { defaultConfig { minSdkVersion 19 - targetSdkVersion 33 + targetSdkVersion 36 } } dependencies { - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" } diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties index 2ec77e5..f407850 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.13-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists 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..32045e4 100644 --- a/android/src/main/kotlin/com/codingdevs/thermal_printer/ThermalPrinterPlugin.kt +++ b/android/src/main/kotlin/com/codingdevs/thermal_printer/ThermalPrinterPlugin.kt @@ -13,7 +13,7 @@ import android.os.Looper import android.os.Message import android.util.Log import android.widget.Toast -import androidx.annotation.NonNull +import androidx.annotation.RequiresApi import androidx.core.app.ActivityCompat import androidx.core.app.ActivityCompat.startActivityForResult import com.codingdevs.thermal_printer.bluetooth.BluetoothConnection @@ -52,7 +52,7 @@ class ThermalPrinterPlugin : FlutterPlugin, MethodCallHandler, PluginRegistry.Re private var requestPermissionBT: Boolean = false private var isBle: Boolean = false private var isScan: Boolean = false - lateinit var adapter: USBPrinterService + private lateinit var adapter: USBPrinterService private lateinit var bluetoothService: BluetoothService @@ -92,7 +92,7 @@ class ThermalPrinterPlugin : FlutterPlugin, MethodCallHandler, PluginRegistry.Re try { val result = msg.obj as Result? result?.success(true) - } catch (e: Exception) { + } catch (_: Exception) { } eventSink?.success(2) bluetoothService.removeReconnectHandlers() @@ -113,7 +113,7 @@ class ThermalPrinterPlugin : FlutterPlugin, MethodCallHandler, PluginRegistry.Re try { val result = msg.obj as Result? result?.success(false) - } catch (e: Exception) { + } catch (_: Exception) { } eventSink?.success(0) } @@ -156,7 +156,7 @@ class ThermalPrinterPlugin : FlutterPlugin, MethodCallHandler, PluginRegistry.Re } - override fun onDetachedFromEngine(@NonNull binding: FlutterPlugin.FlutterPluginBinding) { + override fun onDetachedFromEngine(binding: FlutterPlugin.FlutterPluginBinding) { channel.setMethodCallHandler(null) messageChannel?.setStreamHandler(null) messageUSBChannel?.setStreamHandler(null) @@ -168,11 +168,11 @@ class ThermalPrinterPlugin : FlutterPlugin, MethodCallHandler, PluginRegistry.Re adapter.setHandler(null) } - override fun onAttachedToEngine(@NonNull flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) { - channel = MethodChannel(flutterPluginBinding.binaryMessenger, methodChannel) + override fun onAttachedToEngine(flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) { + channel = MethodChannel(flutterPluginBinding.binaryMessenger, METHOD_CHANNEL) channel.setMethodCallHandler(this) - messageChannel = EventChannel(flutterPluginBinding.binaryMessenger, eventChannelBT) + messageChannel = EventChannel(flutterPluginBinding.binaryMessenger, EVENT_CHANNEL_BT) messageChannel?.setStreamHandler(object : EventChannel.StreamHandler { override fun onListen(p0: Any?, sink: EventChannel.EventSink) { @@ -184,7 +184,7 @@ class ThermalPrinterPlugin : FlutterPlugin, MethodCallHandler, PluginRegistry.Re } }) - messageUSBChannel = EventChannel(flutterPluginBinding.binaryMessenger, eventChannelUSB) + messageUSBChannel = EventChannel(flutterPluginBinding.binaryMessenger, EVENT_CHANNEL_USB) messageUSBChannel?.setStreamHandler(object : EventChannel.StreamHandler { override fun onListen(p0: Any?, sink: EventChannel.EventSink) { @@ -203,7 +203,8 @@ class ThermalPrinterPlugin : FlutterPlugin, MethodCallHandler, PluginRegistry.Re bluetoothService = BluetoothService.getInstance(bluetoothHandler) } - override fun onMethodCall(@NonNull call: MethodCall, @NonNull result: Result) { + @RequiresApi(Build.VERSION_CODES.LOLLIPOP) + override fun onMethodCall(call: MethodCall, result: Result) { isScan = false when { call.method.equals("getBluetoothList") -> { @@ -315,6 +316,7 @@ class ThermalPrinterPlugin : FlutterPlugin, MethodCallHandler, PluginRegistry.Re return true } + @RequiresApi(Build.VERSION_CODES.LOLLIPOP) private fun getUSBDeviceList(result: Result) { val usbDevices: List = adapter.deviceList val list = ArrayList>() @@ -380,6 +382,8 @@ class ThermalPrinterPlugin : FlutterPlugin, MethodCallHandler, PluginRegistry.Re permissions.add(Manifest.permission.BLUETOOTH_CONNECT) } + if (context == null || currentActivity == null) return false + if (!hasPermissions(context, *permissions.toTypedArray())) { ActivityCompat.requestPermissions(currentActivity!!, permissions.toTypedArray(), PERMISSION_ALL) return false @@ -467,9 +471,9 @@ class ThermalPrinterPlugin : FlutterPlugin, MethodCallHandler, PluginRegistry.Re companion object { const val PERMISSION_ALL = 1 const val PERMISSION_ENABLE_BLUETOOTH = 999 - const val methodChannel = "com.codingdevs.thermal_printer" - const val eventChannelBT = "com.codingdevs.thermal_printer/bt_state" - const val eventChannelUSB = "com.codingdevs.thermal_printer/usb_state" + const val METHOD_CHANNEL = "com.codingdevs.thermal_printer" + const val EVENT_CHANNEL_BT = "com.codingdevs.thermal_printer/bt_state" + const val EVENT_CHANNEL_USB = "com.codingdevs.thermal_printer/usb_state" } } 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 deleted file mode 100644 index dc93fb5..0000000 --- a/android/src/main/kotlin/com/codingdevs/thermal_printer/adapter/USBPrinterAdapter.kt +++ /dev/null @@ -1,266 +0,0 @@ -package com.codingdevs.thermal_printer - -import android.app.PendingIntent -import android.content.BroadcastReceiver -import android.content.Context -import android.content.Intent -import android.content.IntentFilter -import android.hardware.usb.* -import android.util.Base64 -import android.util.Log -import android.widget.Toast -import com.codingdevs.thermal_printer.R -import com.codingdevs.thermal_printer.usb.USBPrinterService -import java.nio.charset.Charset -import java.util.* - -class USBPrinterAdapter private constructor() { - - private var mContext: Context? = null - private var mUSBManager: UsbManager? = null - private var mPermissionIndent: PendingIntent? = null - private var mUsbDevice: UsbDevice? = null - private var mUsbDeviceConnection: UsbDeviceConnection? = null - private var mUsbInterface: UsbInterface? = null - private var mEndPoint: UsbEndpoint? = null - - fun init(reactContext: Context?) { - mContext = reactContext - mUSBManager = mContext!!.getSystemService(Context.USB_SERVICE) as UsbManager - 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) - } else { - PendingIntent.getBroadcast(mContext, 0, Intent(ACTION_USB_PERMISSION), 0) - } - val filter = IntentFilter(ACTION_USB_PERMISSION) - filter.addAction(UsbManager.ACTION_USB_DEVICE_DETACHED) - mContext!!.registerReceiver(mUsbDeviceReceiver, filter) - Log.v(LOG_TAG, "ESC/POS Printer initialized") - } - - - private val mUsbDeviceReceiver: BroadcastReceiver = object : BroadcastReceiver() { - override fun onReceive(context: Context, intent: Intent) { - val action = intent.action - if ((ACTION_USB_PERMISSION == action)) { - synchronized(this) { - val usbDevice: UsbDevice? = intent.getParcelableExtra(UsbManager.EXTRA_DEVICE) - if (intent.getBooleanExtra(UsbManager.EXTRA_PERMISSION_GRANTED, false)) { - Log.i( - LOG_TAG, - "Success get permission for device " + usbDevice!!.deviceId + ", vendor_id: " + usbDevice.vendorId + " product_id: " + usbDevice.productId - ) - mUsbDevice = usbDevice - } else { - Toast.makeText( - context, mContext?.getString(R.string.user_refuse_perm) + ": ${usbDevice!!.deviceName}", - Toast.LENGTH_LONG - ).show() - } - } - } else if ((UsbManager.ACTION_USB_DEVICE_DETACHED == action)) { - if (mUsbDevice != null) { - Toast.makeText(context, mContext?.getString(R.string.device_off), Toast.LENGTH_LONG).show() - closeConnectionIfExists() - } - } - } - } - - - fun closeConnectionIfExists() { - if (mUsbDeviceConnection != null) { - mUsbDeviceConnection!!.releaseInterface(mUsbInterface) - mUsbDeviceConnection!!.close() - mUsbInterface = null - mEndPoint = null - mUsbDeviceConnection = null - } - } - - val deviceList: List - get() { - if (mUSBManager == null) { - Toast.makeText(mContext, mContext?.getString(R.string.not_usb_manager), Toast.LENGTH_LONG).show() - return emptyList() - } - return ArrayList(mUSBManager!!.deviceList.values) - } - - fun selectDevice(vendorId: Int, productId: Int): Boolean { - if ((mUsbDevice == null) || (mUsbDevice!!.vendorId != vendorId) || (mUsbDevice!!.productId != productId)) { - synchronized(printLock) { - closeConnectionIfExists() - val usbDevices: List = deviceList - for (usbDevice: UsbDevice in usbDevices) { - if ((usbDevice.vendorId == vendorId) && (usbDevice.productId == productId)) { - Log.v( - LOG_TAG, - "Request for device: vendor_id: " + usbDevice.vendorId + ", product_id: " + usbDevice.productId - ) - closeConnectionIfExists() - mUSBManager!!.requestPermission(usbDevice, mPermissionIndent) - return true - } - } - return false - } - } - return true - } - - private fun openConnection(): Boolean { - if (mUsbDevice == null) { - Log.e(LOG_TAG, "USB Deivce is not initialized") - return false - } - if (mUSBManager == null) { - Log.e(LOG_TAG, "USB Manager is not initialized") - return false - } - if (mUsbDeviceConnection != null) { - Log.i(LOG_TAG, "USB Connection already connected") - return true - } - val usbInterface = mUsbDevice!!.getInterface(0) - for (i in 0 until usbInterface.endpointCount) { - val ep = usbInterface.getEndpoint(i) - if (ep.type == UsbConstants.USB_ENDPOINT_XFER_BULK) { - if (ep.direction == UsbConstants.USB_DIR_OUT) { - val usbDeviceConnection = mUSBManager!!.openDevice(mUsbDevice) - if (usbDeviceConnection == null) { - Log.e(LOG_TAG, "Failed to open USB Connection") - return false - } - Toast.makeText(mContext, mContext?.getString(R.string.connected_device), Toast.LENGTH_SHORT).show() - if (usbDeviceConnection.claimInterface(usbInterface, true)) { - mEndPoint = ep - mUsbInterface = usbInterface - mUsbDeviceConnection = usbDeviceConnection - return true - } else { - usbDeviceConnection.close() - Log.e(LOG_TAG, "Failed to retrieve usb connection") - return false - } - } - } - } - return true - } - - fun printText(text: String): Boolean { - Log.v(LOG_TAG, "Printing text") - val isConnected = openConnection() - if (isConnected) { - Log.v(LOG_TAG, "Connected to device") - Thread(Runnable { - synchronized(printLock) { - val bytes: ByteArray = text.toByteArray(Charset.forName("UTF-8")) - val b: Int = - mUsbDeviceConnection!!.bulkTransfer(mEndPoint, bytes, bytes.size, 100000) - Log.i(LOG_TAG, "Return code: $b") - } - }).start() - return true - } else { - Log.v(LOG_TAG, "Failed to connect to device") - return false - } - } - - fun printRawData(data: String): Boolean { - Log.v(LOG_TAG, "Printing raw data: $data") - val isConnected = openConnection() - if (isConnected) { - Log.v(LOG_TAG, "Connected to device") - Thread(object : Runnable { - override fun run() { - synchronized(printLock) { - val bytes: ByteArray = Base64.decode(data, Base64.DEFAULT) - val b: Int = mUsbDeviceConnection!!.bulkTransfer( - mEndPoint, - bytes, - bytes.size, - 100000 - ) - Log.i(LOG_TAG, "Return code: " + b) - } - } - }).start() - return true - } else { - Log.v(LOG_TAG, "Failed to connected to device") - return false - } - } - - fun printBytes(bytes: ArrayList): Boolean { - Log.v(LOG_TAG, "Printing bytes") - val isConnected = openConnection() - if (isConnected) { - val chunkSize = mEndPoint!!.maxPacketSize - Log.v(LOG_TAG, "Max Packet Size: $chunkSize") - Log.v(LOG_TAG, "Connected to device") - Thread { - synchronized(printLock) { - val vectorData: Vector = Vector() - for (i in bytes.indices) { - val `val`: Int = bytes[i] - vectorData.add(`val`.toByte()) - } - val temp: Array = vectorData.toTypedArray() - val bytedata = ByteArray(temp.size) - for (i in temp.indices) { - bytedata[i] = temp[i] as Byte - } - var b: Int = 0 - if (mUsbDeviceConnection != null) { - if (bytedata.size > chunkSize) { - var chunks: Int = bytedata.size / chunkSize - if (bytedata.size % chunkSize > 0) { - ++chunks - } - for (i in 0 until chunks) { - val buffer: ByteArray = - bytedata.copyOfRange(i * chunkSize, chunkSize + i * chunkSize) - b = mUsbDeviceConnection!!.bulkTransfer( - mEndPoint, - buffer, - chunkSize, - 100000 - ) - } - } else { - b = mUsbDeviceConnection!!.bulkTransfer( - mEndPoint, - bytedata, - bytedata.size, - 100000 - ) - } - Log.i(LOG_TAG, "Return code: $b") - } - } - }.start() - return true - } else { - Log.v(LOG_TAG, "Failed to connected to device") - return false - } - } - - companion object { - private var mInstance: USBPrinterAdapter? = null - private const val ACTION_USB_PERMISSION = "com.flutter_pos_printer.USB_PERMISSION" - private const val LOG_TAG = "ESC POS Printer" - private val printLock = Any() - val instance: USBPrinterAdapter - get() { - if (mInstance == null) { - mInstance = USBPrinterAdapter() - } - return mInstance!! - } - } -} \ No newline at end of file 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..d653073 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 @@ -7,10 +7,12 @@ import android.content.Context import android.content.Intent import android.content.IntentFilter import android.hardware.usb.* +import android.os.Build import android.os.Handler import android.util.Base64 import android.util.Log import android.widget.Toast +import androidx.annotation.RequiresApi import com.codingdevs.thermal_printer.R import java.nio.charset.Charset import java.util.* @@ -67,17 +69,22 @@ class USBPrinterService private constructor(private var mHandler: Handler?) { } } + @RequiresApi(Build.VERSION_CODES.O) fun init(reactContext: Context?) { mContext = reactContext mUSBManager = mContext!!.getSystemService(Context.USB_SERVICE) as UsbManager 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, Intent(ACTION_USB_PERMISSION), + PendingIntent.FLAG_IMMUTABLE) } else { - PendingIntent.getBroadcast(mContext, 0, Intent(ACTION_USB_PERMISSION), 0) + PendingIntent.getBroadcast(mContext, 0, Intent(ACTION_USB_PERMISSION), + PendingIntent.FLAG_IMMUTABLE) } val filter = IntentFilter(ACTION_USB_PERMISSION) filter.addAction(UsbManager.ACTION_USB_DEVICE_DETACHED) - mContext!!.registerReceiver(mUsbDeviceReceiver, filter) + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { + mContext!!.registerReceiver(mUsbDeviceReceiver, filter, Context.RECEIVER_EXPORTED) + } 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..1264adf 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 @@ -18,9 +18,11 @@ class UsbReceiver : BroadcastReceiver() { val usbDevice: UsbDevice? = intent.getParcelableExtra(UsbManager.EXTRA_DEVICE) 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, Intent("com.flutter_pos_printer.USB_PERMISSION"), + PendingIntent.FLAG_IMMUTABLE) } else { - PendingIntent.getBroadcast(context, 0, Intent("com.flutter_pos_printer.USB_PERMISSION"), 0) + PendingIntent.getBroadcast(context, 0, Intent("com.flutter_pos_printer.USB_PERMISSION"), + PendingIntent.FLAG_IMMUTABLE) } val mUSBManager = context?.getSystemService(Context.USB_SERVICE) as UsbManager? mUSBManager?.requestPermission(usbDevice, mPermissionIndent) diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index 6cd1658..c901df2 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -1,40 +1,22 @@ -def localProperties = new Properties() -def localPropertiesFile = rootProject.file('local.properties') -if (localPropertiesFile.exists()) { - localPropertiesFile.withReader('UTF-8') { reader -> - localProperties.load(reader) - } -} - -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' +plugins { + id "com.android.application" + id "kotlin-android" + // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins. + id "dev.flutter.flutter-gradle-plugin" } -def flutterVersionName = localProperties.getProperty('flutter.versionName') -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 { - compileSdkVersion flutter.compileSdkVersion + namespace 'com.codingdevs.thermal_printer_example' + //compileSdkVersion flutter.compileSdkVersion + compileSdkVersion 36 compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 + sourceCompatibility JavaVersion.VERSION_11 + targetCompatibility JavaVersion.VERSION_11 } kotlinOptions { - jvmTarget = '1.8' + jvmTarget = '11' } sourceSets { @@ -44,10 +26,11 @@ 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 - targetSdkVersion 33 - versionCode flutterVersionCode.toInteger() - versionName flutterVersionName + minSdk = flutter.minSdkVersion + //targetSdk = flutter.targetSdkVersion + targetSdk = 36 + versionCode = flutter.versionCode + versionName = flutter.versionName } buildTypes { @@ -62,7 +45,3 @@ android { flutter { source '../..' } - -dependencies { - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" -} diff --git a/example/android/build.gradle b/example/android/build.gradle index 92546c1..96418ba 100644 --- a/example/android/build.gradle +++ b/example/android/build.gradle @@ -1,29 +1,26 @@ -buildscript { - ext.kotlin_version = '1.9.10' +allprojects { repositories { google() mavenCentral() } - - dependencies { - classpath 'com.android.tools.build:gradle:7.4.0' - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - } } -allprojects { - repositories { - google() - mavenCentral() +rootProject.buildDir = "../build" +// AGGIUNTO PER FORZARE LA COMPILAZIONE SDK A 36 DELLE LIBRERIE INCLUSE NEL PROGETTO FLUTTER CHE NON SONO GESTIBILI TECNICAMENTE +subprojects { + afterEvaluate { project -> + if (project.hasProperty('android')) { + project.android { + compileSdk 36 + } + } } } - -rootProject.buildDir = '../build' subprojects { project.buildDir = "${rootProject.buildDir}/${project.name}" } subprojects { - project.evaluationDependsOn(':app') + project.evaluationDependsOn(":app") } tasks.register("clean", Delete) { diff --git a/example/android/gradle.properties b/example/android/gradle.properties index c21ea68..2597170 100644 --- a/example/android/gradle.properties +++ b/example/android/gradle.properties @@ -1,3 +1,3 @@ -org.gradle.jvmargs=-Xmx6608M +org.gradle.jvmargs=-Xmx4G -XX:MaxMetaspaceSize=2G -XX:+HeapDumpOnOutOfMemoryError android.useAndroidX=true android.enableJetifier=true diff --git a/example/android/gradle/wrapper/gradle-wrapper.properties b/example/android/gradle/wrapper/gradle-wrapper.properties index 6b66533..8f3239a 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-7.5-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-all.zip diff --git a/example/android/settings.gradle b/example/android/settings.gradle index 44e62bc..7cffcd0 100644 --- a/example/android/settings.gradle +++ b/example/android/settings.gradle @@ -1,11 +1,25 @@ -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.13.0" apply false + id "org.jetbrains.kotlin.android" version "2.2.20" apply false +} + +include ":app" diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 17e411f..d4c9be2 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.3.0 <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 @@ -28,7 +28,7 @@ dependencies: # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. - cupertino_icons: ^1.0.2 + cupertino_icons: ^1.0.8 dart_ping_ios: ^4.0.2 dev_dependencies: @@ -40,7 +40,7 @@ dev_dependencies: # activated in the `analysis_options.yaml` file located at the root of your # package. See that file for information about deactivating specific lint # rules and activating additional ones. - flutter_lints: ^1.0.0 + flutter_lints: ^6.0.0 # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec diff --git a/pubspec.yaml b/pubspec.yaml index 75bf575..70f48fd 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. @@ -10,19 +10,19 @@ platforms: windows: environment: - sdk: '>=2.18.4 <4.0.0' + sdk: '>=3.3.0 <4.0.0' flutter: ">=1.20.0" dependencies: flutter: sdk: flutter - enum_to_string: ^2.0.1 - image: ^4.1.3 + enum_to_string: ^2.2.1 + image: ^4.5.4 - network_info_plus: ^4.1.0 + network_info_plus: ^7.0.0 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