From e05c374d2c9c51a24e4b5a83d3807bab2eef6462 Mon Sep 17 00:00:00 2001 From: Jay Date: Sun, 15 Mar 2020 14:24:07 -0700 Subject: [PATCH] Removed Downloaded fonts + using private scope for manga details presenter --- app/src/main/AndroidManifest.xml | 4 -- .../ui/manga/MangaDetailsController.kt | 22 +++------ .../ui/manga/MangaDetailsPresenter.kt | 47 ++++++++++--------- .../tachiyomi/ui/manga/MangaHeaderHolder.kt | 8 ++-- .../ui/setting/SettingsMainController.kt | 12 ++--- app/src/main/res/font/roboto_medium.xml | 7 --- app/src/main/res/values/font_certs.xml | 17 ------- app/src/main/res/values/preloaded_fonts.xml | 6 --- app/src/main/res/values/strings.xml | 6 +-- app/src/main/res/values/styles.xml | 2 +- 10 files changed, 42 insertions(+), 89 deletions(-) delete mode 100644 app/src/main/res/font/roboto_medium.xml delete mode 100644 app/src/main/res/values/font_certs.xml delete mode 100644 app/src/main/res/values/preloaded_fonts.xml diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 5746d22a48..f4cf12020a 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -148,10 +148,6 @@ android:name=".data.backup.BackupRestoreService" android:exported="false"/> - - diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailsController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailsController.kt index a8756d78c5..985f16655b 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailsController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailsController.kt @@ -163,8 +163,7 @@ class MangaDetailsController : BaseController, */ private var actionMode: ActionMode? = null - // Hold a reference to the current animator, - // so that it can be canceled mid-way. + // Hold a reference to the current animator, so that it can be canceled mid-way. private var currentAnimator: Animator? = null var headerHeight = 0 @@ -206,7 +205,7 @@ class MangaDetailsController : BaseController, (recycler.findViewHolderForAdapterPosition(0) as? MangaHeaderHolder) ?.setTopHeight(headerHeight) fast_scroller?.updateLayoutParams { - topMargin = appbarHeight + insets.systemWindowInsetTop + topMargin = headerHeight bottomMargin = insets.systemWindowInsetBottom } v.updatePaddingRelative(bottom = insets.systemWindowInsetBottom) @@ -254,16 +253,12 @@ class MangaDetailsController : BaseController, setPaletteColor() if (manga?.initialized != true) - swipe_refresh.post { - swipe_refresh.isRefreshing = true - } + swipe_refresh.post { swipe_refresh.isRefreshing = true } - swipe_refresh.setOnRefreshListener { - presenter.refreshAll() - } + swipe_refresh.setOnRefreshListener { presenter.refreshAll() } } - private fun setPaletteColor() { + fun setPaletteColor() { val view = view ?: return GlideApp.with(view.context).load(manga) .diskCacheStrategy(DiskCacheStrategy.AUTOMATIC) @@ -454,7 +449,6 @@ class MangaDetailsController : BaseController, } private fun bookmarkChapters(chapters: List, bookmarked: Boolean) { - //destroyActionModeIfNeeded() presenter.bookmarkChapters(chapters, bookmarked) } @@ -469,12 +463,9 @@ class MangaDetailsController : BaseController, presenter.markChaptersRead(chapters, false) } - private fun openChapter(chapter: Chapter, hasAnimation: Boolean = false) { + private fun openChapter(chapter: Chapter) { val activity = activity ?: return val intent = ReaderActivity.newIntent(activity, manga!!, chapter) - if (hasAnimation) { - intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION) - } startActivity(intent) } @@ -1134,7 +1125,6 @@ class MangaDetailsController : BaseController, } companion object { - const val UPDATE_EXTRA = "update" const val SMART_SEARCH_CONFIG_EXTRA = "smartSearchConfig" diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailsPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailsPresenter.kt index 03d3a664db..e75fe84d1f 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailsPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailsPresenter.kt @@ -34,6 +34,7 @@ import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job import kotlinx.coroutines.async +import kotlinx.coroutines.cancel import kotlinx.coroutines.launch import kotlinx.coroutines.withContext import uy.kohesive.injekt.Injekt @@ -42,7 +43,6 @@ import java.io.File import java.io.FileOutputStream import java.io.OutputStream import java.util.Date -import kotlin.coroutines.CoroutineContext class MangaDetailsPresenter(private val controller: MangaDetailsController, val manga: Manga, @@ -51,11 +51,10 @@ class MangaDetailsPresenter(private val controller: MangaDetailsController, private val coverCache: CoverCache = Injekt.get(), private val db: DatabaseHelper = Injekt.get(), private val downloadManager: DownloadManager = Injekt.get()): - CoroutineScope, DownloadQueue.DownloadListener, LibraryServiceListener { - override var coroutineContext:CoroutineContext = Job() + Dispatchers.Default + private var scope = CoroutineScope(Job() + Dispatchers.Default) var isLockedFromSearch = false var hasRequested = false @@ -93,10 +92,11 @@ class MangaDetailsPresenter(private val controller: MangaDetailsController, fun onDestroy() { downloadManager.removeListener(this) LibraryUpdateService.removeListener(this) + scope.cancel() } fun fetchChapters() { - launch { + scope.launch { getChapters() refreshTracking() withContext(Dispatchers.Main) { controller.updateChapters(chapters) } @@ -142,7 +142,7 @@ class MangaDetailsPresenter(private val controller: MangaDetailsController, override fun updateDownload(download: Download) { chapters.find { it.id == download.chapter.id }?.download = download - launch(Dispatchers.Main) { + scope.launch(Dispatchers.Main) { controller.updateChapterDownload(download) } } @@ -318,7 +318,7 @@ class MangaDetailsPresenter(private val controller: MangaDetailsController, } fun refreshAll() { - launch { + scope.launch { isLoading = true var mangaError: java.lang.Exception? = null var chapterError: java.lang.Exception? = null @@ -346,8 +346,10 @@ class MangaDetailsPresenter(private val controller: MangaDetailsController, manga.copyFrom(networkManga) manga.initialized = true db.insertManga(manga).executeAsBlocking() - if (thumbnailUrl != networkManga.thumbnail_url) + if (thumbnailUrl != networkManga.thumbnail_url) { MangaImpl.setLastCoverFetch(manga.id!!, Date().time) + withContext(Dispatchers.Main) { controller.setPaletteColor() } + } } val finChapters = chapters.await() if (finChapters.isNotEmpty()) { @@ -369,7 +371,7 @@ class MangaDetailsPresenter(private val controller: MangaDetailsController, hasRequested = true isLoading = true - launch(Dispatchers.IO) { + scope.launch(Dispatchers.IO) { val chapters = try { source.fetchChapterList(manga).toBlocking().single() } @@ -401,7 +403,7 @@ class MangaDetailsPresenter(private val controller: MangaDetailsController, * @param selectedChapters the list of chapters to bookmark. */ fun bookmarkChapters(selectedChapters: List, bookmarked: Boolean) { - launch(Dispatchers.IO) { + scope.launch(Dispatchers.IO) { selectedChapters.forEach { it.bookmark = bookmarked } @@ -416,7 +418,7 @@ class MangaDetailsPresenter(private val controller: MangaDetailsController, * @param read whether to mark chapters as read or unread. */ fun markChaptersRead(selectedChapters: List, read: Boolean) { - launch(Dispatchers.IO) { + scope.launch(Dispatchers.IO) { selectedChapters.forEach { it.read = read if (!read) { @@ -460,7 +462,7 @@ class MangaDetailsPresenter(private val controller: MangaDetailsController, } private fun asyncUpdateMangaAndChapters(justChapters:Boolean = false) { - launch { + scope.launch { if (!justChapters) withContext(Dispatchers.IO) { db.updateFlags(manga).executeAsBlocking() } updateChapters() @@ -550,7 +552,7 @@ class MangaDetailsPresenter(private val controller: MangaDetailsController, val destDir = File(context.cacheDir, "shared_image") - launch(Dispatchers.IO) { + scope.launch(Dispatchers.IO) { destDir.deleteRecursively() try { val image = saveImage(cover, destDir, manga) @@ -669,9 +671,8 @@ class MangaDetailsPresenter(private val controller: MangaDetailsController, // Tracking - private fun fetchTrackings() { - launch { + scope.launch { trackList = loggedServices.map { service -> TrackItem(tracks.find { it.sync_id == service.id }, service) } @@ -687,7 +688,7 @@ class MangaDetailsPresenter(private val controller: MangaDetailsController, } fun refreshTrackers() { - launch { + scope.launch { val list = trackList.filter { it.track != null }.map { item -> withContext(Dispatchers.IO) { val trackItem = try { @@ -709,7 +710,7 @@ class MangaDetailsPresenter(private val controller: MangaDetailsController, } fun trackSearch(query: String, service: TrackService) { - launch(Dispatchers.IO) { + scope.launch(Dispatchers.IO) { val results = try {service.search(query) } catch (e: Exception) { withContext(Dispatchers.Main) { controller.trackSearchError(e) } @@ -724,7 +725,7 @@ class MangaDetailsPresenter(private val controller: MangaDetailsController, if (item != null) { item.manga_id = manga.id!! - launch { + scope.launch { val binding = try { service.bind(item) } catch (e: Exception) { trackError(e) @@ -735,7 +736,7 @@ class MangaDetailsPresenter(private val controller: MangaDetailsController, refreshTracking() } } else { - launch { + scope.launch { withContext(Dispatchers.IO) { db.deleteTrackForManga(manga, service) .executeAsBlocking() } refreshTracking() @@ -744,7 +745,7 @@ class MangaDetailsPresenter(private val controller: MangaDetailsController, } private fun updateRemote(track: Track, service: TrackService) { - launch { + scope.launch { val binding = try { service.update(track) } catch (e: Exception) { trackError(e) @@ -758,12 +759,12 @@ class MangaDetailsPresenter(private val controller: MangaDetailsController, } } - private suspend fun trackRefreshDone() { - async(Dispatchers.Main) { controller.trackRefreshDone() } + private fun trackRefreshDone() { + scope.launch(Dispatchers.Main) { controller.trackRefreshDone() } } - private suspend fun trackError(error: Exception) { - async(Dispatchers.Main) { controller.trackRefreshError(error) } + private fun trackError(error: Exception) { + scope.launch(Dispatchers.Main) { controller.trackRefreshError(error) } } fun setStatus(item: TrackItem, index: Int) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaHeaderHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaHeaderHolder.kt index 7bac6c3ebd..da47fa5ff9 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaHeaderHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaHeaderHolder.kt @@ -165,13 +165,13 @@ class MangaHeaderHolder( else { val name = nextChapter.name resources.getString( - if (nextChapter.last_page_read > 0) R.string.continue_reading_x - else R.string.start_reading_x, name + if (nextChapter.last_page_read > 0) R.string.continue_reading + else R.string.start_reading ) } } else { - text = resources.getString(R.string.all_caught_up) + text = resources.getString(R.string.start_reading) } } @@ -237,7 +237,7 @@ class MangaHeaderHolder( } fun updateTracking() { - val presenter = adapter.coverListener?.mangaPresenter() ?: return + val presenter = adapter.coverListener.mangaPresenter() ?: return val tracked = presenter.isTracked() with(track_button) { text = itemView.context.getString(if (tracked) R.string.action_filter_tracked diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsMainController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsMainController.kt index 762bcf79de..2e60af0912 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsMainController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsMainController.kt @@ -47,18 +47,18 @@ class SettingsMainController : SettingsController() { titleRes = R.string.pref_category_downloads onClick { navigateTo(SettingsDownloadController()) } } - preference { - iconRes = R.drawable.ic_sync_black_24dp - iconTint = tintColor - titleRes = R.string.pref_category_tracking - onClick { navigateTo(SettingsTrackingController()) } - } preference { iconRes = R.drawable.ic_swap_calls_white_24dp iconTint = tintColor titleRes = R.string.label_migration onClick { navigateTo(MigrationController()) } } + preference { + iconRes = R.drawable.ic_sync_black_24dp + iconTint = tintColor + titleRes = R.string.pref_category_tracking + onClick { navigateTo(SettingsTrackingController()) } + } preference { iconRes = R.drawable.ic_backup_black_24dp iconTint = tintColor diff --git a/app/src/main/res/font/roboto_medium.xml b/app/src/main/res/font/roboto_medium.xml deleted file mode 100644 index 59df90bc82..0000000000 --- a/app/src/main/res/font/roboto_medium.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - diff --git a/app/src/main/res/values/font_certs.xml b/app/src/main/res/values/font_certs.xml deleted file mode 100644 index d2226ac01c..0000000000 --- a/app/src/main/res/values/font_certs.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - @array/com_google_android_gms_fonts_certs_dev - @array/com_google_android_gms_fonts_certs_prod - - - - MIIEqDCCA5CgAwIBAgIJANWFuGx90071MA0GCSqGSIb3DQEBBAUAMIGUMQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRh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+++FGfvjJ/CxURaSxaBvGdGDhfXE28LWuT9ozCl5xw4Yq5OGazvV24mZVSoOO0yZ31j7kYvtwYK6NeADwbSxDdJEqO4k//0zOHKrUiGYXtqw/A0LFFtqoZKFjnkCAQOjgdkwgdYwHQYDVR0OBBYEFMd9jMIhF1Ylmn/Tgt9r45jk14alMIGmBgNVHSMEgZ4wgZuAFMd9jMIhF1Ylmn/Tgt9r45jk14aloXikdjB0MQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEUMBIGA1UEChMLR29vZ2xlIEluYy4xEDAOBgNVBAsTB0FuZHJvaWQxEDAOBgNVBAMTB0FuZHJvaWSCCQDC4IdGZEowjTAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBAUAA4IBAQBt0lLO74UwLDYKqs6Tm8/yzKkEu116FmH4rkaymUIE0P9KaMftGlMexFlaYjzmB2OxZyl6euNXEsQH8gjwyxCUKRJNexBiGcCEyj6z+a1fuHHvkiaai+KL8W1EyNmgjmyy8AW7P+LLlkR+ho5zEHatRbM/YAnqGcFh5iZBqpknHf1SKMXFh4dd239FJ1jWYfbMDMy3NS5CTMQ2XFI1MvcyUTdZPErjQfTbQe3aDQsQcafEQPD+nqActifKZ0Np0IS9L9kR/wbNvyz6ENwPiTrjV2KRkEjH78ZMcUQXg0L3BYHJ3lc69Vs5Ddf9uUGGMYldX3WfMBEmh/9iFBDAaTCK - - - diff --git a/app/src/main/res/values/preloaded_fonts.xml b/app/src/main/res/values/preloaded_fonts.xml deleted file mode 100644 index 3ad41da55e..0000000000 --- a/app/src/main/res/values/preloaded_fonts.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - @font/roboto_medium - - diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index ac5440994e..f890fc5622 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -469,8 +469,7 @@ Hide unread badges Show unread badges Show unread count - You can show filters by again tapping the Library tab when - hidden + To show filters again, tap the Library icon Search filters @@ -523,14 +522,11 @@ No description Mark all chapters as read? Remove from library - All caught up Select starting chapter Select ending chapter Start reading - Start reading %1$s - Continue reading %1$s Start reading Chapter %1$s Continue reading Chapter %1$s Continue reading diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 04e59dfc98..730f68e3f1 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -45,7 +45,7 @@