Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Android 12 support, fix com.sunmi:sunmiui:latest.release download http 401 error #19

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
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
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ Plugin based on https://github.com/labibramadhan/cordova-sunmi-inner-printer

### Changes as follows:

#### Changelog May 27, 2023

1. Add `framework directive` into `plugin.xml` to automatically add `"com.sunmi:printerlibrary:latest.release"` into gradle.

2. Add android:exported in Manifest to support Android 12

3. Update version to `1.1.2`

#### Changelog Aug 11, 2019

1. Add `framework directive` into `plugin.xml` to automatically add `"com.sunmi:sunmiui:latest.release"` into gradle.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@
}
}
},
"version": "1.1.1",
"version": "1.1.3",
"publishConfig": { "registry": "https://npm.pkg.github.com/" }
}
6 changes: 3 additions & 3 deletions plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
</js-module>
<platform name="android">
<preference name="ANDROID_SUPPORT_V13_VERSION" default="27.+"/>
<framework src="com.sunmi:sunmiui:latest.release"/>
<framework src="com.sunmi:printerlibrary:latest.release"/>
<config-file target="res/xml/config.xml" parent="/*">
<feature name="Printer">
<param name="android-package" value="com.sunmi.innerprinter.Printer"/>
<param name="onload" value="true" />
</feature>
</config-file>
<config-file target="AndroidManifest.xml" parent="/manifest/application">
<receiver android:name="com.sunmi.innerprinter.PrinterStatusReceiver" android:enabled="true">
<receiver android:exported="true" android:name="com.sunmi.innerprinter.PrinterStatusReceiver" android:enabled="true">
<intent-filter android:priority="1000">
<action android:name="woyou.aidlservice.jiuv5.OUT_OF_PAPER_ACTION" />
<action android:name="woyou.aidlservice.jiuv5.ERROR_ACTION" />
Expand All @@ -33,7 +33,7 @@
<action android:name="woyou.aidlservice.jiuv5.FIRMWARE_UPDATING_ACITON" />
</intent-filter>
</receiver>
<service android:name="woyou.aidlservice.jiuiv5.IWoyouService">
<service android:exported="true" android:name="woyou.aidlservice.jiuiv5.IWoyouService">
<intent-filter>
<action android:name="woyou.aidlservice.jiuiv5.IWoyouService" />
</intent-filter>
Expand Down
180 changes: 121 additions & 59 deletions www/innerprinter.js
Original file line number Diff line number Diff line change
@@ -1,66 +1,128 @@
exec = require('cordova/exec');
exec = require("cordova/exec");

module.exports = {

printerInit: function (resolve, reject) {
exec(resolve, reject, "Printer", "printerInit", []);
},
printerSelfChecking: function (resolve, reject) {
exec(resolve, reject, "Printer", "printerSelfChecking", []);
},
getPrinterSerialNo: function (resolve, reject) {
exec(resolve, reject, "Printer", "getPrinterSerialNo", []);
},
getPrinterVersion: function (resolve, reject) {
exec(resolve, reject, "Printer", "getPrinterVersion", []);
},
hasPrinter: function (resolve, reject) {
exec(resolve, reject, "Printer", "hasPrinter", []);
},
getPrintedLength: function (resolve, reject) {
exec(resolve, reject, "Printer", "getPrintedLength", []);
},
lineWrap: function (count, resolve, reject) {
exec(resolve, reject, "Printer", "lineWrap", [count]);
},
sendRAWData: function (base64Data, resolve, reject) {
exec(resolve, reject, "Printer", "sendRAWData", [base64Data]);
},
setAlignment: function (alignment, resolve, reject) {
exec(resolve, reject, "Printer", "setAlignment", [alignment]);
},
setFontName: function (typeface, resolve, reject) {
exec(resolve, reject, "Printer", "setFontName", [typeface]);
},
setFontSize: function (fontSize, resolve, reject) {
exec(resolve, reject, "Printer", "setFontSize", [fontSize]);
},
printTextWithFont: function (text, typeface, fontSize, resolve, reject) {
exec(resolve, reject, "Printer", "printTextWithFont", [text, typeface, fontSize]);
},
printColumnsText: function (colsTextArr, colsWidthArr, colsAlign, resolve, reject) {
exec(resolve, reject, "Printer", "printColumnsText", [colsTextArr, colsWidthArr, colsAlign]);
},
printBitmap: function (base64Data, width, height, resolve, reject) {
exec(resolve, reject, "Printer", "printBitmap", [base64Data, width, height]);
},
printBarCode: function (barCodeData, symbology, width, height, textPosition, resolve, reject) {
exec(resolve, reject, "Printer", "printBarCode", [barCodeData, symbology, width, height, textPosition]);
},
printQRCode: function (qrCodeData, moduleSize, errorLevel, resolve, reject) {
exec(resolve, reject, "Printer", "printQRCode", [qrCodeData, moduleSize, errorLevel]);
},
printOriginalText: function (text, resolve, reject) {
exec(resolve, reject, "Printer", "printOriginalText", [text]);
},
printString: function (text, resolve, reject) {
exec(resolve, reject, "Printer", "printString", [text]);
printerInit: function () {
return new Promise(function (resolve, reject) {
exec(resolve, reject, "Printer", "printerInit", []);
});
},
printerSelfChecking: function () {
return new Promise(function (resolve, reject) {
exec(resolve, reject, "Printer", "printerSelfChecking", []);
});
},
getPrinterSerialNo: function () {
return new Promise(function (resolve, reject) {
exec(resolve, reject, "Printer", "getPrinterSerialNo", []);
});
},
getPrinterVersion: function () {
return new Promise(function (resolve, reject) {
exec(resolve, reject, "Printer", "getPrinterVersion", []);
});
},
hasPrinter: function () {
return new Promise(function (resolve, reject) {
exec(resolve, reject, "Printer", "hasPrinter", []);
});
},
getPrintedLength: function () {
return new Promise(function (resolve, reject) {
exec(resolve, reject, "Printer", "getPrintedLength", []);
});
},
lineWrap: function (count) {
return new Promise(function (resolve, reject) {
exec(resolve, reject, "Printer", "lineWrap", [count]);
});
},
sendRAWData: function (base64Data) {
return new Promise(function (resolve, reject) {
exec(resolve, reject, "Printer", "sendRAWData", [base64Data]);
});
},
setAlignment: function (alignment) {
return new Promise(function (resolve, reject) {
exec(resolve, reject, "Printer", "setAlignment", [alignment]);
});
},
setFontName: function (typeface) {
return new Promise(function (resolve, reject) {
exec(resolve, reject, "Printer", "setFontName", [typeface]);
});
},
setFontSize: function (fontSize) {
return new Promise(function (resolve, reject) {
exec(resolve, reject, "Printer", "setFontSize", [fontSize]);
});
},
printTextWithFont: function (text, typeface, fontSize) {
return new Promise(function (resolve, reject) {
exec(resolve, reject, "Printer", "printTextWithFont", [
text,
typeface,
fontSize,
]);
});
},
printColumnsText: function (colsTextArr, colsWidthArr, colsAlign) {
return new Promise(function (resolve, reject) {
exec(resolve, reject, "Printer", "printColumnsText", [
colsTextArr,
colsWidthArr,
colsAlign,
]);
});
},
printBitmap: function (base64Data, width, height) {
return new Promise(function (resolve, reject) {
exec(resolve, reject, "Printer", "printBitmap", [
base64Data,
width,
height,
]);
});
},
printBarCode: function (barCodeData, symbology, width, height, textPosition) {
return new Promise(function (resolve, reject) {
exec(resolve, reject, "Printer", "printBarCode", [
barCodeData,
symbology,
width,
height,
textPosition,
]);
});
},
printQRCode: function (qrCodeData, moduleSize, errorLevel) {
return new Promise(function (resolve, reject) {
exec(resolve, reject, "Printer", "printQRCode", [
qrCodeData,
moduleSize,
errorLevel,
]);
});
},
printOriginalText: function (text) {
return new Promise(function (resolve, reject) {
exec(resolve, reject, "Printer", "printOriginalText", [text]);
});
},
printString: function (text) {
return new Promise(function (resolve, reject) {
exec(resolve, reject, "Printer", "printString", [text]);
});
},
printerStatusStartListener: function (onSuccess, onError) {
exec(onSuccess, onError, "Printer", "printerStatusStartListener", []);
},
printerStatusStopListener: function () {
exec(function () {}, function () {}, "Printer", "printerStatusStopListener", []);
}

}
exec(
function () {},
function () {},
"Printer",
"printerStatusStopListener",
[]
);
},
};