Skip to content

Commit

Permalink
opt:Flutter->android->api->12960->跟新开启SDK日志的api。每条打印之后添加0A指令,12960 【r…
Browse files Browse the repository at this point in the history
…eact-native-printer】【SDK】printColumnsText打印时没有数据出来,只走纸

方案:NA
影响范围:NA
  • Loading branch information
xiehuayan committed Apr 9, 2024
1 parent 967aa21 commit 62c8d29
Show file tree
Hide file tree
Showing 9 changed files with 96 additions and 4 deletions.
3 changes: 2 additions & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,13 @@ android {
}
}
dependencies {

implementation files('libs\\iminPrinterSDK-12_V1.2.0_2404031803.jar')
testImplementation 'junit:junit:4.13.2'
testImplementation 'org.mockito:mockito-core:5.0.0'
implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
// implementation files('libs/IminLibs1.0.15.jar')
implementation files('libs/IminStraElectronicSDK_V1.2.jar')
implementation files('libs/iminPrinterSDK-10_V1.0.9_2306201823.jar')
implementation "androidx.multidex:multidex:2.0.1"
implementation 'com.github.iminsoftware:IminPrinterLibrary:V1.0.0.11'
implementation 'com.github.bumptech.glide:glide:4.16.0'
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,8 @@ public void run() {
if (call.argument("alignment") != null) {
int alignmentMode = call.argument("alignment");
if (iminPrintUtils != null) {
Log.e("IminPrinter"," printQrCode ==> "+qrStr+" "+alignmentMode);

iminPrintUtils.printQrCode(qrStr, alignmentMode);
} else {
if (call.argument("qrSize") != null && call.argument("level") != null) {
Expand Down Expand Up @@ -612,7 +614,7 @@ public void run() {
break;
case "openCashBox":
if (iminPrintUtils != null) {
// Utils.getInstance().opencashBox();
Utils.getInstance().opencashBox();
} else {
PrinterHelper.getInstance().openDrawer();
}
Expand Down Expand Up @@ -1127,6 +1129,20 @@ public void onPrintResult(int code, String msg) throws RemoteException {
}
result.success(true);
break;
case "setIsOpenLog":
if (iminPrintUtils != null){
int open = call.argument("open");
iminPrintUtils.setIsOpenLog(open);
}
result.success(true);
break;
case "sendRAWDataHexStr":
if (iminPrintUtils != null){
String open = call.argument("hex");
iminPrintUtils.sendRAWData(open);
}
result.success(true);
break;
default:
result.notImplemented();
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ public void opencashBox(){
String cmd = "echo "+open+" > /sys/class/neostra_gpioctl/dev/gpioctl " + "\n";
String model = getModel();
if(model.equals("D1") || (model.equals("D1-Pro"))
|| (model.equals("Falcon 1"))|| (model.equals("I22T01"))
|| (model.equals("Falcon 1"))|| (model.equals("I22T01")) || (model.equals("TF1-11"))
|| getPlaform().equalsIgnoreCase("ums512")){
cmd = "echo "+open+" > /sys/extcon-usb-gpio/cashbox_en " + "\n";
}/*else if(model.equals("Swan 1") || model.equals("DS1-11")){
Expand Down
39 changes: 38 additions & 1 deletion example/lib/pages/v1/home.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:imin_printer/imin_printer.dart';
Expand All @@ -7,6 +8,8 @@ import 'package:imin_printer/column_maker.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:fluttertoast/fluttertoast.dart';

import '../v2/home.dart';

class Home extends StatefulWidget {
const Home({super.key});
@override
Expand All @@ -22,6 +25,7 @@ class _HomeState extends State<Home> {
getMediaFilePermission();
}

int open = 1;
/// 获取媒体文件读写权限
Future<void> getMediaFilePermission() async {
Map<Permission, PermissionStatus> statuses =
Expand Down Expand Up @@ -89,6 +93,7 @@ class _HomeState extends State<Home> {
'iMin advocates the core values of "Integrity, Customer First, Invention&Creation, Patience”, using cloud-based technology to help businesses to get access to the Internet and also increases their data base, by providing more solutions so that their business can take a step further. Through their efficiency enhancement, cost improvement, service innovation, and better services for consumers, these aspect will drives the entire industry development.',
style: IminTextStyle(wordWrap: true));
await iminPrinter.printAndFeedPaper(100);
await iminPrinter.sendRAWDataHexStr("0A");
},
child: const Text('Text in word wrap')),
ElevatedButton(
Expand All @@ -97,6 +102,7 @@ class _HomeState extends State<Home> {
style:
IminTextStyle(align: IminPrintAlign.center));
await iminPrinter.printAndFeedPaper(100);
await iminPrinter.sendRAWDataHexStr("0A");
},
child: const Text('text alignment'))
]),
Expand All @@ -112,6 +118,7 @@ class _HomeState extends State<Home> {
await iminPrinter.printText('测试字体大小',
style: IminTextStyle(fontSize: 25));
await iminPrinter.printAndFeedPaper(100);
await iminPrinter.sendRAWDataHexStr("0A");
},
child: const Text('Text fontSize')),
ElevatedButton(
Expand All @@ -120,6 +127,7 @@ class _HomeState extends State<Home> {
style: IminTextStyle(
typeface: IminTypeface.typefaceMonospace));
await iminPrinter.printAndFeedPaper(100);
await iminPrinter.sendRAWDataHexStr("0A");
},
child: const Text('Text typeface'))
],
Expand Down Expand Up @@ -148,6 +156,7 @@ class _HomeState extends State<Home> {
// typeface: IminTypeface.typefaceDefault
fontStyle: IminFontStyle.italic));
await iminPrinter.printAndFeedPaper(100);
await iminPrinter.sendRAWDataHexStr("0A");
},
child: const Text('Text style')),
ElevatedButton(
Expand All @@ -159,7 +168,9 @@ class _HomeState extends State<Home> {
height: 50,
)
);
await iminPrinter.sendRAWDataHexStr("0A");
await iminPrinter.printAndFeedPaper(100);
await iminPrinter.sendRAWDataHexStr("0A");
},
child: const Text('print singleBitmap'))
],
Expand All @@ -178,6 +189,7 @@ class _HomeState extends State<Home> {
ElevatedButton(
onPressed: () async {
await iminPrinter.printAndFeedPaper(100);
await iminPrinter.sendRAWDataHexStr("0A");
},
child: const Text('print AndFeedPaper'))
],
Expand All @@ -193,6 +205,7 @@ class _HomeState extends State<Home> {
await iminPrinter.printText(
'测试打印字体iMin is a service provider who focuses mainly on the field of business intelligence, bringing IoT, AI and cloud service to the business sector. We develop and provide a wide range of intelligent commercial hardware solutions which help businesses to run more cost effectively.');
await iminPrinter.printAndFeedPaper(100);
await iminPrinter.sendRAWDataHexStr("0A");
},
child: const Text('print Text')),
ElevatedButton(
Expand All @@ -213,7 +226,9 @@ class _HomeState extends State<Home> {
width: 250,
height: 70,
));
await iminPrinter.sendRAWDataHexStr("0A");
await iminPrinter.printAndFeedPaper(200);
await iminPrinter.sendRAWDataHexStr("0A");
},
child: const Text('print singleBitmap in align'))
],
Expand All @@ -233,6 +248,7 @@ class _HomeState extends State<Home> {
qrSize: 4,
align: IminPrintAlign.left));
await iminPrinter.printAndFeedPaper(100);
await iminPrinter.sendRAWDataHexStr("0A");
},
child: const Text('print QrCode')),
ElevatedButton(
Expand All @@ -254,7 +270,9 @@ class _HomeState extends State<Home> {
fontSize: 26,
align: IminPrintAlign.right)
]);
await iminPrinter.sendRAWDataHexStr("0A");
await iminPrinter.printAndFeedPaper(100);
await iminPrinter.sendRAWDataHexStr("0A");
},
child: const Text('print ColumnsText'))
],
Expand All @@ -274,6 +292,7 @@ class _HomeState extends State<Home> {
align: IminPrintAlign.center,
position: IminBarcodeTextPos.textAbove));
await iminPrinter.printAndFeedPaper(100);
await iminPrinter.sendRAWDataHexStr("0A");
},
child: const Text('print barCode')),
ElevatedButton(
Expand All @@ -295,7 +314,9 @@ class _HomeState extends State<Home> {
width: 250,
height: 30,
));
await iminPrinter.printAndFeedPaper(100);
await iminPrinter.sendRAWDataHexStr("0A");
await iminPrinter.printAndFeedPaper(100);
await iminPrinter.sendRAWDataHexStr("0A");
},
child: const Text('print multiBitmap'))
],
Expand All @@ -311,6 +332,7 @@ class _HomeState extends State<Home> {
await iminPrinter.printAntiWhiteText(
'iMin is a service provider who focuses mainly on the field of business intelligence, bringing IoT, AI and cloud service to the business sector. We develop and provide a wide range of intelligent commercial hardware solutions which help businesses to run more cost effectively.');
await iminPrinter.printAndFeedPaper(100);
await iminPrinter.sendRAWDataHexStr("0A");
},
child: const Text('print antiWhiteText')),
ElevatedButton(
Expand All @@ -324,6 +346,7 @@ class _HomeState extends State<Home> {
),
doubleQRSize: 5);
await iminPrinter.printAndFeedPaper(100);
await iminPrinter.sendRAWDataHexStr("0A");
},
child: const Text('print DoubleQR'))
]),
Expand All @@ -345,6 +368,20 @@ class _HomeState extends State<Home> {
child: const Text('opencashBox'))
]),
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
ElevatedButton(
onPressed: () async {
open = (open==1?0:1);
await iminPrinter.openLogs(open==1?1:0);
},
child: const Text('openLogs')),

]),
),
],
)),
),
Expand Down
16 changes: 16 additions & 0 deletions lib/imin_printer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -706,4 +706,20 @@ class IminPrinter {
Future<void> setPrinterEncode(int encode) {
return IminPrinterPlatform.instance.setPrinterEncode(encode);
}

/// print partial cut in your printer
///
/// {@tool snippet}
///
/// ```dart
/// iminPrinter.openLogs()
/// ```
/// {@end-tool}
Future<void> openLogs(int open) {
return IminPrinterPlatform.instance.openLogs(open);
}

Future<void> sendRAWDataHexStr(String hex) {
return IminPrinterPlatform.instance.sendRAWDataHexStr(hex);
}
}
12 changes: 12 additions & 0 deletions lib/imin_printer_method_channel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -843,4 +843,16 @@ class MethodChannelIminPrinter extends IminPrinterPlatform {
return await methodChannel
.invokeMethod<List<String>>('getPrinterPaperTypeList');
}

@override
Future<void> openLogs(int encode) async {
Map<String, dynamic> arguments = <String, dynamic>{"open": encode};
await methodChannel.invokeMethod<void>('setIsOpenLog', arguments);
}

@override
Future<void> sendRAWDataHexStr(String hex) async {
Map<String, dynamic> arguments = <String, dynamic>{"hex": hex};
await methodChannel.invokeMethod<void>('sendRAWDataHexStr', arguments);
}
}
6 changes: 6 additions & 0 deletions lib/imin_printer_platform_interface.dart
Original file line number Diff line number Diff line change
Expand Up @@ -407,4 +407,10 @@ abstract class IminPrinterPlatform extends PlatformInterface {
Future<void> setPrinterEncode(int encode) {
throw UnimplementedError('setPrinterEncode() has not been implemented.');
}
Future<void> openLogs(int encode) {
throw UnimplementedError('setPrinterEncode() has not been implemented.');
}
Future<void> sendRAWDataHexStr(String bytes) {
throw UnimplementedError('sendRAWData() has not been implemented.');
}
}
4 changes: 4 additions & 0 deletions test/imin_printer_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,10 @@ class MockIminPrinterPlatform
Future<int?> getPrinterSpeed() => Future.value();
@override
Future<List<String>?> getPrinterPaperTypeList() => Future.value();
@override
Future<int?> openLogs(int encode) => Future.value();
@override
Future<List<String>?> sendRAWDataHexStr(String hex) => Future.value();
}

void main() {
Expand Down

0 comments on commit 62c8d29

Please sign in to comment.