mirror of
https://github.com/null2264/yokai.git
synced 2025-06-21 10:44:42 +00:00
Continue to use big style for skips/errors
compact text will still say tap for details etc
This commit is contained in:
parent
0f439d1d94
commit
1932b16770
2 changed files with 34 additions and 16 deletions
|
@ -89,21 +89,33 @@ class LibraryUpdateNotifier(private val context: Context) {
|
|||
/**
|
||||
* Shows notification containing update entries that failed with action to open full log.
|
||||
*
|
||||
* @param errorCount Count of entry titles that failed to update.
|
||||
* @param errors List of entry titles that failed to update.
|
||||
* @param uri Uri for error log file containing all titles that failed.
|
||||
*/
|
||||
fun showUpdateErrorNotification(errorCount: Int, uri: Uri) {
|
||||
if (errorCount == 0) {
|
||||
fun showUpdateErrorNotification(errors: List<String>, uri: Uri) {
|
||||
if (errors.isEmpty()) {
|
||||
return
|
||||
}
|
||||
|
||||
val pendingIntent = NotificationReceiver.openErrorOrSkippedLogPendingActivity(context, uri)
|
||||
context.notificationManager.notify(
|
||||
Notifications.ID_LIBRARY_ERROR,
|
||||
context.notificationBuilder(Notifications.CHANNEL_LIBRARY_ERROR) {
|
||||
setContentTitle(context.getString(R.string.notification_update_error, errorCount))
|
||||
setContentTitle(context.getString(R.string.notification_update_error, errors.size))
|
||||
setContentText(context.getString(R.string.tap_to_see_details))
|
||||
setContentIntent(NotificationReceiver.openErrorOrSkippedLogPendingActivity(context, uri))
|
||||
setStyle(
|
||||
NotificationCompat.BigTextStyle().bigText(
|
||||
errors.joinToString("\n") {
|
||||
it.chop(TITLE_MAX_LEN)
|
||||
}
|
||||
)
|
||||
)
|
||||
setContentIntent(pendingIntent)
|
||||
setSmallIcon(R.drawable.ic_tachij2k_notification)
|
||||
addAction(
|
||||
R.drawable.nnf_ic_file_folder,
|
||||
context.getString(R.string.open_log),
|
||||
pendingIntent
|
||||
)
|
||||
}
|
||||
.build()
|
||||
)
|
||||
|
@ -112,26 +124,32 @@ class LibraryUpdateNotifier(private val context: Context) {
|
|||
/**
|
||||
* Shows notification containing update entries that were skipped with actions to open full log and learn more.
|
||||
*
|
||||
* @param skippedCount Count of entry titles that were skipped to update.
|
||||
* @param skips List of entry titles that were skipped.
|
||||
* @param uri Uri for error log file containing all titles that were skipped.
|
||||
*/
|
||||
fun showUpdateSkippedNotification(skippedCount: Int, uri: Uri) {
|
||||
if (skippedCount == 0) {
|
||||
fun showUpdateSkippedNotification(skips: List<String>, uri: Uri) {
|
||||
if (skips.isEmpty()) {
|
||||
return
|
||||
}
|
||||
|
||||
context.notificationManager.notify(
|
||||
Notifications.ID_LIBRARY_SKIPPED,
|
||||
context.notificationBuilder(Notifications.CHANNEL_LIBRARY_SKIPPED) {
|
||||
setContentTitle(context.getString(R.string.notification_update_skipped, skippedCount))
|
||||
setContentTitle(context.getString(R.string.notification_update_skipped, skips.size))
|
||||
setContentText(context.getString(R.string.tap_to_learn_more))
|
||||
setStyle(
|
||||
NotificationCompat.BigTextStyle().bigText(
|
||||
skips.joinToString("\n") {
|
||||
it.chop(TITLE_MAX_LEN)
|
||||
}
|
||||
)
|
||||
)
|
||||
setContentIntent(NotificationHandler.openUrl(context, HELP_SKIPPED_URL))
|
||||
setSmallIcon(R.drawable.ic_tachij2k_notification)
|
||||
addAction(
|
||||
R.drawable.ic_help_24dp,
|
||||
R.drawable.nnf_ic_file_folder,
|
||||
context.getString(R.string.open_log),
|
||||
NotificationReceiver.openErrorOrSkippedLogPendingActivity(context, uri)
|
||||
|
||||
)
|
||||
}
|
||||
.build()
|
||||
|
|
|
@ -370,17 +370,17 @@ class LibraryUpdateService(
|
|||
}
|
||||
newUpdates.clear()
|
||||
}
|
||||
if (skippedUpdates.isNotEmpty()) {
|
||||
if (skippedUpdates.isNotEmpty() && Notifications.isNotificationChannelEnabled(this, Notifications.CHANNEL_LIBRARY_SKIPPED)) {
|
||||
val skippedFile = writeErrorFile(
|
||||
skippedUpdates,
|
||||
"skipped",
|
||||
getString(R.string.learn_more_at_, LibraryUpdateNotifier.HELP_SKIPPED_URL)
|
||||
).getUriCompat(this)
|
||||
notifier.showUpdateSkippedNotification(skippedUpdates.size, skippedFile)
|
||||
notifier.showUpdateSkippedNotification(skippedUpdates.map { it.key.title }, skippedFile)
|
||||
}
|
||||
if (failedUpdates.isNotEmpty()) {
|
||||
if (failedUpdates.isNotEmpty() && Notifications.isNotificationChannelEnabled(this, Notifications.CHANNEL_LIBRARY_ERROR)) {
|
||||
val errorFile = writeErrorFile(failedUpdates).getUriCompat(this)
|
||||
notifier.showUpdateErrorNotification(failedUpdates.size, errorFile)
|
||||
notifier.showUpdateErrorNotification(failedUpdates.map { it.key.title }, errorFile)
|
||||
}
|
||||
mangaShortcutManager.updateShortcuts()
|
||||
failedUpdates.clear()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue