Skip to content

Commit

Permalink
Merge pull request #802 from CarlosEsco/2.7.3
Browse files Browse the repository at this point in the history
2.7.3
  • Loading branch information
nonproto authored Dec 27, 2021
2 parents 5be82ec + a12fdb5 commit eceea82
Show file tree
Hide file tree
Showing 25 changed files with 211 additions and 85 deletions.
24 changes: 11 additions & 13 deletions CurrentChangeLog.MD
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
## 🥳 New
Lime Time Theme (@Jays2Kings)
Compress to cbz after downloading (@Seishirou101)
Rating will now show again in MangaDex (once they fix the api)
Related Manga from MangaDex now show in the similar page
## 🏗️ Changes
Use official check if a12 device supports dynamic themes (@Jays2Kings)
Bottom Nav animation is fade in but not fade out (@Jays2Kings)
Updated mapping database for mal/anilist (@Goldbattle)
Update chapter api logic to correspond to MangaDex api changes
## 🐜 Fixes
Reading webtoon style no longer shows when default reading mode is webtoon (@Jays2Kings)
Incognito turning off when entering series from reader (@Jays2Kings)
Tako dark color (@Jays2Kings)
Saving split images (@Jays2Kings)
Split in webtoons when gif format is used (@Jays2Kings)
Manga Covers on tablets (@Jays2Kings)
Missing back/forward buttons on webview (@Jays2Kings)
H badge shows on top of cover now
Download notification was old green
Browse items fail to load when having the first 20 in library, and hide library enabled
Log file button didn't show on restore when only skipped titles and no errors
Collapsing/Expanding a dynamic category was doing the action on all the categories
Changing download folder was not working until app was restarted
reauthorize login before attempting to get reading statuses on library update
non visible error on aggregate endpoint
## 🛠️ Other
update libraries
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ object Configs {
const val minSdkVersion = 24
const val targetSdkVersion = 30
const val testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
const val versionCode = 135
const val versionName = "2.7.2"
const val versionCode = 136
const val versionName = "2.7.3"
}

plugins {
Expand Down
19 changes: 10 additions & 9 deletions app/src/main/java/eu/kanade/tachiyomi/data/backup/RestoreHelper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import eu.kanade.tachiyomi.util.lang.chop
import eu.kanade.tachiyomi.util.storage.getUriCompat
import eu.kanade.tachiyomi.util.system.notificationManager
import java.io.File
import java.text.SimpleDateFormat
import java.util.Locale

class RestoreHelper(val context: Context) {

Expand Down Expand Up @@ -102,7 +100,7 @@ class RestoreHelper(val context: Context) {
totalAmount: Int,
cancelled: Int,
errors: List<String>,
trackingErrors: List<String>,
trackingErrorsInitial: List<String>,
) {
val content = mutableListOf<String>()
if (categoriesAmount > 0) {
Expand Down Expand Up @@ -141,7 +139,7 @@ class RestoreHelper(val context: Context) {
)
}

val trackingErrors = trackingErrors.distinct()
val trackingErrors = trackingErrorsInitial.distinct()
if (trackingErrors.isNotEmpty()) {
val trackingErrorsString = trackingErrors.distinct().joinToString("\n")
content.add(trackingErrorsString)
Expand All @@ -160,12 +158,12 @@ class RestoreHelper(val context: Context) {
.setSmallIcon(R.drawable.ic_neko_notification)
.setColor(ContextCompat.getColor(context, R.color.new_neko_accent))
.setPriority(NotificationCompat.PRIORITY_HIGH)
if (errors.isNotEmpty() && !path.isNullOrEmpty() && !file.isNullOrEmpty()) {
if (!path.isNullOrEmpty() && !file.isNullOrEmpty()) {
resultNotification.addAction(
R.drawable.ic_close_24dp,
context.getString(
R.string
.view_all_errors
.view_log
),
getErrorLogIntent(path, file)
)
Expand All @@ -177,11 +175,14 @@ class RestoreHelper(val context: Context) {
/**
* Write errors to error log
*/
fun writeErrorLog(errors: List<String>, skippedAmount: Int, skippedTitles: List<String>): File {
fun writeErrorLog(
errors: List<String>,
skippedAmount: Int,
skippedTitles: List<String>,
): File? {
try {
if (errors.isNotEmpty() || skippedTitles.isNotEmpty()) {
val destFile = File(context.externalCacheDir, "neko_restore.log")
val sdf = SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS", Locale.getDefault())

destFile.bufferedWriter().use { out ->
if (skippedAmount > 0) {
Expand All @@ -202,6 +203,6 @@ class RestoreHelper(val context: Context) {
} catch (e: Exception) {
XLog.e(e)
}
return File("")
return null
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ class FullRestore(val context: Context, val job: Job?) {

val logFile = restoreHelper.writeErrorLog(errors, skippedAmount, skippedTitles)
restoreHelper.showResultNotification(
logFile.parent,
logFile.name,
logFile?.parent,
logFile?.name,
categoriesAmount,
restoreProgress,
restoreAmount,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ internal class DownloadNotifier(private val context: Context) {
setAutoCancel(false)
clearActions()
// Open download manager when clicked
color = ContextCompat.getColor(context, R.color.secondaryTachiyomi)
color = ContextCompat.getColor(context, R.color.new_neko_accent)
setContentIntent(NotificationHandler.openDownloadManagerPendingActivity(context))
isDownloading = true
// Pause action
Expand Down Expand Up @@ -160,7 +160,7 @@ internal class DownloadNotifier(private val context: Context) {
setSmallIcon(R.drawable.ic_pause_24dp)
setAutoCancel(false)
setProgress(0, 0, false)
color = ContextCompat.getColor(context, R.color.secondaryTachiyomi)
color = ContextCompat.getColor(context, R.color.new_neko_accent)
clearActions()
// Open download manager when clicked
setContentIntent(NotificationHandler.openDownloadManagerPendingActivity(context))
Expand Down Expand Up @@ -192,7 +192,7 @@ internal class DownloadNotifier(private val context: Context) {
with(errorNotificationBuilder) {
setContentTitle(context.getString(R.string.downloads))
setContentText(reason)
color = ContextCompat.getColor(context, R.color.secondaryTachiyomi)
color = ContextCompat.getColor(context, R.color.new_neko_accent)
setSmallIcon(android.R.drawable.stat_sys_warning)
setAutoCancel(true)
clearActions()
Expand Down Expand Up @@ -242,7 +242,7 @@ internal class DownloadNotifier(private val context: Context) {
} else {
setContentIntent(NotificationHandler.openDownloadManagerPendingActivity(context))
}
color = ContextCompat.getColor(context, R.color.secondaryTachiyomi)
color = ContextCompat.getColor(context, R.color.new_neko_accent)
setProgress(0, 0, false)
show(Notifications.ID_DOWNLOAD_CHAPTER_ERROR)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ import eu.kanade.tachiyomi.source.SourceManager
import eu.kanade.tachiyomi.source.model.isMergedChapter
import eu.kanade.tachiyomi.util.lang.isUUID
import eu.kanade.tachiyomi.util.storage.DiskUtil
import kotlinx.coroutines.flow.drop
import kotlinx.coroutines.flow.onEach
import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get
import uy.kohesive.injekt.injectLazy
Expand All @@ -33,21 +31,12 @@ class DownloadProvider(private val context: Context) {
private val preferences: PreferencesHelper by injectLazy()
private val source = Injekt.get<SourceManager>().getMangadex()

/**
* The root directory for downloads.
*/
private var downloadsDir = preferences.downloadsDirectory().get().let {
fun downloadsDir(): UniFile = preferences.downloadsDirectory().get().let {
val dir = UniFile.fromUri(context, it.toUri())
DiskUtil.createNoMediaFile(dir, context)
dir
}

init {
preferences.downloadsDirectory().asFlow().drop(1).onEach {
downloadsDir = UniFile.fromUri(context, it.toUri())
}
}

/**
* Returns the download directory for a manga. For internal use only.
*
Expand All @@ -60,7 +49,7 @@ class DownloadProvider(private val context: Context) {
val mangaDirName = getMangaDirName(manga)
val sourceDirName = getSourceDirName()
XLog.d("creating directory for $sourceDirName : $mangaDirName")
return downloadsDir.createDirectory(sourceDirName)
return downloadsDir().createDirectory(sourceDirName)
.createDirectory(mangaDirName)
} catch (e: Exception) {
XLog.e("error getting download folder for ${manga.title}", e)
Expand All @@ -74,7 +63,7 @@ class DownloadProvider(private val context: Context) {
* @param source the source to query.
*/
fun findSourceDir(): UniFile? {
return downloadsDir.findFile(getSourceDirName(), true)
return downloadsDir().findFile(getSourceDirName(), true)
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import eu.kanade.tachiyomi.source.SourceManager
import eu.kanade.tachiyomi.source.model.SManga
import eu.kanade.tachiyomi.source.model.isMerged
import eu.kanade.tachiyomi.source.model.isMergedChapter
import eu.kanade.tachiyomi.source.online.MangaDexLoginHelper
import eu.kanade.tachiyomi.source.online.handlers.StatusHandler
import eu.kanade.tachiyomi.source.online.utils.FollowStatus
import eu.kanade.tachiyomi.source.online.utils.MdUtil
Expand Down Expand Up @@ -70,6 +71,7 @@ class LibraryUpdateService(
val preferences: PreferencesHelper = Injekt.get(),
val downloadManager: DownloadManager = Injekt.get(),
val trackManager: TrackManager = Injekt.get(),
val mangaDexLoginHelper: MangaDexLoginHelper = Injekt.get(),
) : Service() {

/**
Expand Down Expand Up @@ -361,6 +363,7 @@ class LibraryUpdateService(
if (mangaToUpdateMap[source] == null) return false
var currentCount = 0
var hasDownloads = false
mangaDexLoginHelper.reAuthIfNeeded()
while (currentCount < mangaToUpdateMap[source]!!.size) {

val manga = mangaToUpdateMap[source]!![currentCount]
Expand Down Expand Up @@ -552,13 +555,14 @@ class LibraryUpdateService(
}

suspend fun updateReadingStatus(mangaList: List<LibraryManga>?) {
XLog.d("Attempting to update reading statuses")
if (mangaList.isNullOrEmpty()) return
if (sourceManager.getMangadex().isLogged() && job?.isCancelled == false) {
runCatching {
val readingStatus = statusHandler.fetchReadingStatusForAllManga()
if (readingStatus.isNotEmpty()) {
XLog.d("Updating follow statuses")
mangaList!!.map { libraryManga ->
mangaList.map { libraryManga ->
runCatching {
db.getTracks(libraryManga).executeOnIO()
.toMutableList()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ import eu.kanade.tachiyomi.source.online.models.dto.LegacyIdDto
import eu.kanade.tachiyomi.source.online.models.dto.LegacyMappingDto
import eu.kanade.tachiyomi.source.online.models.dto.MangaDto
import eu.kanade.tachiyomi.source.online.models.dto.MangaListDto
import eu.kanade.tachiyomi.source.online.models.dto.RelationListDto
import eu.kanade.tachiyomi.source.online.models.dto.ResultDto
import eu.kanade.tachiyomi.source.online.models.dto.StatisticResponseDto
import eu.kanade.tachiyomi.source.online.utils.MdApi
import eu.kanade.tachiyomi.source.online.utils.MdConstants
import retrofit2.http.Body
Expand All @@ -36,6 +38,14 @@ interface MangaDexService {
@Query(value = "translatedLanguage[]") translatedLanguages: List<String>,
): ApiResponse<AggregateDto>

@GET(MdApi.statistics)
suspend fun mangaStatistics(
@Query(value = "manga[]") mangaId: String,
): ApiResponse<StatisticResponseDto>

@GET("${MdApi.manga}/{id}/relation")
suspend fun relatedManga(@Path("id") id: String): ApiResponse<RelationListDto>

@Headers("Cache-Control: no-cache")
@GET("${MdApi.manga}/{id}/feed?limit=500&contentRating[]=${MdConstants.ContentRating.safe}&contentRating[]=${MdConstants.ContentRating.suggestive}&contentRating[]=${MdConstants.ContentRating.erotica}&contentRating[]=${MdConstants.ContentRating.pornographic}&includes[]=${MdConstants.Types.scanlator}&order[volume]=desc&order[chapter]=desc")
suspend fun viewChapters(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,10 @@ class MangaDexLoginHelper {
}
return login(username, password)
}

suspend fun reAuthIfNeeded() {
if (!isAuthenticated() && !refreshToken()) {
login()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import eu.kanade.tachiyomi.source.model.SManga
import eu.kanade.tachiyomi.source.online.models.dto.ChapterDataDto
import eu.kanade.tachiyomi.source.online.models.dto.ChapterDto
import eu.kanade.tachiyomi.source.online.models.dto.MangaDataDto
import eu.kanade.tachiyomi.source.online.models.dto.asMdAggregateVolumeMap
import eu.kanade.tachiyomi.source.online.models.dto.asMdMap
import eu.kanade.tachiyomi.source.online.utils.MdConstants
import eu.kanade.tachiyomi.source.online.utils.MdUtil
Expand Down Expand Up @@ -46,12 +47,26 @@ class ApiMangaParser {
this.log("trying to aggregate for ${mangaDto.id}")
}.getOrNull()

aggregateDto?.volumes?.values
aggregateDto?.volumes?.asMdAggregateVolumeMap()?.values
?.flatMap { it.chapters.values }
?.map { it.chapter }
?: emptyList()
}

withIOContext {
val stats = network.service.mangaStatistics(mangaDto.id)
.onError {
this.log("trying to get rating for ${mangaDto.id}")
}.onException {
this.log("trying to get rating for ${mangaDto.id}")
}.getOrNull()
val rating = stats?.statistics?.get(mangaDto.id)?.rating?.average ?: 0.0
if (rating > 0) {
manga.rating = rating.toString()
}
}


manga.description =
MdUtil.cleanDescription(mangaAttributesDto.description.asMdMap()["en"] ?: "")

Expand Down
Loading

0 comments on commit eceea82

Please sign in to comment.