Migrations now using mat grid style

Migrations will also no longer be cancelled by switching tabs
This commit is contained in:
Jay 2020-02-21 21:39:50 -08:00
parent 3940d42185
commit 3044dca9bb
8 changed files with 69 additions and 160 deletions

View File

@ -59,6 +59,10 @@ class LibraryBadge @JvmOverloads constructor(context: Context, attrs: AttributeS
} }
} }
fun setChapters(chapters: Int?) {
setUnreadDownload(chapters ?: 0, 0, chapters != null)
}
fun setInLibrary(inLibrary: Boolean) { fun setInLibrary(inLibrary: Boolean) {
badge_view.visibility = if (inLibrary) View.VISIBLE else View.GONE badge_view.visibility = if (inLibrary) View.VISIBLE else View.GONE
unread_angle.visibility = View.GONE unread_angle.visibility = View.GONE

View File

@ -208,7 +208,7 @@ open class LibraryController(
presenter.onRestore() presenter.onRestore()
val library = presenter.getAllManga() val library = presenter.getAllManga()
if (library != null) presenter.updateViewBlocking() //onNextLibraryUpdate(presenter.categories, library) if (library != null) presenter.updateViewBlocking()
else { else {
contentView().alpha = 0f contentView().alpha = 0f
presenter.getLibraryBlocking() presenter.getLibraryBlocking()

View File

@ -170,6 +170,7 @@ class LibraryListController(bundle: Bundle? = null) : LibraryController(bundle),
} }
override fun onNextLibraryUpdate(mangaMap: List<LibraryItem>, freshStart: Boolean) { override fun onNextLibraryUpdate(mangaMap: List<LibraryItem>, freshStart: Boolean) {
val recyclerLayout = recycler_layout ?: return
if (mangaMap.isNotEmpty()) { if (mangaMap.isNotEmpty()) {
empty_view?.hide() empty_view?.hide()
} else { } else {
@ -179,7 +180,7 @@ class LibraryListController(bundle: Bundle? = null) : LibraryController(bundle),
spinner.onItemSelectedListener = null spinner.onItemSelectedListener = null
spinnerAdapter = SpinnerAdapter(view!!.context, R.layout.library_spinner_textview, spinnerAdapter = SpinnerAdapter(spinner.context, R.layout.library_spinner_textview,
presenter.categories.map { it.name }.toTypedArray()) presenter.categories.map { it.name }.toTypedArray())
spinnerAdapter?.setDropDownViewResource(R.layout.library_spinner_entry_text) spinnerAdapter?.setDropDownViewResource(R.layout.library_spinner_entry_text)
spinner.adapter = spinnerAdapter spinner.adapter = spinnerAdapter
@ -188,8 +189,8 @@ class LibraryListController(bundle: Bundle? = null) : LibraryController(bundle),
spinner.setSelection(min(presenter.categories.size - 1, activeCategory + 1)) spinner.setSelection(min(presenter.categories.size - 1, activeCategory + 1))
if (!freshStart) { if (!freshStart) {
justStarted = false justStarted = false
if (recycler_layout.alpha == 0f) if (recyclerLayout.alpha == 0f)
recycler_layout.animate().alpha(1f).setDuration(500).start() recyclerLayout.animate().alpha(1f).setDuration(500).start()
}else { }else {

View File

@ -18,6 +18,7 @@ import androidx.appcompat.content.res.AppCompatResources
import androidx.appcompat.graphics.drawable.DrawerArrowDrawable import androidx.appcompat.graphics.drawable.DrawerArrowDrawable
import androidx.biometric.BiometricManager import androidx.biometric.BiometricManager
import androidx.core.view.GravityCompat import androidx.core.view.GravityCompat
import com.afollestad.materialdialogs.MaterialDialog
import com.bluelinelabs.conductor.Conductor import com.bluelinelabs.conductor.Conductor
import com.bluelinelabs.conductor.Controller import com.bluelinelabs.conductor.Controller
import com.bluelinelabs.conductor.ControllerChangeHandler import com.bluelinelabs.conductor.ControllerChangeHandler
@ -49,6 +50,7 @@ import eu.kanade.tachiyomi.ui.extension.ExtensionController
import eu.kanade.tachiyomi.ui.library.LibraryController import eu.kanade.tachiyomi.ui.library.LibraryController
import eu.kanade.tachiyomi.ui.library.LibraryListController import eu.kanade.tachiyomi.ui.library.LibraryListController
import eu.kanade.tachiyomi.ui.manga.MangaController import eu.kanade.tachiyomi.ui.manga.MangaController
import eu.kanade.tachiyomi.ui.migration.manga.process.MigrationListController
import eu.kanade.tachiyomi.ui.recent_updates.RecentChaptersController import eu.kanade.tachiyomi.ui.recent_updates.RecentChaptersController
import eu.kanade.tachiyomi.ui.recently_read.RecentlyReadController import eu.kanade.tachiyomi.ui.recently_read.RecentlyReadController
import eu.kanade.tachiyomi.ui.setting.SettingsMainController import eu.kanade.tachiyomi.ui.setting.SettingsMainController
@ -128,6 +130,19 @@ open class MainActivity : BaseActivity(), DownloadServiceListener {
navigationView.setOnNavigationItemSelectedListener { item -> navigationView.setOnNavigationItemSelectedListener { item ->
val id = item.itemId val id = item.itemId
val currentController = router.backstack.lastOrNull()?.controller()
if (currentController is MigrationListController &&
currentController.migrationsJob?.isCancelled == false) {
MaterialDialog(this).show {
title(R.string.stop_migration)
positiveButton(R.string.action_stop) {
currentController.migrationsJob?.cancel()
this@MainActivity.navigationView.selectedItemId = id
}
negativeButton(android.R.string.cancel)
}
return@setOnNavigationItemSelectedListener false
}
val currentRoot = router.backstack.firstOrNull() val currentRoot = router.backstack.firstOrNull()
if (currentRoot?.tag()?.toIntOrNull() != id) { if (currentRoot?.tag()?.toIntOrNull() != id) {

View File

@ -27,12 +27,12 @@ import eu.kanade.tachiyomi.ui.base.controller.BaseController
import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction
import eu.kanade.tachiyomi.ui.migration.MigrationMangaDialog import eu.kanade.tachiyomi.ui.migration.MigrationMangaDialog
import eu.kanade.tachiyomi.ui.migration.SearchController import eu.kanade.tachiyomi.ui.migration.SearchController
import eu.kanade.tachiyomi.util.view.RecyclerWindowInsetsListener
import eu.kanade.tachiyomi.util.system.await
import eu.kanade.tachiyomi.util.system.launchUI
import eu.kanade.tachiyomi.util.chapter.syncChaptersWithSource import eu.kanade.tachiyomi.util.chapter.syncChaptersWithSource
import eu.kanade.tachiyomi.util.system.toast import eu.kanade.tachiyomi.util.system.await
import eu.kanade.tachiyomi.util.system.getResourceColor import eu.kanade.tachiyomi.util.system.getResourceColor
import eu.kanade.tachiyomi.util.system.launchUI
import eu.kanade.tachiyomi.util.system.toast
import eu.kanade.tachiyomi.util.view.RecyclerWindowInsetsListener
import kotlinx.android.synthetic.main.chapters_controller.* import kotlinx.android.synthetic.main.chapters_controller.*
import kotlinx.coroutines.CancellationException import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
@ -69,7 +69,8 @@ class MigrationListController(bundle: Bundle? = null) : BaseController(bundle),
private val smartSearchEngine = SmartSearchEngine(coroutineContext, config?.extraSearchParams) private val smartSearchEngine = SmartSearchEngine(coroutineContext, config?.extraSearchParams)
private var migrationsJob: Job? = null var migrationsJob: Job? = null
private set
private var migratingManga: MutableList<MigratingManga>? = null private var migratingManga: MutableList<MigratingManga>? = null
private var selectedPosition:Int? = null private var selectedPosition:Int? = null
private var manaulMigrations = 0 private var manaulMigrations = 0

View File

@ -2,7 +2,9 @@ package eu.kanade.tachiyomi.ui.migration.manga.process
import android.view.View import android.view.View
import androidx.appcompat.widget.PopupMenu import androidx.appcompat.widget.PopupMenu
import androidx.constraintlayout.widget.ConstraintLayout
import com.bumptech.glide.load.engine.DiskCacheStrategy import com.bumptech.glide.load.engine.DiskCacheStrategy
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions
import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.database.DatabaseHelper import eu.kanade.tachiyomi.data.database.DatabaseHelper
import eu.kanade.tachiyomi.data.database.models.Manga import eu.kanade.tachiyomi.data.database.models.Manga
@ -13,13 +15,15 @@ import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction
import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder
import eu.kanade.tachiyomi.ui.manga.MangaController import eu.kanade.tachiyomi.ui.manga.MangaController
import eu.kanade.tachiyomi.util.system.getResourceColor import eu.kanade.tachiyomi.util.system.getResourceColor
import eu.kanade.tachiyomi.util.system.launchUI
import eu.kanade.tachiyomi.util.view.gone import eu.kanade.tachiyomi.util.view.gone
import eu.kanade.tachiyomi.util.view.invisible import eu.kanade.tachiyomi.util.view.invisible
import eu.kanade.tachiyomi.util.system.launchUI
import eu.kanade.tachiyomi.util.view.setVectorCompat import eu.kanade.tachiyomi.util.view.setVectorCompat
import eu.kanade.tachiyomi.util.view.visible import eu.kanade.tachiyomi.util.view.visible
import kotlinx.android.synthetic.main.migration_manga_card.view.* import eu.kanade.tachiyomi.widget.StateImageViewTarget
import kotlinx.android.synthetic.main.catalogue_grid_item.view.*
import kotlinx.android.synthetic.main.migration_process_item.* import kotlinx.android.synthetic.main.migration_process_item.*
import kotlinx.android.synthetic.main.unread_download_badge.view.*
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext import kotlinx.coroutines.withContext
import uy.kohesive.injekt.injectLazy import uy.kohesive.injekt.injectLazy
@ -62,7 +66,7 @@ class MigrationProcessHolder(
migration_manga_card_to.resetManga() migration_manga_card_to.resetManga()
if (manga != null) { if (manga != null) {
withContext(Dispatchers.Main) { withContext(Dispatchers.Main) {
migration_manga_card_from.attachManga(manga, source) migration_manga_card_from.attachManga(manga, source, false)
migration_manga_card_from.setOnClickListener { migration_manga_card_from.setOnClickListener {
adapter.controller.router.pushController( adapter.controller.router.pushController(
MangaController( MangaController(
@ -94,7 +98,7 @@ class MigrationProcessHolder(
return@withContext return@withContext
} }
if (searchResult != null && resultSource != null) { if (searchResult != null && resultSource != null) {
migration_manga_card_to.attachManga(searchResult, resultSource) migration_manga_card_to.attachManga(searchResult, resultSource, true)
migration_manga_card_to.setOnClickListener { migration_manga_card_to.setOnClickListener {
adapter.controller.router.pushController( adapter.controller.router.pushController(
MangaController( MangaController(
@ -103,7 +107,7 @@ class MigrationProcessHolder(
) )
} }
} else { } else {
migration_manga_card_to.loading_group.gone() migration_manga_card_to.progress.gone()
migration_manga_card_to.title.text = migration_manga_card_to.title.text =
view.context.applicationContext.getString(R.string.no_alternatives_found) view.context.applicationContext.getString(R.string.no_alternatives_found)
} }
@ -116,32 +120,40 @@ class MigrationProcessHolder(
} }
private fun View.resetManga() { private fun View.resetManga() {
loading_group.visible() progress.visible()
thumbnail.setImageDrawable(null) cover_thumbnail.setImageDrawable(null)
compact_title.text = ""
title.text = "" title.text = ""
manga_source_label.text = "" subtitle.text = ""
manga_chapters.text = "" badge_view.setChapters(null)
manga_chapters.gone() (layoutParams as ConstraintLayout.LayoutParams).verticalBias = 0.5f
manga_last_chapter_label.text = "" subtitle.text = ""
migration_manga_card_to.setOnClickListener(null) migration_manga_card_to.setOnClickListener(null)
} }
private fun View.attachManga(manga: Manga, source: Source) { private fun View.attachManga(manga: Manga, source: Source, isTo: Boolean) {
loading_group.gone() (layoutParams as ConstraintLayout.LayoutParams).verticalBias = 1f
GlideApp.with(view.context.applicationContext) progress.gone()
.load(manga) GlideApp.with(view.context.applicationContext).load(manga).apply {
.diskCacheStrategy(DiskCacheStrategy.RESOURCE) diskCacheStrategy(DiskCacheStrategy.RESOURCE)
.centerCrop() if (isTo) {
.into(thumbnail) transition(DrawableTransitionOptions.withCrossFade())
.into(StateImageViewTarget(cover_thumbnail, progress))
}
else
into(cover_thumbnail)
}
title.text = if (manga.currentTitle().isBlank()) { compact_title.visible()
gradient.visible()
compact_title.text = if (manga.currentTitle().isBlank()) {
view.context.getString(R.string.unknown) view.context.getString(R.string.unknown)
} else { } else {
manga.currentTitle() manga.currentTitle()
} }
gradient.visible() gradient.visible()
manga_source_label.text = /*if (source.id == MERGED_SOURCE_ID) { title.text = /*if (source.id == MERGED_SOURCE_ID) {
MergedSource.MangaConfig.readFromUrl(gson, manga.url).children.map { MergedSource.MangaConfig.readFromUrl(gson, manga.url).children.map {
sourceManager.getOrStub(it.source).toString() sourceManager.getOrStub(it.source).toString()
}.distinct().joinToString() }.distinct().joinToString()
@ -150,15 +162,14 @@ class MigrationProcessHolder(
// } // }
val mangaChapters = db.getChapters(manga).executeAsBlocking() val mangaChapters = db.getChapters(manga).executeAsBlocking()
manga_chapters.visible() badge_view.setChapters(mangaChapters.size)
manga_chapters.text = mangaChapters.size.toString()
val latestChapter = mangaChapters.maxBy { it.chapter_number }?.chapter_number ?: -1f val latestChapter = mangaChapters.maxBy { it.chapter_number }?.chapter_number ?: -1f
if (latestChapter > 0f) { if (latestChapter > 0f) {
manga_last_chapter_label.text = context.getString(R.string.latest_x, subtitle.text = context.getString(R.string.latest_x,
DecimalFormat("#.#").format(latestChapter)) DecimalFormat("#.#").format(latestChapter))
} else { } else {
manga_last_chapter_label.text = context.getString(R.string.latest_x, subtitle.text = context.getString(R.string.latest_x,
context.getString(R.string.unknown)) context.getString(R.string.unknown))
} }
} }

View File

@ -1,125 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="?selectable_library_drawable">
<FrameLayout
android:id="@+id/card"
android:layout_width="wrap_content"
android:layout_height="220dp"
android:background="@drawable/card_background"
app:layout_constraintDimensionRatio="0.75"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintWidth_min="100dp"
app:layout_constraintHeight_min="100dp">
<ImageView
android:id="@+id/thumbnail"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?android:attr/colorBackground"
tools:background="?android:attr/colorBackground"
tools:ignore="ContentDescription"
tools:src="@mipmap/ic_launcher" />
<View
android:id="@+id/gradient"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="@drawable/gradient_shape" />
<ProgressBar
android:id="@+id/loading_group"
android:layout_width="56dp"
android:layout_height="56dp"
android:layout_gravity="center" />
<TextView
android:id="@+id/manga_chapters"
style="@style/TextAppearance.Regular.Caption.Light"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/md_white_1000"
android:background="@color/md_teal_500"
android:paddingBottom="1dp"
android:paddingLeft="3dp"
android:paddingRight="3dp"
android:paddingTop="1dp"
android:visibility="gone"
tools:visibility="visible"
android:text="101"
android:layout_marginStart="4dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginTop="4dp"/>
<eu.kanade.tachiyomi.widget.PTSansTextView
android:id="@+id/title"
style="@style/TextAppearance.Regular.Body1.Light"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/md_white_1000"
android:layout_gravity="bottom"
android:ellipsize="end"
android:lineSpacingExtra="-4dp"
android:maxLines="2"
android:padding="8dp"
android:shadowColor="@color/md_black_1000_87"
android:shadowDx="0"
android:shadowDy="0"
android:shadowRadius="4"
app:typeface="ptsansNarrowBold"
tools:text="Sample name" />
<ProgressBar
android:id="@+id/progress"
style="?android:attr/progressBarStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:visibility="gone" />
</FrameLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:paddingBottom="20dp"
android:gravity="start"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="@id/card"
app:layout_constraintStart_toStartOf="@id/card"
app:layout_constraintTop_toBottomOf="@id/card">
<TextView
android:id="@+id/manga_source_label"
style="@style/TextAppearance.Medium.Body2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="false"
android:textIsSelectable="false"
app:layout_constraintLeft_toLeftOf="parent"
android:ellipsize="end"
android:maxLines="1"
tools:layout_editor_absoluteY="57dp" />
<TextView
android:id="@+id/manga_last_chapter_label"
style="@style/TextAppearance.Regular.Body1.Secondary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="false"
android:textIsSelectable="false" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -8,8 +8,9 @@
<include <include
android:id="@+id/migration_manga_card_from" android:id="@+id/migration_manga_card_from"
layout="@layout/migration_manga_card" layout="@layout/catalogue_grid_item"
android:layout_width="150dp" android:layout_width="150dp"
app:layout_constraintVertical_bias="1.0"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/imageView" app:layout_constraintEnd_toStartOf="@+id/imageView"
@ -34,7 +35,8 @@
<include <include
android:id="@+id/migration_manga_card_to" android:id="@+id/migration_manga_card_to"
layout="@layout/migration_manga_card" layout="@layout/catalogue_grid_item"
app:layout_constraintVertical_bias="1.0"
android:layout_width="150dp" android:layout_width="150dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"