mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-24 04:11:52 +01:00
Migrations now using mat grid style
Migrations will also no longer be cancelled by switching tabs
This commit is contained in:
parent
3940d42185
commit
3044dca9bb
@ -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) {
|
||||
badge_view.visibility = if (inLibrary) View.VISIBLE else View.GONE
|
||||
unread_angle.visibility = View.GONE
|
||||
|
@ -208,7 +208,7 @@ open class LibraryController(
|
||||
|
||||
presenter.onRestore()
|
||||
val library = presenter.getAllManga()
|
||||
if (library != null) presenter.updateViewBlocking() //onNextLibraryUpdate(presenter.categories, library)
|
||||
if (library != null) presenter.updateViewBlocking()
|
||||
else {
|
||||
contentView().alpha = 0f
|
||||
presenter.getLibraryBlocking()
|
||||
|
@ -170,6 +170,7 @@ class LibraryListController(bundle: Bundle? = null) : LibraryController(bundle),
|
||||
}
|
||||
|
||||
override fun onNextLibraryUpdate(mangaMap: List<LibraryItem>, freshStart: Boolean) {
|
||||
val recyclerLayout = recycler_layout ?: return
|
||||
if (mangaMap.isNotEmpty()) {
|
||||
empty_view?.hide()
|
||||
} else {
|
||||
@ -179,7 +180,7 @@ class LibraryListController(bundle: Bundle? = null) : LibraryController(bundle),
|
||||
|
||||
|
||||
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())
|
||||
spinnerAdapter?.setDropDownViewResource(R.layout.library_spinner_entry_text)
|
||||
spinner.adapter = spinnerAdapter
|
||||
@ -188,8 +189,8 @@ class LibraryListController(bundle: Bundle? = null) : LibraryController(bundle),
|
||||
spinner.setSelection(min(presenter.categories.size - 1, activeCategory + 1))
|
||||
if (!freshStart) {
|
||||
justStarted = false
|
||||
if (recycler_layout.alpha == 0f)
|
||||
recycler_layout.animate().alpha(1f).setDuration(500).start()
|
||||
if (recyclerLayout.alpha == 0f)
|
||||
recyclerLayout.animate().alpha(1f).setDuration(500).start()
|
||||
|
||||
|
||||
}else {
|
||||
|
@ -18,6 +18,7 @@ import androidx.appcompat.content.res.AppCompatResources
|
||||
import androidx.appcompat.graphics.drawable.DrawerArrowDrawable
|
||||
import androidx.biometric.BiometricManager
|
||||
import androidx.core.view.GravityCompat
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import com.bluelinelabs.conductor.Conductor
|
||||
import com.bluelinelabs.conductor.Controller
|
||||
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.LibraryListController
|
||||
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.recently_read.RecentlyReadController
|
||||
import eu.kanade.tachiyomi.ui.setting.SettingsMainController
|
||||
@ -128,6 +130,19 @@ open class MainActivity : BaseActivity(), DownloadServiceListener {
|
||||
|
||||
navigationView.setOnNavigationItemSelectedListener { item ->
|
||||
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()
|
||||
if (currentRoot?.tag()?.toIntOrNull() != id) {
|
||||
|
@ -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.migration.MigrationMangaDialog
|
||||
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.system.toast
|
||||
import eu.kanade.tachiyomi.util.system.await
|
||||
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.coroutines.CancellationException
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
@ -69,7 +69,8 @@ class MigrationListController(bundle: Bundle? = null) : BaseController(bundle),
|
||||
|
||||
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 selectedPosition:Int? = null
|
||||
private var manaulMigrations = 0
|
||||
|
@ -2,7 +2,9 @@ package eu.kanade.tachiyomi.ui.migration.manga.process
|
||||
|
||||
import android.view.View
|
||||
import androidx.appcompat.widget.PopupMenu
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
||||
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
||||
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.manga.MangaController
|
||||
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.invisible
|
||||
import eu.kanade.tachiyomi.util.system.launchUI
|
||||
import eu.kanade.tachiyomi.util.view.setVectorCompat
|
||||
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.unread_download_badge.view.*
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
@ -62,7 +66,7 @@ class MigrationProcessHolder(
|
||||
migration_manga_card_to.resetManga()
|
||||
if (manga != null) {
|
||||
withContext(Dispatchers.Main) {
|
||||
migration_manga_card_from.attachManga(manga, source)
|
||||
migration_manga_card_from.attachManga(manga, source, false)
|
||||
migration_manga_card_from.setOnClickListener {
|
||||
adapter.controller.router.pushController(
|
||||
MangaController(
|
||||
@ -94,7 +98,7 @@ class MigrationProcessHolder(
|
||||
return@withContext
|
||||
}
|
||||
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 {
|
||||
adapter.controller.router.pushController(
|
||||
MangaController(
|
||||
@ -103,7 +107,7 @@ class MigrationProcessHolder(
|
||||
)
|
||||
}
|
||||
} else {
|
||||
migration_manga_card_to.loading_group.gone()
|
||||
migration_manga_card_to.progress.gone()
|
||||
migration_manga_card_to.title.text =
|
||||
view.context.applicationContext.getString(R.string.no_alternatives_found)
|
||||
}
|
||||
@ -116,32 +120,40 @@ class MigrationProcessHolder(
|
||||
}
|
||||
|
||||
private fun View.resetManga() {
|
||||
loading_group.visible()
|
||||
thumbnail.setImageDrawable(null)
|
||||
progress.visible()
|
||||
cover_thumbnail.setImageDrawable(null)
|
||||
compact_title.text = ""
|
||||
title.text = ""
|
||||
manga_source_label.text = ""
|
||||
manga_chapters.text = ""
|
||||
manga_chapters.gone()
|
||||
manga_last_chapter_label.text = ""
|
||||
subtitle.text = ""
|
||||
badge_view.setChapters(null)
|
||||
(layoutParams as ConstraintLayout.LayoutParams).verticalBias = 0.5f
|
||||
subtitle.text = ""
|
||||
migration_manga_card_to.setOnClickListener(null)
|
||||
}
|
||||
|
||||
private fun View.attachManga(manga: Manga, source: Source) {
|
||||
loading_group.gone()
|
||||
GlideApp.with(view.context.applicationContext)
|
||||
.load(manga)
|
||||
.diskCacheStrategy(DiskCacheStrategy.RESOURCE)
|
||||
.centerCrop()
|
||||
.into(thumbnail)
|
||||
private fun View.attachManga(manga: Manga, source: Source, isTo: Boolean) {
|
||||
(layoutParams as ConstraintLayout.LayoutParams).verticalBias = 1f
|
||||
progress.gone()
|
||||
GlideApp.with(view.context.applicationContext).load(manga).apply {
|
||||
diskCacheStrategy(DiskCacheStrategy.RESOURCE)
|
||||
if (isTo) {
|
||||
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)
|
||||
} else {
|
||||
manga.currentTitle()
|
||||
}
|
||||
|
||||
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 {
|
||||
sourceManager.getOrStub(it.source).toString()
|
||||
}.distinct().joinToString()
|
||||
@ -150,15 +162,14 @@ class MigrationProcessHolder(
|
||||
// }
|
||||
|
||||
val mangaChapters = db.getChapters(manga).executeAsBlocking()
|
||||
manga_chapters.visible()
|
||||
manga_chapters.text = mangaChapters.size.toString()
|
||||
badge_view.setChapters(mangaChapters.size)
|
||||
val latestChapter = mangaChapters.maxBy { it.chapter_number }?.chapter_number ?: -1f
|
||||
|
||||
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))
|
||||
} 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))
|
||||
}
|
||||
}
|
||||
|
@ -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>
|
@ -8,8 +8,9 @@
|
||||
|
||||
<include
|
||||
android:id="@+id/migration_manga_card_from"
|
||||
layout="@layout/migration_manga_card"
|
||||
layout="@layout/catalogue_grid_item"
|
||||
android:layout_width="150dp"
|
||||
app:layout_constraintVertical_bias="1.0"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@+id/imageView"
|
||||
@ -34,7 +35,8 @@
|
||||
|
||||
<include
|
||||
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_height="wrap_content"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
|
Loading…
Reference in New Issue
Block a user