host config address fix

This commit is contained in:
MooN 2026-01-29 13:29:50 +06:30
parent 3c77d4d9c7
commit f6067f8de6
4 changed files with 238 additions and 252 deletions

View File

@ -1,11 +1,18 @@
package com.utsmm.kbz.ui.settings;
import static com.utsmyanmar.paylibs.print.printx.BaseXPrint.wrapAddressText;
import android.text.TextUtils;
import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;
import com.utsmm.kbz.BuildConfig;
import com.utsmyanmar.paylibs.utils.core_utils.SystemParamsOperation;
import java.util.ArrayList;
import java.util.List;
public class HostConfigViewModel extends ViewModel {
public String appVersion = BuildConfig.VERSION_NAME;
@ -38,13 +45,11 @@ public class HostConfigViewModel extends ViewModel {
public void loadConfig() {
SystemParamsOperation sp = SystemParamsOperation.getInstance();
// Merchant Info
merchantName.setValue(sp.getMerchantName());
merchantPhone.setValue(sp.getMerchantPhoneNo());
merchantAddress1.setValue(sp.getMerchantAddress());
merchantAddress1.setValue(wrapForUi(sp.getMerchantAddress()));
merchantAddress2.setValue(sp.getMerchantAddress2());
terminalName.setValue(sp.getTerminalName());
@ -81,6 +86,22 @@ public class HostConfigViewModel extends ViewModel {
}
}
public static String wrapForUi(String text) {
if (text == null || text.isEmpty()) return "";
List<String> result = new ArrayList<>();
String[] paragraphs = text.split("\\n");
for (String paragraph : paragraphs) {
List<String> wrappedLines = wrapAddressText(paragraph.trim(), 29);
result.addAll(wrappedLines);
}
return TextUtils.join("\n", result);
}
private String[] split(String raw) {
if (raw == null || raw.trim().isEmpty()) {
return new String[]{"", ""};

View File

@ -1,21 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:bind="http://schemas.android.com/tools">
xmlns:tools="http://schemas.android.com/tools">
<data>
<import type="android.view.View"/>
<import type="android.text.TextUtils"/>
<variable
name="viewModel"
type="com.utsmm.kbz.ui.settings.HostConfigViewModel" />
type="com.utsmm.kbz.ui.settings.HostConfigViewModel"/>
<variable
name="sharedViewModel"
type="com.utsmm.kbz.ui.core_viewmodel.SharedViewModel" />
type="com.utsmm.kbz.ui.core_viewmodel.SharedViewModel"/>
<variable
name="click"
type="com.utsmm.kbz.ui.settings.HostConfigFragment.ClickHandler" />
type="com.utsmm.kbz.ui.settings.HostConfigFragment.ClickHandler"/>
</data>
<androidx.constraintlayout.widget.ConstraintLayout
@ -23,12 +25,11 @@
android:layout_height="match_parent"
android:padding="16dp">
<!-- CARD SECTION -->
<!-- ================= CARD ================= -->
<androidx.cardview.widget.CardView
android:id="@+id/hostCard"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginBottom="8dp"
app:cardCornerRadius="16dp"
app:cardElevation="0dp"
app:layout_constraintTop_toTopOf="parent"
@ -53,292 +54,204 @@
android:layout_height="wrap_content"
android:orientation="vertical">
<!-- HEADER -->
<!-- Merchant Info -->
<!-- <TextView-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:text="@{viewModel.merchantName}"-->
<!-- android:fontFamily="@font/rubik_regular"-->
<!-- android:textSize="16sp"-->
<!-- android:textStyle="bold"-->
<!-- android:textAlignment="center"-->
<!-- tools:text="Someone Mart"/>-->
<!-- ===== HEADER ===== -->
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@{viewModel.terminalName}"
android:fontFamily="@font/rubik_regular"
android:textSize="16sp"
android:textStyle="bold"
android:textAlignment="center"
tools:text="Terminal_Name"/>
android:gravity="center"
style="@style/HostLabelStyle"
android:fontFamily="@font/rubik_regular"
tools:text="Terminal Name"
android:layout_height="wrap_content"
android:layout_width="match_parent"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@{viewModel.merchantAddress1}"
android:fontFamily="@font/rubik_regular"
android:textSize="16sp"
android:textSize="14sp"
style="@style/HostLabelStyle"
android:textStyle="bold"
android:textAlignment="center"
tools:text="Corner of Bogyoke and Botahtaung Pagoda Street"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@{viewModel.merchantAddress2}"
android:gravity="center"
android:fontFamily="@font/rubik_regular"
android:textSize="16sp"
android:textStyle="bold"
android:textAlignment="center"
tools:text="Yangon"/>
<!-- <TextView-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:text="@{viewModel.terminalName}"-->
<!-- android:fontFamily="@font/rubik_regular"-->
<!-- android:textSize="16sp"-->
<!-- android:textStyle="bold"-->
<!-- tools:text="Terminal_Name"/>-->
tools:text="Merchant Address Line 1"
android:layout_height="wrap_content"
android:layout_width="match_parent"/>
<TextView
android:layout_width="match_parent"
android:text="--------------------------------------------------------------------------"
android:gravity="left"
android:paddingVertical="8dp"
android:layout_height="wrap_content"
android:text="*************************************************"
android:paddingTop="8dp"
android:paddingBottom="8dp"
tools:text="*********************************************************"/>
android:layout_width="match_parent"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="TERMINAL CONFIGURATION"
android:fontFamily="@font/rubik_regular"
android:textSize="16sp"
android:textStyle="bold"
android:textAlignment="center"
style="@style/HostLabelStyle"
android:gravity="center"
android:paddingBottom="12dp"
tools:text="TERMINAL CONFIGURATION"/>
<!-- PRIMARY HOST -->
<TextView
android:layout_width="match_parent"
android:fontFamily="@font/rubik_regular"
android:layout_height="wrap_content"
android:layout_width="match_parent"/>
<!-- ===== PRIMARY HOST ===== -->
<TextView
android:text="PRIMARY HOST"
android:fontFamily="@font/rubik_regular"
android:textSize="14sp"
android:textStyle="bold"
tools:text="PRIMARY HOST"/>
android:paddingBottom="4dp"
style="@style/HostLabelStyle"
android:layout_height="wrap_content"
android:layout_width="match_parent"/>
<TextView
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text='@{"Name : " + viewModel.hostName}'
android:fontFamily="@font/rubik_regular"
android:textSize="14sp"
android:textStyle="bold"
tools:text="Name : Card Host"/>
android:stretchColumns="1">
<TableRow>
<TextView style="@style/HostLabelStyle" android:text="Name"/>
<TextView style="@style/HostValueStyle"
android:text='@{": " + viewModel.hostName}'/>
</TableRow>
<TableRow>
<TextView style="@style/HostLabelStyle" android:text="TID"/>
<TextView style="@style/HostValueStyle"
android:text='@{": " + viewModel.tid}'/>
</TableRow>
<TableRow>
<TextView style="@style/HostLabelStyle" android:text="MID"/>
<TextView style="@style/HostValueStyle"
android:text='@{": " + viewModel.mid}'/>
</TableRow>
<TableRow>
<TextView style="@style/HostLabelStyle" android:text="Primary IP"/>
<TextView style="@style/HostValueStyle"
android:text='@{": " + viewModel.primaryIp}'/>
</TableRow>
<TableRow>
<TextView style="@style/HostLabelStyle" android:text="Primary Port"/>
<TextView style="@style/HostValueStyle"
android:text='@{": " + viewModel.primaryPort}'/>
</TableRow>
<TableRow>
<TextView style="@style/HostLabelStyle" android:text="Secondary IP"/>
<TextView style="@style/HostValueStyle"
android:text='@{": " + viewModel.secondaryIp}'/>
</TableRow>
<TableRow>
<TextView style="@style/HostLabelStyle" android:text="Secondary Port"/>
<TextView style="@style/HostValueStyle"
android:text='@{": " + viewModel.secondaryPort}'/>
</TableRow>
<TableRow>
<TextView style="@style/HostLabelStyle" android:text="Currency"/>
<TextView style="@style/HostValueStyle"
android:text='@{": " + viewModel.currencyCode}'/>
</TableRow>
</TableLayout>
<TextView
android:layout_width="match_parent"
android:text="--------------------------------------------------------------------------"
android:gravity="left"
android:paddingVertical="8dp"
android:layout_height="wrap_content"
android:text='@{"TID : " + viewModel.tid}'
android:fontFamily="@font/rubik_regular"
android:textSize="14sp"
android:textStyle="bold"
tools:text="TID : 12345678"/>
android:layout_width="match_parent"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text='@{"MID : " + viewModel.mid}'
android:fontFamily="@font/rubik_regular"
android:textSize="14sp"
android:textStyle="bold"
tools:text="MID : 123456789876543"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text='@{"PRIMARY IP : " + viewModel.primaryIp}'
android:fontFamily="@font/rubik_regular"
android:textSize="14sp"
android:textStyle="bold"
tools:text="PRIMARY IP : primaryidport.com"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text='@{"PRIMARY PORT : " + viewModel.primaryPort}'
android:fontFamily="@font/rubik_regular"
android:textSize="14sp"
android:textStyle="bold"
tools:text="PRIMARY PORT : 8080"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text='@{"SECONDARY IP : " + viewModel.secondaryIp}'
android:fontFamily="@font/rubik_regular"
android:textSize="14sp"
android:textStyle="bold"
tools:text="SECONDARY IP : secondaryidport.com"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text='@{"SECONDARY PORT : " + viewModel.secondaryPort}'
android:fontFamily="@font/rubik_regular"
android:textSize="14sp"
android:textStyle="bold"
tools:text="SECONDARY PORT : 8080"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text='@{"CURRENCY CODE : " + viewModel.currencyCode}'
android:fontFamily="@font/rubik_regular"
android:textSize="14sp"
android:textStyle="bold"
tools:text="CURRENCY CODE : MMK"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="*************************************************"
android:paddingTop="8dp"
android:paddingBottom="8dp"
tools:text="********************************************************"/>
<!-- SECONDARY HOST -->
<!-- ===== SECONDARY HOST ===== -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility='@{!viewModel.secHostName.isEmpty() ? View.VISIBLE : View.GONE}'
android:visibility='@{!TextUtils.isEmpty(viewModel.secHostName) ? View.VISIBLE : View.GONE}'
tools:visibility="visible">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="SECONDARY HOST"
android:fontFamily="@font/rubik_regular"
android:textSize="14sp"
style="@style/HostLabelStyle"
android:textStyle="bold"
tools:text="SECONDARY HOST"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text='@{"Name : " + viewModel.secHostName}'
android:fontFamily="@font/rubik_regular"
android:textSize="14sp"
android:textStyle="bold"
tools:text="Name : QR Host"/>
<!-- <TextView-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:text='@{"TID : " + viewModel.secHostTid}'-->
<!-- android:fontFamily="@font/rubik_regular"-->
<!-- android:textSize="14sp"-->
<!-- android:textStyle="bold"-->
<!-- tools:text="TID : 87654321"/>-->
<!-- <TextView-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:text='@{"MID : " + viewModel.secHostMid}'-->
<!-- android:fontFamily="@font/rubik_regular"-->
<!-- android:textSize="14sp"-->
<!-- android:textStyle="bold"-->
<!-- tools:text="MID : 987654321012345"/>-->
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text='@{"SHORT CODE : " + viewModel.shortCode}'
android:fontFamily="@font/rubik_regular"
android:textSize="14sp"
android:textStyle="bold"
tools:text="SHORT CODE : 12345678987"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text='@{"Primary Ip : " + viewModel.secHostPrimaryIp}'
android:fontFamily="@font/rubik_regular"
android:textSize="14sp"
android:textStyle="bold"
tools:text="Primary Ip : 10.10.10.10"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text='@{"Primary Port : " + viewModel.secHostPrimaryPort}'
android:fontFamily="@font/rubik_regular"
android:textSize="14sp"
android:textStyle="bold"
tools:text="Primary Port : 5000"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text='@{"Secondary Ip : " + viewModel.secHostSecondaryIp}'
android:fontFamily="@font/rubik_regular"
android:textSize="14sp"
android:textStyle="bold"
tools:text="Secondary Ip : 10.10.10.11"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text='@{"Secondary Port : " + viewModel.secHostSecondaryPort}'
android:fontFamily="@font/rubik_regular"
android:textSize="14sp"
android:textStyle="bold"
tools:text="Secondary Port : 5001"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text='@{"Currency Code : " + viewModel.currencyCode}'
android:fontFamily="@font/rubik_regular"
android:textSize="14sp"
android:textStyle="bold"
tools:text="Currency Code : MMK"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="*************************************************"
android:paddingTop="8dp"
android:paddingBottom="8dp"
tools:text="********************************************************"/>
android:layout_height="wrap_content"
android:layout_width="match_parent"/>
</LinearLayout>
<LinearLayout
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
tools:visibility="visible">
android:stretchColumns="1">
<TableRow>
<TextView style="@style/HostLabelStyle" android:text="Name"/>
<TextView style="@style/HostValueStyle"
android:text='@{": " + viewModel.secHostName}'/>
</TableRow>
<TableRow>
<TextView style="@style/HostLabelStyle" android:text="Short Code"/>
<TextView style="@style/HostValueStyle"
android:text='@{": " + viewModel.shortCode}'/>
</TableRow>
<TableRow>
<TextView style="@style/HostLabelStyle" android:text="Primary IP"/>
<TextView style="@style/HostValueStyle"
android:text='@{": " + viewModel.secHostPrimaryIp}'/>
</TableRow>
<TableRow>
<TextView style="@style/HostLabelStyle" android:text="Primary Port"/>
<TextView style="@style/HostValueStyle"
android:text='@{": " + viewModel.secHostPrimaryPort}'/>
</TableRow>
<TableRow>
<TextView style="@style/HostLabelStyle" android:text="Secondary IP"/>
<TextView style="@style/HostValueStyle"
android:text='@{": " + viewModel.secHostSecondaryIp}'/>
</TableRow>
<TableRow>
<TextView style="@style/HostLabelStyle" android:text="Secondary Port"/>
<TextView style="@style/HostValueStyle"
android:text='@{": " + viewModel.secHostSecondaryPort}'/>
</TableRow>
<TableRow>
<TextView style="@style/HostLabelStyle" android:text="Currency"/>
<TextView style="@style/HostValueStyle"
android:text='@{": " + viewModel.currencyCode}'/>
</TableRow>
</TableLayout>
<TextView
android:layout_width="match_parent"
android:text="--------------------------------------------------------------------------"
android:gravity="left"
android:paddingVertical="8dp"
android:layout_height="wrap_content"
android:layout_width="match_parent"/>
</LinearLayout>
<!-- ===== APP VERSION ===== -->
<TextView
android:text='@{"App Version : " + viewModel.appVersion}'
android:fontFamily="@font/rubik_regular"
android:textSize="14sp"
android:textStyle="bold"
tools:text="App Version : 1.0"/>
</LinearLayout>
style="@style/HostLabelStyle"
android:fontFamily="@font/rubik_regular"
android:layout_height="wrap_content"
android:layout_width="match_parent"/>
</LinearLayout>
</ScrollView>
</FrameLayout>
</androidx.cardview.widget.CardView>
<!-- ACTION BUTTONS -->
<!-- ================= BUTTONS ================= -->
<LinearLayout
android:id="@+id/actionButtons"
android:layout_width="match_parent"
@ -356,8 +269,7 @@
android:onClick="@{()-> click.onCancel()}"
android:background="@drawable/bg_rounded_btn_cancel_cv"
android:textColor="@color/colorPrimary"
android:textStyle="bold"
tools:text="Cancel"/>
android:textStyle="bold"/>
<Button
android:layout_width="0dp"
@ -368,8 +280,7 @@
android:onClick="@{()-> click.onPrint()}"
android:background="@drawable/bg_rounded_btn_cv"
android:textColor="@color/white"
android:textStyle="bold"
tools:text="Print"/>
android:textStyle="bold"/>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingVertical="2dp">
<!-- LABEL -->
<TextView
android:id="@+id/tvLabel"
android:layout_width="120dp"
android:layout_height="wrap_content"
android:text="Label"
android:textSize="14sp"
android:textStyle="bold"
android:fontFamily="@font/rubik_regular"/>
<!-- COLON -->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" : "
android:textSize="14sp"
android:textStyle="bold"
android:fontFamily="@font/rubik_regular"/>
<!-- VALUE -->
<TextView
android:id="@+id/tvValue"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Value"
android:textSize="14sp"
android:textStyle="bold"
android:fontFamily="@font/rubik_regular"/>
</LinearLayout>

View File

@ -94,4 +94,21 @@
<item name="android:textColor">@color/colorPrimary</item>
</style>
<style name="HostLabelStyle">
<item name="android:layout_width">110dp</item> <item name="android:layout_height">wrap_content</item>
<item name="android:fontFamily">@font/rubik_regular</item>
<item name="android:textSize">14sp</item>
<item name="android:textStyle">bold</item>
<item name="android:textColor">#000000</item>
</style>
<style name="HostValueStyle">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:fontFamily">@font/rubik_regular</item>
<item name="android:textSize">14sp</item>
<item name="android:textStyle">bold</item>
<item name="android:textColor">#000000</item>
</style>
</resources>