mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-10 16:17:48 +01:00
Remove setting to disable update error notifications and split out notification channel
Users can exclude things from updating if needed, or disable the notification channel from system settings.
This commit is contained in:
parent
33b3be0d0e
commit
fce3cd00a1
7 changed files with 74 additions and 73 deletions
|
@ -51,7 +51,7 @@ class LibraryUpdateNotifier(private val context: Context) {
|
||||||
* Cached progress notification to avoid creating a lot.
|
* Cached progress notification to avoid creating a lot.
|
||||||
*/
|
*/
|
||||||
val progressNotificationBuilder by lazy {
|
val progressNotificationBuilder by lazy {
|
||||||
context.notificationBuilder(Notifications.CHANNEL_LIBRARY) {
|
context.notificationBuilder(Notifications.CHANNEL_LIBRARY_PROGRESS) {
|
||||||
setContentTitle(context.getString(R.string.app_name))
|
setContentTitle(context.getString(R.string.app_name))
|
||||||
setSmallIcon(R.drawable.ic_refresh_24dp)
|
setSmallIcon(R.drawable.ic_refresh_24dp)
|
||||||
setLargeIcon(notificationBitmap)
|
setLargeIcon(notificationBitmap)
|
||||||
|
@ -101,7 +101,7 @@ class LibraryUpdateNotifier(private val context: Context) {
|
||||||
|
|
||||||
context.notificationManager.notify(
|
context.notificationManager.notify(
|
||||||
Notifications.ID_LIBRARY_ERROR,
|
Notifications.ID_LIBRARY_ERROR,
|
||||||
context.notificationBuilder(Notifications.CHANNEL_LIBRARY) {
|
context.notificationBuilder(Notifications.CHANNEL_LIBRARY_ERROR) {
|
||||||
setContentTitle(context.resources.getQuantityString(R.plurals.notification_update_error, errors.size, errors.size))
|
setContentTitle(context.resources.getQuantityString(R.plurals.notification_update_error, errors.size, errors.size))
|
||||||
setStyle(
|
setStyle(
|
||||||
NotificationCompat.BigTextStyle().bigText(
|
NotificationCompat.BigTextStyle().bigText(
|
||||||
|
|
|
@ -350,7 +350,7 @@ class LibraryUpdateService(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (preferences.showLibraryUpdateErrors() && failedUpdates.isNotEmpty()) {
|
if (failedUpdates.isNotEmpty()) {
|
||||||
val errorFile = writeErrorFile(failedUpdates)
|
val errorFile = writeErrorFile(failedUpdates)
|
||||||
notifier.showUpdateErrorNotification(
|
notifier.showUpdateErrorNotification(
|
||||||
failedUpdates.map { it.first.title },
|
failedUpdates.map { it.first.title },
|
||||||
|
|
|
@ -24,8 +24,10 @@ object Notifications {
|
||||||
/**
|
/**
|
||||||
* Notification channel and ids used by the library updater.
|
* Notification channel and ids used by the library updater.
|
||||||
*/
|
*/
|
||||||
const val CHANNEL_LIBRARY = "library_channel"
|
private const val GROUP_LIBRARY = "group_library"
|
||||||
|
const val CHANNEL_LIBRARY_PROGRESS = "library_progress_channel"
|
||||||
const val ID_LIBRARY_PROGRESS = -101
|
const val ID_LIBRARY_PROGRESS = -101
|
||||||
|
const val CHANNEL_LIBRARY_ERROR = "library_errors_channel"
|
||||||
const val ID_LIBRARY_ERROR = -102
|
const val ID_LIBRARY_ERROR = -102
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -77,7 +79,8 @@ object Notifications {
|
||||||
|
|
||||||
private val deprecatedChannels = listOf(
|
private val deprecatedChannels = listOf(
|
||||||
"downloader_channel",
|
"downloader_channel",
|
||||||
"backup_restore_complete_channel"
|
"backup_restore_complete_channel",
|
||||||
|
"library_channel",
|
||||||
)
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -89,24 +92,38 @@ object Notifications {
|
||||||
fun createChannels(context: Context) {
|
fun createChannels(context: Context) {
|
||||||
val notificationService = NotificationManagerCompat.from(context)
|
val notificationService = NotificationManagerCompat.from(context)
|
||||||
|
|
||||||
val channelGroupList = listOf(
|
notificationService.createNotificationChannelGroupsCompat(
|
||||||
|
listOf(
|
||||||
buildNotificationChannelGroup(GROUP_BACKUP_RESTORE) {
|
buildNotificationChannelGroup(GROUP_BACKUP_RESTORE) {
|
||||||
setName(context.getString(R.string.group_backup_restore))
|
setName(context.getString(R.string.label_backup))
|
||||||
},
|
},
|
||||||
buildNotificationChannelGroup(GROUP_DOWNLOADER) {
|
buildNotificationChannelGroup(GROUP_DOWNLOADER) {
|
||||||
setName(context.getString(R.string.group_downloader))
|
setName(context.getString(R.string.download_notifier_downloader_title))
|
||||||
}
|
},
|
||||||
|
buildNotificationChannelGroup(GROUP_LIBRARY) {
|
||||||
|
setName(context.getString(R.string.label_library))
|
||||||
|
},
|
||||||
|
)
|
||||||
)
|
)
|
||||||
notificationService.createNotificationChannelGroupsCompat(channelGroupList)
|
|
||||||
|
|
||||||
val channelList = listOf(
|
notificationService.createNotificationChannelsCompat(
|
||||||
|
listOf(
|
||||||
buildNotificationChannel(CHANNEL_COMMON, IMPORTANCE_LOW) {
|
buildNotificationChannel(CHANNEL_COMMON, IMPORTANCE_LOW) {
|
||||||
setName(context.getString(R.string.channel_common))
|
setName(context.getString(R.string.channel_common))
|
||||||
},
|
},
|
||||||
buildNotificationChannel(CHANNEL_LIBRARY, IMPORTANCE_LOW) {
|
buildNotificationChannel(CHANNEL_LIBRARY_PROGRESS, IMPORTANCE_LOW) {
|
||||||
setName(context.getString(R.string.channel_library))
|
setName(context.getString(R.string.channel_progress))
|
||||||
|
setGroup(GROUP_LIBRARY)
|
||||||
setShowBadge(false)
|
setShowBadge(false)
|
||||||
},
|
},
|
||||||
|
buildNotificationChannel(CHANNEL_LIBRARY_ERROR, IMPORTANCE_LOW) {
|
||||||
|
setName(context.getString(R.string.channel_errors))
|
||||||
|
setGroup(GROUP_LIBRARY)
|
||||||
|
setShowBadge(false)
|
||||||
|
},
|
||||||
|
buildNotificationChannel(CHANNEL_NEW_CHAPTERS, IMPORTANCE_DEFAULT) {
|
||||||
|
setName(context.getString(R.string.channel_new_chapters))
|
||||||
|
},
|
||||||
buildNotificationChannel(CHANNEL_DOWNLOADER_PROGRESS, IMPORTANCE_LOW) {
|
buildNotificationChannel(CHANNEL_DOWNLOADER_PROGRESS, IMPORTANCE_LOW) {
|
||||||
setName(context.getString(R.string.channel_progress))
|
setName(context.getString(R.string.channel_progress))
|
||||||
setGroup(GROUP_DOWNLOADER)
|
setGroup(GROUP_DOWNLOADER)
|
||||||
|
@ -122,12 +139,6 @@ object Notifications {
|
||||||
setGroup(GROUP_DOWNLOADER)
|
setGroup(GROUP_DOWNLOADER)
|
||||||
setShowBadge(false)
|
setShowBadge(false)
|
||||||
},
|
},
|
||||||
buildNotificationChannel(CHANNEL_NEW_CHAPTERS, IMPORTANCE_DEFAULT) {
|
|
||||||
setName(context.getString(R.string.channel_new_chapters))
|
|
||||||
},
|
|
||||||
buildNotificationChannel(CHANNEL_UPDATES_TO_EXTS, IMPORTANCE_DEFAULT) {
|
|
||||||
setName(context.getString(R.string.channel_ext_updates))
|
|
||||||
},
|
|
||||||
buildNotificationChannel(CHANNEL_BACKUP_RESTORE_PROGRESS, IMPORTANCE_LOW) {
|
buildNotificationChannel(CHANNEL_BACKUP_RESTORE_PROGRESS, IMPORTANCE_LOW) {
|
||||||
setName(context.getString(R.string.channel_progress))
|
setName(context.getString(R.string.channel_progress))
|
||||||
setGroup(GROUP_BACKUP_RESTORE)
|
setGroup(GROUP_BACKUP_RESTORE)
|
||||||
|
@ -145,8 +156,11 @@ object Notifications {
|
||||||
buildNotificationChannel(CHANNEL_INCOGNITO_MODE, IMPORTANCE_LOW) {
|
buildNotificationChannel(CHANNEL_INCOGNITO_MODE, IMPORTANCE_LOW) {
|
||||||
setName(context.getString(R.string.pref_incognito_mode))
|
setName(context.getString(R.string.pref_incognito_mode))
|
||||||
},
|
},
|
||||||
|
buildNotificationChannel(CHANNEL_UPDATES_TO_EXTS, IMPORTANCE_DEFAULT) {
|
||||||
|
setName(context.getString(R.string.channel_ext_updates))
|
||||||
|
},
|
||||||
|
)
|
||||||
)
|
)
|
||||||
notificationService.createNotificationChannelsCompat(channelList)
|
|
||||||
|
|
||||||
// Delete old notification channels
|
// Delete old notification channels
|
||||||
deprecatedChannels.forEach(notificationService::deleteNotificationChannel)
|
deprecatedChannels.forEach(notificationService::deleteNotificationChannel)
|
||||||
|
|
|
@ -171,8 +171,6 @@ object PreferenceKeys {
|
||||||
|
|
||||||
const val autoUpdateTrackers = "auto_update_trackers"
|
const val autoUpdateTrackers = "auto_update_trackers"
|
||||||
|
|
||||||
const val showLibraryUpdateErrors = "show_library_update_errors"
|
|
||||||
|
|
||||||
const val downloadNew = "download_new"
|
const val downloadNew = "download_new"
|
||||||
|
|
||||||
const val downloadNewCategories = "download_new_categories"
|
const val downloadNewCategories = "download_new_categories"
|
||||||
|
|
|
@ -86,8 +86,6 @@ class PreferencesHelper(val context: Context) {
|
||||||
|
|
||||||
fun autoUpdateTrackers() = prefs.getBoolean(Keys.autoUpdateTrackers, false)
|
fun autoUpdateTrackers() = prefs.getBoolean(Keys.autoUpdateTrackers, false)
|
||||||
|
|
||||||
fun showLibraryUpdateErrors() = prefs.getBoolean(Keys.showLibraryUpdateErrors, true)
|
|
||||||
|
|
||||||
fun themeMode() = flowPrefs.getEnum(Keys.themeMode, system)
|
fun themeMode() = flowPrefs.getEnum(Keys.themeMode, system)
|
||||||
|
|
||||||
fun appTheme() = flowPrefs.getEnum(Keys.appTheme, Values.AppTheme.DEFAULT)
|
fun appTheme() = flowPrefs.getEnum(Keys.appTheme, Values.AppTheme.DEFAULT)
|
||||||
|
|
|
@ -282,11 +282,6 @@ class SettingsLibraryController : SettingsController() {
|
||||||
defaultValue = false
|
defaultValue = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
switchPreference {
|
|
||||||
key = Keys.showLibraryUpdateErrors
|
|
||||||
titleRes = R.string.pref_library_update_error_notification
|
|
||||||
defaultValue = true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -226,7 +226,6 @@
|
||||||
<string name="pref_library_update_refresh_metadata_summary">Check for new cover and details when updating library</string>
|
<string name="pref_library_update_refresh_metadata_summary">Check for new cover and details when updating library</string>
|
||||||
<string name="pref_library_update_refresh_trackers">Automatically refresh trackers</string>
|
<string name="pref_library_update_refresh_trackers">Automatically refresh trackers</string>
|
||||||
<string name="pref_library_update_refresh_trackers_summary">Update trackers when updating library</string>
|
<string name="pref_library_update_refresh_trackers_summary">Update trackers when updating library</string>
|
||||||
<string name="pref_library_update_error_notification">Show update errors notifications</string>
|
|
||||||
|
|
||||||
<string name="default_category">Default category</string>
|
<string name="default_category">Default category</string>
|
||||||
<string name="default_category_summary">Always ask</string>
|
<string name="default_category_summary">Always ask</string>
|
||||||
|
@ -775,9 +774,6 @@
|
||||||
<string name="channel_progress">Progress</string>
|
<string name="channel_progress">Progress</string>
|
||||||
<string name="channel_complete">Complete</string>
|
<string name="channel_complete">Complete</string>
|
||||||
<string name="channel_errors">Errors</string>
|
<string name="channel_errors">Errors</string>
|
||||||
<string name="channel_library">Library</string>
|
|
||||||
<string name="group_downloader">Downloads</string>
|
|
||||||
<string name="group_backup_restore">Backup and restore</string>
|
|
||||||
<string name="channel_new_chapters">Chapter updates</string>
|
<string name="channel_new_chapters">Chapter updates</string>
|
||||||
<string name="channel_ext_updates">Extension updates</string>
|
<string name="channel_ext_updates">Extension updates</string>
|
||||||
<string name="channel_crash_logs">Crash logs</string>
|
<string name="channel_crash_logs">Crash logs</string>
|
||||||
|
|
Loading…
Reference in a new issue