diff --git a/app/changelog.md b/app/changelog.md
index 9da2a5f..8fad3b2 100644
--- a/app/changelog.md
+++ b/app/changelog.md
@@ -7,4 +7,8 @@
* Amount and Card Number show in signature pad
* fixed recent transaction only working for top 3
* routed to dashboard after printing receipt
-* receipt printing animation re-scale
\ No newline at end of file
+* receipt printing animation re-scale
+*
+### version 3.4
+* disable display always on
+* auto-settlement
\ No newline at end of file
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 4c31a32..68dac2f 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -19,6 +19,7 @@
+
@@ -39,7 +40,7 @@
android:supportsRtl="true"
android:theme="@style/Theme.MOBPOS">
-
+
= Build.VERSION_CODES.O){
+ private fun startForegroundNotification() {
+ LogUtil.d(AutoSettleService::class.java.simpleName, "foreground noti called")
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
val channel = NotificationChannel(
CHANNEL_ID,
"AUTO SETTLEMENT",
- NotificationManager.IMPORTANCE_LOW
+ NotificationManager.IMPORTANCE_HIGH
)
+ channel.description = "Auto Settlement notification"
+ channel.enableVibration(true)
+ channel.setSound(
+ RingtoneManager.getDefaultUri(
+ RingtoneManager.TYPE_NOTIFICATION
+ ), AudioAttributes.Builder().setUsage(AudioAttributes.USAGE_NOTIFICATION).build()
+ )
+ val manager = getSystemService(NotificationManager::class.java)
manager?.createNotificationChannel(channel)
}
@@ -59,6 +70,7 @@ class AutoSettleService : Service(){
.setSmallIcon(R.drawable.logo_mob)
.setContentTitle("Auto Settlement")
.setContentText("Processing...")
+ .setPriority(NotificationCompat.PRIORITY_HIGH)
.build()
startForeground(NOTIFICATION_ID, notification)
diff --git a/app/src/main/java/com/mob/utsmyanmar/auto_settlement/SettlementScheduler.kt b/app/src/main/java/com/mob/utsmyanmar/auto_settlement/SettlementScheduler.kt
new file mode 100644
index 0000000..fc1b38b
--- /dev/null
+++ b/app/src/main/java/com/mob/utsmyanmar/auto_settlement/SettlementScheduler.kt
@@ -0,0 +1,84 @@
+package com.mob.utsmyanmar.auto_settlement
+
+import android.Manifest
+import android.annotation.SuppressLint
+import android.app.AlarmManager
+import android.app.PendingIntent
+import android.content.Context
+import android.content.Intent
+import androidx.annotation.RequiresPermission
+import java.util.Calendar
+
+object SettlementScheduler {
+
+ @RequiresPermission(Manifest.permission.SCHEDULE_EXACT_ALARM)
+ fun schedule(context: Context) {
+
+ val calendar = Calendar.getInstance().apply {
+
+ // Auto settlement time
+ set(Calendar.HOUR_OF_DAY, 1)
+ set(Calendar.MINUTE, 10)
+ set(Calendar.SECOND, 0)
+
+
+ if (before(Calendar.getInstance())) {
+ add(Calendar.DAY_OF_MONTH, 1)
+ }
+ }
+
+
+ val alarmManager =
+ context.getSystemService(Context.ALARM_SERVICE)
+ as AlarmManager
+
+
+ val intent = Intent(
+ context,
+ AlarmReceiver::class.java
+ )
+
+
+ val pendingIntent = PendingIntent.getBroadcast(
+ context,
+ 100,
+ intent,
+ PendingIntent.FLAG_UPDATE_CURRENT or
+ PendingIntent.FLAG_IMMUTABLE
+ )
+
+
+ alarmManager.setExactAndAllowWhileIdle(
+ AlarmManager.RTC_WAKEUP,
+ calendar.timeInMillis,
+ pendingIntent
+ )
+ }
+
+
+ @SuppressLint("ServiceCast")
+ fun cancel(context: Context) {
+
+ val alarmManager =
+ context.getSystemService(Context.ALARM_SERVICE)
+ as AlarmManager
+
+
+ val intent = Intent(
+ context,
+ AlarmReceiver::class.java
+ )
+
+
+ val pendingIntent = PendingIntent.getBroadcast(
+ context,
+ 100,
+ intent,
+ PendingIntent.FLAG_UPDATE_CURRENT or
+ PendingIntent.FLAG_IMMUTABLE
+ )
+
+
+ alarmManager.cancel(pendingIntent)
+ }
+}
\ No newline at end of file