Skip to content

Commit

Permalink
Android端打印调整
Browse files Browse the repository at this point in the history
  • Loading branch information
JackZhang1994 committed Nov 28, 2019
1 parent afebcc0 commit 9e82340
Show file tree
Hide file tree
Showing 10 changed files with 480 additions and 381 deletions.
124 changes: 69 additions & 55 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ android {

dependencies {
// 蓝牙打印机引用的jar
implementation files('libs/DzPrinter-2017-06-16.jar')
implementation files('libs/LPAPI-2019-11-20-R.jar')

implementation 'androidx.annotation:annotation:1.1.0'
}
Binary file removed android/libs/DzPrinter-2017-06-16.jar
Binary file not shown.
Binary file added android/libs/LPAPI-2019-11-20-R.jar
Binary file not shown.
5 changes: 3 additions & 2 deletions android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
package="com.jvtd.flutter_bt_printer">

<!-- 蓝牙相关 -->
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
<uses-feature android:name="android.hardware.bluetooth_le" android:required="false"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
package com.jvtd.flutter_bt_printer;

import android.content.Context;
import android.content.SharedPreferences;

import com.dothantech.common.DzEnum;
import com.dothantech.common.DzToast;
import com.dothantech.printer.IDzPrinter;
import com.jvtd.flutter_bt_printer.utils.PrintUtil;
import com.jvtd.flutter_bt_printer.utils.LPUtil;

import io.flutter.plugin.common.MethodCall;
import io.flutter.plugin.common.MethodChannel;
Expand Down Expand Up @@ -42,22 +38,26 @@ public void onMethodCall(MethodCall call, Result result)
switch (method)
{
case "init":
// 初始化 IDzPrinter 对象(简单起见,不处理结果通知)
PrintUtil.getInstance(context).init();
LPUtil.getInstance(context).init();
result.success("success");
break;

case "print":
String assetNumber = call.argument("asset_number");
String assetName = call.argument("asset_name");
String assetModel = call.argument("asset_model");
PrintUtil.getInstance(context).print(assetNumber, assetName, assetModel);
String topTitle = call.argument("top_title");
String bottomTitle = call.argument("bottom_title");
String qrCode = call.argument("qr_code");
String label1Title = call.argument("label1_title");
String label1Value = call.argument("label1_value");
String label2Title = call.argument("label2_title");
String label2Value = call.argument("label2_value");
String label3Title = call.argument("label3_title");
String label3Value = call.argument("label3_value");
LPUtil.getInstance(context).print(topTitle, bottomTitle, qrCode, label1Title, label1Value, label2Title, label2Value, label3Title, label3Value);
result.success("success");
break;

case "quit":
// 断开蓝牙连接,释放 IDzPrinter 对象
PrintUtil.getInstance(context).quit();
LPUtil.getInstance(context).quit();
result.success("success");
break;

Expand Down
Loading

0 comments on commit 9e82340

Please sign in to comment.