Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ import android.app.Notification
import android.app.PendingIntent
import android.app.Service
import android.content.Intent
import android.os.Build
import android.os.IBinder
import androidx.annotation.RequiresApi
import androidx.core.app.NotificationCompat
import androidx.core.content.ContextCompat
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.CoroutineScope
Expand Down Expand Up @@ -65,9 +68,6 @@ class LightningNodeService : Service() {
handlePaymentReceived(event)
}
).onSuccess {
val notification = createNotification()
startForeground(ID_NOTIFICATION_NODE, notification)

walletRepo.setWalletExistsState()
walletRepo.refreshBip21()
walletRepo.syncBalances()
Expand Down Expand Up @@ -116,8 +116,10 @@ class LightningNodeService : Service() {
return NotificationCompat.Builder(this, CHANNEL_ID_NODE)
.setContentTitle(getString(R.string.app_name))
.setContentText(contentText)
.setSmallIcon(R.drawable.ic_launcher_fg_regtest)
.setSmallIcon(R.drawable.ic_bitkit_outlined)
.setColor(ContextCompat.getColor(this, R.color.brand))
.setContentIntent(pendingIntent)
.setOngoing(true)
.addAction(
R.drawable.ic_x,
getString(R.string.notification__service__stop),
Expand Down Expand Up @@ -151,6 +153,16 @@ class LightningNodeService : Service() {
super.onDestroy()
}

@RequiresApi(Build.VERSION_CODES.VANILLA_ICE_CREAM)
override fun onTimeout(startId: Int, fgsType: Int) {
Logger.warn("Foreground service timeout reached", context = TAG)
serviceScope.launch {
lightningRepo.stop()
stopSelf()
}
super.onTimeout(startId, fgsType)
}

override fun onBind(intent: Intent?): IBinder? = null

companion object {
Expand Down
14 changes: 14 additions & 0 deletions app/src/main/res/drawable/ic_bitkit_outlined.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="600dp"
android:height="600dp"
android:viewportWidth="600"
android:viewportHeight="600">
<group>
<clip-path
android:pathData="M0,0h600v600h-600z"/>
<path
android:pathData="M377.4,496.6C338.39,543.97 279.29,574.17 213.13,574.17C95.66,574.17 0.43,478.94 0.43,361.47C0.43,244 95.66,148.77 213.13,148.77C214,148.77 214.86,148.78 215.73,148.79L249.12,25H453.95C530.29,25 599.4,83.19 599.4,162.18C599.4,191.47 594,222.8 577,249.89C575.09,252.93 573.07,255.87 570.93,258.7C573.27,262 575.47,265.44 577.51,269.04C593.91,297.9 597.33,330.73 594.22,362.36C590.75,397.6 576.5,431.81 549.28,457.38C521.72,483.26 484.78,496.6 443.08,496.6H377.4ZM213.13,200.37C209.29,200.37 205.48,200.51 201.71,200.77C118.06,206.63 52.03,276.34 52.03,361.47C52.03,450.45 124.16,522.57 213.13,522.57C262.51,522.57 306.7,500.36 336.25,465.38C344.9,455.14 352.29,443.81 358.2,431.62C368.47,410.41 374.23,386.62 374.23,361.47C374.23,287.67 324.61,225.47 256.91,206.39C342.83,226.91 402.58,297.92 402.58,392.7C402.58,393.74 402.58,394.77 402.56,395.8C402.27,413.25 399.57,430.15 394.75,446.2H443.08C444.4,446.2 445.72,446.18 447.02,446.14C505.86,444.53 539.09,406.65 543.92,357.44C546.49,331.33 542.93,309.2 532.4,291.95C530.71,289.16 528.83,286.5 526.76,283.98C517.11,272.16 503.41,263.2 485.33,257.49L485.32,257.48C485.15,257.43 484.99,257.38 484.83,257.33L484.63,257.27C484.41,257.25 484.25,257.07 484.25,256.86C484.25,256.74 484.29,256.64 484.36,256.57C484.43,256.5 484.52,256.45 484.63,256.44L484.71,256.42L484.79,256.41L484.9,256.38C503.74,252.1 517.85,243.51 527.95,231.64C529.96,229.28 531.81,226.79 533.51,224.17C544.23,207.68 548.87,186.35 548.87,162.18C548.87,114.85 506.37,75.4 453.95,75.4H287.85L252.82,205.3C240.12,202.08 226.82,200.37 213.13,200.37Z"
android:fillColor="#ffffff"
android:fillType="evenOdd"/>
</group>
</vector>
Loading