Fix notifications
This commit is contained in:
@@ -40,6 +40,7 @@ class CaptchaNotifier(
|
|||||||
.setPriority(NotificationCompat.PRIORITY_DEFAULT)
|
.setPriority(NotificationCompat.PRIORITY_DEFAULT)
|
||||||
.setDefaults(NotificationCompat.DEFAULT_SOUND)
|
.setDefaults(NotificationCompat.DEFAULT_SOUND)
|
||||||
.setSmallIcon(android.R.drawable.stat_notify_error)
|
.setSmallIcon(android.R.drawable.stat_notify_error)
|
||||||
|
.setGroup(GROUP_CAPTCHA)
|
||||||
.setAutoCancel(true)
|
.setAutoCancel(true)
|
||||||
.setVisibility(
|
.setVisibility(
|
||||||
if (exception.source?.contentType == ContentType.HENTAI) {
|
if (exception.source?.contentType == ContentType.HENTAI) {
|
||||||
@@ -82,5 +83,6 @@ class CaptchaNotifier(
|
|||||||
private const val PARAM_IGNORE_CAPTCHA = "ignore_captcha"
|
private const val PARAM_IGNORE_CAPTCHA = "ignore_captcha"
|
||||||
private const val CHANNEL_ID = "captcha"
|
private const val CHANNEL_ID = "captcha"
|
||||||
private const val TAG = CHANNEL_ID
|
private const val TAG = CHANNEL_ID
|
||||||
|
private const val GROUP_CAPTCHA = "org.koitharu.kotatsu.CAPTCHA"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,6 +65,12 @@ class FavouritesRepository @Inject constructor(
|
|||||||
.distinctUntilChanged()
|
.distinctUntilChanged()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suspend fun getCategories(): List<FavouriteCategory> {
|
||||||
|
return db.getFavouriteCategoriesDao().findAll().map {
|
||||||
|
it.toFavouriteCategory()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun observeCategories(): Flow<List<FavouriteCategory>> {
|
fun observeCategories(): Flow<List<FavouriteCategory>> {
|
||||||
return db.getFavouriteCategoriesDao().observeAll().mapItems {
|
return db.getFavouriteCategoriesDao().observeAll().mapItems {
|
||||||
it.toFavouriteCategory()
|
it.toFavouriteCategory()
|
||||||
|
|||||||
@@ -273,6 +273,7 @@ class SuggestionsWorker @AssistedInject constructor(
|
|||||||
with(builder) {
|
with(builder) {
|
||||||
setContentText(tagsText)
|
setContentText(tagsText)
|
||||||
setContentTitle(title)
|
setContentTitle(title)
|
||||||
|
setGroup(GROUP_SUGGESTION)
|
||||||
setLargeIcon(
|
setLargeIcon(
|
||||||
coil.execute(
|
coil.execute(
|
||||||
ImageRequest.Builder(applicationContext)
|
ImageRequest.Builder(applicationContext)
|
||||||
@@ -425,6 +426,7 @@ class SuggestionsWorker @AssistedInject constructor(
|
|||||||
const val DATA_COUNT = "count"
|
const val DATA_COUNT = "count"
|
||||||
const val WORKER_CHANNEL_ID = "suggestion_worker"
|
const val WORKER_CHANNEL_ID = "suggestion_worker"
|
||||||
const val MANGA_CHANNEL_ID = "suggestions"
|
const val MANGA_CHANNEL_ID = "suggestions"
|
||||||
|
const val GROUP_SUGGESTION = "org.koitharu.kotatsu.SUGGESTIONS"
|
||||||
const val WORKER_NOTIFICATION_ID = 36
|
const val WORKER_NOTIFICATION_ID = 36
|
||||||
const val MAX_RESULTS = 80
|
const val MAX_RESULTS = 80
|
||||||
const val MAX_PARALLELISM = 3
|
const val MAX_PARALLELISM = 3
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import org.koitharu.kotatsu.core.parser.RemoteMangaRepository
|
|||||||
import org.koitharu.kotatsu.core.prefs.AppSettings
|
import org.koitharu.kotatsu.core.prefs.AppSettings
|
||||||
import org.koitharu.kotatsu.core.util.CompositeMutex2
|
import org.koitharu.kotatsu.core.util.CompositeMutex2
|
||||||
import org.koitharu.kotatsu.core.util.ext.toInstantOrNull
|
import org.koitharu.kotatsu.core.util.ext.toInstantOrNull
|
||||||
|
import org.koitharu.kotatsu.favourites.domain.FavouritesRepository
|
||||||
import org.koitharu.kotatsu.history.data.HistoryRepository
|
import org.koitharu.kotatsu.history.data.HistoryRepository
|
||||||
import org.koitharu.kotatsu.parsers.model.Manga
|
import org.koitharu.kotatsu.parsers.model.Manga
|
||||||
import org.koitharu.kotatsu.parsers.util.runCatchingCancellable
|
import org.koitharu.kotatsu.parsers.util.runCatchingCancellable
|
||||||
@@ -26,6 +27,7 @@ class Tracker @Inject constructor(
|
|||||||
private val settings: AppSettings,
|
private val settings: AppSettings,
|
||||||
private val repository: TrackingRepository,
|
private val repository: TrackingRepository,
|
||||||
private val historyRepository: HistoryRepository,
|
private val historyRepository: HistoryRepository,
|
||||||
|
private val favouritesRepository: FavouritesRepository,
|
||||||
private val channels: TrackerNotificationChannels,
|
private val channels: TrackerNotificationChannels,
|
||||||
private val mangaRepositoryFactory: MangaRepository.Factory,
|
private val mangaRepositoryFactory: MangaRepository.Factory,
|
||||||
) {
|
) {
|
||||||
@@ -45,6 +47,11 @@ class Tracker @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suspend fun updateNotificationsChannels() {
|
||||||
|
val categories = favouritesRepository.getCategories()
|
||||||
|
channels.updateChannels(categories)
|
||||||
|
}
|
||||||
|
|
||||||
suspend fun gc() {
|
suspend fun gc() {
|
||||||
repository.gc()
|
repository.gc()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -104,6 +104,7 @@ class TrackWorker @AssistedInject constructor(
|
|||||||
if (!settings.isTrackerEnabled) {
|
if (!settings.isTrackerEnabled) {
|
||||||
return Result.success(workDataOf(0, 0))
|
return Result.success(workDataOf(0, 0))
|
||||||
}
|
}
|
||||||
|
tracker.updateNotificationsChannels()
|
||||||
val tracks = tracker.getTracks(if (isFullRun) Int.MAX_VALUE else BATCH_SIZE)
|
val tracks = tracker.getTracks(if (isFullRun) Int.MAX_VALUE else BATCH_SIZE)
|
||||||
logger.log("Total ${tracks.size} tracks")
|
logger.log("Total ${tracks.size} tracks")
|
||||||
if (tracks.isEmpty()) {
|
if (tracks.isEmpty()) {
|
||||||
@@ -194,6 +195,7 @@ class TrackWorker @AssistedInject constructor(
|
|||||||
).toBitmapOrNull(),
|
).toBitmapOrNull(),
|
||||||
)
|
)
|
||||||
setSmallIcon(R.drawable.ic_stat_book_plus)
|
setSmallIcon(R.drawable.ic_stat_book_plus)
|
||||||
|
setGroup(GROUP_NEW_CHAPTERS)
|
||||||
val style = NotificationCompat.InboxStyle(this)
|
val style = NotificationCompat.InboxStyle(this)
|
||||||
for (chapter in newChapters) {
|
for (chapter in newChapters) {
|
||||||
style.addLine(chapter.name)
|
style.addLine(chapter.name)
|
||||||
@@ -366,6 +368,7 @@ class TrackWorker @AssistedInject constructor(
|
|||||||
|
|
||||||
const val WORKER_CHANNEL_ID = "track_worker"
|
const val WORKER_CHANNEL_ID = "track_worker"
|
||||||
const val WORKER_NOTIFICATION_ID = 35
|
const val WORKER_NOTIFICATION_ID = 35
|
||||||
|
const val GROUP_NEW_CHAPTERS = "org.koitharu.kotatsu.NEW_CHAPTERS"
|
||||||
const val TAG = "tracking"
|
const val TAG = "tracking"
|
||||||
const val TAG_ONESHOT = "tracking_oneshot"
|
const val TAG_ONESHOT = "tracking_oneshot"
|
||||||
const val MAX_PARALLELISM = 6
|
const val MAX_PARALLELISM = 6
|
||||||
|
|||||||
Reference in New Issue
Block a user