Loading app/src/main/java/it/lavermicocca/giacomo/beautifulnotification/HelperMessages.kt +14 −15 Changes for app/src/main/java/it/lavermicocca/giacomo/beautifulnotification/HelperMessages.kt: 14 added lines, 15 removed lines. Original line number Original line Diff line number Diff line package it.lavermicocca.giacomo.beautifulnotification package it.lavermicocca.giacomo.beautifulnotification import android.util.Log import android.util.Log import it.lavermicocca.giacomo.beautifulnotification.mappers.Arguments class HelperMessages{ class HelperMessages{ enum class STATUS { UNKNOWN, TIMEOUT, GARAGE_OPEN, GARAGE_CLOSE, BRIGHTNESS } enum class STATUS { UNKNOWN, TIMEOUT, GARAGE_OPENED, GARAGE_CLOSED, BRIGHTNESS, CANCELLO_OPEN_RESPONSE, GARAGE_OPEN_RESPONSE, LED_ACCESO } fun Do(messaggio: String) : STATUS{ fun Do(messaggio: String) : STATUS{ when(messaggio) { if(messaggio.contains("L.C. : p : 21", true)){ "L.C. : r : 37 1"-> { return STATUS.GARAGE_OPEN_RESPONSE } else if(messaggio.contains("L.C. : p : 17", true)){ return STATUS.CANCELLO_OPEN_RESPONSE } else if(messaggio.contains("L.C. : p : 13", true)){ return STATUS.LED_ACCESO } else if(messaggio.contains("L.C. : r : 37 1", true)){ Log.e("TTAG", "UNO") Log.e("TTAG", "UNO") return STATUS.GARAGE_OPEN return STATUS.GARAGE_OPENED } } else if (messaggio.contains("L.C. : r : 37 0", true)){ "L.C. : r : 37 0"-> { Log.e("TTAG", "ZERO") Log.e("TTAG", "ZERO") return STATUS.GARAGE_CLOSE return STATUS.GARAGE_CLOSED } } else if(messaggio.contains("Timeout command", true)){ "Timeout command" -> { Log.e("TTAG", "Timeout") Log.e("TTAG", "Timeout") return STATUS.TIMEOUT return STATUS.TIMEOUT } } else if(messaggio.contains("L.C. : b ")) } if(messaggio.contains("L.C. : b ")) { { return STATUS.BRIGHTNESS return STATUS.BRIGHTNESS } } Loading app/src/main/java/it/lavermicocca/giacomo/beautifulnotification/Sender.kt +27 −23 Changes for app/src/main/java/it/lavermicocca/giacomo/beautifulnotification/Sender.kt: 27 added lines, 23 removed lines. Original line number Original line Diff line number Diff line Loading @@ -9,7 +9,6 @@ import android.widget.Toast import it.lavermicocca.giacomo.beautifulnotification.mappers.Arguments import it.lavermicocca.giacomo.beautifulnotification.mappers.Arguments import it.lavermicocca.giacomo.beautifulnotification.services.Helper import it.lavermicocca.giacomo.beautifulnotification.services.Helper import okhttp3.* import okhttp3.* import unsigned.Ubyte import java.io.IOException import java.io.IOException class Sender(val context: Context) { class Sender(val context: Context) { Loading Loading @@ -56,7 +55,6 @@ class Sender(val context: Context) { //UNO //UNO fun SendPin(pin: Int) { fun SendPin(pin: Int) { Helper.StartForegroundServiceNotification(context, "CANCELLO/GARAGE IN APERTURA...", Helper.FULL_ON) val prf = context.getSharedPreferences("myPref", Context.MODE_PRIVATE) val prf = context.getSharedPreferences("myPref", Context.MODE_PRIVATE) Loading @@ -71,8 +69,6 @@ class Sender(val context: Context) { val client = OkHttpClient() val client = OkHttpClient() Helper.StartForegroundServiceNotification(context, "${Arguments.PIN} $pin", Helper.FULL_ON) client.newCall(request).enqueue(object : Callback { client.newCall(request).enqueue(object : Callback { override fun onFailure(call: Call, e: IOException) { override fun onFailure(call: Call, e: IOException) { e.printStackTrace() e.printStackTrace() Loading Loading @@ -132,10 +128,13 @@ class Sender(val context: Context) { override fun run() { override fun run() { //TODO("not implemented") //To change body of created functions use File | Settings | File Templates. //TODO("not implemented") //To change body of created functions use File | Settings | File Templates. Toast.makeText(context, networkResp, Toast.LENGTH_LONG).show() Toast.makeText(context, networkResp, Toast.LENGTH_LONG).show() if(networkResp.contains(Arguments.PIN, true)) //Helper.StartForegroundServiceNotification(context, networkResp, Helper.FULL_ON) if(networkResp.contains(Arguments.BRIGHTNESS, true)) { { Log.e("TTAG", "RICHIESTA PIN") Log.e("TTAG", "RICHIESTA PIN") SendCheck(false) //SendCheck(false) } } } } }) }) Loading Loading @@ -189,7 +188,7 @@ class Sender(val context: Context) { //DUE //DUE fun SendCheck(oneShot:Boolean) { fun SendCheck(oneShot:Boolean) { Thread.sleep(1000); Thread.sleep(3000); val prf = context.getSharedPreferences("myPref", Context.MODE_PRIVATE) val prf = context.getSharedPreferences("myPref", Context.MODE_PRIVATE) val ipServer = prf.getString("ip_server", "192.168.43.176") val ipServer = prf.getString("ip_server", "192.168.43.176") Loading @@ -216,26 +215,31 @@ class Sender(val context: Context) { if(status == HelperMessages.STATUS.TIMEOUT) { if(status == HelperMessages.STATUS.TIMEOUT) { Helper.StartForegroundServiceNotification(context, "TIMEOUT su CHECK", Helper.FULL_ON_STOP_PROGRESS) Helper.StartForegroundServiceNotification(context, "TIMEOUT su CHECK", Helper.FULL_ON_STOP_PROGRESS) } else if(status == HelperMessages.STATUS.GARAGE_CLOSED) { Helper.StartForegroundServiceNotification(context, "IL GARAGE É APERTO!", Helper.FULL_ON_STOP_PROGRESS) } else if(status == HelperMessages.STATUS.GARAGE_OPENED) { Helper.StartForegroundServiceNotification(context, "IL GARAGE É CHIUSO!", Helper.FULL_ON_STOP_PROGRESS) } else if(status == HelperMessages.STATUS.GARAGE_OPEN_RESPONSE) { Helper.StartForegroundServiceNotification(context, "GARAGE IN APERTURA...", Helper.FULL_ON_STOP_PROGRESS) } else if(status == HelperMessages.STATUS.CANCELLO_OPEN_RESPONSE) { Helper.StartForegroundServiceNotification(context, "CANCELLO IN APERTURA...", Helper.FULL_ON_STOP_PROGRESS) }else if(status == HelperMessages.STATUS.LED_ACCESO) { Helper.StartForegroundServiceNotification(context, "LUCE ACCESA!", Helper.FULL_ON_STOP_PROGRESS) } } else if(status == HelperMessages.STATUS.GARAGE_CLOSE) { else { Helper.StartForegroundServiceNotification(context, "GARAGE OPEN", Helper.FULL_ON_STOP_PROGRESS) } else if(status == HelperMessages.STATUS.GARAGE_OPEN) { Helper.StartForegroundServiceNotification(context, "GARAGE CLOSE", Helper.FULL_ON_STOP_PROGRESS) } else { Helper.StartForegroundServiceNotification(context, networkResp, Helper.FULL_ON_STOP_PROGRESS) Helper.StartForegroundServiceNotification(context, networkResp, Helper.FULL_ON_STOP_PROGRESS) } } if(!oneShot) // if(!oneShot) { // { var looper = Looper.getMainLooper() // var looper = Looper.getMainLooper() // Handler(looper).post(object :Runnable{ // Handler(looper).post(object :Runnable{ override fun run() { // override fun run() { CountD(networkResp) // CountD(networkResp) } // } }) // }) } // } } } }) }) } } Loading app/src/main/java/it/lavermicocca/giacomo/beautifulnotification/mappers/Arguments.kt +1 −0 Changes for app/src/main/java/it/lavermicocca/giacomo/beautifulnotification/mappers/Arguments.kt: 1 added line, 0 removed lines. Original line number Original line Diff line number Diff line Loading @@ -6,5 +6,6 @@ class Arguments{ var PIN = "pin" var PIN = "pin" var GPIO = "gpio" var GPIO = "gpio" var CHECK = "check" var CHECK = "check" var BRIGHTNESS = "brightness" } } } } app/src/main/java/it/lavermicocca/giacomo/beautifulnotification/notifications/GenericNotificationClass.kt +6 −2 Changes for app/src/main/java/it/lavermicocca/giacomo/beautifulnotification/notifications/GenericNotificationClass.kt: 6 added lines, 2 removed lines. Original line number Original line Diff line number Diff line Loading @@ -16,9 +16,9 @@ class GenericNotificationClass(val service: Service, val text : String, val stat private val builder:NotificationCompat.Builder private val builder:NotificationCompat.Builder private val notificationManager:NotificationManager private val notificationManager:NotificationManager private val notification:Notification private val notification:Notification private val CHANNEL_ID = "media_playback_channel" private val CHANNEL_ID = "my_channel" enum class STATUS {none, garage, cancello, all, portone, brightness, lastCommand} enum class STATUS {none, garage, cancello, all, portone, brightness, led, lastCommand} init { init { val ns = Context.NOTIFICATION_SERVICE val ns = Context.NOTIFICATION_SERVICE Loading Loading @@ -122,10 +122,14 @@ class GenericNotificationClass(val service: Service, val text : String, val stat prepareData(switchIntent, STATUS.portone) prepareData(switchIntent, STATUS.portone) val openClosePortone = PendingIntent.getBroadcast(service, STATUS.portone.ordinal, switchIntent, PendingIntent.FLAG_UPDATE_CURRENT) val openClosePortone = PendingIntent.getBroadcast(service, STATUS.portone.ordinal, switchIntent, PendingIntent.FLAG_UPDATE_CURRENT) prepareData(switchIntent, STATUS.led) val brightness = PendingIntent.getBroadcast(service, STATUS.led.ordinal, switchIntent, PendingIntent.FLAG_UPDATE_CURRENT) notificationView.setOnClickPendingIntent(R.id.last_command, lastCommand) notificationView.setOnClickPendingIntent(R.id.last_command, lastCommand) notificationView.setOnClickPendingIntent(R.id.open_close_garage, openCloseGarage) notificationView.setOnClickPendingIntent(R.id.open_close_garage, openCloseGarage) notificationView.setOnClickPendingIntent(R.id.open_close_cancello, openCloseCancello) notificationView.setOnClickPendingIntent(R.id.open_close_cancello, openCloseCancello) notificationView.setOnClickPendingIntent(R.id.open_close_portone, openClosePortone) notificationView.setOnClickPendingIntent(R.id.open_close_portone, openClosePortone) notificationView.setOnClickPendingIntent(R.id.brightness, brightness) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { val channel = NotificationChannel(CHANNEL_ID, "Channel beauty notification", NotificationManager.IMPORTANCE_HIGH) val channel = NotificationChannel(CHANNEL_ID, "Channel beauty notification", NotificationManager.IMPORTANCE_HIGH) Loading app/src/main/java/it/lavermicocca/giacomo/beautifulnotification/notifications/SwitchButtonListener.kt +18 −4 Changes for app/src/main/java/it/lavermicocca/giacomo/beautifulnotification/notifications/SwitchButtonListener.kt: 18 added lines, 4 removed lines. Original line number Original line Diff line number Diff line Loading @@ -4,7 +4,9 @@ import android.content.BroadcastReceiver import android.content.Context import android.content.Context import android.content.Intent import android.content.Intent import android.util.Log import android.util.Log import it.lavermicocca.giacomo.beautifulnotification.mappers.Arguments import it.lavermicocca.giacomo.beautifulnotification.notifications.GenericNotificationClass import it.lavermicocca.giacomo.beautifulnotification.notifications.GenericNotificationClass import it.lavermicocca.giacomo.beautifulnotification.services.Helper import unsigned.Ubyte import unsigned.Ubyte import unsigned.toUbyte import unsigned.toUbyte Loading @@ -26,11 +28,23 @@ class SwitchButtonListener : BroadcastReceiver() { )] )] when(status){ when(status){ GenericNotificationClass.STATUS.lastCommand -> sender.SendRead(37) GenericNotificationClass.STATUS.lastCommand -> { Helper.StartForegroundServiceNotification(context, "VERIFICA SE GARAGE è APERTO", Helper.FULL_OFF) sender.SendRead(37) } GenericNotificationClass.STATUS.portone -> sender.SendPinPortone() //17 GPIO pin locale GenericNotificationClass.STATUS.portone -> sender.SendPinPortone() //17 GPIO pin locale GenericNotificationClass.STATUS.cancello -> sender.SendPin(17) GenericNotificationClass.STATUS.cancello -> { GenericNotificationClass.STATUS.garage -> sender.SendPin(21) Helper.StartForegroundServiceNotification(context, "CANCELLO IN APERTURA...", Helper.FULL_OFF) sender.SendPin(17) } GenericNotificationClass.STATUS.garage -> { Helper.StartForegroundServiceNotification(context, "GARAGE IN APERTURA...", Helper.FULL_OFF) sender.SendPin(21) } GenericNotificationClass.STATUS.led -> { Helper.StartForegroundServiceNotification(context, "LUCE ACCESA...", Helper.FULL_OFF) sender.SendPin(13) } GenericNotificationClass.STATUS.brightness -> sender.SendBrightness(previousBrightness) GenericNotificationClass.STATUS.brightness -> sender.SendBrightness(previousBrightness) } } Loading Loading
app/src/main/java/it/lavermicocca/giacomo/beautifulnotification/HelperMessages.kt +14 −15 Changes for app/src/main/java/it/lavermicocca/giacomo/beautifulnotification/HelperMessages.kt: 14 added lines, 15 removed lines. Original line number Original line Diff line number Diff line package it.lavermicocca.giacomo.beautifulnotification package it.lavermicocca.giacomo.beautifulnotification import android.util.Log import android.util.Log import it.lavermicocca.giacomo.beautifulnotification.mappers.Arguments class HelperMessages{ class HelperMessages{ enum class STATUS { UNKNOWN, TIMEOUT, GARAGE_OPEN, GARAGE_CLOSE, BRIGHTNESS } enum class STATUS { UNKNOWN, TIMEOUT, GARAGE_OPENED, GARAGE_CLOSED, BRIGHTNESS, CANCELLO_OPEN_RESPONSE, GARAGE_OPEN_RESPONSE, LED_ACCESO } fun Do(messaggio: String) : STATUS{ fun Do(messaggio: String) : STATUS{ when(messaggio) { if(messaggio.contains("L.C. : p : 21", true)){ "L.C. : r : 37 1"-> { return STATUS.GARAGE_OPEN_RESPONSE } else if(messaggio.contains("L.C. : p : 17", true)){ return STATUS.CANCELLO_OPEN_RESPONSE } else if(messaggio.contains("L.C. : p : 13", true)){ return STATUS.LED_ACCESO } else if(messaggio.contains("L.C. : r : 37 1", true)){ Log.e("TTAG", "UNO") Log.e("TTAG", "UNO") return STATUS.GARAGE_OPEN return STATUS.GARAGE_OPENED } } else if (messaggio.contains("L.C. : r : 37 0", true)){ "L.C. : r : 37 0"-> { Log.e("TTAG", "ZERO") Log.e("TTAG", "ZERO") return STATUS.GARAGE_CLOSE return STATUS.GARAGE_CLOSED } } else if(messaggio.contains("Timeout command", true)){ "Timeout command" -> { Log.e("TTAG", "Timeout") Log.e("TTAG", "Timeout") return STATUS.TIMEOUT return STATUS.TIMEOUT } } else if(messaggio.contains("L.C. : b ")) } if(messaggio.contains("L.C. : b ")) { { return STATUS.BRIGHTNESS return STATUS.BRIGHTNESS } } Loading
app/src/main/java/it/lavermicocca/giacomo/beautifulnotification/Sender.kt +27 −23 Changes for app/src/main/java/it/lavermicocca/giacomo/beautifulnotification/Sender.kt: 27 added lines, 23 removed lines. Original line number Original line Diff line number Diff line Loading @@ -9,7 +9,6 @@ import android.widget.Toast import it.lavermicocca.giacomo.beautifulnotification.mappers.Arguments import it.lavermicocca.giacomo.beautifulnotification.mappers.Arguments import it.lavermicocca.giacomo.beautifulnotification.services.Helper import it.lavermicocca.giacomo.beautifulnotification.services.Helper import okhttp3.* import okhttp3.* import unsigned.Ubyte import java.io.IOException import java.io.IOException class Sender(val context: Context) { class Sender(val context: Context) { Loading Loading @@ -56,7 +55,6 @@ class Sender(val context: Context) { //UNO //UNO fun SendPin(pin: Int) { fun SendPin(pin: Int) { Helper.StartForegroundServiceNotification(context, "CANCELLO/GARAGE IN APERTURA...", Helper.FULL_ON) val prf = context.getSharedPreferences("myPref", Context.MODE_PRIVATE) val prf = context.getSharedPreferences("myPref", Context.MODE_PRIVATE) Loading @@ -71,8 +69,6 @@ class Sender(val context: Context) { val client = OkHttpClient() val client = OkHttpClient() Helper.StartForegroundServiceNotification(context, "${Arguments.PIN} $pin", Helper.FULL_ON) client.newCall(request).enqueue(object : Callback { client.newCall(request).enqueue(object : Callback { override fun onFailure(call: Call, e: IOException) { override fun onFailure(call: Call, e: IOException) { e.printStackTrace() e.printStackTrace() Loading Loading @@ -132,10 +128,13 @@ class Sender(val context: Context) { override fun run() { override fun run() { //TODO("not implemented") //To change body of created functions use File | Settings | File Templates. //TODO("not implemented") //To change body of created functions use File | Settings | File Templates. Toast.makeText(context, networkResp, Toast.LENGTH_LONG).show() Toast.makeText(context, networkResp, Toast.LENGTH_LONG).show() if(networkResp.contains(Arguments.PIN, true)) //Helper.StartForegroundServiceNotification(context, networkResp, Helper.FULL_ON) if(networkResp.contains(Arguments.BRIGHTNESS, true)) { { Log.e("TTAG", "RICHIESTA PIN") Log.e("TTAG", "RICHIESTA PIN") SendCheck(false) //SendCheck(false) } } } } }) }) Loading Loading @@ -189,7 +188,7 @@ class Sender(val context: Context) { //DUE //DUE fun SendCheck(oneShot:Boolean) { fun SendCheck(oneShot:Boolean) { Thread.sleep(1000); Thread.sleep(3000); val prf = context.getSharedPreferences("myPref", Context.MODE_PRIVATE) val prf = context.getSharedPreferences("myPref", Context.MODE_PRIVATE) val ipServer = prf.getString("ip_server", "192.168.43.176") val ipServer = prf.getString("ip_server", "192.168.43.176") Loading @@ -216,26 +215,31 @@ class Sender(val context: Context) { if(status == HelperMessages.STATUS.TIMEOUT) { if(status == HelperMessages.STATUS.TIMEOUT) { Helper.StartForegroundServiceNotification(context, "TIMEOUT su CHECK", Helper.FULL_ON_STOP_PROGRESS) Helper.StartForegroundServiceNotification(context, "TIMEOUT su CHECK", Helper.FULL_ON_STOP_PROGRESS) } else if(status == HelperMessages.STATUS.GARAGE_CLOSED) { Helper.StartForegroundServiceNotification(context, "IL GARAGE É APERTO!", Helper.FULL_ON_STOP_PROGRESS) } else if(status == HelperMessages.STATUS.GARAGE_OPENED) { Helper.StartForegroundServiceNotification(context, "IL GARAGE É CHIUSO!", Helper.FULL_ON_STOP_PROGRESS) } else if(status == HelperMessages.STATUS.GARAGE_OPEN_RESPONSE) { Helper.StartForegroundServiceNotification(context, "GARAGE IN APERTURA...", Helper.FULL_ON_STOP_PROGRESS) } else if(status == HelperMessages.STATUS.CANCELLO_OPEN_RESPONSE) { Helper.StartForegroundServiceNotification(context, "CANCELLO IN APERTURA...", Helper.FULL_ON_STOP_PROGRESS) }else if(status == HelperMessages.STATUS.LED_ACCESO) { Helper.StartForegroundServiceNotification(context, "LUCE ACCESA!", Helper.FULL_ON_STOP_PROGRESS) } } else if(status == HelperMessages.STATUS.GARAGE_CLOSE) { else { Helper.StartForegroundServiceNotification(context, "GARAGE OPEN", Helper.FULL_ON_STOP_PROGRESS) } else if(status == HelperMessages.STATUS.GARAGE_OPEN) { Helper.StartForegroundServiceNotification(context, "GARAGE CLOSE", Helper.FULL_ON_STOP_PROGRESS) } else { Helper.StartForegroundServiceNotification(context, networkResp, Helper.FULL_ON_STOP_PROGRESS) Helper.StartForegroundServiceNotification(context, networkResp, Helper.FULL_ON_STOP_PROGRESS) } } if(!oneShot) // if(!oneShot) { // { var looper = Looper.getMainLooper() // var looper = Looper.getMainLooper() // Handler(looper).post(object :Runnable{ // Handler(looper).post(object :Runnable{ override fun run() { // override fun run() { CountD(networkResp) // CountD(networkResp) } // } }) // }) } // } } } }) }) } } Loading
app/src/main/java/it/lavermicocca/giacomo/beautifulnotification/mappers/Arguments.kt +1 −0 Changes for app/src/main/java/it/lavermicocca/giacomo/beautifulnotification/mappers/Arguments.kt: 1 added line, 0 removed lines. Original line number Original line Diff line number Diff line Loading @@ -6,5 +6,6 @@ class Arguments{ var PIN = "pin" var PIN = "pin" var GPIO = "gpio" var GPIO = "gpio" var CHECK = "check" var CHECK = "check" var BRIGHTNESS = "brightness" } } } }
app/src/main/java/it/lavermicocca/giacomo/beautifulnotification/notifications/GenericNotificationClass.kt +6 −2 Changes for app/src/main/java/it/lavermicocca/giacomo/beautifulnotification/notifications/GenericNotificationClass.kt: 6 added lines, 2 removed lines. Original line number Original line Diff line number Diff line Loading @@ -16,9 +16,9 @@ class GenericNotificationClass(val service: Service, val text : String, val stat private val builder:NotificationCompat.Builder private val builder:NotificationCompat.Builder private val notificationManager:NotificationManager private val notificationManager:NotificationManager private val notification:Notification private val notification:Notification private val CHANNEL_ID = "media_playback_channel" private val CHANNEL_ID = "my_channel" enum class STATUS {none, garage, cancello, all, portone, brightness, lastCommand} enum class STATUS {none, garage, cancello, all, portone, brightness, led, lastCommand} init { init { val ns = Context.NOTIFICATION_SERVICE val ns = Context.NOTIFICATION_SERVICE Loading Loading @@ -122,10 +122,14 @@ class GenericNotificationClass(val service: Service, val text : String, val stat prepareData(switchIntent, STATUS.portone) prepareData(switchIntent, STATUS.portone) val openClosePortone = PendingIntent.getBroadcast(service, STATUS.portone.ordinal, switchIntent, PendingIntent.FLAG_UPDATE_CURRENT) val openClosePortone = PendingIntent.getBroadcast(service, STATUS.portone.ordinal, switchIntent, PendingIntent.FLAG_UPDATE_CURRENT) prepareData(switchIntent, STATUS.led) val brightness = PendingIntent.getBroadcast(service, STATUS.led.ordinal, switchIntent, PendingIntent.FLAG_UPDATE_CURRENT) notificationView.setOnClickPendingIntent(R.id.last_command, lastCommand) notificationView.setOnClickPendingIntent(R.id.last_command, lastCommand) notificationView.setOnClickPendingIntent(R.id.open_close_garage, openCloseGarage) notificationView.setOnClickPendingIntent(R.id.open_close_garage, openCloseGarage) notificationView.setOnClickPendingIntent(R.id.open_close_cancello, openCloseCancello) notificationView.setOnClickPendingIntent(R.id.open_close_cancello, openCloseCancello) notificationView.setOnClickPendingIntent(R.id.open_close_portone, openClosePortone) notificationView.setOnClickPendingIntent(R.id.open_close_portone, openClosePortone) notificationView.setOnClickPendingIntent(R.id.brightness, brightness) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { val channel = NotificationChannel(CHANNEL_ID, "Channel beauty notification", NotificationManager.IMPORTANCE_HIGH) val channel = NotificationChannel(CHANNEL_ID, "Channel beauty notification", NotificationManager.IMPORTANCE_HIGH) Loading
app/src/main/java/it/lavermicocca/giacomo/beautifulnotification/notifications/SwitchButtonListener.kt +18 −4 Changes for app/src/main/java/it/lavermicocca/giacomo/beautifulnotification/notifications/SwitchButtonListener.kt: 18 added lines, 4 removed lines. Original line number Original line Diff line number Diff line Loading @@ -4,7 +4,9 @@ import android.content.BroadcastReceiver import android.content.Context import android.content.Context import android.content.Intent import android.content.Intent import android.util.Log import android.util.Log import it.lavermicocca.giacomo.beautifulnotification.mappers.Arguments import it.lavermicocca.giacomo.beautifulnotification.notifications.GenericNotificationClass import it.lavermicocca.giacomo.beautifulnotification.notifications.GenericNotificationClass import it.lavermicocca.giacomo.beautifulnotification.services.Helper import unsigned.Ubyte import unsigned.Ubyte import unsigned.toUbyte import unsigned.toUbyte Loading @@ -26,11 +28,23 @@ class SwitchButtonListener : BroadcastReceiver() { )] )] when(status){ when(status){ GenericNotificationClass.STATUS.lastCommand -> sender.SendRead(37) GenericNotificationClass.STATUS.lastCommand -> { Helper.StartForegroundServiceNotification(context, "VERIFICA SE GARAGE è APERTO", Helper.FULL_OFF) sender.SendRead(37) } GenericNotificationClass.STATUS.portone -> sender.SendPinPortone() //17 GPIO pin locale GenericNotificationClass.STATUS.portone -> sender.SendPinPortone() //17 GPIO pin locale GenericNotificationClass.STATUS.cancello -> sender.SendPin(17) GenericNotificationClass.STATUS.cancello -> { GenericNotificationClass.STATUS.garage -> sender.SendPin(21) Helper.StartForegroundServiceNotification(context, "CANCELLO IN APERTURA...", Helper.FULL_OFF) sender.SendPin(17) } GenericNotificationClass.STATUS.garage -> { Helper.StartForegroundServiceNotification(context, "GARAGE IN APERTURA...", Helper.FULL_OFF) sender.SendPin(21) } GenericNotificationClass.STATUS.led -> { Helper.StartForegroundServiceNotification(context, "LUCE ACCESA...", Helper.FULL_OFF) sender.SendPin(13) } GenericNotificationClass.STATUS.brightness -> sender.SendBrightness(previousBrightness) GenericNotificationClass.STATUS.brightness -> sender.SendBrightness(previousBrightness) } } Loading