mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-04 08:55:06 +01:00
More updates
Seperation of Updating Library and New Chapters found If there is only one manga update, a start reading action is added to the notificaion Fixed issue with nav bar not being transparent when starting a shortcut from launcher Insets work on manga info scrolling text
This commit is contained in:
parent
81ef7acffd
commit
7f7acfc55a
@ -10,6 +10,7 @@ import eu.kanade.tachiyomi.data.notification.NotificationHandler
|
||||
import eu.kanade.tachiyomi.data.notification.NotificationReceiver
|
||||
import eu.kanade.tachiyomi.data.notification.Notifications
|
||||
import eu.kanade.tachiyomi.util.chop
|
||||
import eu.kanade.tachiyomi.util.getResourceColor
|
||||
import eu.kanade.tachiyomi.util.notificationManager
|
||||
import java.util.regex.Pattern
|
||||
|
||||
@ -214,9 +215,11 @@ internal class DownloadNotifier(private val context: Context) {
|
||||
setContentTitle(chapter ?: context.getString(R.string.download_notifier_downloader_title))
|
||||
setContentText(error ?: context.getString(R.string.download_notifier_unkown_error))
|
||||
setSmallIcon(android.R.drawable.stat_sys_warning)
|
||||
setCategory(NotificationCompat.CATEGORY_ERROR)
|
||||
clearActions()
|
||||
setAutoCancel(false)
|
||||
setAutoCancel(true)
|
||||
setContentIntent(NotificationHandler.openDownloadManagerPendingActivity(context))
|
||||
color = context.getResourceColor(R.attr.colorAccent)
|
||||
setProgress(0, 0, false)
|
||||
}
|
||||
notification.show(Notifications.ID_DOWNLOAD_CHAPTER_ERROR)
|
||||
|
@ -29,6 +29,8 @@ import eu.kanade.tachiyomi.source.SourceManager
|
||||
import eu.kanade.tachiyomi.source.model.SManga
|
||||
import eu.kanade.tachiyomi.source.online.HttpSource
|
||||
import eu.kanade.tachiyomi.ui.main.MainActivity
|
||||
import eu.kanade.tachiyomi.ui.reader.ReaderActivity
|
||||
import eu.kanade.tachiyomi.ui.recent_updates.RecentChapterItem
|
||||
import eu.kanade.tachiyomi.util.*
|
||||
import rx.Observable
|
||||
import rx.Subscription
|
||||
@ -88,6 +90,7 @@ class LibraryUpdateService(
|
||||
.setLargeIcon(notificationBitmap)
|
||||
.setOngoing(true)
|
||||
.setOnlyAlertOnce(true)
|
||||
.setColor(getResourceColor(R.attr.colorAccent))
|
||||
.addAction(R.drawable.ic_clear_grey_24dp_img, getString(android.R.string.cancel), cancelIntent)
|
||||
}
|
||||
|
||||
@ -444,7 +447,7 @@ class LibraryUpdateService(
|
||||
// Append new chapters from a previous, existing notification
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
val previousNotification = notificationManager.activeNotifications
|
||||
.find { it.id == Notifications.ID_LIBRARY_RESULT }
|
||||
.find { it.id == Notifications.ID_NEW_CHAPTERS }
|
||||
|
||||
if (previousNotification != null) {
|
||||
val oldUpdates = previousNotification.notification.extras
|
||||
@ -456,16 +459,28 @@ class LibraryUpdateService(
|
||||
}
|
||||
}
|
||||
|
||||
notificationManager.notify(Notifications.ID_LIBRARY_RESULT, notification(Notifications.CHANNEL_LIBRARY) {
|
||||
notificationManager.notify(Notifications.ID_NEW_CHAPTERS, notification(Notifications.CHANNEL_NEW_CHAPTERS) {
|
||||
setSmallIcon(R.drawable.ic_book_white_24dp)
|
||||
setLargeIcon(notificationBitmap)
|
||||
setContentTitle(getString(R.string.notification_new_chapters))
|
||||
color = getResourceColor(R.attr.colorAccent)
|
||||
if (newUpdates.size > 1) {
|
||||
setContentText(getString(R.string.notification_new_chapters_text, newUpdates.size))
|
||||
setStyle(NotificationCompat.BigTextStyle().bigText(newUpdates.joinToString("\n")))
|
||||
setNumber(newUpdates.size)
|
||||
} else {
|
||||
val onlyManga = updates.first()
|
||||
val id = onlyManga.id ?: 0
|
||||
setContentText(newUpdates.first())
|
||||
|
||||
val context = applicationContext
|
||||
val db = DatabaseHelper(context)
|
||||
val chapters = db.getChapters(onlyManga).executeAsBlocking()
|
||||
val chapter = chapters.sortedByDescending { it.source_order }.find { !it.read }
|
||||
if (chapter != null) {
|
||||
addAction(R.drawable.ic_in_library_24dp, getString(R.string.action_start_reading),
|
||||
NotificationReceiver.openChapterPendingBroadcast(context, onlyManga, chapter))
|
||||
}
|
||||
}
|
||||
priority = NotificationCompat.PRIORITY_HIGH
|
||||
setContentIntent(getNotificationIntent())
|
||||
|
@ -1,5 +1,6 @@
|
||||
package eu.kanade.tachiyomi.data.notification
|
||||
|
||||
import android.app.Notification
|
||||
import android.app.PendingIntent
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
@ -101,17 +102,19 @@ class NotificationReceiver : BroadcastReceiver() {
|
||||
* @param chapterId id of chapter
|
||||
*/
|
||||
internal fun openChapter(context: Context, mangaId: Long, chapterId: Long) {
|
||||
dismissNotification(context, Notifications.ID_NEW_CHAPTERS)
|
||||
val db = DatabaseHelper(context)
|
||||
val manga = db.getManga(mangaId).executeAsBlocking()
|
||||
val chapter = db.getChapter(chapterId).executeAsBlocking()
|
||||
|
||||
val it = Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)
|
||||
context.sendBroadcast(it)
|
||||
if (manga != null && chapter != null) {
|
||||
val intent = ReaderActivity.newIntent(context, manga, chapter).apply {
|
||||
flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP
|
||||
}
|
||||
context.startActivity(intent)
|
||||
} else {
|
||||
context.toast(context.getString(R.string.chapter_error))
|
||||
context.toast(context.getString(R.string.no_next_chapter))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,6 @@ object Notifications {
|
||||
*/
|
||||
const val CHANNEL_LIBRARY = "library_channel"
|
||||
const val ID_LIBRARY_PROGRESS = 101
|
||||
const val ID_LIBRARY_RESULT = 102
|
||||
|
||||
/**
|
||||
* Notification channel and ids used by the downloader.
|
||||
@ -33,6 +32,12 @@ object Notifications {
|
||||
const val ID_DOWNLOAD_CHAPTER = 201
|
||||
const val ID_DOWNLOAD_CHAPTER_ERROR = 202
|
||||
|
||||
/**
|
||||
* Notification channel and ids used by the library updater.
|
||||
*/
|
||||
const val CHANNEL_NEW_CHAPTERS = "new_chapters_channel"
|
||||
const val ID_NEW_CHAPTERS = 301
|
||||
|
||||
/**
|
||||
* Creates the notification channels introduced in Android Oreo.
|
||||
*
|
||||
@ -44,10 +49,16 @@ object Notifications {
|
||||
val channels = listOf(
|
||||
NotificationChannel(CHANNEL_COMMON, context.getString(R.string.channel_common),
|
||||
NotificationManager.IMPORTANCE_LOW),
|
||||
NotificationChannel(CHANNEL_LIBRARY, context.getString(R.string.channel_library),
|
||||
NotificationManager.IMPORTANCE_LOW),
|
||||
NotificationChannel(CHANNEL_LIBRARY, context.getString(R.string.channel_library_updates),
|
||||
NotificationManager.IMPORTANCE_LOW).apply {
|
||||
setShowBadge(false)
|
||||
},
|
||||
NotificationChannel(CHANNEL_DOWNLOADER, context.getString(R.string.channel_downloader),
|
||||
NotificationManager.IMPORTANCE_LOW)
|
||||
NotificationManager.IMPORTANCE_LOW).apply {
|
||||
setShowBadge(false)
|
||||
},
|
||||
NotificationChannel(CHANNEL_NEW_CHAPTERS, context.getString(R.string.channel_new_chapters),
|
||||
NotificationManager.IMPORTANCE_DEFAULT)
|
||||
)
|
||||
context.notificationManager.createNotificationChannels(channels)
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import com.evernote.android.job.JobManager
|
||||
import com.evernote.android.job.JobRequest
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.notification.Notifications
|
||||
import eu.kanade.tachiyomi.util.getResourceColor
|
||||
import eu.kanade.tachiyomi.util.notificationManager
|
||||
|
||||
class UpdaterJob : Job() {
|
||||
@ -27,6 +28,7 @@ class UpdaterJob : Job() {
|
||||
setContentTitle(context.getString(R.string.app_name))
|
||||
setContentText(context.getString(R.string.update_check_notification_update_available))
|
||||
setSmallIcon(android.R.drawable.stat_sys_download_done)
|
||||
color = context.getResourceColor(R.attr.colorAccent)
|
||||
// Download action
|
||||
addAction(android.R.drawable.stat_sys_download_done,
|
||||
context.getString(R.string.action_download),
|
||||
|
@ -7,6 +7,7 @@ import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.notification.NotificationHandler
|
||||
import eu.kanade.tachiyomi.data.notification.NotificationReceiver
|
||||
import eu.kanade.tachiyomi.data.notification.Notifications
|
||||
import eu.kanade.tachiyomi.util.getResourceColor
|
||||
import eu.kanade.tachiyomi.util.notificationManager
|
||||
|
||||
/**
|
||||
@ -95,6 +96,7 @@ internal class UpdaterNotifier(private val context: Context) {
|
||||
setSmallIcon(android.R.drawable.stat_sys_warning)
|
||||
setOnlyAlertOnce(false)
|
||||
setProgress(0, 0, false)
|
||||
color = context.getResourceColor(R.attr.colorAccent)
|
||||
// Retry action
|
||||
addAction(R.drawable.ic_refresh_grey_24dp_img,
|
||||
context.getString(R.string.action_retry),
|
||||
|
@ -137,6 +137,9 @@ class MainActivity : BaseActivity() {
|
||||
val container: ViewGroup = findViewById(R.id.controller_container)
|
||||
|
||||
val content: LinearLayout = findViewById(R.id.main_content)
|
||||
container.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or
|
||||
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or
|
||||
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
|
||||
content.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or
|
||||
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or
|
||||
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
|
||||
|
@ -223,7 +223,7 @@ class ChaptersPresenter(
|
||||
*/
|
||||
fun getNextUnreadChapter(): ChapterItem? {
|
||||
return chapters.sortedByDescending { it.source_order }.find { !it.read }
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Mark the selected chapter list as read/unread.
|
||||
|
@ -52,7 +52,7 @@
|
||||
android:layout_marginBottom="0dp"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:paddingTop="9dp"
|
||||
android:paddingTop="16dp"
|
||||
android:paddingBottom="16dp"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
|
@ -72,10 +72,12 @@
|
||||
android:id="@+id/info_scrollview"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:layout_marginLeft="0dp"
|
||||
android:layout_marginTop="0dp"
|
||||
android:layout_marginBottom="0dp"
|
||||
android:layout_marginStart="0dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:paddingTop="16dp"
|
||||
android:paddingBottom="24dp"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toTopOf="@+id/guideline"
|
||||
app:layout_constraintLeft_toLeftOf="@+id/guideline2"
|
||||
|
@ -62,6 +62,7 @@
|
||||
<string name="action_sort_down">Sort down</string>
|
||||
<string name="action_show_downloaded">Downloaded</string>
|
||||
<string name="action_next_unread">Next unread</string>
|
||||
<string name="action_start_reading">Start Reading</string>
|
||||
<string name="action_start">Start</string>
|
||||
<string name="action_stop">Stop</string>
|
||||
<string name="action_pause">Pause</string>
|
||||
@ -523,5 +524,7 @@
|
||||
<string name="channel_common">Common</string>
|
||||
<string name="channel_library">Library</string>
|
||||
<string name="channel_downloader">Downloader</string>
|
||||
<string name="channel_library_updates">Updating Library</string>
|
||||
<string name="channel_new_chapters">New Chapters</string>
|
||||
|
||||
</resources>
|
||||
|
Loading…
Reference in New Issue
Block a user