diff --git a/app/changelog.md b/app/changelog.md index 69ea3f3..b5f48c2 100644 --- a/app/changelog.md +++ b/app/changelog.md @@ -18,4 +18,16 @@ * amount, date, time fixed in Void Preview * show reversal status in trans records * error_slip_print enable/disable in tms -* auto_settlement enable/disable in tms \ No newline at end of file +* auto_settlement enable/disable in tms + +### version 3.5 +* "always with you" in mob receipt logo +* "..." full width in both P2 and P3 preview screens +* JCB logo added in Card Capture Screen +* "-" in void, refund and cash adv amounts +* disable sale button if amount is 0 or 0.00 +* changed date formats to dd/mm/yy to dd/mm/yyyy +* changed keyboard design in reprint any transactions + +### version 3.6 +* auto-settlement for both P2 and P3 \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index fe77493..f1076b0 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -23,6 +23,7 @@ + @@ -43,6 +44,11 @@ android:supportsRtl="true" android:theme="@style/Theme.MOBPOS"> + + + + + = Build.VERSION_CODES.S && !alarmManager.canScheduleExactAlarms() ) { + return scheduleFallback(context) + } + + val calendar = nextAlarmCalendar() ?: return false + val pendingIntent = alarmPendingIntent(context) + + alarmManager.setExactAndAllowWhileIdle( + AlarmManager.RTC_WAKEUP, + calendar.timeInMillis, + pendingIntent + ) + + return true + } + + fun scheduleFallback(context: Context): Boolean { + if (!SystemParamsOperation.getInstance().isAutoSettlement()) { + cancel(context) return false } - val configuredTime = parseTime( -// SystemParamsOperation.getInstance().clearBatchTime - "21:35:00" - ) ?: parseTime(FALLBACK_ALERT_TIME)!! + val alarmManager = + context.getSystemService(Context.ALARM_SERVICE) as AlarmManager - val calendar = Calendar.getInstance().apply { + val calendar = nextAlarmCalendar() ?: return false + val pendingIntent = alarmPendingIntent(context) + + alarmManager.setAndAllowWhileIdle( + AlarmManager.RTC_WAKEUP, + calendar.timeInMillis, + pendingIntent + ) + + return true + } + + private fun nextAlarmCalendar(): Calendar? { + val configuredTime = parseTime( + SystemParamsOperation.getInstance().clearBatchTime +// "15:45:00" + ) ?: parseTime(FALLBACK_ALERT_TIME) ?: return null + + return Calendar.getInstance().apply { set(Calendar.HOUR_OF_DAY, configuredTime.first) set(Calendar.MINUTE, configuredTime.second) set(Calendar.SECOND, configuredTime.third) @@ -42,30 +77,18 @@ object SettlementScheduler { add(Calendar.DAY_OF_MONTH, 1) } } + } + private fun alarmPendingIntent(context: Context): PendingIntent { + val intent = Intent(context, AlarmReceiver::class.java) - val intent = Intent( + return PendingIntent.getBroadcast( context, - AlarmReceiver::class.java - ) - - - val pendingIntent = PendingIntent.getBroadcast( - context, - 100, + REQUEST_CODE, intent, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE ) - - - alarmManager.setExactAndAllowWhileIdle( - AlarmManager.RTC_WAKEUP, - calendar.timeInMillis, - pendingIntent - ) - - return true } private fun parseTime(value: String): Triple? { diff --git a/app/src/main/java/com/mob/utsmyanmar/ui/dashboard/DashboardScreen.kt b/app/src/main/java/com/mob/utsmyanmar/ui/dashboard/DashboardScreen.kt index 2c596c5..3b87b9a 100644 --- a/app/src/main/java/com/mob/utsmyanmar/ui/dashboard/DashboardScreen.kt +++ b/app/src/main/java/com/mob/utsmyanmar/ui/dashboard/DashboardScreen.kt @@ -3,6 +3,8 @@ package com.mob.utsmyanmar.ui.dashboard import android.os.Build import android.os.Handler import android.os.Looper +import androidmads.library.qrgenearator.QRGContents +import androidmads.library.qrgenearator.QRGEncoder import androidx.annotation.RequiresApi import androidx.compose.foundation.Image import androidx.compose.foundation.background @@ -46,6 +48,7 @@ import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip +import androidx.compose.ui.graphics.asImageBitmap import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.res.painterResource import androidx.compose.ui.text.font.FontWeight @@ -359,6 +362,38 @@ fun DashboardScreen2( trailingIcon = {}, ) + Spacer(modifier = Modifier.height(16.dp)) + val adUrl = "https://www.mobmyanmar.com/" + val qrBitmap = remember { + runCatching { + val encoder = QRGEncoder(adUrl, null, QRGContents.Type.TEXT, 256) + encoder.colorBlack = android.graphics.Color.BLACK + encoder.colorWhite = android.graphics.Color.WHITE + encoder.bitmap.asImageBitmap() + }.getOrNull() + } + qrBitmap?.let { bitmap -> + Column( + horizontalAlignment = Alignment.CenterHorizontally, + modifier = Modifier + .fillMaxWidth() + .padding(horizontal = 16.dp) + ) { + Image( + bitmap = bitmap, + contentDescription = "Scan for User Guide", + modifier = Modifier.size(150.dp) + ) + Spacer(modifier = Modifier.height(4.dp)) + Text( + text = "Scan for Offers", + style = MaterialTheme.typography.labelSmall, + color = Color.Gray + ) + } + } + Spacer(modifier = Modifier.height(8.dp)) + Spacer(modifier = Modifier.weight(1f)) Text( text = "v${BuildConfig.VERSION_NAME}", diff --git a/app/src/main/java/com/mob/utsmyanmar/ui/navigation/AppNavGraph.kt b/app/src/main/java/com/mob/utsmyanmar/ui/navigation/AppNavGraph.kt index a2bc36e..8d639cd 100644 --- a/app/src/main/java/com/mob/utsmyanmar/ui/navigation/AppNavGraph.kt +++ b/app/src/main/java/com/mob/utsmyanmar/ui/navigation/AppNavGraph.kt @@ -436,7 +436,14 @@ fun AppNavGraph( SettlementScreen( sharedViewModel = sharedViewModel, settlementViewMode = settlementViewMode, - onBack = { navController.popBackStack(Routes.Dashboard.route,false) }, + onBack = { + onAutoSettlementHandled() + if (!navController.popBackStack(Routes.Dashboard.route, false)) { + navController.navigate(Routes.Dashboard.route) { + launchSingleTop = true + } + } + }, autoStartSettlement = autoSettlementRequested, onStartSettlement = { sharedViewModel.transactionsType.value = TransactionsType.SETTLEMENT