Browse Source

add Printer SDK success ; write&test UniPlugin_PrinterPad v1 success

dev
赵明涛 1 year ago
parent
commit
04f5b40856
  1. 1
      app/build.gradle
  2. 10
      app/src/main/assets/dcloud_uniplugins.json
  3. 3
      settings.gradle
  4. 1
      uniplugin_padprinter/.gitignore
  5. 44
      uniplugin_padprinter/build.gradle
  6. 0
      uniplugin_padprinter/consumer-rules.pro
  7. BIN
      uniplugin_padprinter/libs/printersdkv5.7.2.jar
  8. 21
      uniplugin_padprinter/proguard-rules.pro
  9. 26
      uniplugin_padprinter/src/androidTest/java/net/zmt/padprinter/ExampleInstrumentedTest.java
  10. 5
      uniplugin_padprinter/src/main/AndroidManifest.xml
  11. 241
      uniplugin_padprinter/src/main/java/net/zmt/padprinter/Helper/Printer_Helper.java
  12. 113
      uniplugin_padprinter/src/main/java/net/zmt/padprinter/Helper/UsbDeviceList.java
  13. 483
      uniplugin_padprinter/src/main/java/net/zmt/padprinter/Helper/XTUtils.java
  14. 96
      uniplugin_padprinter/src/main/java/net/zmt/padprinter/UniPluginPadPrinter.java
  15. 28
      uniplugin_padprinter/src/main/java/net/zmt/padprinter/UniPluginPadPrinter_AppProxy.java
  16. 37
      uniplugin_padprinter/src/main/java/net/zmt/padprinter/global/GlobalContants.java
  17. BIN
      uniplugin_padprinter/src/main/res/drawable/test.jpg
  18. 24
      uniplugin_padprinter/src/main/res/layout/device_item.xml
  19. 32
      uniplugin_padprinter/src/main/res/layout/device_list.xml
  20. 371
      uniplugin_padprinter/src/main/res/values/strings.xml
  21. 17
      uniplugin_padprinter/src/test/java/net/zmt/padprinter/ExampleUnitTest.java

1
app/build.gradle

@ -102,6 +102,7 @@ dependencies {
implementation project(':uniplugin_component')
implementation project(':uniplugin_module')
implementation project(':uniplugin_richalert')
implementation project(':uniplugin_padprinter') //Pad Printer
// implementation project(':uniplugin_v4_ph')
// implementation project(':daemonlibrary')

10
app/src/main/assets/dcloud_uniplugins.json

@ -57,6 +57,16 @@
"class": "com.shihoo.daemon.Daemon_Uni"
}
]
},
{
"hooksClass": "net.zmt.padprinter.UniPluginPadPrinter_AppProxy",
"plugins": [
{
"type": "module",
"name": "OX_Pad_Printer",
"class": "net.zmt.padprinter.UniPluginPadPrinter"
}
]
}
]
}

3
settings.gradle

@ -5,4 +5,5 @@ include ':uniplugin_richalert'
//include ':uniplugin_v4_ph'
//include ':daemonlibrary'
//include ':uniplugin_module_nanohttpd'
//include ':uniplugin_module_nanohttpd'
include ':uniplugin_padprinter'

1
uniplugin_padprinter/.gitignore

@ -0,0 +1 @@
/build

44
uniplugin_padprinter/build.gradle

@ -0,0 +1,44 @@
//plugins {
// id 'com.android.library'
//}
apply plugin: 'com.android.library'
android {
compileSdkVersion 33
buildToolsVersion "33.0.1"
defaultConfig {
minSdkVersion 21
targetSdkVersion 33
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
// implementation 'androidx.appcompat:appcompat:1.2.0'
// implementation 'com.google.android.material:material:1.2.1'
// testImplementation 'junit:junit:4.+'
// androidTestImplementation 'androidx.test.ext:junit:1.1.2'
// androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation fileTree(dir: '../app/libs', include: ['uniapp-v8-release.aar'])
// compileOnly 'com.alibaba:fastjson:1.1.46.android'
compileOnly 'com.alibaba:fastjson:1.2.83' //uni离线SDK升级后升级
implementation files('libs\\printersdkv5.7.2.jar')
}

0
uniplugin_padprinter/consumer-rules.pro

BIN
uniplugin_padprinter/libs/printersdkv5.7.2.jar

21
uniplugin_padprinter/proguard-rules.pro

@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile

26
uniplugin_padprinter/src/androidTest/java/net/zmt/padprinter/ExampleInstrumentedTest.java

@ -0,0 +1,26 @@
package net.zmt.padprinter;
import android.content.Context;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("net.zmt.padprinter.test", appContext.getPackageName());
}
}

5
uniplugin_padprinter/src/main/AndroidManifest.xml

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="net.zmt.padprinter">
</manifest>

241
uniplugin_padprinter/src/main/java/net/zmt/padprinter/Helper/Printer_Helper.java

@ -0,0 +1,241 @@
package net.zmt.padprinter.Helper;
import android.annotation.SuppressLint;
import android.app.Application;
import android.app.PendingIntent;
import android.app.ProgressDialog;
import android.bluetooth.BluetoothDevice;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.Resources;
import android.hardware.usb.UsbDevice;
import android.hardware.usb.UsbManager;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.widget.Toast;
import com.printer.sdk.PrinterConstants;
import com.printer.sdk.PrinterInstance;
import com.printer.sdk.PrinterConstants.Command;
import com.printer.sdk.PrinterConstants.Connect;
import com.printer.sdk.usb.USBPort;
import com.printer.sdk.utils.PrefUtils;
import com.printer.sdk.utils.XLog;
import net.zmt.padprinter.R;
import net.zmt.padprinter.global.GlobalContants;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
public class Printer_Helper {
private static final String TAG = "Printer_Helper";
// PrinterInstance mPrinter;
private static PrinterInstance myPrinter;
private List<UsbDevice> deviceList;
private static UsbDevice mUSBDevice;
public static String devicesName = "未知设备";
private static String devicesAddress;
public static boolean isConnected = false;// 蓝牙连接状态
private int interfaceType = 0;
private int printerId = 0;
private IntentFilter bluDisconnectFilter;
private static boolean hasRegDisconnectReceiver = false;
private static BluetoothDevice mDevice;
private ProgressDialog dialog;
private static final String ACTION_USB_PERMISSION = "com.android.usb.USB_PERMISSION";
private Context mContext;
public Printer_Helper(Context context){
myPrinter = PrinterInstance.mPrinter;
this.mContext = context;
}
public Printer_Helper(Application application){
myPrinter = PrinterInstance.mPrinter;
this.mContext = application.getApplicationContext();
}
public void TestPrinter(Application application){
Log.d(TAG, "TestPrinter: 1");
UsbManager manager = (UsbManager) application.getSystemService(application.USB_SERVICE);
Log.d(TAG, "TestPrinter: 2"+manager.getDeviceList().toString());
myPrinter = PrinterInstance.mPrinter;
usbAutoConn(manager);
if (myPrinter.equals(null)){
Log.d(TAG, "TestPrinter: null");
myPrinter = PrinterInstance.mPrinter;
}else{
Log.d(TAG, "TestPrinter: not null---"+myPrinter.toString());
}
Log.d(TAG, "TestPrinter: "+myPrinter.getCharsetName());
Log.d(TAG, "TestPrinter_getCurrentStatus: "+myPrinter.getCurrentStatus());
new Thread(new Runnable() {
public void run() {
// this.getResources()
XTUtils.printNote(application.getResources(), myPrinter);
}
}).start();
}
@SuppressLint({"InlinedApi", "NewApi", "WrongConstant"})
public void usbAutoConn(UsbManager manager) {
// Context mContext = context;
// PrinterInstance myPrinter = mPrinter;
doDiscovery(manager);
if (deviceList.isEmpty()) {
Toast.makeText(mContext, R.string.no_connected, 0).show();
return;
}
mUSBDevice = deviceList.get(0);
if (mUSBDevice == null) {//处理连接失败
// mHandler.obtainMessage(PrinterConstants.Connect.FAILED).sendToTarget();
return;
}
myPrinter = PrinterInstance.getPrinterInstance(mContext, mUSBDevice, mHandler);
devicesName = mUSBDevice.getDeviceName();
devicesAddress = "vid: " + mUSBDevice.getVendorId() + " pid: " + mUSBDevice.getProductId();
UsbManager mUsbManager = (UsbManager) mContext.getSystemService(Context.USB_SERVICE);
if (mUsbManager.hasPermission(mUSBDevice)) {
myPrinter.openConnection();
} else {
// 没有权限询问用户是否授予权限
PendingIntent pendingIntent = PendingIntent.getBroadcast(mContext, 0, new Intent(ACTION_USB_PERMISSION), 0);
IntentFilter filter = new IntentFilter(ACTION_USB_PERMISSION);
filter.addAction(UsbManager.ACTION_USB_DEVICE_ATTACHED);
filter.addAction(UsbManager.ACTION_USB_DEVICE_DETACHED);
mContext.registerReceiver(mUsbReceiver, filter);
mUsbManager.requestPermission(mUSBDevice, pendingIntent); // 该代码执行后系统弹出一个对话框
}
}
private final BroadcastReceiver mUsbReceiver = new BroadcastReceiver() {
// Context mContext = context;
// PrinterInstance myPrinter = mPrinter;
@SuppressLint("NewApi")
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
Log.w(TAG, "receiver action: " + action);
if (ACTION_USB_PERMISSION.equals(action)) {
synchronized (this) {
mContext.unregisterReceiver(mUsbReceiver);
UsbDevice device = (UsbDevice) intent.getParcelableExtra(UsbManager.EXTRA_DEVICE);
if (intent.getBooleanExtra(UsbManager.EXTRA_PERMISSION_GRANTED, false)
&& mUSBDevice.equals(device)) {
myPrinter.openConnection();
} else {
// mHandler.obtainMessage(PrinterConstants.Connect.FAILED).sendToTarget();
Log.e(TAG, "permission denied for device " + device);
}
}
}
}
};
@SuppressLint("NewApi")
private void doDiscovery(UsbManager manager) {
HashMap<String, UsbDevice> devices = manager.getDeviceList();
deviceList = new ArrayList<UsbDevice>();
for (UsbDevice device : devices.values()) {
if (USBPort.isUsbPrinter(device)) {
deviceList.add(device);
}
}
}
// 用于接受连接状态消息的 Handler
private Handler mHandler = new Handler() {
@SuppressLint("ShowToast")
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
case Connect.SUCCESS:
isConnected = true;
GlobalContants.ISCONNECTED = isConnected;
GlobalContants.DEVICENAME = devicesName;
if (interfaceType == 0) {
PrefUtils.setString(mContext, GlobalContants.DEVICEADDRESS, devicesAddress);
bluDisconnectFilter = new IntentFilter();
bluDisconnectFilter.addAction(BluetoothDevice.ACTION_ACL_DISCONNECTED);
mContext.registerReceiver(myReceiver, bluDisconnectFilter);
hasRegDisconnectReceiver = true;
}
// TOTO 暂时将TSPL指令设置参数的设置放在这
// if (setPrinterTSPL(myPrinter)) {
// if (interfaceType == 0) {
// Toast.makeText(mContext,
// R.string.settingactivitty_toast_bluetooth_set_tspl_successful,
// 0)
// .show();
// } else if (interfaceType == 1) {
// Toast.makeText(mContext,
// R.string.settingactivity_toast_usb_set_tspl_succefful,
// 0).show();
// }
// }
break;
case Connect.FAILED:
isConnected = false;
Toast.makeText(mContext, R.string.conn_failed, Toast.LENGTH_SHORT).show();
XLog.i(TAG, "ZL at SettingActivity Handler() 连接失败!");
break;
case Connect.CLOSED:
isConnected = false;
GlobalContants.ISCONNECTED = isConnected;
GlobalContants.DEVICENAME = devicesName;
Toast.makeText(mContext, R.string.conn_closed, Toast.LENGTH_SHORT).show();
XLog.i(TAG, "ZL at SettingActivity Handler() 连接关闭!");
break;
case Connect.NODEVICE:
isConnected = false;
Toast.makeText(mContext, R.string.conn_no, Toast.LENGTH_SHORT).show();
break;
// case 10:
// if (setPrinterTSPL(myPrinter)) {
// Toast.makeText(mContext, "蓝牙连接设置TSPL指令成功", 0).show();
// }
default:
break;
}
// updateButtonState(isConnected);
if (dialog != null && dialog.isShowing()) {
dialog.dismiss();
}
}
};
int count = 0;
public BroadcastReceiver myReceiver = new BroadcastReceiver() {
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
if (action.equals(BluetoothDevice.ACTION_ACL_DISCONNECTED)) {
if (device != null && myPrinter != null && isConnected && device.equals(mDevice)) {
myPrinter.closeConnection();
mHandler.obtainMessage(Connect.CLOSED).sendToTarget();
}
}
}
};
}

113
uniplugin_padprinter/src/main/java/net/zmt/padprinter/Helper/UsbDeviceList.java

@ -0,0 +1,113 @@
package net.zmt.padprinter.Helper;
import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.hardware.usb.UsbDevice;
import android.hardware.usb.UsbManager;
import android.os.Build;
import android.os.Bundle;
//import android.support.annotation.RequiresApi;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;
import com.printer.sdk.usb.USBPort;
import net.zmt.padprinter.R;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
/**
* This Activity appears as a dialog. It lists any paired devices and devices
* detected in the area after discovery. When a device is chosen by the user,
* the MAC address of the device is sent back to the parent Activity in the
* result Intent.
*
* @param <V>
*/
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR1)
public class UsbDeviceList<V> extends Activity {
private ArrayAdapter<String> deviceArrayAdapter;
private ListView mFoundDevicesListView;
private Button scanButton;
private Button backButton;
private List<UsbDevice> deviceList;
// @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
setContentView(R.layout.device_list);
setTitle(R.string.select_device);
setResult(Activity.RESULT_CANCELED);
// scanButton = (Button) findViewById(R.id.button_scan);
scanButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
doDiscovery();
}
});
backButton= (Button) findViewById(R.id.button_bace);
backButton.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v)
{
finish();
}
});
deviceArrayAdapter = new ArrayAdapter<String>(this,
R.layout.device_item);
mFoundDevicesListView = (ListView) findViewById(R.id.paired_devices);
mFoundDevicesListView.setAdapter(deviceArrayAdapter);
mFoundDevicesListView.setOnItemClickListener(mDeviceClickListener);
doDiscovery();
}
// @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
private void doDiscovery() {
deviceArrayAdapter.clear();
UsbManager manager = (UsbManager) getSystemService(Context.USB_SERVICE);
HashMap<String, UsbDevice> devices = manager.getDeviceList();
deviceList = new ArrayList<UsbDevice>();
for (UsbDevice device : devices.values()) {
if (USBPort.isUsbPrinter(device)) {
deviceArrayAdapter.add(device.getDeviceName() + "\nvid: "
+ device.getVendorId() + " pid: "
+ device.getProductId() + "\n" + device.getProductName());
deviceList.add(device);
}
}
}
private void returnToPreviousActivity(UsbDevice device) {
Intent intent = new Intent();
Bundle bundle = new Bundle();
bundle.putParcelable(UsbManager.EXTRA_DEVICE, device);
intent.putExtras(bundle);
setResult(Activity.RESULT_OK, intent);
finish();
}
private OnItemClickListener mDeviceClickListener = new OnItemClickListener() {
public void onItemClick(AdapterView<?> av, View v, int position, long id) {
returnToPreviousActivity(deviceList.get(position));
}
};
}

483
uniplugin_padprinter/src/main/java/net/zmt/padprinter/Helper/XTUtils.java

@ -0,0 +1,483 @@
package net.zmt.padprinter.Helper;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.Resources;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.util.Log;
//import com.printer.demo.R;
import com.printer.sdk.PrinterConstants;
import com.printer.sdk.PrinterConstants.Command;
import com.printer.sdk.PrinterInstance;
import com.printer.sdk.Table;
import net.zmt.padprinter.R;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.net.Inet4Address;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.util.Enumeration;
@SuppressLint("DefaultLocale")
public class XTUtils {
private static final String TAG = "XUtils";
public static byte[] string2bytes(String content) {
Log.i(TAG, "" + content);
try {
content = new String(content.getBytes("gbk"));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
char[] charArray = content.toCharArray();
byte[] tempByte = new byte[512];
tempByte[0] = 0x34;
int count = 0;
for (int i = 0; i < charArray.length; i++) {
if (charArray[i] == 'x' || charArray[i] == 'X') {
tempByte[count++] = (byte) (char2Int(charArray[i + 1]) * 16 + char2Int(charArray[i + 2]));
}
}
Log.i(TAG, "---------------");
byte[] retByte = new byte[count];
System.arraycopy(tempByte, 0, retByte, 0, count);
for (int i = 0; i < retByte.length; i++) {
Log.i(TAG, retByte[i] + "");
}
return tempByte;
}
private static int char2Int(char data) {
if (data >= 48 && data <= 57)// 0~9
data -= 48;
else if (data >= 65 && data <= 70)// A~F
data -= 55;
else if (data >= 97 && data <= 102)// a~f
data -= 87;
return Integer.valueOf(data);
}
/**
*
* @Description: TODO
* @param
* @return String
*/
public static String bytesToHexString(byte[] src, int datalength) {
StringBuilder stringBuilder = new StringBuilder("");
if (src == null || src.length <= 0) {
return null;
}
for (int i = 0; i < datalength; i++) {
int v = src[i] & 0xFF;
String hv = Integer.toHexString(v);
if (hv.length() < 2) {
stringBuilder.append(0);
}
stringBuilder.append("0x").append(hv).append(" ");
}
stringBuilder.append("0x0a 0x0d");
return stringBuilder.toString();
}
/**
* 字符串转换为16进制字符串
*
* @param s
* @return
*/
public static String stringToHexString(String s) {
String str = "";
for (int i = 0; i < s.length(); i++) {
int ch = (int) s.charAt(i);
String s4 = Integer.toHexString(ch);
str = str + s4;
}
return str;
}
/**
*
*
* 16进制字符串转换为字符串
*
* @param s
* @return
*
*/
public static String hexStringToString(String s) {
if (s == null || s.equals("")) {
return null;
}
s = s.replace(" ", "");
byte[] baKeyword = new byte[s.length() / 4];
for (int i = 0; i < baKeyword.length; i++) {
try {
baKeyword[i] = (byte) (0xff & Integer.parseInt(s.substring(i * 4, i * 4 + 4).substring(2, 4), 16));
} catch (Exception e) {
e.printStackTrace();
}
}
try {
s = new String(baKeyword, "gbk");
new String();
} catch (Exception e1) {
e1.printStackTrace();
}
return s;
}
public synchronized static void printNote(Resources resources, PrinterInstance mPrinter) {
mPrinter.initPrinter();
mPrinter.setFont(0, 0, 0, 0, 0);
mPrinter.setPrinter(Command.ALIGN, Command.ALIGN_LEFT);
mPrinter.printText(resources.getString(R.string.str_note));
mPrinter.setPrinter(Command.PRINT_AND_WAKE_PAPER_BY_LINE, 2);
StringBuffer sb = new StringBuffer();
mPrinter.setPrinter(Command.ALIGN, Command.ALIGN_CENTER);
mPrinter.setFont(0, 1, 1, 0, 0);
mPrinter.printText(resources.getString(R.string.shop_company_title) + "\n");
mPrinter.setPrinter(Command.ALIGN, Command.ALIGN_LEFT);
// 字号使用默认
mPrinter.setFont(0, 0, 0, 0, 0);
sb.append(resources.getString(R.string.shop_num) + "574001\n");
sb.append(resources.getString(R.string.shop_receipt_num) + "S00003169\n");
sb.append(resources.getString(R.string.shop_cashier_num) + "s004_s004\n");
sb.append(resources.getString(R.string.shop_receipt_date) + "2012-06-17\n");
sb.append(resources.getString(R.string.shop_print_time) + "2012-06-17 13:37:24\n");
mPrinter.printText(sb.toString()); // 打印
printTable1(resources, mPrinter); // 打印表格
sb = new StringBuffer();
if (PrinterConstants.paperWidth == 384) {
sb.append(resources.getString(R.string.shop_goods_number) + " 6.00\n");
sb.append(resources.getString(R.string.shop_goods_total_price) + " 35.00\n");
sb.append(resources.getString(R.string.shop_payment) + " 100.00\n");
sb.append(resources.getString(R.string.shop_change) + " 65.00\n");
} else if (PrinterConstants.paperWidth == 576) {
sb.append(resources.getString(R.string.shop_goods_number) + " 6.00\n");
sb.append(resources.getString(R.string.shop_goods_total_price) + " 35.00\n");
sb.append(resources.getString(R.string.shop_payment) + " 100.00\n");
sb.append(resources.getString(R.string.shop_change) + " 65.00\n");
} else if (PrinterConstants.paperWidth == 724) {
sb.append(resources.getString(R.string.shop_goods_number)
+ " 6.00\n");
sb.append(resources.getString(R.string.shop_goods_total_price)
+ " 35.00\n");
sb.append(resources.getString(R.string.shop_payment)
+ " 100.00\n");
sb.append(
resources.getString(R.string.shop_change) + " 65.00\n");
}
sb.append(resources.getString(R.string.shop_company_name) + "\n");
sb.append(resources.getString(R.string.shop_company_site) + "www.jiangsuxxxx.com\n");
sb.append(resources.getString(R.string.shop_company_address) + "\n");
sb.append(resources.getString(R.string.shop_company_tel) + "0574-12345678\n");
sb.append(resources.getString(R.string.shop_Service_Line) + "4008-123-456 \n");
if (PrinterConstants.paperWidth == 384) {
sb.append("==============================\n");
} else if (PrinterConstants.paperWidth == 576) {
sb.append("==============================================\n");
} else if (PrinterConstants.paperWidth == 724) {
sb.append("================================================================\n");
}
mPrinter.printText(sb.toString());
mPrinter.setPrinter(Command.ALIGN, Command.ALIGN_CENTER);
mPrinter.setFont(0, 0, 1, 0, 0);
mPrinter.printText(resources.getString(R.string.shop_thanks) + "\n");
mPrinter.printText(resources.getString(R.string.shop_demo) + "\n\n\n");
mPrinter.setFont(0, 0, 0, 0, 0);
mPrinter.setPrinter(Command.ALIGN, Command.ALIGN_LEFT);
mPrinter.setPrinter(Command.PRINT_AND_WAKE_PAPER_BY_LINE, 3);
}
public static void printTable1(Resources resources, PrinterInstance mPrinter) {
String column = resources.getString(R.string.note_title);
Table table = null;
if (PrinterConstants.paperWidth == 384) {
table = new Table(column, ";", new int[] { 14, 6, 6, 6 });
} else if (PrinterConstants.paperWidth == 576) {
table = new Table(column, ";", new int[] { 18, 10, 10, 12 });
} else if (PrinterConstants.paperWidth == 724) {
table = new Table(column, ";", new int[] { 22, 14, 14, 18 });
}
table.addRow("" + resources.getString(R.string.bags) + ";10.00;1;10.00");
table.addRow("" + resources.getString(R.string.hook) + ";5.00;2;10.00");
table.addRow("" + resources.getString(R.string.umbrella) + ";5.00;3;15.00");
mPrinter.printTable(table);
}
public static synchronized void printTest(Resources resources, PrinterInstance mPrinter) {
mPrinter.initPrinter();
mPrinter.printText(resources.getString(R.string.str_text));
mPrinter.setPrinter(Command.PRINT_AND_WAKE_PAPER_BY_LINE, 2);
mPrinter.setFont(0, 0, 0, 0, 0);
mPrinter.setPrinter(Command.ALIGN, 0);
mPrinter.printText(resources.getString(R.string.str_text_left));
mPrinter.setPrinter(Command.PRINT_AND_WAKE_PAPER_BY_LINE, 2);// 2
mPrinter.setPrinter(Command.ALIGN, 1);
mPrinter.printText(resources.getString(R.string.str_text_center));
mPrinter.setPrinter(Command.PRINT_AND_WAKE_PAPER_BY_LINE, 2);// 2
mPrinter.setPrinter(Command.ALIGN, 2);
mPrinter.printText(resources.getString(R.string.str_text_right));
mPrinter.setPrinter(Command.PRINT_AND_WAKE_PAPER_BY_LINE, 3); // 3
mPrinter.setPrinter(Command.ALIGN, 0);
mPrinter.setFont(0, 0, 0, 1, 0);
mPrinter.printText(resources.getString(R.string.str_text_strong));
mPrinter.setPrinter(Command.PRINT_AND_WAKE_PAPER_BY_LINE, 2); // 2
mPrinter.setFont(0, 0, 0, 0, 1);
mPrinter.sendBytesData(new byte[] { (byte) 0x1C, (byte) 0x21, (byte) 0x80 });
mPrinter.printText(resources.getString(R.string.str_text_underline));
mPrinter.sendBytesData(new byte[] { (byte) 0x1C, (byte) 0x21, (byte) 0x00 });
mPrinter.setPrinter(Command.PRINT_AND_WAKE_PAPER_BY_LINE, 2); // 2
mPrinter.setFont(0, 0, 0, 0, 0);
mPrinter.printText(resources.getString(R.string.str_text_height));
for (int i = 0; i < 4; i++) {
mPrinter.setFont(0, i, i, 0, 0);
mPrinter.printText((i + 1) + resources.getString(R.string.times));
}
mPrinter.setPrinter(Command.PRINT_AND_WAKE_PAPER_BY_LINE, 1);
mPrinter.setPrinter(Command.PRINT_AND_WAKE_PAPER_BY_LINE, 3);
for (int i = 0; i < 4; i++) {
mPrinter.setFont(0, i, i, 0, 0);
mPrinter.printText(resources.getString(R.string.bigger) + (i + 1) + resources.getString(R.string.bigger1));
mPrinter.setPrinter(Command.PRINT_AND_WAKE_PAPER_BY_LINE, 3);
}
mPrinter.setFont(0, 0, 0, 0, 0);
mPrinter.setPrinter(Command.ALIGN, 0);
mPrinter.setPrinter(Command.PRINT_AND_WAKE_PAPER_BY_LINE, 3);
}
/**
* @param is
* 输入流
* @return String 返回的字符串
* @throws IOException
*/
public static String readFromStream(InputStream is) throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int len = 0;
while ((len = is.read(buffer)) != -1) {
baos.write(buffer, 0, len);
}
is.close();
String result = baos.toString();
baos.close();
return result;
}
/**
* 将一个字符串中的所有字母均转换为大写
*
* @param devicesAddress
* @return
*/
public static String formatTheString(String devicesAddress) {
StringBuffer newDevicesAddress = new StringBuffer("");
for (int i = 0; i < devicesAddress.length(); i++) {
char chars = devicesAddress.charAt(i);
String childString = "" + chars;
childString = childString.toUpperCase();
newDevicesAddress.append(childString);
}
return newDevicesAddress.toString().substring(0, 17);
// return newDevicesAddress.toString();
}
public static boolean isLetter(String str) {
java.util.regex.Pattern pattern = java.util.regex.Pattern.compile("[a-zA-Z]+");
java.util.regex.Matcher m = pattern.matcher(str);
return m.matches();
}
/**
* Android获取当前手机IP地址的两种方式
*/
// 1
public static String getIPAddress(Context context) {
NetworkInfo info = ((ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE))
.getActiveNetworkInfo();
if (info != null && info.isConnected()) {
if (info.getType() == ConnectivityManager.TYPE_MOBILE) {// 当前使用2G/3G/4G网络
try {
// Enumeration<NetworkInterface>
// en=NetworkInterface.getNetworkInterfaces();
for (Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); en
.hasMoreElements();) {
NetworkInterface intf = en.nextElement();
for (Enumeration<InetAddress> enumIpAddr = intf.getInetAddresses(); enumIpAddr
.hasMoreElements();) {
InetAddress inetAddress = enumIpAddr.nextElement();
if (!inetAddress.isLoopbackAddress() && inetAddress instanceof Inet4Address) {
return inetAddress.getHostAddress();
}
}
}
} catch (SocketException e) {
e.printStackTrace();
}
} else if (info.getType() == ConnectivityManager.TYPE_WIFI) {// 当前使用无线网络
WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
String ipAddress = intIP2StringIP(wifiInfo.getIpAddress());// 得到IPV4地址
return ipAddress;
}
} else {
// 当前无网络连接,请在设置中打开网络
WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
wifiManager.setWifiEnabled(true);
}
return null;
}
/**
* 将得到的int类型的IP转换为String类型
*
* @param ip
* @return
*/
public static String intIP2StringIP(int ip) {
return (ip & 0xFF) + "." + ((ip >> 8) & 0xFF) + "." + ((ip >> 16) & 0xFF) + "." + (ip >> 24 & 0xFF);
}
// 2
public String getLocalIpAddress() {
try {
for (Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements();) {
NetworkInterface intf = en.nextElement();
for (Enumeration<InetAddress> enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements();) {
InetAddress inetAddress = enumIpAddr.nextElement();
if (!inetAddress.isLoopbackAddress()) {
return inetAddress.getHostAddress().toString();
}
}
}
} catch (SocketException ex) {
Log.e("WifiPreference IpAddress", ex.toString());
}
return null;
}
/**
*
* @Description: TODO
* @param
* @return String
*/
public static String bytesToHexString2(byte[] src, int datalength) {
StringBuilder stringBuilder = new StringBuilder("");
if (src == null || src.length <= 0) {
return null;
}
for (int i = 0; i < datalength; i++) {
int v = src[i] & 0xFF;
String hv = Integer.toHexString(v);
if (hv.length() < 2) {
stringBuilder.append(0);
}
stringBuilder.append(hv);
}
if (!stringBuilder.toString().endsWith("0a0d")) {
stringBuilder.append("0a0d");
}
return stringBuilder.toString();
}
/**
*
*
* 16进制字符串转换为字符串
*
* @param s
* @return
*
*/
public static String hexStringToString2(String s) {
if (s == null || s.equals("")) {
return null;
}
s = s.replace(" ", "");
byte[] baKeyword = new byte[s.length() / 2];
for (int i = 0; i < baKeyword.length; i++) {
try {
baKeyword[i] = (byte) (0xff & Integer.parseInt(s.substring(i * 2, i * 2 + 2).substring(0, 2), 16));
} catch (Exception e) {
e.printStackTrace();
}
}
try {
s = new String(baKeyword, "gbk");
new String();
} catch (Exception e1) {
e1.printStackTrace();
}
return s;
}
public static byte[] string2bytes2(String content) {
Log.i(TAG, "" + content);
try {
content = new String(content.getBytes("gbk"));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
char[] charArray = content.toCharArray();
byte[] tempByte = new byte[512];
tempByte[0] = 0x34;
int count = 0;
for (int i = 0; i < charArray.length; i = i + 2) {
tempByte[count++] = (byte) (char2Int(charArray[i]) * 16 + char2Int(charArray[i + 1]));
}
Log.i(TAG, "---------------");
byte[] retByte = new byte[count];
System.arraycopy(tempByte, 0, retByte, 0, count);
for (int i = 0; i < retByte.length; i++) {
Log.i(TAG, retByte[i] + "");
}
return tempByte;
}
}

96
uniplugin_padprinter/src/main/java/net/zmt/padprinter/UniPluginPadPrinter.java

@ -0,0 +1,96 @@
package net.zmt.padprinter;
import android.content.Context;
import android.util.Log;
import org.json.JSONException;
import org.json.JSONObject;
import io.dcloud.feature.uniapp.annotation.UniJSMethod;
import io.dcloud.feature.uniapp.bridge.UniJSCallback;
import io.dcloud.feature.uniapp.common.UniModule;
public class UniPluginPadPrinter extends UniModule {
String TAG = "UniPluginPadPrinter Module";
// static Context ct = UniSDKInstance.getContext().getApplicationContext();
// static Context ct;
// Context ct1= mUniSDKInstance.getContext(); //
public static void initContext(Context applicationContext) {
// ct = applicationContext;
}
// private static UniJSCallback mjscallbackPh; //
// public UniJSCallback getMjscallbackCard(){
// return this.mjscallbackPh;
// }
// public void setMjscallbackCard(final UniJSCallback jb){
// this.mjscallbackPh = jb;
// }
@UniJSMethod(uiThread = true)
public void execAPI_V4(JSONObject options, UniJSCallback callback) throws JSONException {//执行简单api_name的控制方法
Log.e(TAG, "execAPI--"+options+"----");
if(callback != null) {
Context ct = mUniSDKInstance.getContext();
String api_name = options.getString("api_name");
//判断不同的api_name, 执行不同的操作
String code = "0";
String reason = api_name;
String status = null;
boolean isPhAvailable = false;
try {
Class.forName("com.peripheral.library.PhController");
isPhAvailable = true;
} catch (ClassNotFoundException e) {
e.printStackTrace();
Log.e(TAG, "Ph SDK 不可用"+e);
}
if (isPhAvailable) {
// lztek SDK 可用的代码
} else {
// lztek SDK 不可用的代码
// 执行其他逻辑或提示用户
return;
}
try{
}catch ( Exception e){
Log.e(TAG, "execAPI--"+e.toString());
code = "error";
reason = e.toString();
}
JSONObject data = new JSONObject();
data.put("code", code);
data.put("reason", reason);
data.put("status", status);
Log.e(TAG, "PhController execAPI--end");
callback.invoke(data);
//callback.invokeAndKeepAlive(data);
}else{
Log.e(TAG, "PhController execAPI--callback null");
}
}
public void testSDKVersion(){
Context context = mUniSDKInstance.getContext();
}
@UniJSMethod(uiThread = false)
public JSONObject testSyncFunc() throws JSONException {
JSONObject data = new JSONObject();
data.put("code", "success");
return data;
}
}

28
uniplugin_padprinter/src/main/java/net/zmt/padprinter/UniPluginPadPrinter_AppProxy.java

@ -0,0 +1,28 @@
package net.zmt.padprinter;
import android.app.Application;
import net.zmt.padprinter.Helper.Printer_Helper;
import io.dcloud.feature.uniapp.UniAppHookProxy;
public class UniPluginPadPrinter_AppProxy implements UniAppHookProxy {
@Override
public void onCreate(Application application) {
//可写初始化触发逻辑
System.out.println("UniPluginPadPrinter_AppProxy onCreate");
initTest(application);
}
@Override
public void onSubProcessCreate(Application application) {
//子进程初始化回调
}
public void initTest(Application application){
System.out.println("UniPluginPadPrinter_AppProxy initTest");
new Printer_Helper(application).TestPrinter(application);
}
}

37
uniplugin_padprinter/src/main/java/net/zmt/padprinter/global/GlobalContants.java

@ -0,0 +1,37 @@
package net.zmt.padprinter.global;
/**
* 定义全局参数
*
* @author Kevin
*
*/
public class GlobalContants {
public static final String CONNECTSTATE = "connectState";
public static final String PRINTERID = "printerID";
public static final String INTERFACETYPE = "interfacetype";
public static final String DEVICEADDRESS = "deviceAddress";
public static String DEVICENAME = "deviceName";
public static final String WIFINAME = "wifiname";
public static final String PAPERWIDTH = "paperwidth";
public static final String LiuKongType = "liukong";
public static final String PRINTERTYPE = "printertype";
public static boolean ISCONNECTED;
public static final int NO_NEW_VERSION = 0;
public static final int HAS_NEW_VERSION = 1;
public static final int URL_ERROR = 2;
public static final int NETWORK_ERROR = 3;
public static final int JSON_ERROR = 4;
public static final int PROGRESS_UPDATE = 5;
public static final int START_UPDATE = 6;
public static final int FINISH_UPDATE = 7;
public static int NEED_UPDATE=0;
public static String description="";
public static String apkurl="";
}

BIN
uniplugin_padprinter/src/main/res/drawable/test.jpg

After

Width: 480  |  Height: 320  |  Size: 28 KiB

24
uniplugin_padprinter/src/main/res/layout/device_item.xml

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2009 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#00000000"
android:padding="1dp"
android:textColor="#ffffff"
android:textSize="25sp" />

32
uniplugin_padprinter/src/main/res/layout/device_list.xml

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/test"
android:orientation="vertical" >
<ListView
android:id="@+id/paired_devices"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/button_scan"
android:layout_alignParentTop="true" />
<Button
android:id="@+id/button_scan"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/button_bace"
android:layout_margin="10dp"
android:text="@string/button_scan" />
<Button
android:id="@+id/button_bace"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:text="@string/back" />
</RelativeLayout>

371
uniplugin_padprinter/src/main/res/values/strings.xml

@ -0,0 +1,371 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<resources>
<string name="title_activity_pdf_print">PdfPrintActivity</string>
<string name="title_activity_lable_print">LablePrintActivity</string>
<string name="app_name">PrintDemo</string>
<string name="action_settings">Settings</string>
<string name="hello_world">Hello world!</string>
<string name="title_activity_setting">SettingActivity</string>
<!-- MainActivity -->
<string name="setting">Setting</string>
<string name="lable_print">Print Lable</string>
<string name="text_print">print Text</string>
<string name="pdf_print">Print PDF</string>
<string name="picture_print">Print Picture</string>
<string name="collect_print">Collect And Print</string>
<string name="barcode_print">Print BarCode</string>
<string name="no_connected">Printer Not Connected</string>
<string name="reconnect">Printer reset, please reconnect</string>
<string name="about_us">Update Online</string>
<!-- LablePrintActivity -->
<string name="lable_of_library_58mm">Library Lable 58mm</string>
<string name="lable_of_physical_distribution_100mm">Physical Distribution 100mm</string>
<string name="lable_of_anneng_physical_distribution_80mm">Physical Distribution 80mm</string>
<string name="lable_of_material_transport_80mm">Material Transport 80mm</string>
<string name="lable_of_fruit">Label Of Fruit And Vegetables</string>
<string name="lable_of_milky_tea">Label Of Milky Tea Room</string>
<string name="lable_of_material_transport_80mm2">Material Transport 80mm</string>
<string name="lable_of_tracking_number">Label Of Tracking Number</string>
<string name="lable_of_storage">Label Of Storage Sector</string>
<string name="tv_show_msg">This feature is only available on the Y33 Printer</string>
<!-- SettingActivity -->
<string-array name="interface_type">
<item>Bluetooth</item>
<item>USB</item>
<item>Wifi</item>
<item>Serial port</item>
</string-array>
<string-array name="tear_data">
<item>tear</item>
<item>strip</item>
<item>close</item>
</string-array>
<string-array name="cash_data">
<item>prohibit open the box</item>
<item>open the box before print</item>
<item>open the box after print</item>
</string-array>
<string-array name="beep_data">
<item>ban buzzer</item>
<item>buzzer rang before print</item>
<item>buzzer rang after print</item>
</string-array>
<string-array name="printertype">
<item>L31</item>
<item>L51</item>
<item>T10</item>
<item>T9</item>
<item>T7</item>
<item>POS58</item>
<item>POS885</item>
<item>EU80 series</item>
</string-array>
<string-array name="spingarr">
<item>115200</item>
<item>9600</item>
<item>230400</item>
</string-array>
<string name="settingactivity_orderset">orderset</string>
<string name="settingactivity_cpcl_orderset">CPCL</string>
<string name="settingactivity_tspl_orderset">TSPL</string>
<string name="settingactivity_gap">gap(mm):</string>
<string name="settingactivity_gap_offset">gap offset(mm):</string>
<string name="settingactivity_speed">speed(inch/seconds):</string>
<string name="settingactivity_concentration">concentration:</string>
<string name="settingactivity_label_offset">label offset(mm):</string>
<string name="settingactivity_print_numbers">print numbers:</string>
<string name="settingactivity_not_print_area">no print area</string>
<string name="settingactivity_margin_left">margin left(mm):</string>
<string name="settingactivity_margin_top">margin top(mm):</string>
<string name="settingactivity_other_settings">other settings</string>
<string name="settingactivity_tear_setting">tear setting:</string>
<string name="settingactivity_cash_box_setting">cash box setting:</string>
<string name="settingactivity_buzzer_setting">buzzer setting:</string>
<string name="settingactivity_print_test">print test</string>
<string name="settingactivity_print_self_checking_page">SelfCheckingPage Print</string>
<string name="Settingactivity_status_test">status test</string>
<string name="settingactivitty_toast_bluetooth_set_tspl_successful">TSPL set successful with BT</string>
<string name="settingactivity_toast_usb_set_tspl_succefful">TSPL set successful with USB</string>
<string name="String_judge1">prohibit open the box</string>
<string name="String_judge2">open the box before print</string>
<string name="String_judge3">open the box after print</string>
<string name="String_judge4">ban buzzer</string>
<string name="String_judge5">buzzer rang before print</string>
<string name="String_judge6">buzzer rang after print</string>
<string name="bt_not_enabled">Bluetooth is not enabled</string>
<string name="printerName">device name:no connection</string>
<string name="printerAddress">deivice address:no connection</string>
<string name="printerType">Printer Model</string>
<string name="interface_type">Printer Interface Type</string>
<string name="openConnection">OPEN CONNECTION</string>
<string name="scan_connect">Scan And Connection</string>
<string name="paper_width">Paper Width</string>
<string name="cut_test">CutPaperTest</string>
<string name="half_cut">HalfCut</string>
<string name="all_cut">AllCut</string>
<string name="copies_number">Number of Copies</string>
<string name="check_status">Check Status</string>
<string name="print_test">Print TestPage</string>
<string name="button_scan">Scan New Devices</string>
<string name="back">Back</string>
<string name="str_message">Tips:</string>
<string name="str_connlast">connected to the last device?</string>
<string name="yesconn">Connect to Last Time</string>
<string name="str_resel">New Search</string>
<string name="disconnect">Close Connection</string>
<string name="connect">Connect</string>
<string name="switch_wifi">Switch WiFi</string>
<string name="str_text">打印文本效果展示:</string>
<string name="str_text_left">文字居左效果演示abc123:</string>
<string name="str_text_right">文字居右效果演示abc123:</string>
<string name="str_text_center">文字居中效果演示abc123:</string>
<string name="str_text_strong">文字加粗效果演示abc123:</string>
<string name="str_text_underline">文字下划线效果演示abc123:</string>
<string name="str_text_height">同行不同高效果演示::</string>
<string name="times"></string>
<string name="bigger">放大</string>
<string name="bigger1">倍效果演示abc123</string>
<string name="connecting">Connecting...</string>
<string name="please_wait">Please Wait...</string>
<!-- DeviceListActivity -->
<string name="scanning">Scanning...</string>
<string name="select_device">Pleaase select the device to connect</string>
<string name="none_paired">No Paired Device</string>
<string name="has_paired">Already Paired</string>
<string name="not_paired">Have not Paired</string>
<string name="none_found">No found</string>
<string name="scan_text">Put the qr code in the box and scan automatically</string>
<string name="conn_failed">Connect Failed</string>
<string name="conn_closed">Connect Closed</string>
<string name="conn_no">No devices can connect</string>
<!-- TextPrintActivity -->
<string name="text_input">Please input content:</string>
<string name="hex_close">Hex_Close</string>
<string name="hex_open">Hex_Open</string>
<string name="content_to_print">Please input the text need to print...</string>
<string name="print_note">Show Example of Receipt</string>
<string name="example_for_codepage_print">Show CodePage</string>
<string name="company_name">打印机公司</string>
<string name="shop_company_title">零售小票</string>
<string name="shop_num">门店号:</string>
<string name="shop_note_num">单据号:</string>
<string name="shop_cashier_num">收银员:</string>
<string name="shop_receipt_date">单据日期:</string>
<string name="shop_print_time">打印时间:</string>
<string name="shop_goods_number">数量:</string>
<string name="shop_goods_total_price">总计:</string>
<string name="shop_payment">付款:</string>
<string name="shop_change">找零:</string>
<string name="shop_company_name">公司名称:江苏某某家居用品有限公司</string>
<string name="shop_company_site">公司网址:</string>
<string name="shop_company_address">地址:江苏省宁波市某某路某某号</string>
<string name="shop_company_tel">电话:</string>
<string name="shop_Service_Line">服务专线:</string>
<string name="shop_thanks">谢谢惠顾,欢迎再次光临!</string>
<string name="shop_demo">Demo 版本!</string>
<string name="note_title">品名;数量;单价;金额</string>
<string name="coffee">咖啡</string>
<string name="tableware">消毒餐具</string>
<string name="peanuts">油炸花生米</string>
<string name="cucumber">蒜泥黄瓜</string>
<string name="frog">干锅田鸡</string>
<string name="rice">米饭</string>
<string name="str_note">打印小票效果演示:</string>
<string name="str_show">演示:</string>
<string name="shop_receipt_num">单据</string>
<string name="bags">保鲜袋</string>
<string name="umbrella">雨伞</string>
<string name="hook">铁丝挂钩</string>
<string name="textprintactivty_input_content">This is just a test!</string>
<!-- PdfPrintActivity -->
<string name="choose_pdf_file">choose pdf file</string>
<string name="previous_page">Previous Page</string>
<string name="next_page">Next Pag</string>
<string name="print_this_page">Present Page Print</string>
<string name="print_all_pdf_document">PDF Print</string>
<!-- BarcoePrintActivity -->
<string-array name="barNoteArray">
<item>Default</item>
<item>Above</item>
<item>Below</item>
<item>Both</item>
</string-array>
<string-array name="barEnlargeArray">
<item>6</item>
<item>5</item>
<item>4</item>
<item>3</item>
<item>2</item>
<item>1</item>
</string-array>
<string-array name="barcode2">
<item>QRCODE</item>
<item>PDF417</item>
<item>DATAMATRIX</item>
</string-array>
<string-array name="barcode1">
<item>CODE128</item>
<item>CODE39</item>
<item>CODEBAR</item>
<item>ITF</item>
<item>CODE93</item>
<item>UPC-A</item>
<item>UPC-E</item>
<item>EAN13</item>
<item>EAN8</item>
<item>All Types</item>
</string-array>
<string name="barcode">Barcode</string>
<string name="qrcode"> QR Code</string>
<string name="tv_barcode_width">Width Of Code:</string>
<string name="tv_barcode_height">height Of Code:</string>
<string name="barcode_content">Content of code</string>
<string name="barcode_data_send">Send Data And Print</string>
<string name="barcode_data_defalut">Default</string>
<string name="tv_barcode_setting">Setting</string>
<string name="tv_barcode_type">Code Type</string>
<string name="send_data">Send Data To Print</string>
<string name="chose_barcode_type">Please choose the type of barcode</string>
<string name="data_range">Data Range</string>
<string name="barcode_print_show">Show Example</string>
<string name="barcode_example">Show Barcode</string>
<string name="qrcode_example">Show QrBarcode</string>
<string name="scan_and_print">Scan And Print</string>
<string name="barcode_width">Width:</string>
<string name="width_data_range"> Range(2~6)</string>
<string name="barcode_height">Height:</string>
<string name="height_data_range"> Rrange(0~255)</string>
<string name="content_position">Position:</string>
<string name="barcode_width_default_value">2</string>
<string name="barcode_height_default_value">162</string>
<string name="version">Version:</string>
<string name="verion_range">Range(0~40)</string>
<string name="level">level:</string>
<string name="level_range"> Range(72,76,77,81)</string>
<string name="version_default_value">1</string>
<string name="level_default_value">76</string>
<string name="multiple">Multiple:</string>
<string name="upc_e_default_value">000000000000</string>
<string name="ean_13_default_value">1234567891234</string>
<string name="ean_8_default_value">12345678</string>
<string name="characters_in_line">Char/line:</string>
<string name="characters_range"> Range(1~30)</string>
<string name="characters_default_value">0</string>
<string name="level_range_qrcode"> Range(0~8)</string>
<string name="barcode_width_data_range_datamatrix"> Range(8~144)</string>
<string name="barcode_height_data_range_datamatrix"> Range(0~144)</string>
<string name="level_range_default_value_qrcode">8</string>
<string name="barcode_height_default_value_datamatrix">0</string>
<string name="tips_for_not_connect">Sorry,there is no connected Printer!</string>
<string name="default_code_content">01051661178</string>
<string name="default_content_position">Default</string>
<string name="default_barcode_type">CODE128</string>
<string name="default_qrcode_type">QRCODE</string>
<string-array name="codepages">
<item>CP437 [U.S.A., Standard Europe]</item>
<item>Katakana</item>
<item>CP850 [Multilingual]</item>
<item>CP860 [Portuguese]</item>
<item>CP863 [Canadian-French]</item>
<item>CP865 [Nordic]</item>
<item>WCP1251 [Cyrillic]</item>
<item>CP866 Cyrilliec #2</item>
<item>MIK[Cyrillic /Bulgarian]</item>
<item>CP755 [East Europe,Latvian 2]</item>
<item>Iran</item>
<item>reserve</item>
<item>reserve</item>
<item>reserve</item>
<item>reserve</item>
<item>CP862 [Hebrew]</item>
<item>WCP1252 Latin I</item>
<item>WCP1253 [Greek]</item>
<item>CP852 [Latina 2]</item>
<item>CP858 Multilingual Latin Ⅰ+Euro)</item>
<item>Iran II</item>
<item>Latvian</item>
<item>CP864 [Arabic]</item>
<item>ISO-8859-1 [West Europe]</item>
<item>CP737 [Greek]</item>
<item>WCP1257 [Baltic]</item>
<item>Thai</item>
<item>CP720[Arabic]</item>
<item>CP855</item>
<item>CP857[Turkish]</item>
<item>WCP1250[Central Eurpoe]</item>
<item>CP775</item>
<item>WCP1254[Turkish]</item>
<item>WCP1255[Hebrew]</item>
<item>WCP1256[Arabic]</item>
<item>WCP1258[Vietnam]</item>
<item>ISO-8859-2[Latin 2]</item>
<item>ISO-8859-3[Latin 3]</item>
<item>ISO-8859-4[Baltic]</item>
<item>ISO-8859-5[Cyrillic]</item>
<item>ISO-8859-6[Arabic]</item>
<item>ISO-8859-7[Greek]</item>
<item>ISO-8859-8[Hebrew]</item>
<item>ISO-8859-9[Turkish]</item>
<item>ISO-8859-15 [Latin 3]</item>
<item>Thai2</item>
<item>CP856</item>
<item>全选</item>
</string-array>
<!-- PriturePrintActivity -->
<string name="monochrome_print">Print Monochrome</string>
<string name="take_phtoto_print">Take Pictures And Print</string>
<string name="select_photos">Gallery</string>
<string name="canvas_print">Canvas</string>
<string name="page_mode_printing">Page mode printing</string>
<string name="str_canvas">Show Canvas:</string>
<string name="print_codepage">Print CodePage</string>
<string name="print">Print</string>
<string name="not_support">This phone does not support this feature</string>
<string name="cancel">Cancel</string>
<string name="codepageTest">Select CodePage Models:</string>
<string name="tv_example">Show Example</string>
<string name="print_table">Show Example of Table</string>
<string name="qrcode_scann">Scan QrCode</string>
<string name="scann_new_devices">Scan for New Devices</string>
<string name="tv_current_wifi">Present Wifi:</string>
<string name="test">Test</string>
<string name="content_after_scann">Content after scanning</string>
<string name="unknown_device">unknown device</string>
<!-- BaseActivity -->
<string name="headview_setting">Setting</string>
<string name="headview_LablePrint">Lable</string>
<string name="headview_TextPrint">Text</string>
<string name="headview_PdfPrint">PDF</string>
<string name="headview_BarcodePrint">Barcode</string>
<string name="headview_PicturePrint">Picture</string>
<string name="headview_CollectPrint">Collect</string>
<!-- headView -->
<string name="on_line">device online</string>
<string name="off_line">device offline</string>
<!-- AboutUsActivity -->
<string name="title_activity_about_us">AboutUsActivity</string>
<string name="version_update">Version Update</string>
<string name="user_guide">User Guide</string>
<string name="website">Website</string>
<string name="call_us">Call Us</string>
<string name="about">About</string>
<string name="title_activity_splash">SplashActivity</string>
<string name="title_activity_material_transport">MaterialTransportActivity</string>
<string name="title_activity_test_tcp">TestTCP</string>
<string name="title_activity_main_activitya">MainActivitya</string>
<string name="notroot">The device is likely to have no root privileges, and the serial port requires root privileges</string>
<string name="choosePDFFile">choose the PDF file</string>
<string name="start_checkupdate_has_new_version">There is a new version, please update!</string>
<string name="start_checkupdate_url_error">URL error</string>
<string name="start_checkupdate_net_error">APP updates can be detected online</string>
<string name="start_checkupdate_json_error">JSON parsing error</string>
<string name="button_redpoint_description">Save redpoint or not</string>
<string name="current_app_version">App Version:</string>
<string name="new_version">new version</string>
<string name="printer_type">Printer type</string>
<string name="printer_normal">Normal Pinter</string>
<string name="printer_t7">T7 Printer</string>
</resources>

17
uniplugin_padprinter/src/test/java/net/zmt/padprinter/ExampleUnitTest.java

@ -0,0 +1,17 @@
package net.zmt.padprinter;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() {
assertEquals(4, 2 + 2);
}
}
Loading…
Cancel
Save