mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-05 01:35:10 +01:00
Fixes for this new auto migration ui
This commit is contained in:
parent
10206ae7b3
commit
6d6ff95982
@ -84,7 +84,6 @@ class MigrationListController(bundle: Bundle? = null) : BaseController(bundle),
|
||||
super.onViewCreated(view)
|
||||
setTitle()
|
||||
val config = this.config ?: return
|
||||
activity?.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT
|
||||
|
||||
val newMigratingManga = migratingManga ?: run {
|
||||
val new = config.mangaIds.map {
|
||||
|
@ -30,10 +30,6 @@ class MigrationProcessAdapter(
|
||||
super.updateDataSet(items)
|
||||
}
|
||||
|
||||
fun indexOf(item: MigrationProcessItem): Int {
|
||||
return items.indexOf(item)
|
||||
}
|
||||
|
||||
interface MigrationProcessInterface {
|
||||
fun onMenuItemClick(position: Int, item: MenuItem)
|
||||
fun enableButtons()
|
||||
|
@ -14,6 +14,7 @@ import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder
|
||||
import eu.kanade.tachiyomi.ui.manga.MangaController
|
||||
import eu.kanade.tachiyomi.util.getResourceColor
|
||||
import eu.kanade.tachiyomi.util.gone
|
||||
import eu.kanade.tachiyomi.util.invisible
|
||||
import eu.kanade.tachiyomi.util.launchUI
|
||||
import eu.kanade.tachiyomi.util.setVectorCompat
|
||||
import eu.kanade.tachiyomi.util.visible
|
||||
@ -31,6 +32,8 @@ class MigrationProcessHolder(
|
||||
|
||||
private val db: DatabaseHelper by injectLazy()
|
||||
private val sourceManager: SourceManager by injectLazy()
|
||||
private var item:MigrationProcessItem? = null
|
||||
|
||||
|
||||
init {
|
||||
// We need to post a Runnable to show the popup to make sure that the PopupMenu is
|
||||
@ -41,18 +44,21 @@ class MigrationProcessHolder(
|
||||
}
|
||||
|
||||
fun bind(item: MigrationProcessItem) {
|
||||
this.item = item
|
||||
launchUI {
|
||||
val manga = item.manga.manga()
|
||||
val source = item.manga.mangaSource()
|
||||
|
||||
migration_menu.setVectorCompat(R.drawable.ic_more_vert_black_24dp, view.context.getResourceColor(R.attr.icon_color))
|
||||
migration_menu.setVectorCompat(R.drawable.ic_more_vert_black_24dp, view.context
|
||||
.getResourceColor(R.attr.icon_color))
|
||||
skip_manga.setVectorCompat(R.drawable.baseline_close_24, view.context.getResourceColor(R
|
||||
.attr.icon_color))
|
||||
migration_menu.gone()
|
||||
migration_menu.invisible()
|
||||
skip_manga.visible()
|
||||
migration_manga_card_to.resetManga()
|
||||
if (manga != null) {
|
||||
withContext(Dispatchers.Main) {
|
||||
migration_manga_card_from.loading_group.gone()
|
||||
attachManga(migration_manga_card_from, manga, source)
|
||||
migration_manga_card_from.attachManga(manga, source)
|
||||
migration_manga_card_from.setOnClickListener {
|
||||
adapter.controller.router.pushController(
|
||||
MangaController(
|
||||
@ -81,9 +87,11 @@ class MigrationProcessHolder(
|
||||
sourceManager.get(it)
|
||||
}
|
||||
withContext(Dispatchers.Main) {
|
||||
if (item.manga.mangaId != this@MigrationProcessHolder.item?.manga?.mangaId) {
|
||||
return@withContext
|
||||
}
|
||||
if (searchResult != null && resultSource != null) {
|
||||
migration_manga_card_to.loading_group.gone()
|
||||
attachManga(migration_manga_card_to, searchResult, resultSource)
|
||||
migration_manga_card_to.attachManga(searchResult, resultSource)
|
||||
migration_manga_card_to.setOnClickListener {
|
||||
adapter.controller.router.pushController(
|
||||
MangaController(
|
||||
@ -107,22 +115,32 @@ class MigrationProcessHolder(
|
||||
migration_manga_card_to.loading_group.visible()
|
||||
}
|
||||
|
||||
fun attachManga(view: View, manga: Manga, source: Source) {
|
||||
view.loading_group.gone()
|
||||
private fun View.resetManga() {
|
||||
loading_group.visible()
|
||||
thumbnail.setImageDrawable(null)
|
||||
title.text = ""
|
||||
manga_source_label.text = ""
|
||||
manga_chapters.text = ""
|
||||
manga_chapters.gone()
|
||||
manga_last_chapter_label.text = ""
|
||||
}
|
||||
|
||||
private fun View.attachManga(manga: Manga, source: Source) {
|
||||
loading_group.gone()
|
||||
GlideApp.with(view.context.applicationContext)
|
||||
.load(manga)
|
||||
.diskCacheStrategy(DiskCacheStrategy.RESOURCE)
|
||||
.centerCrop()
|
||||
.into(view.thumbnail)
|
||||
.into(thumbnail)
|
||||
|
||||
view.title.text = if (manga.title.isBlank()) {
|
||||
title.text = if (manga.title.isBlank()) {
|
||||
view.context.getString(R.string.unknown)
|
||||
} else {
|
||||
manga.title
|
||||
}
|
||||
|
||||
view.gradient.visible()
|
||||
view.manga_source_label.text = /*if (source.id == MERGED_SOURCE_ID) {
|
||||
gradient.visible()
|
||||
manga_source_label.text = /*if (source.id == MERGED_SOURCE_ID) {
|
||||
MergedSource.MangaConfig.readFromUrl(gson, manga.url).children.map {
|
||||
sourceManager.getOrStub(it.source).toString()
|
||||
}.distinct().joinToString()
|
||||
@ -131,15 +149,15 @@ class MigrationProcessHolder(
|
||||
// }
|
||||
|
||||
val mangaChapters = db.getChapters(manga).executeAsBlocking()
|
||||
view.manga_chapters.visible()
|
||||
view.manga_chapters.text = mangaChapters.size.toString()
|
||||
manga_chapters.visible()
|
||||
manga_chapters.text = mangaChapters.size.toString()
|
||||
val latestChapter = mangaChapters.maxBy { it.chapter_number }?.chapter_number ?: -1f
|
||||
|
||||
if (latestChapter > 0f) {
|
||||
view.manga_last_chapter_label.text = view.context.getString(R.string.latest_x,
|
||||
manga_last_chapter_label.text = context.getString(R.string.latest_x,
|
||||
DecimalFormat("#.#").format(latestChapter))
|
||||
} else {
|
||||
view.manga_last_chapter_label.setText(R.string.unknown)
|
||||
manga_last_chapter_label.setText(R.string.unknown)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,7 @@ class MigrationProcessItem(val manga: MigratingManga) :
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
return manga.mangaId.hashCode()
|
||||
return manga.mangaId.toInt()
|
||||
}
|
||||
|
||||
}
|
@ -1,38 +1,35 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<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="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center|start">
|
||||
android:gravity="center">
|
||||
|
||||
<include
|
||||
android:id="@+id/migration_manga_card_from"
|
||||
layout="@layout/migration_new_manga_card"
|
||||
android:layout_width="150dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@+id/imageView"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintWidth_max="450dp" />
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="25dp"
|
||||
android:layout_marginStart="-10dp"
|
||||
android:layout_marginEnd="-10dp"
|
||||
android:layout_marginBottom="30dp"
|
||||
android:adjustViewBounds="true"
|
||||
android:contentDescription="migrating to"
|
||||
android:contentDescription="@string/migrating_to"
|
||||
android:scaleType="center"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/migration_manga_card_from"
|
||||
android:layout_marginBottom="45dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@+id/migration_manga_card_to"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toEndOf="@+id/migration_manga_card_from"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:srcCompat="@drawable/ic_keyboard_arrow_right_black_24dp" />
|
||||
|
||||
<include
|
||||
@ -40,40 +37,36 @@
|
||||
layout="@layout/migration_new_manga_card"
|
||||
android:layout_width="150dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/imageView"
|
||||
app:layout_constraintWidth_max="450dp" />
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@+id/migration_menu"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toEndOf="@+id/imageView"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/migration_menu"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginBottom="30dp"
|
||||
android:contentDescription="@string/description_cover"
|
||||
android:paddingTop="30dp"
|
||||
android:paddingBottom="30dp"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
android:layout_marginBottom="45dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toEndOf="@+id/migration_manga_card_to"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:srcCompat="@drawable/ic_more_vert_black_24dp" />
|
||||
app:srcCompat="@drawable/ic_more_vert_black_24dp"
|
||||
android:visibility="invisible"/>
|
||||
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/skip_manga"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginBottom="30dp"
|
||||
android:contentDescription="@string/description_cover"
|
||||
android:paddingTop="30dp"
|
||||
android:paddingBottom="30dp"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:srcCompat="@drawable/baseline_close_24"
|
||||
android:visibility="gone"/>
|
||||
</LinearLayout>
|
||||
app:layout_constraintBottom_toBottomOf="@+id/migration_menu"
|
||||
app:layout_constraintEnd_toEndOf="@+id/migration_menu"
|
||||
app:layout_constraintStart_toStartOf="@+id/migration_menu"
|
||||
app:layout_constraintTop_toTopOf="@+id/migration_menu"
|
||||
app:srcCompat="@drawable/baseline_close_24" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
@ -565,5 +565,6 @@
|
||||
<string name="keep_old_manga">Keep old manga</string>
|
||||
<string name="use_intelligent_search">Use intelligent search algorithm</string>
|
||||
<string name="begin_migration">Begin migration</string>
|
||||
<string name="migrating_to">migrating to</string>
|
||||
|
||||
</resources>
|
||||
|
Loading…
Reference in New Issue
Block a user