diff --git a/pos_android_app/src/main/java/com/dspread/pos/common/base/BaseAppViewModel.java b/pos_android_app/src/main/java/com/dspread/pos/common/base/BaseAppViewModel.java index aa215ce..dd65bd3 100644 --- a/pos_android_app/src/main/java/com/dspread/pos/common/base/BaseAppViewModel.java +++ b/pos_android_app/src/main/java/com/dspread/pos/common/base/BaseAppViewModel.java @@ -190,7 +190,12 @@ public class BaseAppViewModel extends BaseViewModel implements WebSocketManager. }).start(); break; case "payment": - onPaymentUpdated(json.toString()); + new Thread(() -> { + + new Handler(Looper.getMainLooper()).post(() -> + onPaymentUpdated(json.toString())); + }).start(); + break; case "ping": // Handle ping requests @@ -206,6 +211,8 @@ public class BaseAppViewModel extends BaseViewModel implements WebSocketManager. } } + + /** * Handle ping requests from server */ diff --git a/pos_android_app/src/main/java/com/dspread/pos/printerAPI/PrinterHelper.java b/pos_android_app/src/main/java/com/dspread/pos/printerAPI/PrinterHelper.java index 0698abc..d0d0f82 100644 --- a/pos_android_app/src/main/java/com/dspread/pos/printerAPI/PrinterHelper.java +++ b/pos_android_app/src/main/java/com/dspread/pos/printerAPI/PrinterHelper.java @@ -9,6 +9,7 @@ import android.os.RemoteException; import com.action.printerservice.PrintStyle; import com.action.printerservice.barcode.Barcode1D; import com.action.printerservice.barcode.Barcode2D; +import com.dspread.pos.data.local.PreferencesManager; import com.dspread.pos.utils.DeviceUtils; import com.dspread.pos.utils.QRCodeUtil; import com.dspread.pos.utils.TRACE; @@ -18,6 +19,10 @@ import com.dspread.print.device.PrinterInitListener; import com.dspread.print.device.bean.PrintLineStyle; import com.dspread.print.widget.PrintLine; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Locale; + public class PrinterHelper { protected PrinterDevice mPrinter; public static PrinterHelper printerCommand; @@ -210,6 +215,142 @@ public class PrinterHelper { mPrinter.print(context); } + public void printReceipt(Context context, + PreferencesManager prefs, + double amount, + String currencySymbol, + String paymentMethod, + String printingReciptQRcode, + String printingReciptURL) throws RemoteException { + + + mPrinter.setPrinterSpeed(5); + mPrinter.setPrinterDensity(2); + + // Handle logos - supports both resource IDs and file paths + int mainLogoRes = prefs.getInt("main_logo", -1); + if (mainLogoRes == -1) { + // Load from file path + String path = prefs.getString("main_logo_path", null); + if (path != null) { + Bitmap bitmap = BitmapFactory.decodeFile(path); + if (bitmap != null) { + mPrinter.addBitmap(bitmap); + } + } + } else { + // Regular resource ID - convert resource ID to Bitmap + Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(), mainLogoRes); + if (bitmap != null) { + mPrinter.addBitmap(bitmap); + } + } + +// mPrinter.addPrintLintStyle(new PrintLineStyle(PrintStyle.FontStyle.BOLD, PrintLine.CENTER, 20)); + +// if (bitmap == null) { +// throw new IllegalArgumentException("Bitmap cannot be null"); +// } +// mPrinter.printBitmap(context, bitmap); +// mPrinter.addBitmap(bitmap); +// mPrinter.addText("АО Альфа-Банк"); + +// mPrinter.setLineSpace(8); + + mPrinter.addPrintLintStyle(new PrintLineStyle(PrintStyle.FontStyle.NORMAL, PrintLine.CENTER, 14)); +// mPrinter.addText("ИНН 1234567890"); +// mPrinter.setLineSpace(8); + +// mPrinter.addText("8 800 550-91-23"); +// mPrinter.setLineSpace(8); + // ================== ADDRESS ================== +// mPrinter.addText("г. Волгоград, пр. Ленина, д. 92"); + // ================== RECEIPT DETAILS ================== + mPrinter.addText("ЧЕК №" + 123465); + mPrinter.addText("Кассир: Иванов И.И."); + SimpleDateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy", Locale.getDefault()); + SimpleDateFormat timeFormat = new SimpleDateFormat("HH:mm:ss", Locale.getDefault()); + + Date currentDate = new Date(); + +// Get separated date and time strings + String dateString = dateFormat.format(currentDate); + String timeString = timeFormat.format(currentDate); + + mPrinter.addTexts( + new String[]{dateString, timeString}, // Actual date and time values + new int[]{1, 1}, // Equal column width + new int[]{PrintStyle.Alignment.NORMAL, PrintStyle.Alignment.ALIGN_OPPOSITE}, + new int[]{PrintStyle.FontStyle.BOLD, PrintStyle.FontStyle.BOLD}, + 14 // Font size + ); + mPrinter.addText("------------------------------"); + // ================== ITEMS ================== + mPrinter.addTexts( + new String[]{"1. Тест Документ", String.format("%.2f %s", amount, currencySymbol)}, + new int[]{2, 1}, // Left column wider than right + new int[]{PrintStyle.Alignment.CENTER, PrintStyle.Alignment.ALIGN_OPPOSITE} + ); + + mPrinter.addTexts( + new String[]{" НДС 20%", "= " + String.format("%.2f %s", amount * 0.2, currencySymbol)}, + new int[]{2, 1}, + new int[]{PrintStyle.Alignment.NORMAL, PrintStyle.Alignment.ALIGN_OPPOSITE} + ); +// ================== TOTALS ================== + mPrinter.addText("--------------------------------"); + mPrinter.addPrintLintStyle(new PrintLineStyle(PrintStyle.FontStyle.BOLD, PrintLine.CENTER, 28)); + mPrinter.addTexts( + new String[]{"ИТОГО:", String.format("%.2f %s", amount, currencySymbol)}, + new int[]{1, 1}, // Equal column width + new int[]{PrintStyle.Alignment.NORMAL, PrintStyle.Alignment.ALIGN_OPPOSITE}, + new int[]{PrintStyle.FontStyle.NORMAL, PrintStyle.FontStyle.BOLD}, 28 + ); + + mPrinter.addPrintLintStyle(new PrintLineStyle(PrintStyle.FontStyle.NORMAL, PrintLine.CENTER, 14)); + + mPrinter.addTexts( + new String[]{"Форма расчета:", paymentMethod }, + new int[]{1, 1}, // Equal column width + new int[]{PrintStyle.Alignment.NORMAL, PrintStyle.Alignment.ALIGN_OPPOSITE} + ); + + // ================== FISCAL DATA ================== + mPrinter.addText("--------------------------------"); + + // ================== QR CODE AND CONTACTS ================== +// mPrinter.addBarCode(context, Barcode1D.CODE_128.name(), 400, 100, "datexpay.ru", PrintLine.CENTER); + mPrinter.addQRCode(280, Barcode2D.QR_CODE.name(), printingReciptQRcode, PrintLine.CENTER); + mPrinter.addPrintLintStyle(new PrintLineStyle(PrintStyle.FontStyle.NORMAL, PrintLine.CENTER, 14)); + mPrinter.addText(printingReciptURL); + +// mPrinter.addBitmap(mulberry); + + // Handle logos - supports both resource IDs and file paths + int footerLogoRes = prefs.getInt("footer_logo", -1); + if (footerLogoRes == -1) { + // Load from file path + String path = prefs.getString("footer_logo_path", null); + if (path != null) { + Bitmap bitmap = BitmapFactory.decodeFile(path); + if (bitmap != null) { + mPrinter.addBitmap(bitmap); + } + } + } else { + // Regular resource ID - convert resource ID to Bitmap + Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(), footerLogoRes); + if (bitmap != null) { + mPrinter.addBitmap(bitmap); + } + } + + + mPrinter.setFooter(80); + //Print the document + mPrinter.print(context); + } + public void getPrinterStatus() throws RemoteException { mPrinter.getPrinterStatus(); } diff --git a/pos_android_app/src/main/java/com/dspread/pos/ui/home/HomeViewModel.java b/pos_android_app/src/main/java/com/dspread/pos/ui/home/HomeViewModel.java index 27291d8..d5932b9 100644 --- a/pos_android_app/src/main/java/com/dspread/pos/ui/home/HomeViewModel.java +++ b/pos_android_app/src/main/java/com/dspread/pos/ui/home/HomeViewModel.java @@ -1,6 +1,8 @@ package com.dspread.pos.ui.home; import android.app.Application; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; import android.util.Log; import androidx.annotation.NonNull; @@ -9,6 +11,7 @@ import androidx.lifecycle.LiveData; import com.dspread.pos.common.base.BaseAppViewModel; import com.dspread.pos.utils.CurrencySymbolUtils; +import com.dspread.pos.utils.PosParameters; import com.dspread.pos.utils.TRACE; import com.dspread.pos_android_app.R; @@ -21,7 +24,8 @@ public class HomeViewModel extends BaseAppViewModel { public ObservableField amount = new ObservableField<>("0.00"); public ObservableField currencyCode = new ObservableField<>("RUB"); public SingleLiveEvent paymentStartEvent = new SingleLiveEvent<>(); - + public final ObservableField mainLogo = new ObservableField<>(); + public final ObservableField mainLogoBitmap = new ObservableField<>(); public StringBuilder amountBuilder = new StringBuilder(); private static final int MAX_DIGITS = 12; // Maximum amount digits @@ -32,9 +36,44 @@ public class HomeViewModel extends BaseAppViewModel { currencyCode.set(symbolForCurrency); // Set symbol // currencyCode.set(prefs.getString("CurrencyCode", "RUB")); Log.d("HomeViewModel", "symbolForCurrency: " + symbolForCurrency ); + // Handle logos - supports both resource IDs and file paths + int mainLogoRes = prefs.getInt("main_logo", -1); + if (mainLogoRes == -1) { + // Load from file path + String path = prefs.getString("main_logo_path", null); + if (path != null) { + Bitmap bitmap = BitmapFactory.decodeFile(path); + if (bitmap != null) { + // Use a custom binding adapter to set bitmap + mainLogoBitmap.set(bitmap); + } + } + } else { + // Regular resource ID + mainLogo.set(mainLogoRes); + } } - + @Override + protected void onConfigurationUpdated() { + int mainLogoRes = prefs.getInt("main_logo", -1); + if (mainLogoRes == -1) { + // Load from file path + String path = prefs.getString("main_logo_path", null); + if (path != null) { + Bitmap bitmap = BitmapFactory.decodeFile(path); + if (bitmap != null) { + // Use a custom binding adapter to set bitmap + mainLogoBitmap.set(bitmap); + } + } + } else { + // Regular resource ID + mainLogo.set(mainLogoRes); + } + } + + // Update amount display private void updateAmountDisplay() { if (amountBuilder.length() == 0) { @@ -42,7 +81,7 @@ public class HomeViewModel extends BaseAppViewModel { return; } - + String amountStr = amountBuilder.toString(); // Convert to display an amount with two decimal places if (amountStr.length() == 1) { diff --git a/pos_android_app/src/main/java/com/dspread/pos/ui/mulberry/MulberryViewModel.java b/pos_android_app/src/main/java/com/dspread/pos/ui/mulberry/MulberryViewModel.java index d00b0cc..369d419 100644 --- a/pos_android_app/src/main/java/com/dspread/pos/ui/mulberry/MulberryViewModel.java +++ b/pos_android_app/src/main/java/com/dspread/pos/ui/mulberry/MulberryViewModel.java @@ -341,7 +341,7 @@ public class MulberryViewModel extends BaseAppViewModel { public void onItemClick(MulberryItemViewModel item) { Log.d(TAG, "Navigation item clicked: " + item.title.get()); - sendWebSocketMessage("Navigation item clicked: " + item.title.get()); +// sendWebSocketMessage("{\"type\":\"message\", \"content\": \"Navigation item clicked\" }"); if (item.fragmentId != null) { navigateToFragment.setValue(item.fragmentId); diff --git a/pos_android_app/src/main/java/com/dspread/pos/ui/payment/PaymentActivity.java b/pos_android_app/src/main/java/com/dspread/pos/ui/payment/PaymentActivity.java index 6334ccb..82e80d1 100644 --- a/pos_android_app/src/main/java/com/dspread/pos/ui/payment/PaymentActivity.java +++ b/pos_android_app/src/main/java/com/dspread/pos/ui/payment/PaymentActivity.java @@ -49,6 +49,7 @@ import java.util.ArrayList; import java.util.Calendar; import java.util.Hashtable; import java.util.List; +import java.util.Locale; import me.goldze.mvvmhabit.base.BaseActivity; import me.goldze.mvvmhabit.utils.SPUtils; @@ -61,7 +62,7 @@ import com.dspread.pos_android_app.databinding.WaitingForCardBinding; // Generat public class PaymentActivity extends BaseActivity implements PaymentServiceCallback { - + private String amount; private String transactionTypeString; private String cashbackAmounts; @@ -78,7 +79,7 @@ public class PaymentActivity extends BaseActivity { + QRMood = Boolean.TRUE.equals(qrEnabled); + }); + + // Observe FaceID mode + viewModel.getFaceIDMode().observe(this, faceIDEnabled -> { + FaceIDMood = Boolean.TRUE.equals(faceIDEnabled); + }); + //Stop DoTrade viewModel.StopReadingCard.observe(this, aBoolean -> { Log.d("PaymentAct", "StopReadingCard: " + aBoolean); if (aBoolean) { // Unregister the callback - QPOSCallbackManager.getInstance().unregisterPaymentCallback(); +// QPOSCallbackManager.getInstance().unregisterPaymentCallback(); + POS.getInstance().cancelTrade(); + + } }); // Add this observer for receipt content @@ -456,12 +525,20 @@ public class PaymentActivity extends BaseActivity { - String msg = HandleTxnsResultUtils.getTransactionResultMessage(transactionResult, PaymentActivity.this); - if (!msg.isEmpty()) { + + if (QRMood || FaceIDMood){ + simulatePaymentAfterDelay(); + } + else { + runOnUiThread(() -> { + String msg = HandleTxnsResultUtils.getTransactionResultMessage(transactionResult, PaymentActivity.this); + if (!msg.isEmpty()) { viewModel.setTransactionFailed(msg); - } - }); + } + }); + } + + } @Override @@ -556,6 +633,7 @@ public class PaymentActivity extends BaseActivity { // viewModel.setTransactionFailed("Transaction is canceled!"); + finish(); }); } diff --git a/pos_android_app/src/main/java/com/dspread/pos/ui/payment/PaymentViewModel.java b/pos_android_app/src/main/java/com/dspread/pos/ui/payment/PaymentViewModel.java index 3821167..d5fef92 100644 --- a/pos_android_app/src/main/java/com/dspread/pos/ui/payment/PaymentViewModel.java +++ b/pos_android_app/src/main/java/com/dspread/pos/ui/payment/PaymentViewModel.java @@ -15,6 +15,9 @@ import android.widget.TextView; import androidx.annotation.NonNull; import androidx.databinding.ObservableBoolean; import androidx.databinding.ObservableField; +import androidx.lifecycle.LiveData; +import androidx.lifecycle.MutableLiveData; +import androidx.lifecycle.ViewModel; import com.dspread.pos.common.base.BaseAppViewModel; import com.dspread.pos.common.http.RetrofitClient; @@ -37,6 +40,7 @@ import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Objects; import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.functions.Consumer; @@ -70,6 +74,10 @@ public class PaymentViewModel extends BaseAppViewModel { public SingleLiveEvent isOnlineSuccess = new SingleLiveEvent(); public SingleLiveEvent isContinueTrx = new SingleLiveEvent(); public SingleLiveEvent StopReadingCard = new SingleLiveEvent(); + + // Add these for QR and FaceID modes + private final MutableLiveData qrMode = new MutableLiveData<>(false); + private final MutableLiveData faceIDMode = new MutableLiveData<>(false); public ObservableBoolean showPinpad = new ObservableBoolean(false); public ObservableBoolean showResultStatus = new ObservableBoolean(false); public ObservableField receiptContent = new ObservableField<>(); @@ -81,6 +89,30 @@ public class PaymentViewModel extends BaseAppViewModel { this.mContext = mContext; } + // Public getters for the LiveData + public LiveData getQrMode() { + return qrMode; + } + + public LiveData getFaceIDMode() { + return faceIDMode; + } + + // Methods to set the modes + public void setQrMode(boolean enabled) { + qrMode.setValue(enabled); + } + + public void setFaceIDMode(boolean enabled) { + faceIDMode.setValue(enabled); + } + + // Reset both modes to false (call this when activity starts) + public void resetModes() { + qrMode.setValue(false); + faceIDMode.setValue(false); + } + public void simulateSuccessfulPayment() { Log.d("PaymentVM", "simulateSuccessfulPayment ... "); setTransactionSuccess("Simulated successful payment"); @@ -117,8 +149,9 @@ public class PaymentViewModel extends BaseAppViewModel { case "success": Log.d(TAG, "QR Payment Success"); // Unregister callback through the activity - StopReadingCard.setValue(true);// This will trigger the activity to unregister - simulateSuccessfulPayment(); + setQrMode(true); + StopReadingCard.setValue(true); +// simulateSuccessfulPayment(); break; case "failed": Log.d(TAG, "QR Payment Failed"); @@ -127,11 +160,11 @@ public class PaymentViewModel extends BaseAppViewModel { break; default: Log.w(TAG, "Unknown JSON type: " + status); - StopReadingCard.setValue(true);// This will trigger the activity to unregister +// StopReadingCard.setValue(true);// This will trigger the activity to unregister } } catch (JSONException e) { Log.e("PaymentVM", "Error parsing JSON", e); - StopReadingCard.setValue(true); // This will trigger the activity to unregister +// StopReadingCard.setValue(true); // This will trigger the activity to unregister } } @@ -174,7 +207,7 @@ public class PaymentViewModel extends BaseAppViewModel { } public void setAmount(String newAmount) { - amount.set("¥" + newAmount); + amount.set( newAmount); } public void setWaitingStatus(boolean isWaitings){ @@ -202,6 +235,18 @@ public class PaymentViewModel extends BaseAppViewModel { loadingText.set(""); } + public static Double convertCentsToDollars(String amountValue) { + if (amountValue == null || amountValue.isEmpty()) { + return 0.0; // Default value if the input is null or empty + } + try { + return Double.parseDouble(amountValue) / 100.0; // Convert cents to dollars + } catch (NumberFormatException e) { + e.printStackTrace(); + return 0.0; // Default value if parsing fails + } + } + public BindingCommand continueTxnsCommand = new BindingCommand(new BindingAction() { @Override public void call() { @@ -219,31 +264,79 @@ public class PaymentViewModel extends BaseAppViewModel { public BindingCommand sendReceiptCommand = new BindingCommand(new BindingAction() { @Override public void call() { - isPrinting.set(true); - PrinterManager instance = PrinterManager.getInstance(); - PrinterDevice mPrinter = instance.getPrinter(); - PrinterHelper.getInstance().setPrinter(mPrinter); - PrinterHelper.getInstance().initPrinter(mContext); - TRACE.i("bitmap = "+receiptBitmap); - new Handler().postDelayed(() -> { - try { - PrinterHelper.getInstance().printBitmap(getApplication(),receiptBitmap); - } catch (RemoteException e) { - throw new RuntimeException(e); + String CurrentID = SPUtils.getInstance().getString("posID"); + + // Extract the String value from the ObservableField + String amountValue = amount != null ? amount.get() : "0"; + String currencySymbol = SPUtils.getInstance().getString("symbolForCurrency", "$"); + // Convert the amount from cents to dollars using the utility function + Double amountDouble = convertCentsToDollars(amountValue); + + if (Objects.equals(CurrentID, "01534090202502210065")){ + com.alibaba.fastjson.JSONObject paymentData = new com.alibaba.fastjson.JSONObject(); + paymentData.put("type", "redirect"); + paymentData.put("amount", amountDouble); + paymentData.put("currencySymbol", currencySymbol); + paymentData.put("id", "01723060202412010160"); + + Log.d(TAG, "call: this is M50 maybe"); + sendWebSocketMessage(paymentData.toString()); + + + }else { + isPrinting.set(true); + PrinterManager instance = PrinterManager.getInstance(); + PrinterDevice mPrinter = instance.getPrinter(); + PrinterHelper.getInstance().setPrinter(mPrinter); + PrinterHelper.getInstance().initPrinter(mContext); + + Boolean isQR = getQrMode().getValue(); + Boolean isFaceID = getFaceIDMode().getValue(); + + String paymentMethod; + if (isQR != null && isQR) { + paymentMethod = "QR Code"; + } else if (isFaceID != null && isFaceID) { + paymentMethod = "Face ID"; + } else { + paymentMethod = "Крата"; } - PrinterHelper.getInstance().getmPrinter().setPrintListener(new PrintListener() { - @Override - public void printResult(boolean b, String s, PrinterDevice.ResultType resultType) { - if(b){ - ToastUtils.showShort("Print Finished!"); - }else { - ToastUtils.showShort("Print Result: "+s); - } - isPrinting.set(false); - finish(); + TRACE.i("bitmap = " + receiptBitmap); + + + new Handler().postDelayed(() -> { + try { +// PrinterHelper.getInstance().printBitmap(getApplication(),receiptBitmap); + assert amountValue != null; + PrinterHelper.getInstance().printReceipt( + getApplication(), prefs, + amountDouble, + currencySymbol, + paymentMethod, + "String printingReciptQRcode", + "www.mulberrypos.ru" + ); + } catch (RemoteException e) { + throw new RuntimeException(e); } - }); - },100); + PrinterHelper.getInstance().getmPrinter().setPrintListener(new PrintListener() { + @Override + public void printResult(boolean b, String s, PrinterDevice.ResultType resultType) { + if (b) { +// ToastUtils.showShort("Print Finished!"); + Log.d(TAG, "printResult: Finished"); + } else { +// ToastUtils.showShort("Print Result: "+s); + Log.d(TAG, "printResult: Result" + s); + + } + isPrinting.set(false); +// finish(); + } + }); + }, 100); + + } // else if not M50 } }); diff --git a/pos_android_app/src/main/java/com/dspread/pos/ui/payment/WaitingForCardViewModel.java b/pos_android_app/src/main/java/com/dspread/pos/ui/payment/WaitingForCardViewModel.java index 536360c..f9d4f3e 100644 --- a/pos_android_app/src/main/java/com/dspread/pos/ui/payment/WaitingForCardViewModel.java +++ b/pos_android_app/src/main/java/com/dspread/pos/ui/payment/WaitingForCardViewModel.java @@ -26,11 +26,23 @@ public class WaitingForCardViewModel extends BaseViewModel { public void setAmount(String amount) { - this.amount.set(amount); + Double amountDouble = convertCentsToDollars(amount); + this.amount.set(String.valueOf(amountDouble)); } public void setCurrencySymbol(String symbol) { this.currencySymbol.set(symbol); } + public static Double convertCentsToDollars(String amountValue) { + if (amountValue == null || amountValue.isEmpty()) { + return 0.0; // Default value if the input is null or empty + } + try { + return Double.parseDouble(amountValue) / 100.0; // Convert cents to dollars + } catch (NumberFormatException e) { + e.printStackTrace(); + return 0.0; // Default value if parsing fails + } + } public void generateQRCode(String paymentData) { try { Bitmap qrCode = QRCodeGenerator.generateQRCode(paymentData, 500, 500); diff --git a/pos_android_app/src/main/java/com/dspread/pos/ui/setting/connection_settings/ConnectionSettingsFragment.java b/pos_android_app/src/main/java/com/dspread/pos/ui/setting/connection_settings/ConnectionSettingsFragment.java index 65fd63b..1c44b6f 100644 --- a/pos_android_app/src/main/java/com/dspread/pos/ui/setting/connection_settings/ConnectionSettingsFragment.java +++ b/pos_android_app/src/main/java/com/dspread/pos/ui/setting/connection_settings/ConnectionSettingsFragment.java @@ -169,13 +169,13 @@ public class ConnectionSettingsFragment extends BaseFragment= Build.VERSION_CODES.JELLY_BEAN_MR1) { + configuration.setLocale(locale); + } else { + configuration.locale = locale; + } + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { + return context.createConfigurationContext(configuration); + } else { + resources.updateConfiguration(configuration, resources.getDisplayMetrics()); + return context; + } + } + + public static String getLanguage(Context context) { + Configuration config = context.getResources().getConfiguration(); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { + return config.getLocales().get(0).getLanguage(); + } else { + return config.locale.getLanguage(); + } + } +} \ No newline at end of file diff --git a/pos_android_app/src/main/res/layout/fragment_home.xml b/pos_android_app/src/main/res/layout/fragment_home.xml index 871ff8b..875839a 100644 --- a/pos_android_app/src/main/res/layout/fragment_home.xml +++ b/pos_android_app/src/main/res/layout/fragment_home.xml @@ -6,6 +6,7 @@ +