mirror of
https://github.com/readrops/Readrops.git
synced 2025-02-09 00:18:52 +01:00
Change sync channel importance and set auto-cancel to sync result notification
This commit is contained in:
parent
85b867462c
commit
05f8fc56a7
@ -48,7 +48,7 @@ public class ReadropsApp extends Application {
|
|||||||
opmlExportChannel.setDescription(getString(R.string.opml_export_description));
|
opmlExportChannel.setDescription(getString(R.string.opml_export_description));
|
||||||
|
|
||||||
NotificationChannel syncChannel = new NotificationChannel(SYNC_CHANNEL_ID,
|
NotificationChannel syncChannel = new NotificationChannel(SYNC_CHANNEL_ID,
|
||||||
getString(R.string.auto_synchro), NotificationManager.IMPORTANCE_DEFAULT);
|
getString(R.string.auto_synchro), NotificationManager.IMPORTANCE_LOW);
|
||||||
syncChannel.setDescription(getString(R.string.account_synchro));
|
syncChannel.setDescription(getString(R.string.account_synchro));
|
||||||
|
|
||||||
NotificationManager manager = getSystemService(NotificationManager.class);
|
NotificationManager manager = getSystemService(NotificationManager.class);
|
||||||
|
@ -35,7 +35,7 @@ class SyncWorker(context: Context, parameters: WorkerParameters) : Worker(contex
|
|||||||
val syncResults = mutableMapOf<Account, SyncResult>()
|
val syncResults = mutableMapOf<Account, SyncResult>()
|
||||||
accounts.forEach {
|
accounts.forEach {
|
||||||
notificationBuilder.setContentText(it.accountName)
|
notificationBuilder.setContentText(it.accountName)
|
||||||
notificationManager.notify(NOTIFICATION_ID, notificationBuilder.build())
|
notificationManager.notify(SYNC_NOTIFICATION_ID, notificationBuilder.build())
|
||||||
|
|
||||||
val repository = ARepository.repositoryFactory(it, applicationContext)
|
val repository = ARepository.repositoryFactory(it, applicationContext)
|
||||||
|
|
||||||
@ -46,7 +46,7 @@ class SyncWorker(context: Context, parameters: WorkerParameters) : Worker(contex
|
|||||||
syncResults[it] = repository.syncResult
|
syncResults[it] = repository.syncResult
|
||||||
}
|
}
|
||||||
|
|
||||||
notificationManager.cancel(NOTIFICATION_ID)
|
notificationManager.cancel(SYNC_NOTIFICATION_ID)
|
||||||
displaySyncResultNotif(syncResults)
|
displaySyncResultNotif(syncResults)
|
||||||
|
|
||||||
return result
|
return result
|
||||||
@ -56,7 +56,7 @@ class SyncWorker(context: Context, parameters: WorkerParameters) : Worker(contex
|
|||||||
super.onStopped()
|
super.onStopped()
|
||||||
|
|
||||||
disposable.dispose()
|
disposable.dispose()
|
||||||
notificationManager.cancel(NOTIFICATION_ID)
|
notificationManager.cancel(SYNC_NOTIFICATION_ID)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun displaySyncResultNotif(syncResults: Map<Account, SyncResult>) {
|
private fun displaySyncResultNotif(syncResults: Map<Account, SyncResult>) {
|
||||||
@ -70,11 +70,12 @@ class SyncWorker(context: Context, parameters: WorkerParameters) : Worker(contex
|
|||||||
.setContentText(notifContent.content)
|
.setContentText(notifContent.content)
|
||||||
.setSmallIcon(R.drawable.ic_notif)
|
.setSmallIcon(R.drawable.ic_notif)
|
||||||
.setContentIntent(PendingIntent.getActivity(applicationContext, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT))
|
.setContentIntent(PendingIntent.getActivity(applicationContext, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT))
|
||||||
|
.setAutoCancel(true)
|
||||||
|
|
||||||
if (notifContent.largeIcon != null)
|
if (notifContent.largeIcon != null)
|
||||||
notificationBuilder.setLargeIcon(notifContent.largeIcon)
|
notificationBuilder.setLargeIcon(notifContent.largeIcon)
|
||||||
|
|
||||||
notificationManager.notify(ITEMS_NOTIFICATION_ID,
|
notificationManager.notify(SYNC_RESULT_NOTIFICATION_ID,
|
||||||
notificationBuilder.build())
|
notificationBuilder.build())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,7 +83,7 @@ class SyncWorker(context: Context, parameters: WorkerParameters) : Worker(contex
|
|||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val TAG = SyncWorker::class.java.simpleName
|
val TAG = SyncWorker::class.java.simpleName
|
||||||
private const val NOTIFICATION_ID = 2
|
private const val SYNC_NOTIFICATION_ID = 2
|
||||||
private const val ITEMS_NOTIFICATION_ID = 3
|
private const val SYNC_RESULT_NOTIFICATION_ID = 3
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user