diff --git a/app/schemas/io.heckel.ntfy.db.Database/12.json b/app/schemas/io.heckel.ntfy.db.Database/12.json index f5d24cf..e9e36a1 100644 --- a/app/schemas/io.heckel.ntfy.db.Database/12.json +++ b/app/schemas/io.heckel.ntfy.db.Database/12.json @@ -2,11 +2,11 @@ "formatVersion": 1, "database": { "version": 12, - "identityHash": "2be334bfcfa91ab5ffde61a5b295565d", + "identityHash": "d230005f4d9824ba9aa34c61003bdcbb", "entities": [ { "tableName": "Subscription", - "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER NOT NULL, `baseUrl` TEXT NOT NULL, `topic` TEXT NOT NULL, `instant` INTEGER NOT NULL, `mutedUntil` INTEGER NOT NULL, `minPriority` INTEGER NOT NULL, `autoDelete` INTEGER NOT NULL, `lastNotificationId` TEXT, `icon` TEXT, `upAppId` TEXT, `upConnectorToken` TEXT, `displayName` TEXT, `ownNotificationChannels` INTEGER NOT NULL, PRIMARY KEY(`id`))", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER NOT NULL, `baseUrl` TEXT NOT NULL, `topic` TEXT NOT NULL, `instant` INTEGER NOT NULL, `mutedUntil` INTEGER NOT NULL, `minPriority` INTEGER NOT NULL, `autoDelete` INTEGER NOT NULL, `lastNotificationId` TEXT, `icon` TEXT, `upAppId` TEXT, `upConnectorToken` TEXT, `displayName` TEXT, PRIMARY KEY(`id`))", "fields": [ { "fieldPath": "id", @@ -79,12 +79,6 @@ "columnName": "displayName", "affinity": "TEXT", "notNull": false - }, - { - "fieldPath": "ownNotificationChannels", - "columnName": "ownNotificationChannels", - "affinity": "INTEGER", - "notNull": true } ], "primaryKey": { @@ -344,7 +338,7 @@ "views": [], "setupQueries": [ "CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)", - "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '2be334bfcfa91ab5ffde61a5b295565d')" + "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'd230005f4d9824ba9aa34c61003bdcbb')" ] } } \ No newline at end of file diff --git a/app/schemas/io.heckel.ntfy.db.Database/13.json b/app/schemas/io.heckel.ntfy.db.Database/13.json index 68ded30..dfb5031 100644 --- a/app/schemas/io.heckel.ntfy.db.Database/13.json +++ b/app/schemas/io.heckel.ntfy.db.Database/13.json @@ -2,11 +2,11 @@ "formatVersion": 1, "database": { "version": 13, - "identityHash": "2be334bfcfa91ab5ffde61a5b295565d", + "identityHash": "39849793e1ed04fe89f0d71a59a56956", "entities": [ { "tableName": "Subscription", - "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER NOT NULL, `baseUrl` TEXT NOT NULL, `topic` TEXT NOT NULL, `instant` INTEGER NOT NULL, `mutedUntil` INTEGER NOT NULL, `minPriority` INTEGER NOT NULL, `autoDelete` INTEGER NOT NULL, `lastNotificationId` TEXT, `icon` TEXT, `upAppId` TEXT, `upConnectorToken` TEXT, `displayName` TEXT, `ownNotificationChannels` INTEGER NOT NULL, PRIMARY KEY(`id`))", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER NOT NULL, `baseUrl` TEXT NOT NULL, `topic` TEXT NOT NULL, `instant` INTEGER NOT NULL, `mutedUntil` INTEGER NOT NULL, `minPriority` INTEGER NOT NULL, `autoDelete` INTEGER NOT NULL, `lastNotificationId` TEXT, `icon` TEXT, `upAppId` TEXT, `upConnectorToken` TEXT, `displayName` TEXT, `dedicatedChannels` INTEGER NOT NULL, PRIMARY KEY(`id`))", "fields": [ { "fieldPath": "id", @@ -81,8 +81,8 @@ "notNull": false }, { - "fieldPath": "ownNotificationChannels", - "columnName": "ownNotificationChannels", + "fieldPath": "dedicatedChannels", + "columnName": "dedicatedChannels", "affinity": "INTEGER", "notNull": true } @@ -344,7 +344,7 @@ "views": [], "setupQueries": [ "CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)", - "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '2be334bfcfa91ab5ffde61a5b295565d')" + "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '39849793e1ed04fe89f0d71a59a56956')" ] } } \ No newline at end of file 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 5e80c57..f730c20 100644 --- a/app/src/main/java/io/heckel/ntfy/backup/Backuper.kt +++ b/app/src/main/java/io/heckel/ntfy/backup/Backuper.kt @@ -99,7 +99,7 @@ class Backuper(val context: Context) { baseUrl = s.baseUrl, topic = s.topic, instant = s.instant, - ownNotificationChannels = s.ownNotificationChannels, + dedicatedChannels = s.dedicatedChannels, mutedUntil = s.mutedUntil, minPriority = s.minPriority ?: Repository.MIN_PRIORITY_USE_GLOBAL, autoDelete = s.autoDelete ?: Repository.AUTO_DELETE_USE_GLOBAL, @@ -237,7 +237,7 @@ class Backuper(val context: Context) { baseUrl = s.baseUrl, topic = s.topic, instant = s.instant, - ownNotificationChannels = s.ownNotificationChannels, + dedicatedChannels = s.dedicatedChannels, mutedUntil = s.mutedUntil, minPriority = s.minPriority, autoDelete = s.autoDelete, @@ -355,7 +355,7 @@ data class Subscription( val baseUrl: String, val topic: String, val instant: Boolean, - val ownNotificationChannels: Boolean, + val dedicatedChannels: Boolean, val mutedUntil: Long, val minPriority: Int?, val autoDelete: Long?, diff --git a/app/src/main/java/io/heckel/ntfy/db/Database.kt b/app/src/main/java/io/heckel/ntfy/db/Database.kt index 8b05a5a..60b4e7d 100644 --- a/app/src/main/java/io/heckel/ntfy/db/Database.kt +++ b/app/src/main/java/io/heckel/ntfy/db/Database.kt @@ -23,14 +23,14 @@ data class Subscription( @ColumnInfo(name = "upAppId") val upAppId: String?, // UnifiedPush application package name @ColumnInfo(name = "upConnectorToken") val upConnectorToken: String?, // UnifiedPush connector token @ColumnInfo(name = "displayName") val displayName: String?, - @ColumnInfo(name = "ownNotificationChannels") val ownNotificationChannels: Boolean, + @ColumnInfo(name = "dedicatedChannels") val dedicatedChannels: Boolean, @Ignore val totalCount: Int = 0, // Total notifications @Ignore val newCount: Int = 0, // New notifications @Ignore val lastActive: Long = 0, // Unix timestamp @Ignore val state: ConnectionState = ConnectionState.NOT_APPLICABLE ) { - constructor(id: Long, baseUrl: String, topic: String, instant: Boolean, mutedUntil: Long, minPriority: Int, autoDelete: Long, lastNotificationId: String, icon: String, upAppId: String, upConnectorToken: String, displayName: String?, ownNotificationChannels: Boolean?) : - this(id, baseUrl, topic, instant, mutedUntil, minPriority, autoDelete, lastNotificationId, icon, upAppId, upConnectorToken, displayName, ownNotificationChannels == true, 0, 0, 0, ConnectionState.NOT_APPLICABLE) + constructor(id: Long, baseUrl: String, topic: String, instant: Boolean, mutedUntil: Long, minPriority: Int, autoDelete: Long, lastNotificationId: String, icon: String, upAppId: String, upConnectorToken: String, displayName: String?, dedicatedChannels: Boolean?) : + this(id, baseUrl, topic, instant, mutedUntil, minPriority, autoDelete, lastNotificationId, icon, upAppId, upConnectorToken, displayName, dedicatedChannels == true, 0, 0, 0, ConnectionState.NOT_APPLICABLE) } enum class ConnectionState { @@ -50,7 +50,7 @@ data class SubscriptionWithMetadata( val upAppId: String?, val upConnectorToken: String?, val displayName: String?, - val ownNotificationChannels: Boolean, + val dedicatedChannels: Boolean, val totalCount: Int, val newCount: Int, val lastActive: Long @@ -289,7 +289,7 @@ abstract class Database : RoomDatabase() { private val MIGRATION_12_13 = object : Migration(12, 13) { override fun migrate(db: SupportSQLiteDatabase) { - db.execSQL("ALTER TABLE Subscription ADD COLUMN ownNotificationChannels INTEGER NOT NULL DEFAULT('0')") + db.execSQL("ALTER TABLE Subscription ADD COLUMN dedicatedChannels INTEGER NOT NULL DEFAULT('0')") } } } @@ -299,7 +299,7 @@ abstract class Database : RoomDatabase() { interface SubscriptionDao { @Query(""" SELECT - s.id, s.baseUrl, s.topic, s.instant, s.mutedUntil, s.minPriority, s.autoDelete, s.lastNotificationId, s.icon, s.upAppId, s.upConnectorToken, s.displayName, s.ownNotificationChannels, + s.id, s.baseUrl, s.topic, s.instant, s.mutedUntil, s.minPriority, s.autoDelete, s.lastNotificationId, s.icon, s.upAppId, s.upConnectorToken, s.displayName, s.dedicatedChannels, COUNT(n.id) totalCount, COUNT(CASE n.notificationId WHEN 0 THEN NULL ELSE n.id END) newCount, IFNULL(MAX(n.timestamp),0) AS lastActive @@ -312,7 +312,7 @@ interface SubscriptionDao { @Query(""" SELECT - s.id, s.baseUrl, s.topic, s.instant, s.mutedUntil, s.minPriority, s.autoDelete, s.lastNotificationId, s.icon, s.upAppId, s.upConnectorToken, s.displayName, s.ownNotificationChannels, + s.id, s.baseUrl, s.topic, s.instant, s.mutedUntil, s.minPriority, s.autoDelete, s.lastNotificationId, s.icon, s.upAppId, s.upConnectorToken, s.displayName, s.dedicatedChannels, COUNT(n.id) totalCount, COUNT(CASE n.notificationId WHEN 0 THEN NULL ELSE n.id END) newCount, IFNULL(MAX(n.timestamp),0) AS lastActive @@ -325,7 +325,7 @@ interface SubscriptionDao { @Query(""" SELECT - s.id, s.baseUrl, s.topic, s.instant, s.mutedUntil, s.minPriority, s.autoDelete, s.lastNotificationId, s.icon, s.upAppId, s.upConnectorToken, s.displayName, s.ownNotificationChannels, + s.id, s.baseUrl, s.topic, s.instant, s.mutedUntil, s.minPriority, s.autoDelete, s.lastNotificationId, s.icon, s.upAppId, s.upConnectorToken, s.displayName, s.dedicatedChannels, COUNT(n.id) totalCount, COUNT(CASE n.notificationId WHEN 0 THEN NULL ELSE n.id END) newCount, IFNULL(MAX(n.timestamp),0) AS lastActive @@ -338,7 +338,7 @@ interface SubscriptionDao { @Query(""" SELECT - s.id, s.baseUrl, s.topic, s.instant, s.mutedUntil, s.minPriority, s.autoDelete, s.lastNotificationId, s.icon, s.upAppId, s.upConnectorToken, s.displayName, s.ownNotificationChannels, + s.id, s.baseUrl, s.topic, s.instant, s.mutedUntil, s.minPriority, s.autoDelete, s.lastNotificationId, s.icon, s.upAppId, s.upConnectorToken, s.displayName, s.dedicatedChannels, COUNT(n.id) totalCount, COUNT(CASE n.notificationId WHEN 0 THEN NULL ELSE n.id END) newCount, IFNULL(MAX(n.timestamp),0) AS lastActive @@ -351,7 +351,7 @@ interface SubscriptionDao { @Query(""" SELECT - s.id, s.baseUrl, s.topic, s.instant, s.mutedUntil, s.minPriority, s.autoDelete, s.lastNotificationId, s.icon, s.upAppId, s.upConnectorToken, s.displayName, s.ownNotificationChannels, + s.id, s.baseUrl, s.topic, s.instant, s.mutedUntil, s.minPriority, s.autoDelete, s.lastNotificationId, s.icon, s.upAppId, s.upConnectorToken, s.displayName, s.dedicatedChannels, COUNT(n.id) totalCount, COUNT(CASE n.notificationId WHEN 0 THEN NULL ELSE n.id END) newCount, IFNULL(MAX(n.timestamp),0) AS lastActive diff --git a/app/src/main/java/io/heckel/ntfy/db/Repository.kt b/app/src/main/java/io/heckel/ntfy/db/Repository.kt index 0949bac..e2cae59 100644 --- a/app/src/main/java/io/heckel/ntfy/db/Repository.kt +++ b/app/src/main/java/io/heckel/ntfy/db/Repository.kt @@ -385,7 +385,7 @@ class Repository(private val sharedPrefs: SharedPreferences, private val databas baseUrl = s.baseUrl, topic = s.topic, instant = s.instant, - ownNotificationChannels = s.ownNotificationChannels, + dedicatedChannels = s.dedicatedChannels, mutedUntil = s.mutedUntil, minPriority = s.minPriority, autoDelete = s.autoDelete, @@ -411,7 +411,7 @@ class Repository(private val sharedPrefs: SharedPreferences, private val databas baseUrl = s.baseUrl, topic = s.topic, instant = s.instant, - ownNotificationChannels = s.ownNotificationChannels, + dedicatedChannels = s.dedicatedChannels, mutedUntil = s.mutedUntil, minPriority = s.minPriority, autoDelete = s.autoDelete, diff --git a/app/src/main/java/io/heckel/ntfy/msg/NotificationService.kt b/app/src/main/java/io/heckel/ntfy/msg/NotificationService.kt index b8ea89d..56ae07c 100644 --- a/app/src/main/java/io/heckel/ntfy/msg/NotificationService.kt +++ b/app/src/main/java/io/heckel/ntfy/msg/NotificationService.kt @@ -87,7 +87,7 @@ class NotificationService(val context: Context) { } fun groupId(subscription: Subscription): String? { - if (subscription.ownNotificationChannels) { + if (subscription.dedicatedChannels) { return "" + subscription.id } else { return null @@ -96,7 +96,7 @@ class NotificationService(val context: Context) { private fun displayInternal(subscription: Subscription, notification: Notification, update: Boolean = false) { val title = formatTitle(subscription, notification) - val scope = if (subscription.ownNotificationChannels) dedicatedNotificationScope(subscription) else DEFAULT_NOTIFICATION_SCOPE + val scope = if (subscription.dedicatedChannels) dedicatedNotificationScope(subscription) else DEFAULT_NOTIFICATION_SCOPE val builder = NotificationCompat.Builder(context, toChannelId(scope, notification.priority)) .setSmallIcon(R.drawable.ic_notification) .setColor(ContextCompat.getColor(context, Colors.notificationIcon(context))) diff --git a/app/src/main/java/io/heckel/ntfy/ui/DetailActivity.kt b/app/src/main/java/io/heckel/ntfy/ui/DetailActivity.kt index af54347..0837770 100644 --- a/app/src/main/java/io/heckel/ntfy/ui/DetailActivity.kt +++ b/app/src/main/java/io/heckel/ntfy/ui/DetailActivity.kt @@ -110,7 +110,7 @@ class DetailActivity : AppCompatActivity(), ActionMode.Callback, NotificationFra baseUrl = baseUrl, topic = topic, instant = instant, - ownNotificationChannels = false, + dedicatedChannels = false, mutedUntil = 0, minPriority = Repository.MIN_PRIORITY_USE_GLOBAL, autoDelete = Repository.AUTO_DELETE_USE_GLOBAL, diff --git a/app/src/main/java/io/heckel/ntfy/ui/DetailSettingsActivity.kt b/app/src/main/java/io/heckel/ntfy/ui/DetailSettingsActivity.kt index 0a5b196..912cf40 100644 --- a/app/src/main/java/io/heckel/ntfy/ui/DetailSettingsActivity.kt +++ b/app/src/main/java/io/heckel/ntfy/ui/DetailSettingsActivity.kt @@ -112,7 +112,7 @@ class DetailSettingsActivity : AppCompatActivity() { private fun loadView() { if (subscription.upAppId == null) { loadInstantPref() - loadOwnNotificationChannelsPref() + loadDedicatedChannelsPrefs() loadMutedUntilPref() loadMinPriorityPref() loadAutoDeletePref() @@ -151,14 +151,14 @@ class DetailSettingsActivity : AppCompatActivity() { } } - private fun loadOwnNotificationChannelsPref() { - val prefId = context?.getString(R.string.detail_settings_notifications_own_notification_channels_key) ?: return + private fun loadDedicatedChannelsPrefs() { + val prefId = context?.getString(R.string.detail_settings_notifications_dedicated_channels_key) ?: return val pref: SwitchPreference? = findPreference(prefId) pref?.isVisible = true - pref?.isChecked = subscription.ownNotificationChannels + pref?.isChecked = subscription.dedicatedChannels pref?.preferenceDataStore = object : PreferenceDataStore() { override fun putBoolean(key: String?, value: Boolean) { - save(subscription.copy(ownNotificationChannels = value)) + save(subscription.copy(dedicatedChannels = value)) if(value) { notificationService.createSubscriptionNotificationChannels(subscription) } else { @@ -167,14 +167,14 @@ class DetailSettingsActivity : AppCompatActivity() { } override fun getBoolean(key: String?, defValue: Boolean): Boolean { - return subscription.ownNotificationChannels + return subscription.dedicatedChannels } } pref?.summaryProvider = Preference.SummaryProvider { preference -> if (preference.isChecked) { - getString(R.string.detail_settings_notifications_own_notification_channels_summay_on) + getString(R.string.detail_settings_notifications_dedicated_channels_summay_on) } else { - getString(R.string.detail_settings_notifications_own_notification_channels_summay_off) + getString(R.string.detail_settings_notifications_dedicated_channels_summay_off) } } } diff --git a/app/src/main/java/io/heckel/ntfy/ui/MainActivity.kt b/app/src/main/java/io/heckel/ntfy/ui/MainActivity.kt index cd3ccb6..9a8f40a 100644 --- a/app/src/main/java/io/heckel/ntfy/ui/MainActivity.kt +++ b/app/src/main/java/io/heckel/ntfy/ui/MainActivity.kt @@ -452,7 +452,7 @@ class MainActivity : AppCompatActivity(), ActionMode.Callback, AddFragment.Subsc baseUrl = baseUrl, topic = topic, instant = instant, - ownNotificationChannels = false, + dedicatedChannels = false, mutedUntil = 0, minPriority = Repository.MIN_PRIORITY_USE_GLOBAL, autoDelete = Repository.AUTO_DELETE_USE_GLOBAL, diff --git a/app/src/main/java/io/heckel/ntfy/up/BroadcastReceiver.kt b/app/src/main/java/io/heckel/ntfy/up/BroadcastReceiver.kt index c192c3c..5ddcd57 100644 --- a/app/src/main/java/io/heckel/ntfy/up/BroadcastReceiver.kt +++ b/app/src/main/java/io/heckel/ntfy/up/BroadcastReceiver.kt @@ -72,7 +72,7 @@ class BroadcastReceiver : android.content.BroadcastReceiver() { baseUrl = baseUrl, topic = topic, instant = true, // No Firebase, always instant! - ownNotificationChannels = false, + dedicatedChannels = false, mutedUntil = 0, minPriority = Repository.MIN_PRIORITY_USE_GLOBAL, autoDelete = Repository.AUTO_DELETE_USE_GLOBAL, diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index e850dea..e14386a 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -349,9 +349,9 @@ Instant delivery 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. - Own notification channels - Use own notification channels for this subscription - Use default notification channels + Use dedicated channels + Use dedicated notification channels for this subscription + Use default notification channels Appearance Subscription icon Set an icon to be displayed in notifications diff --git a/app/src/main/res/values/values.xml b/app/src/main/res/values/values.xml index 8dfe84c..be34678 100644 --- a/app/src/main/res/values/values.xml +++ b/app/src/main/res/values/values.xml @@ -34,7 +34,7 @@ SubscriptionNotifications SubscriptionInstant SubscriptionMutedUntil - SubscriptionOwnNotificationChannels + SubscriptionDedicatedChannels SubscriptionMinPriority SubscriptionAutoDelete SubscriptionAppearance diff --git a/app/src/main/res/xml/detail_preferences.xml b/app/src/main/res/xml/detail_preferences.xml index 382d6e5..651a373 100644 --- a/app/src/main/res/xml/detail_preferences.xml +++ b/app/src/main/res/xml/detail_preferences.xml @@ -15,8 +15,8 @@ app:defaultValue="0" app:isPreferenceVisible="false"/>