Skip to content

Commit f363ad7

Browse files
committed
Cancel the progress notification here
1 parent 7c85013 commit f363ad7

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

app/src/main/kotlin/com/darkrockstudios/app/securecamera/import/ImportPhotosViewModel.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
package com.darkrockstudios.app.securecamera.import
22

3+
import android.app.NotificationManager
4+
import android.content.Context
35
import android.net.Uri
46
import androidx.core.net.toUri
57
import androidx.lifecycle.viewModelScope
68
import androidx.work.*
79
import com.darkrockstudios.app.securecamera.BaseViewModel
10+
import com.darkrockstudios.app.securecamera.import.ImportWorker.Companion.NOTIFICATION_ID
811
import dev.whyoleg.cryptography.CryptographyProvider
912
import dev.whyoleg.cryptography.algorithms.SHA512
1013
import dev.whyoleg.cryptography.operations.Hasher
1114
import kotlinx.coroutines.launch
1215
import timber.log.Timber
1316

1417
class ImportPhotosViewModel(
18+
private val appContext: Context,
1519
private val workManager: WorkManager,
1620
) : BaseViewModel<ImportPhotosState>() {
1721

@@ -128,6 +132,10 @@ class ImportPhotosViewModel(
128132
currentImportWorkName?.let { workName ->
129133
Timber.d("Cancelling import work: $workName")
130134
workManager.cancelUniqueWork(workName)
135+
136+
val notificationManager =
137+
appContext.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
138+
notificationManager.cancel(NOTIFICATION_ID)
131139
}
132140
}
133141
}

0 commit comments

Comments
 (0)