rename "own notification channels" to "dedicated channels"
This commit is contained in:
parent
accf3ccf38
commit
d295f08449
13 changed files with 42 additions and 48 deletions
|
@ -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')"
|
||||
]
|
||||
}
|
||||
}
|
|
@ -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')"
|
||||
]
|
||||
}
|
||||
}
|
|
@ -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?,
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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)))
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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<SwitchPreference> { 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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -349,9 +349,9 @@
|
|||
<string name="detail_settings_notifications_instant_title">Instant delivery</string>
|
||||
<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_own_notification_channels_title">Own notification channels</string>
|
||||
<string name="detail_settings_notifications_own_notification_channels_summay_on">Use own notification channels for this subscription</string>
|
||||
<string name="detail_settings_notifications_own_notification_channels_summay_off">Use default notification channels</string>
|
||||
<string name="detail_settings_notifications_dedicated_channels_title">Use dedicated channels</string>
|
||||
<string name="detail_settings_notifications_dedicated_channels_summay_on">Use dedicated notification channels for this subscription</string>
|
||||
<string name="detail_settings_notifications_dedicated_channels_summay_off">Use default notification channels</string>
|
||||
<string name="detail_settings_appearance_header">Appearance</string>
|
||||
<string name="detail_settings_appearance_icon_set_title">Subscription icon</string>
|
||||
<string name="detail_settings_appearance_icon_set_summary">Set an icon to be displayed in notifications</string>
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
<string name="detail_settings_notifications_header_key" translatable="false">SubscriptionNotifications</string>
|
||||
<string name="detail_settings_notifications_instant_key" translatable="false">SubscriptionInstant</string>
|
||||
<string name="detail_settings_notifications_muted_until_key" translatable="false">SubscriptionMutedUntil</string>
|
||||
<string name="detail_settings_notifications_own_notification_channels_key" translatable="false">SubscriptionOwnNotificationChannels</string>
|
||||
<string name="detail_settings_notifications_dedicated_channels_key" translatable="false">SubscriptionDedicatedChannels</string>
|
||||
<string name="detail_settings_notifications_min_priority_key" translatable="false">SubscriptionMinPriority</string>
|
||||
<string name="detail_settings_notifications_auto_delete_key" translatable="false">SubscriptionAutoDelete</string>
|
||||
<string name="detail_settings_appearance_header_key" translatable="false">SubscriptionAppearance</string>
|
||||
|
|
|
@ -15,8 +15,8 @@
|
|||
app:defaultValue="0"
|
||||
app:isPreferenceVisible="false"/>
|
||||
<SwitchPreference
|
||||
app:key="@string/detail_settings_notifications_own_notification_channels_key"
|
||||
app:title="@string/detail_settings_notifications_own_notification_channels_title"
|
||||
app:key="@string/detail_settings_notifications_dedicated_channels_key"
|
||||
app:title="@string/detail_settings_notifications_dedicated_channels_title"
|
||||
app:isPreferenceVisible="false"/>
|
||||
<ListPreference
|
||||
app:key="@string/detail_settings_notifications_min_priority_key"
|
||||
|
|
Loading…
Reference in a new issue