duel key inject UI
This commit is contained in:
parent
a37b035493
commit
3cb8fe218e
@ -3,6 +3,7 @@ package com.utsmm.kbz.ui.settings;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
@ -22,6 +23,9 @@ import com.utsmm.kbz.databinding.FragmentInjectKeyBinding;
|
||||
import com.utsmyanmar.paylibs.utils.LogUtil;
|
||||
import com.utsmm.kbz.util.tms.TMSUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class InjectKeyFragment extends DataBindingFragment {
|
||||
|
||||
private static final String TAG = InjectKeyFragment.class.getSimpleName();
|
||||
@ -32,6 +36,7 @@ public class InjectKeyFragment extends DataBindingFragment {
|
||||
// Key injection variables
|
||||
private DownloadFlow mDownloadFlow;
|
||||
private int keyIndexTmp = 8; // Default key index
|
||||
private final List<HostSelectionItem> hostSelectionItems = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
protected void initViewModel() {
|
||||
@ -84,22 +89,51 @@ public class InjectKeyFragment extends DataBindingFragment {
|
||||
}
|
||||
|
||||
private void updateConfigurationInfo() {
|
||||
setupHostSelection();
|
||||
binding.serialNumberValue.setText(getDisplayValue(TMSUtil.getInstance().getSerialNumber()));
|
||||
}
|
||||
|
||||
String terminalId = SystemParamsOperation.getInstance().getTerminalId();
|
||||
binding.terminalIdValue.setText(terminalId != null && !terminalId.isEmpty() ?
|
||||
terminalId : "Not configured");
|
||||
private void setupHostSelection() {
|
||||
hostSelectionItems.clear();
|
||||
|
||||
// Update Merchant ID
|
||||
String merchantId = SystemParamsOperation.getInstance().getMerchantId();
|
||||
binding.merchantIdValue.setText(merchantId != null && !merchantId.isEmpty() ?
|
||||
merchantId : "Not configured");
|
||||
String primaryTerminalId = SystemParamsOperation.getInstance().getTerminalId();
|
||||
String primaryMerchantId = SystemParamsOperation.getInstance().getMerchantId();
|
||||
String secondaryTerminalId = SystemParamsOperation.getInstance().getThirdHostTerminalId();
|
||||
String secondaryMerchantId = SystemParamsOperation.getInstance().getThirdHostMerchantId();
|
||||
|
||||
// Update Serial Number
|
||||
String serialNo = TMSUtil.getInstance().getSerialNumber();
|
||||
binding.serialNumberValue.setText(serialNo != null && !serialNo.isEmpty() ?
|
||||
serialNo : "Not configured");
|
||||
hostSelectionItems.add(new HostSelectionItem("Primary Host", primaryTerminalId, primaryMerchantId));
|
||||
|
||||
if (!TextUtils.isEmpty(secondaryTerminalId) || !TextUtils.isEmpty(secondaryMerchantId)) {
|
||||
hostSelectionItems.add(new HostSelectionItem("Secondary Host", secondaryTerminalId, secondaryMerchantId));
|
||||
}
|
||||
|
||||
ArrayAdapter<HostSelectionItem> hostAdapter = new ArrayAdapter<>(
|
||||
requireContext(),
|
||||
android.R.layout.simple_list_item_1,
|
||||
hostSelectionItems
|
||||
);
|
||||
binding.actvHostSelection.setAdapter(hostAdapter);
|
||||
|
||||
if (!hostSelectionItems.isEmpty()) {
|
||||
HostSelectionItem defaultSelection = hostSelectionItems.get(0);
|
||||
binding.actvHostSelection.setText(defaultSelection.toString(), false);
|
||||
applyHostSelection(defaultSelection);
|
||||
}
|
||||
|
||||
binding.actvHostSelection.setOnItemClickListener((parent, view, position, id) -> {
|
||||
if (position >= 0 && position < hostSelectionItems.size()) {
|
||||
applyHostSelection(hostSelectionItems.get(position));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void applyHostSelection(@NonNull HostSelectionItem selectionItem) {
|
||||
binding.terminalIdValue.setText(getDisplayValue(selectionItem.terminalId));
|
||||
binding.merchantIdValue.setText(getDisplayValue(selectionItem.merchantId));
|
||||
}
|
||||
|
||||
private String getDisplayValue(String value) {
|
||||
return !TextUtils.isEmpty(value) ? value : "Not configured";
|
||||
}
|
||||
|
||||
private void loadKeyFromKeyPOS() {
|
||||
@ -177,6 +211,28 @@ public class InjectKeyFragment extends DataBindingFragment {
|
||||
}
|
||||
};
|
||||
|
||||
private static class HostSelectionItem {
|
||||
private final String label;
|
||||
private final String terminalId;
|
||||
private final String merchantId;
|
||||
|
||||
private HostSelectionItem(String label, String terminalId, String merchantId) {
|
||||
this.label = label;
|
||||
this.terminalId = terminalId;
|
||||
this.merchantId = merchantId;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String toString() {
|
||||
return label;
|
||||
}
|
||||
|
||||
private static String getSummaryValue(String value) {
|
||||
return TextUtils.isEmpty(value) ? "Not configured" : value;
|
||||
}
|
||||
}
|
||||
|
||||
// ClickEvent class for data binding - this is the proper pattern
|
||||
public class ClickEvent {
|
||||
|
||||
@ -190,4 +246,4 @@ public class InjectKeyFragment extends DataBindingFragment {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -129,6 +129,84 @@
|
||||
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
<!-- Host Selection Card -->
|
||||
<androidx.cardview.widget.CardView
|
||||
android:id="@+id/hostSelectionCard"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="16dp"
|
||||
app:cardBackgroundColor="@color/white"
|
||||
app:cardCornerRadius="16dp"
|
||||
app:cardElevation="2dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:padding="20dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="@font/rubik_medium"
|
||||
android:text="Host Selection"
|
||||
android:textColor="@color/colorTextTitle"
|
||||
android:textSize="16sp"
|
||||
android:textStyle="bold"
|
||||
tools:fontFamily="sans-serif-medium" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="4dp"
|
||||
android:layout_marginBottom="12dp"
|
||||
android:fontFamily="@font/rubik_regular"
|
||||
android:text="Select Terminal Id and MerchantId to preview before key injection"
|
||||
android:textColor="@color/colorTextContent"
|
||||
android:textSize="14sp"
|
||||
tools:fontFamily="sans-serif" />
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="Select Host"
|
||||
app:endIconMode="dropdown_menu"
|
||||
app:boxBackgroundMode="outline"
|
||||
app:boxCornerRadiusBottomEnd="8dp"
|
||||
app:boxCornerRadiusBottomStart="8dp"
|
||||
app:boxCornerRadiusTopEnd="8dp"
|
||||
app:boxCornerRadiusTopStart="8dp"
|
||||
app:boxStrokeColor="@color/colorPrimary">
|
||||
|
||||
<com.google.android.material.textfield.MaterialAutoCompleteTextView
|
||||
android:id="@+id/actvHostSelection"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="@font/rubik_regular"
|
||||
android:inputType="none"
|
||||
android:focusable="false"
|
||||
android:clickable="true"
|
||||
android:textColor="@color/colorTextTitle"
|
||||
android:textSize="16sp"
|
||||
android:paddingLeft="16sp"
|
||||
tools:fontFamily="sans-serif" />
|
||||
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:fontFamily="@font/rubik_regular"
|
||||
android:text="UI only: current key injection still uses the active TMS configuration."
|
||||
android:textColor="@color/colorTextContent"
|
||||
android:textSize="12sp"
|
||||
tools:fontFamily="sans-serif" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
<!-- Current Configuration Info Card -->
|
||||
<androidx.cardview.widget.CardView
|
||||
android:id="@+id/configInfoCard"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user