Commit e0274d88 authored by MozLando's avatar MozLando
Browse files

Merge #5927



5927: Issue #5886: Add ability to dismiss "migration completed" notification. r=grigoryk a=pocmo

For #5886.
Co-authored-by: default avatarSebastian Kaspari <s.kaspari@gmail.com>
parents e0405287 7270d044
......@@ -23,7 +23,9 @@ import mozilla.components.support.migration.state.MigrationAction
import mozilla.components.support.migration.state.MigrationStore
private const val NOTIFICATION_CHANNEL_ID = "mozac.support.migration.generic"
private const val NOTIFICATION_TAG = "mozac.support.migration.notification"
private const val NOTIFICATION_COMPLETED_ID = 1
private const val TEMPORARY_NOTIFICATION_CHANNEL_NAME = "Migration"
......@@ -103,9 +105,12 @@ abstract class AbstractMigrationService : Service() {
val titleRes: Int = R.string.mozac_support_migration_complete_notification_title
val contentRes: Int = R.string.mozac_support_migration_complete_notification_text
val builder = getNotificationBuilder(titleRes, contentRes, channel)
val id = SharedIdsHelper.getIdForTag(this, NOTIFICATION_TAG)
NotificationManagerCompat.from(this).notify(id, builder.build())
NotificationManagerCompat.from(this).notify(
NOTIFICATION_TAG,
NOTIFICATION_COMPLETED_ID,
builder.build()
)
}
private fun getNotificationBuilder(titleRes: Int, contentRes: Int, channel: String): NotificationCompat.Builder {
......@@ -139,4 +144,16 @@ abstract class AbstractMigrationService : Service() {
return NOTIFICATION_CHANNEL_ID
}
companion object {
/**
* Dismisses the "migration completed" notification.
*/
fun dismissNotification(context: Context) {
NotificationManagerCompat.from(context).cancel(
NOTIFICATION_TAG,
NOTIFICATION_COMPLETED_ID
)
}
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment