Removed Downloaded fonts + using private scope for manga details presenter

This commit is contained in:
Jay 2020-03-15 14:24:07 -07:00
parent 9a044e9037
commit e05c374d2c
10 changed files with 42 additions and 89 deletions

View File

@ -148,10 +148,6 @@
android:name=".data.backup.BackupRestoreService"
android:exported="false"/>
<meta-data
android:name="preloaded_fonts"
android:resource="@array/preloaded_fonts" />
</application>
</manifest>

View File

@ -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<ViewGroup.MarginLayoutParams> {
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<ChapterItem>, 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"

View File

@ -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<ChapterItem>, 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<ChapterItem>, 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) {

View File

@ -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

View File

@ -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

View File

@ -1,7 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<font-family xmlns:app="http://schemas.android.com/apk/res-auto"
app:fontProviderAuthority="com.google.android.gms.fonts"
app:fontProviderPackage="com.google.android.gms"
app:fontProviderQuery="name=Roboto&amp;weight=500"
app:fontProviderCerts="@array/com_google_android_gms_fonts_certs">
</font-family>

View File

@ -1,17 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<array name="com_google_android_gms_fonts_certs">
<item>@array/com_google_android_gms_fonts_certs_dev</item>
<item>@array/com_google_android_gms_fonts_certs_prod</item>
</array>
<string-array name="com_google_android_gms_fonts_certs_dev">
<item>
MIIEqDCCA5CgAwIBAgIJANWFuGx90071MA0GCSqGSIb3DQEBBAUAMIGUMQswCQYDV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8lGmPav5xVwnIiJS6HXk+BVKZF+JcWjAsb/GEuq/eFdpuzSqeYTcfi6idkyugwfYwXFU1+5fZKUaRKYCwkkFQVfcAs1fXA5V+++FGfvjJ/CxURaSxaBvGdGDhfXE28LWuT9ozCl5xw4Yq5OGazvV24mZVSoOO0yZ31j7kYvtwYK6NeADwbSxDdJEqO4k//0zOHKrUiGYXtqw/A0LFFtqoZKFjnkCAQOjgdkwgdYwHQYDVR0OBBYEFMd9jMIhF1Ylmn/Tgt9r45jk14alMIGmBgNVHSMEgZ4wgZuAFMd9jMIhF1Ylmn/Tgt9r45jk14aloXikdjB0MQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEUMBIGA1UEChMLR29vZ2xlIEluYy4xEDAOBgNVBAsTB0FuZHJvaWQxEDAOBgNVBAMTB0FuZHJvaWSCCQDC4IdGZEowjTAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBAUAA4IBAQBt0lLO74UwLDYKqs6Tm8/yzKkEu116FmH4rkaymUIE0P9KaMftGlMexFlaYjzmB2OxZyl6euNXEsQH8gjwyxCUKRJNexBiGcCEyj6z+a1fuHHvkiaai+KL8W1EyNmgjmyy8AW7P+LLlkR+ho5zEHatRbM/YAnqGcFh5iZBqpknHf1SKMXFh4dd239FJ1jWYfbMDMy3NS5CTMQ2XFI1MvcyUTdZPErjQfTbQe3aDQsQcafEQPD+nqActifKZ0Np0IS9L9kR/wbNvyz6ENwPiTrjV2KRkEjH78ZMcUQXg0L3BYHJ3lc69Vs5Ddf9uUGGMYldX3WfMBEmh/9iFBDAaTCK
</item>
</string-array>
</resources>

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<array name="preloaded_fonts" translatable="false">
<item>@font/roboto_medium</item>
</array>
</resources>

View File

@ -469,8 +469,7 @@
<string name="hide_unread">Hide unread badges</string>
<string name="show_unread">Show unread badges</string>
<string name="show_unread_count">Show unread count</string>
<string name="hide_filters_tip">You can show filters by again tapping the Library tab when
hidden</string>
<string name="hide_filters_tip">To show filters again, tap the Library icon</string>
<!-- Catalogue fragment -->
<string name="source_search_options">Search filters</string>
@ -523,14 +522,11 @@
<string name="no_description">No description</string>
<string name="mark_all_as_read_message">Mark all chapters as read?</string>
<string name="remove_from_library">Remove from library</string>
<string name="all_caught_up">All caught up</string>
<string name="select_start_chapter">Select starting chapter</string>
<string name="select_end_chapter">Select ending chapter</string>
<!-- Manga chapters fragment -->
<string name="start_reading">Start reading</string>
<string name="start_reading_x">Start reading %1$s</string>
<string name="continue_reading_x">Continue reading %1$s</string>
<string name="start_reading_chapter">Start reading Chapter %1$s</string>
<string name="continue_reading_chapter">Continue reading Chapter %1$s</string>
<string name="continue_reading">Continue reading</string>

View File

@ -45,7 +45,7 @@
</style>
<style name="TextAppearance.Regular">
<item name="android:fontFamily">sans-serif-regular</item>
<item name="android:fontFamily">sans-serif</item>
</style>
<style name="TextAppearance.Regular.Body1">