package com.shukria.kiosklauncher.ui import android.content.Context import android.text.TextUtils import android.util.Log import print.Print import print.PublicFunction class PublicAction { private var context: Context? = null private val CODEPAGE_KHEMR = "Khemr" constructor() constructor(con: Context?) { context = con } fun BeforePrintAction() { try { Print.LanguageEncode = "gb2312" } catch (e: Exception) { Log.e( "Print", StringBuilder("PublicAction --> BeforePrintAction ") .append(e.message).toString() ) } } fun BeforePrintActionText() { try { val PFun = PublicFunction(context) if (!TextUtils.isEmpty(PFun.ReadSharedPreferencesData("Codepage"))) { val codepage = PFun.ReadSharedPreferencesData("Codepage").split(",".toRegex()) .dropLastWhile { it.isEmpty() } .toTypedArray()[1] val sLEncode = PublicFunction.getLanguageEncode(codepage) //设置Codepage Print.LanguageEncode = sLEncode // if (CODEPAGE_KHEMR.equals(codepage)){ // //开启高棉语 // Print.setKhmerSwitch(true); // Print.setKhemrOrder(); // } } } catch (e: Exception) { Log.e( "Print", StringBuilder("PublicAction --> BeforePrintAction ") .append(e.message).toString() ) } } fun AfterPrintActionText() { try { // PublicFunction PFun=new PublicFunction(context); // if (!TextUtils.isEmpty(PFun.ReadSharedPreferencesData("Codepage"))){ // String codepage = PFun.ReadSharedPreferencesData("Codepage").split(",")[1]; // if (CODEPAGE_KHEMR.equals(codepage)){ // //关闭高棉语 // Print.setKhemrEnd(); // } // } } catch (e: Exception) { Log.e( "Print", StringBuilder("PublicAction --> AfterPrintAction ") .append(e.message).toString() ) } } fun AfterPrintAction() {} fun LanguageEncode(): String { return try { val PFun = PublicFunction(context) val sLanguage = PFun.ReadSharedPreferencesData("Codepage").split(",".toRegex()) .dropLastWhile { it.isEmpty() } .toTypedArray()[1] var sLEncode = "gb2312" var intLanguageNum = 0 sLEncode = PublicFunction.getLanguageEncode(sLanguage) intLanguageNum = PFun.getCodePageIndex(sLanguage) Print.LanguageEncode = sLEncode // Print.SetCharacterSet((byte)intLanguageNum); sLEncode } catch (e: Exception) { Log.e( "SDKSample", StringBuilder("PublicAction --> AfterPrintAction ") .append(e.message).toString() ) "" } } }