diff --git a/README.md b/README.md index f6a11ad..f940f78 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,9 @@ -# Nyx Printer + +# Nyx Printer Flutter Plugin that connect to Nyx devices Printer such as NB55. + ## Installation Install Nyx Printer with pub @@ -9,9 +11,10 @@ Install Nyx Printer with pub ```bash flutter pub add nyx_printer ``` - + ![Receipt](https://raw.githubusercontent.com/Aladdin16659/NyxPrinter/main/example/images/receipt.jpeg) + ## Print Image ```dart @@ -24,7 +27,6 @@ import 'package:nyx_printer/nyx_printer.dart'; await _nyxPrinterPlugin.printImage(image.buffer.asUint8List()); } ``` - ## Print Text ```dart @@ -40,7 +42,6 @@ import 'package:nyx_printer/nyx_printer.dart'; ); } ``` - ## Print QR ```dart @@ -52,8 +53,7 @@ import 'package:nyx_printer/nyx_printer.dart'; ); } ``` - -## Print Barcode +## Print QR ```dart Future printBarcode() async { @@ -65,7 +65,9 @@ import 'package:nyx_printer/nyx_printer.dart'; } ``` + ## License [MIT](https://github.com/Aladdin16659/NyxPrinter/blob/main/LICENSE) Copyright (c) 2023 ALADDIN SID AHMED + diff --git a/android/build.gradle b/android/build.gradle index 19cd4a7..538b030 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -22,34 +22,52 @@ rootProject.allprojects { apply plugin: 'com.android.library' android { - compileSdkVersion 31 - - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 + if (project.android.hasProperty("namespace")) { + namespace = "net.nyx.nyxprinter.nyx_printer" } + compileSdk = 34 + defaultConfig { minSdkVersion 16 + targetSdkVersion 34 + versionCode 1 + versionName "1.0" } - dependencies { - implementation fileTree(include: ['*.jar', '*.aar'], dir: 'libs') - testImplementation 'junit:junit:4.13.2' - testImplementation 'org.mockito:mockito-core:5.0.0' - implementation 'androidx.appcompat:appcompat:1.0.2' - implementation 'androidx.constraintlayout:constraintlayout:1.1.3' - implementation 'org.aspectj:aspectjrt:1.9.6' - implementation 'com.jakewharton.timber:timber:4.7.1' + sourceSets { + main { + jniLibs.srcDirs = ['libs'] + aidl.srcDirs = ['src/main/aidl'] + } + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + buildFeatures { + aidl true } testOptions { unitTests.all { testLogging { - events "passed", "skipped", "failed", "standardOut", "standardError" - outputs.upToDateWhen {false} - showStandardStreams = true + events "passed", "skipped", "failed", "standardOut", "standardError" + outputs.upToDateWhen {false} + showStandardStreams = true } } } } + +dependencies { + implementation fileTree(include: ['*.jar', '*.aar'], dir: 'libs') + testImplementation 'junit:junit:4.13.2' + testImplementation 'org.mockito:mockito-core:5.0.0' + implementation 'androidx.appcompat:appcompat:1.0.2' + implementation 'androidx.constraintlayout:constraintlayout:1.1.3' + implementation 'org.aspectj:aspectjrt:1.9.6' + implementation 'com.jakewharton.timber:timber:4.7.1' +} \ No newline at end of file diff --git a/android/gradle.properties b/android/gradle.properties new file mode 100644 index 0000000..d015431 --- /dev/null +++ b/android/gradle.properties @@ -0,0 +1,2 @@ +android.useAndroidX=true +android.enableJetifier=true \ No newline at end of file diff --git a/android/src/main/java/net/nyx/nyxprinter/nyx_printer/NyxPrinterPlugin.java b/android/src/main/java/net/nyx/nyxprinter/nyx_printer/NyxPrinterPlugin.java index a8829e8..9168fb8 100644 --- a/android/src/main/java/net/nyx/nyxprinter/nyx_printer/NyxPrinterPlugin.java +++ b/android/src/main/java/net/nyx/nyxprinter/nyx_printer/NyxPrinterPlugin.java @@ -22,6 +22,7 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; + /** NyxPrinterPlugin */ public class NyxPrinterPlugin implements FlutterPlugin, MethodCallHandler { /// The MethodChannel that will the communication between Flutter and native Android diff --git a/lib/nyx_printer.dart b/lib/nyx_printer.dart index 5b82f53..f0ae24c 100644 --- a/lib/nyx_printer.dart +++ b/lib/nyx_printer.dart @@ -5,40 +5,25 @@ import 'nyx_text_format.dart'; export 'nyx_text_format.dart'; class NyxPrinter { - /// [getVersion] will return printer version number. - /// success result is 0. Future getVersion() { return NyxPrinterPlatform.instance.getVersion(); } - /// [printText] will print text - /// to format text you can use [NyxTextFormat] to set font size or font style ...ext - /// success result is 0. Future printText(String text, {NyxTextFormat? textFormat}) { return NyxPrinterPlatform.instance .printText(text, textFormat ?? NyxTextFormat()); } - /// [printBarcode] will print QR and you can set width and height. - /// default width is 300 - /// default height is 160 - /// success result is 0. Future printBarcode(String text, {int? width, int? height}) { return NyxPrinterPlatform.instance .printBarcode(text, width ?? 300, height ?? 160); } - /// [printQrCode] will print QR and you can set width and height. - /// default width is 300 - /// default height is 300, - /// success result is 0. Future printQrCode(String text, {int? width, int? height}) { return NyxPrinterPlatform.instance .printQrCode(text, width ?? 300, height ?? 300); } - /// [printImage] will print only png images - /// success result is 0. Future printImage(Uint8List bytes) { return NyxPrinterPlatform.instance.printBitmap(bytes); }