diff --git a/app/src/main/java/io/heckel/ntfy/backup/Backuper.kt b/app/src/main/java/io/heckel/ntfy/backup/Backuper.kt
index fb1be51..89460c4 100644
--- a/app/src/main/java/io/heckel/ntfy/backup/Backuper.kt
+++ b/app/src/main/java/io/heckel/ntfy/backup/Backuper.kt
@@ -7,9 +7,9 @@ import com.google.gson.GsonBuilder
import com.google.gson.stream.JsonReader
import io.heckel.ntfy.R
import io.heckel.ntfy.app.Application
-import io.heckel.ntfy.db.Icon
import io.heckel.ntfy.db.Repository
import io.heckel.ntfy.firebase.FirebaseMessenger
+import io.heckel.ntfy.msg.NotificationService
import io.heckel.ntfy.util.Log
import io.heckel.ntfy.util.topicUrl
import java.io.InputStreamReader
@@ -19,6 +19,7 @@ class Backuper(val context: Context) {
private val resolver = context.applicationContext.contentResolver
private val repository = (context.applicationContext as Application).repository
private val messenger = FirebaseMessenger()
+ private val notifier = NotificationService(context)
suspend fun backup(uri: Uri, withSettings: Boolean = true, withSubscriptions: Boolean = true, withUsers: Boolean = true) {
Log.d(TAG, "Backing up settings to file $uri")
@@ -94,7 +95,8 @@ class Backuper(val context: Context) {
val appBaseUrl = context.getString(R.string.app_base_url)
subscriptions.forEach { s ->
try {
- repository.addSubscription(io.heckel.ntfy.db.Subscription(
+ // Add to database
+ val subscription = io.heckel.ntfy.db.Subscription(
id = s.id,
baseUrl = s.baseUrl,
topic = s.topic,
@@ -109,10 +111,19 @@ class Backuper(val context: Context) {
upAppId = s.upAppId,
upConnectorToken = s.upConnectorToken,
displayName = s.displayName,
- ))
+ )
+ repository.addSubscription(subscription)
+
+ // Subscribe to Firebase topics
if (s.baseUrl == appBaseUrl) {
messenger.subscribe(s.topic)
}
+
+ // Create dedicated channels
+ if (s.dedicatedChannels) {
+ notifier.createSubscriptionNotificationChannels(subscription)
+ // TODO Backup/restore individual notification channel settings
+ }
} catch (e: Exception) {
Log.w(TAG, "Unable to restore subscription ${s.id} (${topicUrl(s.baseUrl, s.topic)}): ${e.message}. Ignoring.", e)
}
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 533e145..b7f57f3 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -354,7 +354,7 @@
Notifications are delivered instantly. Requires a foreground service and consumes more battery.
Notifications are delivered using Firebase. Delivery may be delayed, but consumes less battery.
Custom notification settings
- Using dedicated notification channels for this subscription
+ Using custom settings for this subscription
Using default settings (sounds, Do Not Disturb override, etc.)
Configure notification settings
Do Not Disturb (DND) override, sounds, etc.