fixed nexgo-sdklkey lib not included

This commit is contained in:
kizzy 2025-12-04 08:10:41 +07:00
parent 8b211ca530
commit 1a7e86077c
34 changed files with 2755 additions and 0 deletions

View File

@ -0,0 +1,193 @@
package com.utsmm.kbz.ui.settings;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.nexgo.downloadkey.downloadflow.DownloadFEntity;
import com.nexgo.downloadkey.downloadflow.DownloadFlow;
import com.nexgo.downloadkey.downloadflow.DownloadFlowProcessListener;
import com.nexgo.downloadkey.downloadflow.DownloadFlowResultEntity;
import com.nexgo.downloadkey.downloadflow.DownloadResult;
import com.utsmyanmar.baselib.fragment.DataBindingFragment;
import com.utsmyanmar.baselib.util.DataBindingConfig;
import com.utsmyanmar.paylibs.utils.core_utils.SystemParamsOperation;
import com.utsmm.kbz.BR;
import com.utsmm.kbz.R;
import com.utsmm.kbz.databinding.FragmentInjectKeyBinding;
import com.utsmyanmar.paylibs.utils.LogUtil;
import com.utsmm.kbz.util.tms.TMSUtil;
public class InjectKeyFragment extends DataBindingFragment {
private static final String TAG = InjectKeyFragment.class.getSimpleName();
// Data binding will handle view access automatically
private FragmentInjectKeyBinding binding;
// Key injection variables
private DownloadFlow mDownloadFlow;
private int keyIndexTmp = 8; // Default key index
@Override
protected void initViewModel() {
// No specific viewmodels needed for this fragment
}
@Override
protected DataBindingConfig getDataBindingConfig() {
// This is the key method that links the XML and fragment properly
return new DataBindingConfig(R.layout.fragment_inject_key, 0, null)
.addBindingParam(BR.click, new ClickEvent());
}
@Override
protected int currentId() {
return R.id.injectKeyFragment;
}
@Override
protected int hostId() {
return R.id.nav_host_fragment;
}
@Override
protected int routeId() {
return 0;
}
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
try {
// Get the binding from the base class - this is automatically created
binding = (FragmentInjectKeyBinding) mBinding;
updateConfigurationInfo();
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void onResume() {
super.onResume();
setToolBarTitleWithBackIcon("Inject Key");
}
private void updateConfigurationInfo() {
String terminalId = SystemParamsOperation.getInstance().getTerminalId();
binding.terminalIdValue.setText(terminalId != null && !terminalId.isEmpty() ?
terminalId : "Not configured");
// Update Merchant ID
String merchantId = SystemParamsOperation.getInstance().getMerchantId();
binding.merchantIdValue.setText(merchantId != null && !merchantId.isEmpty() ?
merchantId : "Not configured");
// Update Serial Number
String serialNo = TMSUtil.getInstance().getSerialNumber();
binding.serialNumberValue.setText(serialNo != null && !serialNo.isEmpty() ?
serialNo : "Not configured");
}
private void loadKeyFromKeyPOS() {
try {
if (TextUtils.isEmpty(binding.etKeyIndex.getText())) {
Toast.makeText(getContext(), "Please input key index", Toast.LENGTH_SHORT).show();
return;
}
String keyIndexText = binding.etKeyIndex.getText().toString().trim();
try {
keyIndexTmp = Integer.parseInt(keyIndexText);
} catch (NumberFormatException e) {
Toast.makeText(getContext(), "Invalid key index format", Toast.LENGTH_SHORT).show();
return;
}
showLoadingDialog("Loading key...");
mDownloadFlow = DownloadFlow.getInstance();
String terminalId = SystemParamsOperation.getInstance().getTerminalId();
String merchantId = SystemParamsOperation.getInstance().getMerchantId();
String serialNo = TMSUtil.getInstance().getSerialNumber();
// Validate configuration
if (TextUtils.isEmpty(terminalId) || TextUtils.isEmpty(merchantId) || TextUtils.isEmpty(serialNo)) {
dismissLoadingDialog();
showDeclineDialog("Please configure Terminal ID, Merchant ID first in TMS Configuration");
return;
}
final DownloadFEntity downloadFEntity = new DownloadFEntity();
downloadFEntity.setSn(serialNo.getBytes());
downloadFEntity.setMid(merchantId.getBytes());
downloadFEntity.setTid(terminalId.getBytes());
downloadFEntity.setTmkIndex(keyIndexTmp);
downloadFEntity.setPort(0);
downloadFEntity.setTimeOut(10);
int result = mDownloadFlow.startLoadKey(getActivity(), downloadFEntity, onDownloadFlowProcessListener);
if (result != DownloadResult.Success) {
dismissLoadingDialog();
showDeclineDialog("Failed to start key injection process");
LogUtil.e(TAG, "Failed to start key injection, result: " + result);
}
} catch (Exception e) {
dismissLoadingDialog();
LogUtil.e(TAG, "Error in key injection: " + e.getMessage());
showDeclineDialog("Error occurred during key injection: " + e.getMessage());
}
}
private DownloadFlowProcessListener onDownloadFlowProcessListener = new DownloadFlowProcessListener() {
@Override
public void onFinish(int ret, DownloadFlowResultEntity downloadFlowResultEntity) {
try {
dismissLoadingDialog();
if (ret == DownloadResult.Success) {
// Show success dialog with key index
showSuccessDialog("Key injection successful!\nKey Index: " + keyIndexTmp);
LogUtil.d(TAG, "Key injection successful for index: " + keyIndexTmp);
} else {
// Show decline dialog
showDeclineDialog("Key injection failed!\nError code: " + ret);
LogUtil.e(TAG, "Key injection failed with error code: " + ret);
}
} catch (Exception e) {
LogUtil.e(TAG, "Error handling injection result: " + e.getMessage());
showDeclineDialog("Error processing injection result");
}
}
};
// ClickEvent class for data binding - this is the proper pattern
public class ClickEvent {
public void onInjectKeyClick() {
try {
LogUtil.d(TAG, "Inject key button clicked");
loadKeyFromKeyPOS();
} catch (Exception e) {
LogUtil.e(TAG, "Error in inject key click: " + e.getMessage());
showDeclineDialog("Error occurred: " + e.getMessage());
}
}
}
}

View File

@ -0,0 +1,2 @@
configurations.maybeCreate("default")
artifacts.add("default", file('nexgo-sdk-dlkey-1.0.2.aar'))

View File

@ -0,0 +1 @@
i/jars/classes.jar

View File

@ -0,0 +1 @@
o/nexgo-sdk-dlkey-1.0.2-runtime

View File

@ -0,0 +1 @@
o/nexgo-sdk-dlkey-1.0.2

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.nexgo.downloadkey"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="21"
android:targetSdkVersion="26" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application
android:allowBackup="true"
android:label="@string/app_name"
android:supportsRtl="true" >
</application>
</manifest>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">downloadkey</string>
</resources>

View File

@ -0,0 +1 @@
i/AndroidManifest.xml

View File

@ -0,0 +1 @@
o/nexgo-sdk-dlkey-1.0.2-api.jar

View File

@ -0,0 +1 @@
o/com.nexgo.downloadkey-r.txt

View File

@ -0,0 +1 @@
o/com.nexgo.downloadkey

View File

@ -0,0 +1 @@
o/nexgo-sdk-dlkey-1.0.2-runtime.jar

Binary file not shown.