Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,5 @@
.pub/

build/
example/android
example/build/
example/ios
example/lib
example/test
27 changes: 25 additions & 2 deletions .metadata
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,30 @@
# This file should be version controlled and should not be manually edited.

version:
revision: 8af6b2f038c1172e61d418869363a28dffec3cb4
channel: stable
revision: "3b62efc2a3da49882f43c372e0bc53daef7295a6"
channel: "stable"

project_type: plugin

# Tracks metadata for the flutter migrate command
migration:
platforms:
- platform: root
create_revision: 3b62efc2a3da49882f43c372e0bc53daef7295a6
base_revision: 3b62efc2a3da49882f43c372e0bc53daef7295a6
- platform: android
create_revision: 3b62efc2a3da49882f43c372e0bc53daef7295a6
base_revision: 3b62efc2a3da49882f43c372e0bc53daef7295a6
- platform: ios
create_revision: 3b62efc2a3da49882f43c372e0bc53daef7295a6
base_revision: 3b62efc2a3da49882f43c372e0bc53daef7295a6

# User provided section

# List of Local paths (relative to this file) that should be
# ignored by the migrate tool.
#
# Files that are not part of the templates will be ignored by default.
unmanaged_files:
- 'lib/main.dart'
- 'ios/Runner.xcodeproj/project.pbxproj'
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"java.configuration.updateBuildConfiguration": "interactive"
}
4 changes: 4 additions & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
include: package:flutter_lints/flutter.yaml

# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options
1 change: 1 addition & 0 deletions android/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
.DS_Store
/build
/captures
.cxx
59 changes: 44 additions & 15 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,37 +1,52 @@
group 'com.professor.zebrautility'
version '1.0'
group = "com.professor.zebrautility"
version = "1.0-SNAPSHOT"

buildscript {
ext.kotlin_version = "2.2.20"
repositories {
google()
jcenter()
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
classpath("com.android.tools.build:gradle:8.11.1")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version")
}
}

rootProject.allprojects {
allprojects {
repositories {
google()
jcenter()
mavenCentral()
}
}

apply plugin: 'com.android.library'
apply plugin: "com.android.library"
apply plugin: "kotlin-android"

android {
compileSdkVersion 29
namespace = "com.professor.zebrautility"

defaultConfig {
minSdkVersion 16
compileSdk = 36

compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
lintOptions {
disable 'InvalidPackage'

kotlinOptions {
jvmTarget = JavaVersion.VERSION_17
}

sourceSets {
// main.java.srcDirs += "src/main/kotlin"
// test.java.srcDirs += "src/test/kotlin"
main.java.srcDirs += "src/main/java"
}

defaultConfig {
minSdk = 24
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
Expand All @@ -40,7 +55,21 @@ android {
exclude 'META-INF/DEPENDENCIES'
}

}
dependencies{
compile fileTree(dir: 'libs', include: ['*.jar'])
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
testImplementation("org.jetbrains.kotlin:kotlin-test")
testImplementation("org.mockito:mockito-core:5.0.0")
}

testOptions {
unitTests.all {
useJUnitPlatform()

testLogging {
events "passed", "skipped", "failed", "standardOut", "standardError"
outputs.upToDateWhen {false}
showStandardStreams = true
}
}
}
}
5 changes: 3 additions & 2 deletions android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#Fri May 03 03:28:09 BRT 2024
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-all.zip
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip
zipStoreBase=GRADLE_USER_HOME
Binary file modified android/libs/ZSDK_ANDROID_API.jar
Binary file not shown.
Binary file added android/libs/commons-io-2.18.0.jar
Binary file not shown.
Binary file added android/libs/commons-lang3-3.17.0.jar
Binary file not shown.
Binary file removed android/libs/commons-lang3-3.4.jar
Binary file not shown.
Binary file removed android/libs/commons-net-3.1.jar
Binary file not shown.
Binary file added android/libs/commons-net-3.11.1.jar
Binary file not shown.
Binary file removed android/libs/commons-validator-1.4.0.jar
Binary file not shown.
Binary file added android/libs/commons-validator-1.9.0.jar
Binary file not shown.
Binary file not shown.
Binary file removed android/libs/httpcore-4.3.1.jar
Binary file not shown.
Binary file added android/libs/httpcore-4.4.16.jar
Binary file not shown.
Binary file removed android/libs/httpmime-4.3.2.jar
Binary file not shown.
Binary file added android/libs/httpmime-4.5.14.jar
Binary file not shown.
Binary file added android/libs/jackson-annotations-2.18.3.jar
Binary file not shown.
Binary file removed android/libs/jackson-annotations-2.2.3.jar
Binary file not shown.
Binary file added android/libs/jackson-core-2.18.3.jar
Binary file not shown.
Binary file removed android/libs/jackson-core-2.2.3.jar
Binary file not shown.
Binary file added android/libs/jackson-databind-2.18.3.jar
Binary file not shown.
Binary file removed android/libs/jackson-databind-2.2.3.jar
Binary file not shown.
Binary file removed android/libs/opencsv-2.2.jar
Binary file not shown.
Binary file added android/libs/opencsv-5.10.jar
Binary file not shown.
Binary file not shown.
Binary file removed android/libs/prov-1.53.0.0.jar
Binary file not shown.
Binary file added android/libs/prov-1.58.0.0.jar
Binary file not shown.
41 changes: 40 additions & 1 deletion android/src/main/java/com/professor/zebrautility/Printer.java
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,43 @@ private void printData(String data) {
}
}

public void printPdf(String pdfPath) {
new Thread(new Runnable() {
public void run() {
// enableTestButton(false);
Looper.prepare();
if (isZebraPrinter) {
if (printer != null) {
sendPdf(pdfPath);
} else {
disconnect();
}
}
Looper.loop();
Looper.myLooper().quit();
}
}).start();
}

private void sendPdf(String pdfPath) {
try {
// byte[] bytes = convertDataToByte(data);
setStatus(context.getString(R.string.sending_data), context.getString(R.string.connectingColor));
// ZebraPrinterLinkOs printerLinkOs = ZebraPrinterFactory.getLinkOsPrinter(printerConnection);
printer.sendFileContents(pdfPath);
// printerConnection.write(pdf);
DemoSleeper.sleep(1500);

if (printerConnection instanceof BluetoothConnection) {
DemoSleeper.sleep(500);
}
setStatus(context.getResources().getString(R.string.done), context.getString(R.string.connectedColor));
} catch (ConnectionException e) {
disconnect();
} finally {
}
}


public boolean connectToSelectPrinter(String address) {
isZebraPrinter = true;
Expand Down Expand Up @@ -604,10 +641,12 @@ private void convertBase64ImageToZPLString(String data, int rotation, MethodChan
public void onMethodCall(@NonNull final MethodCall call, @NonNull final MethodChannel.Result result) {
if (call.method.equals("print")) {
print(call.argument("Data").toString());
} else if (call.method.equals("printPdf")){
printPdf(call.argument("pdfPath"));
} else if (call.method.equals("checkPermission")) {
checkPermission(context, result);
} else if (call.method.equals("convertBase64ImageToZPLString")) {
convertBase64ImageToZPLString(call.argument("Data").toString())
convertBase64ImageToZPLString(call.argument("Data").toString()
, Integer.valueOf(call.argument("rotation").toString()), result);
} else if (call.method.equals("disconnect")) {
new Thread(new Runnable() {
Expand Down
24 changes: 22 additions & 2 deletions example/.metadata
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,27 @@
# This file should be version controlled and should not be manually edited.

version:
revision: 8af6b2f038c1172e61d418869363a28dffec3cb4
channel: stable
revision: "3b62efc2a3da49882f43c372e0bc53daef7295a6"
channel: "stable"

project_type: app

# Tracks metadata for the flutter migrate command
migration:
platforms:
- platform: root
create_revision: 3b62efc2a3da49882f43c372e0bc53daef7295a6
base_revision: 3b62efc2a3da49882f43c372e0bc53daef7295a6
- platform: android
create_revision: 3b62efc2a3da49882f43c372e0bc53daef7295a6
base_revision: 3b62efc2a3da49882f43c372e0bc53daef7295a6

# User provided section

# List of Local paths (relative to this file) that should be
# ignored by the migrate tool.
#
# Files that are not part of the templates will be ignored by default.
unmanaged_files:
- 'lib/main.dart'
- 'ios/Runner.xcodeproj/project.pbxproj'
28 changes: 28 additions & 0 deletions example/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# This file configures the analyzer, which statically analyzes Dart code to
# check for errors, warnings, and lints.
#
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
# invoked from the command line by running `flutter analyze`.

# The following line activates a set of recommended lints for Flutter apps,
# packages, and plugins designed to encourage good coding practices.
include: package:flutter_lints/flutter.yaml

linter:
# The lint rules applied to this project can be customized in the
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
# included above or to enable additional rules. A list of all available lints
# and their documentation is published at https://dart.dev/lints.
#
# Instead of disabling a lint rule for the entire project in the
# section below, it can also be suppressed for a single line of code
# or a specific dart file by using the `// ignore: name_of_lint` and
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
# producing the lint.
rules:
# avoid_print: false # Uncomment to disable the `avoid_print` rule
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule

# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options
14 changes: 14 additions & 0 deletions example/android/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
gradle-wrapper.jar
/.gradle
/captures/
/gradlew
/gradlew.bat
/local.properties
GeneratedPluginRegistrant.java
.cxx/

# Remember to never publicly share your keystore.
# See https://flutter.dev/to/reference-keystore
key.properties
**/*.keystore
**/*.jks
64 changes: 64 additions & 0 deletions example/android/app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
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")
}

android {
namespace = "com.example.zebrautility_example"
compileSdk = flutter.compileSdkVersion
ndkVersion = flutter.ndkVersion

compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

kotlinOptions {
jvmTarget = JavaVersion.VERSION_17.toString()
}

defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId = "com.example.zebrautility_example"
// You can update the following values to match your application needs.
// For more information, see: https://flutter.dev/to/review-gradle-config.
minSdk = flutter.minSdkVersion
targetSdk = flutter.targetSdkVersion
versionCode = flutter.versionCode
versionName = flutter.versionName
}

// packagingOptions {
// exclude(META-INF/LICENSE.txt);
// exclude(META-INF/NOTICE.txt);
// exclude(META-INF/NOTICE);
// exclude(META-INF/LICENSE);
// exclude(META-INF/DEPENDENCIES);
// }
packaging {
resources {
excludes += "/META-INF/LICENSE.txt"
excludes += "META-INF/NOTICE.txt"
excludes += "META-INF/NOTICE"
excludes += "META-INF/LICENSE"
excludes += "META-INF/DEPENDENCIES"
}
// jniLibs {
// pickFirsts += "**/libsomefile.so"
// }
}

buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig = signingConfigs.getByName("debug")
}
}
}

flutter {
source = "../.."
}
7 changes: 7 additions & 0 deletions example/android/app/src/debug/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<!-- The INTERNET permission is required for development. Specifically,
the Flutter tool needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
<uses-permission android:name="android.permission.INTERNET"/>
</manifest>
Loading