disable screen

This commit is contained in:
moon 2026-07-10 15:04:21 +06:30
parent 48513f8da9
commit 80594be6f9
3 changed files with 36 additions and 9 deletions

View File

@ -5,9 +5,6 @@ plugins {
id("com.google.dagger.hilt.android") id("com.google.dagger.hilt.android")
} }
// Set default build variant
project.ext.set("android.defaultPublishConfig", "uatDebug")
android { android {
namespace = "com.mob.utsmyanmar" namespace = "com.mob.utsmyanmar"
compileSdk { compileSdk {
@ -62,6 +59,14 @@ android {
"proguard-rules.pro" "proguard-rules.pro"
) )
} }
debug {
isMinifyEnabled = false
isDebuggable = true
// proguardFiles(
// getDefaultProguardFile("proguard-android-optimize.txt"),
// "proguard-rules.pro"
// )
}
} }
compileOptions { compileOptions {
sourceCompatibility = JavaVersion.VERSION_11 sourceCompatibility = JavaVersion.VERSION_11

View File

@ -120,12 +120,25 @@ fun AppNavGraph(
deviceInfoViewModel.loadDeviceInfo() deviceInfoViewModel.loadDeviceInfo()
} }
val tmsSetupUiState by tmsSetupViewModel.uiState.collectAsStateWithLifecycle()
LaunchedEffect(tmsSetupViewModel) { LaunchedEffect(tmsSetupViewModel) {
tmsSetupViewModel.onSyncCompleted.collect { tmsSetupViewModel.onSyncCompleted.collect {
dashboardViewModel.refreshLastSyncTime() dashboardViewModel.refreshLastSyncTime()
} }
} }
LaunchedEffect(tmsSetupUiState.isTerminalDisabled) {
if (tmsSetupUiState.isTerminalDisabled) {
navController.navigate(Routes.TmsSetup.route) {
popUpTo(Routes.Dashboard.route) {
inclusive = true
}
launchSingleTop = true
}
}
}
transProcessViewModel.resetTransactionStatus() transProcessViewModel.resetTransactionStatus()
DashboardScreen2( DashboardScreen2(
dashboardUiState = dashboardUiState, dashboardUiState = dashboardUiState,

View File

@ -2,6 +2,7 @@ package com.mob.utsmyanmar.ui.tms_setup
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.content.Context import android.content.Context
import androidx.core.content.edit
import androidx.lifecycle.ViewModel import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope import androidx.lifecycle.viewModelScope
import com.mob.utsmyanmar.model.sirius.SiriusResponse import com.mob.utsmyanmar.model.sirius.SiriusResponse
@ -48,7 +49,7 @@ class TmsSetupViewModel @Inject constructor(
private val emvParamOperation: EmvParamOperation, private val emvParamOperation: EmvParamOperation,
@ApplicationContext private val context: Context @ApplicationContext private val context: Context
) : ViewModel() { ) : ViewModel() {
private val TAG = TmsSetupViewModel::class.simpleName;
private val _uiState = MutableStateFlow(TmsSetupUiState()) private val _uiState = MutableStateFlow(TmsSetupUiState())
private val _dashboardUiState = MutableStateFlow(DashboardUiState()) private val _dashboardUiState = MutableStateFlow(DashboardUiState())
val uiState: StateFlow<TmsSetupUiState> = _uiState.asStateFlow() val uiState: StateFlow<TmsSetupUiState> = _uiState.asStateFlow()
@ -144,19 +145,27 @@ class TmsSetupViewModel @Inject constructor(
val ops = SystemParamsOperation.getInstance() val ops = SystemParamsOperation.getInstance()
if (!ops.isActive) { if (!ops.isActive) {
LogUtil.d(TAG, "isActive ${ops.isActive}")
val msg = ops.disabledMsg.takeIf { it.isNotEmpty() } val msg = ops.disabledMsg.takeIf { it.isNotEmpty() }
?: "This terminal has been disabled. Please contact your administrator." ?: "This terminal has been disabled. Please contact your administrator."
_uiState.update { it.copy(isLoading = false) } _uiState.update {
viewModelScope.launch { _navigateToDisable.emit(msg) } it.copy(
isLoading = false,
isError = true,
isTerminalDisabled = true,
statusText = "Terminal Disabled",
errorMessage = msg
)
}
return return
} }
val validity = TMSUtil.getInstance().checkParams() val validity = TMSUtil.getInstance().checkParams()
if (validity.status == ValidityStatus.SUCCESS) { if (validity.status == ValidityStatus.SUCCESS) {
context.getSharedPreferences("mobpos_prefs", Context.MODE_PRIVATE) context.getSharedPreferences("mobpos_prefs", Context.MODE_PRIVATE)
.edit() .edit {
.putLong("last_sync_time", System.currentTimeMillis()) putLong("last_sync_time", System.currentTimeMillis())
.apply() }
_uiState.update { it.copy(isLoading = false, statusText = "Ready.") } _uiState.update { it.copy(isLoading = false, statusText = "Ready.") }
viewModelScope.launch { viewModelScope.launch {
_onSyncCompleted.emit(Unit) _onSyncCompleted.emit(Unit)