diff options
author | Philipp Heckel <pheckel@datto.com> | 2022-12-07 11:49:59 -0500 |
---|---|---|
committer | Philipp Heckel <pheckel@datto.com> | 2022-12-07 11:49:59 -0500 |
commit | 803bed5ca0480cf70f6261428a824827e52b9cc3 (patch) | |
tree | c865aaed8cdd058769621aefcd3a522a5a1cabb2 | |
parent | 3e8ba28e63a53f04688acc7fef10b3baa6f0ddc7 (diff) | |
download | ponypush-803bed5ca0480cf70f6261428a824827e52b9cc3.tar.gz ponypush-803bed5ca0480cf70f6261428a824827e52b9cc3.tar.bz2 ponypush-803bed5ca0480cf70f6261428a824827e52b9cc3.zip |
Wording, backup/restore
-rw-r--r-- | app/src/main/java/io/heckel/ntfy/backup/Backuper.kt | 17 | ||||
-rw-r--r-- | app/src/main/res/values/strings.xml | 2 |
2 files changed, 15 insertions, 4 deletions
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 @@ <string name="detail_settings_notifications_instant_summary_on">Notifications are delivered instantly. Requires a foreground service and consumes more battery.</string> <string name="detail_settings_notifications_instant_summary_off">Notifications are delivered using Firebase. Delivery may be delayed, but consumes less battery.</string> <string name="detail_settings_notifications_dedicated_channels_title">Custom notification settings</string> - <string name="detail_settings_notifications_dedicated_channels_summary_on">Using dedicated notification channels for this subscription</string> + <string name="detail_settings_notifications_dedicated_channels_summary_on">Using custom settings for this subscription</string> <string name="detail_settings_notifications_dedicated_channels_summary_off">Using default settings (sounds, Do Not Disturb override, etc.)</string> <string name="detail_settings_notifications_open_channels_title">Configure notification settings</string> <string name="detail_settings_notifications_open_channels_summary">Do Not Disturb (DND) override, sounds, etc.</string> |