From f61f89e79c77813d283ae40459c0200e7ff307e4 Mon Sep 17 00:00:00 2001 From: Fabio Date: Fri, 5 Mar 2021 17:28:26 -0300 Subject: [PATCH] revert: "adds support for text printing on Cielo Lio devices" This reverts commit 5eb9e0abf05e91aa5cf0a516427658bdab8519e8. --- .../printer/client/PrinterAttributes.java | 64 --------------- .../cielo/sdk/order/PrinterListener.java | 13 ---- .../cielo/sdk/printer/PrinterManager.java | 77 ------------------- TotalCrossVM/CMakeLists.txt | 2 - TotalCrossVM/android/app/build.gradle | 6 -- .../app/src/includeSms/AndroidManifest.xml | 2 +- .../android/app/src/main/AndroidManifest.xml | 4 - .../android/cielo/PrinterManager4A.java | 52 ------------- .../app/src/singleApk/AndroidManifest.xml | 2 +- TotalCrossVM/src/init/android/startup_c.h | 1 - TotalCrossVM/src/init/globals.c | 2 +- TotalCrossVM/src/init/globals.h | 2 +- TotalCrossVM/src/init/nativeProcAddressesTC.c | 1 - TotalCrossVM/src/nm/NativeMethods.h | 1 - TotalCrossVM/src/nm/NativeMethods.txt | 1 - .../src/nm/NativeMethodsPrototypes.txt | 5 -- .../src/nm/cielo/printer/PrinterManager.c | 31 -------- .../cielo/printer/android/PrinterManager_c.h | 18 ----- 18 files changed, 4 insertions(+), 280 deletions(-) delete mode 100644 TotalCrossSDK/src/main/java/totalcross/cielo/printer/client/PrinterAttributes.java delete mode 100644 TotalCrossSDK/src/main/java/totalcross/cielo/sdk/order/PrinterListener.java delete mode 100644 TotalCrossSDK/src/main/java/totalcross/cielo/sdk/printer/PrinterManager.java delete mode 100644 TotalCrossVM/android/app/src/main/java/totalcross/android/cielo/PrinterManager4A.java delete mode 100644 TotalCrossVM/src/nm/cielo/printer/PrinterManager.c delete mode 100644 TotalCrossVM/src/nm/cielo/printer/android/PrinterManager_c.h diff --git a/TotalCrossSDK/src/main/java/totalcross/cielo/printer/client/PrinterAttributes.java b/TotalCrossSDK/src/main/java/totalcross/cielo/printer/client/PrinterAttributes.java deleted file mode 100644 index b34f93054f..0000000000 --- a/TotalCrossSDK/src/main/java/totalcross/cielo/printer/client/PrinterAttributes.java +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright (C) 2019-2020 TotalCross Global Mobile Platform Ltda. -// -// SPDX-License-Identifier: LGPL-2.1-only - -package totalcross.cielo.printer.client; - -public class PrinterAttributes { - - /** - * Printing alignment, value must be one of PrinterAttributes.VAL_ALIGN_CENTER, - * PrinterAttributes.VAL_ALIGN_LEFT or PrinterAttributes.VAL_ALIGN_RIGHT - * - * @see PrinterAttributes.VAL_ALIGN_CENTER - * @see PrinterAttributes.VAL_ALIGN_LEFT - * @see PrinterAttributes.VAL_ALIGN_RIGHT - */ - public static final String KEY_ALIGN = "key_attributes_align"; - - /** - * Text size, must be an integer value - */ - public static final String KEY_TEXT_SIZE = "key_attributes_textsize"; - - /** - * Text font, must be an integer between 0 and 8, where each value is a - * different font - */ - public static final String KEY_TYPEFACE = "key_attributes_typeface"; - - /** - * Left margin, must be an integer value - */ - public static final String KEY_MARGIN_LEFT = "key_attributes_marginleft"; - - /** - * Right margin, must be an integer value - */ - public static final String KEY_MARGIN_RIGHT = "key_attributes_marginright"; - - /** - * Top margin, must be an integer value - */ - public static final String KEY_MARGIN_TOP = "key_attributes_margintop"; - - /** - * Bottom margin, must be an integer value - */ - public static final String KEY_MARGIN_BOTTOM = "key_attributes_marginbottom"; - - /** - * Spacing between consecutive lines, must be an integer value - */ - public static final String KEY_LINE_SPACE = "key_attributes_linespace"; - - /** - * Used when printing multiple columns, to choose the weight of each column, - * must be an integer value - */ - public static final String KEY_WEIGHT = "key_attributes_weight"; - - public static final int VAL_ALIGN_CENTER = 0; - public static final int VAL_ALIGN_LEFT = 1; - public static final int VAL_ALIGN_RIGHT = 2; -} diff --git a/TotalCrossSDK/src/main/java/totalcross/cielo/sdk/order/PrinterListener.java b/TotalCrossSDK/src/main/java/totalcross/cielo/sdk/order/PrinterListener.java deleted file mode 100644 index 811acbbb6e..0000000000 --- a/TotalCrossSDK/src/main/java/totalcross/cielo/sdk/order/PrinterListener.java +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (C) 2019-2020 TotalCross Global Mobile Platform Ltda. -// -// SPDX-License-Identifier: LGPL-2.1-only - -package totalcross.cielo.sdk.order; - -public interface PrinterListener { - public void onPrintSuccess(int printedLines); - - public void onError(Throwable e); - - public void onWithoutPaper(); -} diff --git a/TotalCrossSDK/src/main/java/totalcross/cielo/sdk/printer/PrinterManager.java b/TotalCrossSDK/src/main/java/totalcross/cielo/sdk/printer/PrinterManager.java deleted file mode 100644 index 84bd6951f3..0000000000 --- a/TotalCrossSDK/src/main/java/totalcross/cielo/sdk/printer/PrinterManager.java +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright (C) 2019-2020 TotalCross Global Mobile Platform Ltda. -// -// SPDX-License-Identifier: LGPL-2.1-only - -package totalcross.cielo.sdk.printer; - -import java.util.Map; - -import com.totalcross.annotations.ReplacedByNativeOnDeploy; - -import totalcross.cielo.sdk.order.PrinterListener; -import totalcross.sys.Vm; - -/** - * Usage example: - * - *
- * HashMap printerAttributes = new HashMap<>();
- * 
- * printerAttributes.put(PrinterAttributes.KEY_ALIGN, PrinterAttributes.VAL_ALIGN_CENTER);
- * printerAttributes.put(PrinterAttributes.KEY_TYPEFACE, 1);
- * printerAttributes.put(PrinterAttributes.KEY_TEXT_SIZE, 20);
- * 
- * String textToPrint = "TEXT TO PRINT";
- * PrinterManager.getInstance()
- *               .printText(textToPrint, printerAttributes);
- * 
- */ -public class PrinterManager { - - private static PrinterManager instance; - - private PrinterManager() { - } - - public static PrinterManager getInstance() { - if (instance == null) { - instance = new PrinterManager(); - } - return instance; - } - - static class PrinterListenerInternal { - PrinterListener printerListener; - - PrinterListenerInternal(PrinterListener printerListener) { - this.printerListener = printerListener; - } - } - - public void printText(String textToPrint, Map printerAttributes) { - printText(textToPrint, printerAttributes, null); - } - - private void printText(String textToPrint, Map printerAttributes, - PrinterListener printerListener) { - StringBuffer sb = new StringBuffer(); - for (Map.Entry entry : printerAttributes.entrySet()) { - sb.append(entry.getKey()); - sb.append('='); - sb.append(entry.getValue()); - sb.append('&'); - } - sb.deleteCharAt(sb.length() - 1); - - internalPrintText( - textToPrint, - sb.toString(), - printerListener == null ? null : new PrinterListenerInternal(printerListener)); - } - - @ReplacedByNativeOnDeploy - private void internalPrintText(String textToPrint, String printerAttributes, - PrinterListenerInternal printerListener) { - Vm.debug("PRINT ONLY AVAILABLE ON CIELO DEVICE"); - } -} diff --git a/TotalCrossVM/CMakeLists.txt b/TotalCrossVM/CMakeLists.txt index 0fe236dee2..dc8be73909 100644 --- a/TotalCrossVM/CMakeLists.txt +++ b/TotalCrossVM/CMakeLists.txt @@ -259,8 +259,6 @@ set(SOURCES ${TC_SRCDIR}/scanner/ios/ios_barcode.c - ${TC_SRCDIR}/nm/cielo/printer/PrinterManager.c - ${TC_SRCDIR}/nm/qrcode/qrcode_generation.c ${TC_SRCDIR}/nm/io/device/gpiod/Gpiod.c diff --git a/TotalCrossVM/android/app/build.gradle b/TotalCrossVM/android/app/build.gradle index 3a2200aa33..e9524cb4bb 100644 --- a/TotalCrossVM/android/app/build.gradle +++ b/TotalCrossVM/android/app/build.gradle @@ -159,12 +159,6 @@ dependencies { androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' implementation 'com.android.support:customtabs:25.1.0' - - // https://mvnrepository.com/artifact/cielo.printer.client/printer-manager - //compile group: 'cielo.printer.client', name: 'printer-manager', version: '2.3.1' - - // https://mvnrepository.com/artifact/com.cielo.lio/order-manager - compile group: 'com.cielo.lio', name: 'order-manager', version: '0.19.8' //Youtube API implementation files('libs/YouTubeAndroidPlayerApi.jar') diff --git a/TotalCrossVM/android/app/src/includeSms/AndroidManifest.xml b/TotalCrossVM/android/app/src/includeSms/AndroidManifest.xml index 7af3db3dac..be97ef2a6a 100644 --- a/TotalCrossVM/android/app/src/includeSms/AndroidManifest.xml +++ b/TotalCrossVM/android/app/src/includeSms/AndroidManifest.xml @@ -4,7 +4,7 @@ package="totalcross.android" > - + diff --git a/TotalCrossVM/android/app/src/main/AndroidManifest.xml b/TotalCrossVM/android/app/src/main/AndroidManifest.xml index 3e2741dae5..54b48b7157 100644 --- a/TotalCrossVM/android/app/src/main/AndroidManifest.xml +++ b/TotalCrossVM/android/app/src/main/AndroidManifest.xml @@ -4,11 +4,8 @@ android:versionCode="305419896" android:versionName="!1.0!" android:sharedUserId="totalcross.app.sharedid" - xmlns:tools="http://schemas.android.com/tools" > - - diff --git a/TotalCrossVM/android/app/src/main/java/totalcross/android/cielo/PrinterManager4A.java b/TotalCrossVM/android/app/src/main/java/totalcross/android/cielo/PrinterManager4A.java deleted file mode 100644 index f8f29a8a6e..0000000000 --- a/TotalCrossVM/android/app/src/main/java/totalcross/android/cielo/PrinterManager4A.java +++ /dev/null @@ -1,52 +0,0 @@ -package totalcross.android.cielo; - -import java.util.HashMap; - -import cielo.printer.client.PrinterAttributes; -import cielo.sdk.order.PrinterListener; -import cielo.sdk.printer.PrinterManager; - -import totalcross.Launcher4A; -import totalcross.AndroidUtils; - -public class PrinterManager4A { - - public static void cieloPrintManagerPrintText(String textToPrint, String printerAttributes) { - HashMap attributes = null; - - if (printerAttributes != null) { - attributes = new HashMap<>(); - - String[] elements = printerAttributes.split("&"); - for(String s1: elements) { - String[] keyValue = s1.split("="); - try { - attributes.put(keyValue[0], Integer.valueOf(keyValue[1])); - } catch (NumberFormatException e) { - // just ignore - } - } - } - - PrinterManager printerManager = new PrinterManager(Launcher4A.loader.getApplicationContext()); - PrinterListener listener = new PrinterListener() { - @Override - public void onWithoutPaper() { - AndroidUtils.debug("printer without paper"); - } - - @Override - public void onPrintSuccess() { - AndroidUtils.debug("print success!"); - } - - @Override - public void onError(Throwable throwable) { - AndroidUtils.debug( - String.format("printer error -> %s", throwable.getMessage())); - } - }; - - printerManager.printText(textToPrint, attributes, listener); - } -} diff --git a/TotalCrossVM/android/app/src/singleApk/AndroidManifest.xml b/TotalCrossVM/android/app/src/singleApk/AndroidManifest.xml index 28045c59fd..43ecda071d 100644 --- a/TotalCrossVM/android/app/src/singleApk/AndroidManifest.xml +++ b/TotalCrossVM/android/app/src/singleApk/AndroidManifest.xml @@ -4,7 +4,7 @@ package="totalcross.android" > - + diff --git a/TotalCrossVM/src/init/android/startup_c.h b/TotalCrossVM/src/init/android/startup_c.h index f61b7a3e4e..94376c9e19 100644 --- a/TotalCrossVM/src/init/android/startup_c.h +++ b/TotalCrossVM/src/init/android/startup_c.h @@ -104,7 +104,6 @@ void JNICALL Java_totalcross_Launcher4A_initializeVM(JNIEnv *env, jobject appObj jNotificationManager4A = androidFindClass(env, "totalcross/android/NotificationManager4A"); jFirebaseInstanceId = androidFindClass(env, "com/google/firebase/iid/FirebaseInstanceId"); jTcFirebaseUtils = androidFindClass(env, "totalcross/android/firebase/FirebaseUtils"); - jCieloPrinterManager4A = androidFindClass(env, "totalcross/android/cielo/PrinterManager4A"); jzxing = (*env)->GetStaticMethodID(env, applicationClass, "zxing", "(Ljava/lang/String;)Ljava/lang/String;"); jsoundToText = (*env)->GetStaticMethodID(env, applicationClass, "soundToText", "(Ljava/lang/String;)Ljava/lang/String;"); jsoundFromText = (*env)->GetStaticMethodID(env, applicationClass, "soundFromText", "(Ljava/lang/String;)V"); diff --git a/TotalCrossVM/src/init/globals.c b/TotalCrossVM/src/init/globals.c index 295d75f695..908d92e052 100644 --- a/TotalCrossVM/src/init/globals.c +++ b/TotalCrossVM/src/init/globals.c @@ -53,7 +53,7 @@ bool isMainWindow = false; // extends MainWindow ? #if defined(ANDROID) JavaVM* androidJVM; jobject applicationObj, applicationContext; -jclass applicationClass,jRadioDevice4A,jBluetooth4A,jConnectionManager4A,jSmsManager4A,jNotificationManager4A,jFirebaseInstanceId,jTcFirebaseUtils,jCieloPrinterManager4A; +jclass applicationClass,jRadioDevice4A,jBluetooth4A,jConnectionManager4A,jSmsManager4A,jNotificationManager4A,jFirebaseInstanceId,jTcFirebaseUtils; jfieldID jshowingAlert,jhardwareKeyboardIsVisible; jfieldID jsipVisible,jappTitleH; jmethodID jgetHeight; diff --git a/TotalCrossVM/src/init/globals.h b/TotalCrossVM/src/init/globals.h index 16eca439bd..f7577264ad 100644 --- a/TotalCrossVM/src/init/globals.h +++ b/TotalCrossVM/src/init/globals.h @@ -51,7 +51,7 @@ extern bool isMainWindow; // extends MainWindow ? #if defined(ANDROID) JavaVM* androidJVM; extern jobject applicationObj, applicationContext; -extern jclass applicationClass,jRadioDevice4A,jBluetooth4A,jConnectionManager4A,jSmsManager4A,jNotificationManager4A,jFirebaseInstanceId,jTcFirebaseUtils,jCieloPrinterManager4A; +extern jclass applicationClass,jRadioDevice4A,jBluetooth4A,jConnectionManager4A,jSmsManager4A,jNotificationManager4A,jFirebaseInstanceId,jTcFirebaseUtils; extern jfieldID jshowingAlert,jhardwareKeyboardIsVisible; extern jfieldID jsipVisible,jappTitleH; extern jmethodID jgetHeight; diff --git a/TotalCrossVM/src/init/nativeProcAddressesTC.c b/TotalCrossVM/src/init/nativeProcAddressesTC.c index a293e1181d..2293c6033d 100644 --- a/TotalCrossVM/src/init/nativeProcAddressesTC.c +++ b/TotalCrossVM/src/init/nativeProcAddressesTC.c @@ -550,7 +550,6 @@ void fillNativeProcAddressesTC() htPutPtr(&htNativeProcAddresses, hashCode("ttSM_registerSmsReceiver_si"), &ttSM_registerSmsReceiver_si); htPutPtr(&htNativeProcAddresses, hashCode("tfiFII_getToken"), &tfiFII_getToken); htPutPtr(&htNativeProcAddresses, hashCode("tnNM_notify_n"), &tnNM_notify_n); - htPutPtr(&htNativeProcAddresses, hashCode("tcspPM_internalPrintText_ssp"), &tcspPM_internalPrintText_ssp); htPutPtr(&htNativeProcAddresses, hashCode("tqQRC_nativeGetBytes_sii"), &tqQRC_nativeGetBytes_sii); htPutPtr(&htNativeProcAddresses, hashCode("tidsS_scannerActivate"), &tidsS_scannerActivate); htPutPtr(&htNativeProcAddresses, hashCode("tidsS_setBarcodeParam_ib"), &tidsS_setBarcodeParam_ib); diff --git a/TotalCrossVM/src/nm/NativeMethods.h b/TotalCrossVM/src/nm/NativeMethods.h index 7025266277..01ab54d67c 100644 --- a/TotalCrossVM/src/nm/NativeMethods.h +++ b/TotalCrossVM/src/nm/NativeMethods.h @@ -569,7 +569,6 @@ TC_API void ttSM_registerSmsReceiver_si(NMParams p); TC_API void tfiFII_getToken(NMParams p); TC_API void tnNM_notify_n(NMParams p); TC_API void tcpPBKDF2WHSHA1F_generateSecretI(NMParams p); -TC_API void tcspPM_internalPrintText_ssp(NMParams p); TC_API void tqQRC_nativeGetBytes_sii(NMParams p); TC_API void tidgGC_open_i(NMParams p); TC_API void tidgGL_open_gi(NMParams p); diff --git a/TotalCrossVM/src/nm/NativeMethods.txt b/TotalCrossVM/src/nm/NativeMethods.txt index 5c036c6612..5e5a32ec74 100644 --- a/TotalCrossVM/src/nm/NativeMethods.txt +++ b/TotalCrossVM/src/nm/NativeMethods.txt @@ -544,5 +544,4 @@ totalcross/telephony/SmsManager|public native void sendDataMessage(String destin totalcross/telephony/SmsManager|public native void registerSmsReceiver(totalcross.telephony.SmsReceiver receiver, int port); totalcross/firebase/iid/FirebaseInstanceId|public native String getToken(); totalcross/notification/NotificationManager|public void notify(totalross.notification.Notification notification); -totalcross/cielo/sdk/printer/PrinterManager|private native void internalPrintText(String textToPrint, String printerAttributes, totalcross.cielo.printer.PrinterManager.PrinterListenerInternal printerListener); totalcross/qrcode/QRCode|private native byte[][] nativeGetBytes(String text, int errorCorrection, int version); \ No newline at end of file diff --git a/TotalCrossVM/src/nm/NativeMethodsPrototypes.txt b/TotalCrossVM/src/nm/NativeMethodsPrototypes.txt index 73e1efa9b7..be362f2963 100644 --- a/TotalCrossVM/src/nm/NativeMethodsPrototypes.txt +++ b/TotalCrossVM/src/nm/NativeMethodsPrototypes.txt @@ -544,7 +544,6 @@ TC_API void ttSM_sendDataMessage_ssiB(NMParams p); TC_API void ttSM_registerSmsReceiver_si(NMParams p); TC_API void tfiFII_getToken(NMParams p); TC_API void tnNM_notify_n(NMParams p); -TC_API void tcspPM_internalPrintText_ssp(NMParams p); TC_API void tqQRC_nativeGetBytes_sii(NMParams p); ////////////////////////////////////////////////////////////////////////// @@ -2728,10 +2727,6 @@ TC_API void tnNM_notify_n(NMParams p) // totalcross/notification/NotificationMan { } ////////////////////////////////////////////////////////////////////////// -TC_API void tcspPM_internalPrintText_ssp(NMParams p) // totalcross/cielo/sdk/printer/PrinterManager private native void internalPrintText(String textToPrint, String printerAttributes, totalcross.cielo.printer.PrinterManager.PrinterListenerInternal printerListener); -{ -} -////////////////////////////////////////////////////////////////////////// TC_API void tqQRC_nativeGetBytes_sii(NMParams p) // totalcross/qrcode/QRCode private native byte[][] nativeGetBytes(String text, int errorCorrection, int version); { } diff --git a/TotalCrossVM/src/nm/cielo/printer/PrinterManager.c b/TotalCrossVM/src/nm/cielo/printer/PrinterManager.c deleted file mode 100644 index e770f291a7..0000000000 --- a/TotalCrossVM/src/nm/cielo/printer/PrinterManager.c +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (C) 2000-2013 SuperWaba Ltda. -// Copyright (C) 2014-2020 TotalCross Global Mobile Platform Ltda. -// -// SPDX-License-Identifier: LGPL-2.1-only - -#include "tcvm.h" - -#if defined(ANDROID) -#include "android/PrinterManager_c.h" -#endif - -////////////////////////////////////////////////////////////////////////// -TC_API void tcspPM_internalPrintText_ssp(NMParams p) // totalcross/cielo/sdk/printer/PrinterManager private native void internalPrintText(String textToPrint, String printerAttributes, totalcross.cielo.printer.PrinterManager.PrinterListenerInternal printerListener); -{ - TCObject printerManager = p->obj[0]; - TCObject textToPrint = p->obj[1]; - TCObject printerAttributes = p->obj[2]; - TCObject printerListener = p->obj[3]; - -#if defined (ANDROID) - // first, lock the printerListener to make sure it won't be collected by the GC - if (printerListener != null) { - setObjectLock(printerListener, LOCKED); - } - // make native android call - cieloPrintManagerPrintText(textToPrint, printerAttributes, printerListener); -#endif -} -#ifdef ENABLE_TEST_SUITE -//#include "PrinterManager_test.h" -#endif diff --git a/TotalCrossVM/src/nm/cielo/printer/android/PrinterManager_c.h b/TotalCrossVM/src/nm/cielo/printer/android/PrinterManager_c.h deleted file mode 100644 index 1d9b90fd14..0000000000 --- a/TotalCrossVM/src/nm/cielo/printer/android/PrinterManager_c.h +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (C) 2000-2013 SuperWaba Ltda. -// Copyright (C) 2014-2020 TotalCross Global Mobile Platform Ltda. -// -// SPDX-License-Identifier: LGPL-2.1-only - -static Err cieloPrintManagerPrintText (TCObject textToPrint, TCObject printerAttributes, TCObject printerListener) { - JNIEnv* env = getJNIEnv(); - jmethodID cieloPrintManagerPrintTextMethod = (*env)->GetStaticMethodID(env, jCieloPrinterManager4A, "cieloPrintManagerPrintText", "(Ljava/lang/String;Ljava/lang/String;)V"); - jstring jTextToPrint = (*env)->NewString(env, String_charsStart(textToPrint), String_charsLen(textToPrint)); - jstring jPrinterAttributes = (printerAttributes != null) ? (*env)->NewString(env, String_charsStart(printerAttributes), String_charsLen(printerAttributes)) : null; - - (*env)->CallStaticObjectMethod(env, jCieloPrinterManager4A, cieloPrintManagerPrintTextMethod, jTextToPrint, jPrinterAttributes); - (*env)->DeleteLocalRef(env, jTextToPrint); - if (jPrinterAttributes != null) { - (*env)->DeleteLocalRef(env, jPrinterAttributes); - } - return NO_ERROR; -}