Transfer commit
This commit is contained in:
parent
aca34155b9
commit
3d1c02136a
@ -8,16 +8,21 @@ import com.google.gson.Gson
|
|||||||
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
|
||||||
|
import eu.kanade.tachiyomi.data.database.models.MangaCategory
|
||||||
import eu.kanade.tachiyomi.data.glide.GlideApp
|
import eu.kanade.tachiyomi.data.glide.GlideApp
|
||||||
|
import eu.kanade.tachiyomi.data.preference.getOrDefault
|
||||||
import eu.kanade.tachiyomi.source.Source
|
import eu.kanade.tachiyomi.source.Source
|
||||||
import eu.kanade.tachiyomi.source.SourceManager
|
import eu.kanade.tachiyomi.source.SourceManager
|
||||||
|
import eu.kanade.tachiyomi.source.model.SChapter
|
||||||
import eu.kanade.tachiyomi.source.model.SManga
|
import eu.kanade.tachiyomi.source.model.SManga
|
||||||
import eu.kanade.tachiyomi.source.online.all.MergedSource
|
import eu.kanade.tachiyomi.source.online.all.MergedSource
|
||||||
import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction
|
import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction
|
||||||
import eu.kanade.tachiyomi.ui.manga.MangaController
|
import eu.kanade.tachiyomi.ui.manga.MangaController
|
||||||
import eu.kanade.tachiyomi.ui.manga.info.MangaInfoController
|
import eu.kanade.tachiyomi.ui.manga.info.MangaInfoController
|
||||||
|
import eu.kanade.tachiyomi.ui.migration.MigrationFlags
|
||||||
import eu.kanade.tachiyomi.util.gone
|
import eu.kanade.tachiyomi.util.gone
|
||||||
import eu.kanade.tachiyomi.util.inflate
|
import eu.kanade.tachiyomi.util.inflate
|
||||||
|
import eu.kanade.tachiyomi.util.syncChaptersWithSource
|
||||||
import eu.kanade.tachiyomi.util.visible
|
import eu.kanade.tachiyomi.util.visible
|
||||||
import exh.MERGED_SOURCE_ID
|
import exh.MERGED_SOURCE_ID
|
||||||
import exh.debug.DebugFunctions.sourceManager
|
import exh.debug.DebugFunctions.sourceManager
|
||||||
@ -53,7 +58,7 @@ class MigrationProcedureAdapter(val controller: MigrationProcedureController,
|
|||||||
}
|
}
|
||||||
|
|
||||||
view.accept_migration.setOnClickListener {
|
view.accept_migration.setOnClickListener {
|
||||||
|
view.migrating_frame.visible()
|
||||||
}
|
}
|
||||||
|
|
||||||
val viewTag = ViewTag(coroutineContext)
|
val viewTag = ViewTag(coroutineContext)
|
||||||
@ -63,6 +68,64 @@ class MigrationProcedureAdapter(val controller: MigrationProcedureController,
|
|||||||
return view
|
return view
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun performMigration() {
|
||||||
|
|
||||||
|
}
|
||||||
|
private fun migrateMangaInternal(source: Source,
|
||||||
|
sourceChapters: List<SChapter>,
|
||||||
|
prevManga: Manga,
|
||||||
|
manga: Manga,
|
||||||
|
replace: Boolean) {
|
||||||
|
db.inTransaction {
|
||||||
|
// Update chapters read
|
||||||
|
if (migrateChapters) {
|
||||||
|
try {
|
||||||
|
syncChaptersWithSource(db, sourceChapters, manga, source)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
// Worst case, chapters won't be synced
|
||||||
|
}
|
||||||
|
|
||||||
|
val prevMangaChapters = db.getChapters(prevManga).executeAsBlocking()
|
||||||
|
val maxChapterRead = prevMangaChapters.filter { it.read }
|
||||||
|
.maxBy { it.chapter_number }?.chapter_number
|
||||||
|
if (maxChapterRead != null) {
|
||||||
|
val dbChapters = db.getChapters(manga).executeAsBlocking()
|
||||||
|
for (chapter in dbChapters) {
|
||||||
|
if (chapter.isRecognizedNumber && chapter.chapter_number <= maxChapterRead) {
|
||||||
|
chapter.read = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
db.insertChapters(dbChapters).executeAsBlocking()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Update categories
|
||||||
|
if (migrateCategories) {
|
||||||
|
val categories = db.getCategoriesForManga(prevManga).executeAsBlocking()
|
||||||
|
val mangaCategories = categories.map { MangaCategory.create(manga, it) }
|
||||||
|
db.setMangaCategories(mangaCategories, listOf(manga))
|
||||||
|
}
|
||||||
|
// Update track
|
||||||
|
if (migrateTracks) {
|
||||||
|
val tracks = db.getTracks(prevManga).executeAsBlocking()
|
||||||
|
for (track in tracks) {
|
||||||
|
track.id = null
|
||||||
|
track.manga_id = manga.id!!
|
||||||
|
}
|
||||||
|
db.insertTracks(tracks).executeAsBlocking()
|
||||||
|
}
|
||||||
|
// Update favorite status
|
||||||
|
if (replace) {
|
||||||
|
prevManga.favorite = false
|
||||||
|
db.updateMangaFavorite(prevManga).executeAsBlocking()
|
||||||
|
}
|
||||||
|
manga.favorite = true
|
||||||
|
db.updateMangaFavorite(manga).executeAsBlocking()
|
||||||
|
|
||||||
|
// SearchPresenter#networkToLocalManga may have updated the manga title, so ensure db gets updated title
|
||||||
|
db.updateMangaTitle(manga).executeAsBlocking()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun View.setupView(tag: ViewTag, migratingManga: MigratingManga) {
|
fun View.setupView(tag: ViewTag, migratingManga: MigratingManga) {
|
||||||
tag.launch {
|
tag.launch {
|
||||||
val manga = migratingManga.manga()
|
val manga = migratingManga.manga()
|
||||||
|
@ -71,6 +71,12 @@ class MigrationProcedureController(bundle: Bundle? = null) : BaseExhController(b
|
|||||||
runMigrations(newMigratingManga)
|
runMigrations(newMigratingManga)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateTitle()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun updateTitle() {
|
||||||
|
titleText = "Migrate manga (${pager.currentItem + 1}/${adapter?.count ?: 0})"
|
||||||
}
|
}
|
||||||
|
|
||||||
fun nextMigration() {
|
fun nextMigration() {
|
||||||
@ -80,7 +86,7 @@ class MigrationProcedureController(bundle: Bundle? = null) : BaseExhController(b
|
|||||||
router.popCurrentController()
|
router.popCurrentController()
|
||||||
} else {
|
} else {
|
||||||
pager.setCurrentItem(pager.currentItem + 1, true)
|
pager.setCurrentItem(pager.currentItem + 1, true)
|
||||||
titleText = "Migrate manga (${pager.currentItem + 1}/${adapter.count})"
|
updateTitle()
|
||||||
launch(Dispatchers.Main) {
|
launch(Dispatchers.Main) {
|
||||||
setTitle()
|
setTitle()
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,7 @@
|
|||||||
android:layout_marginStart="8dp"
|
android:layout_marginStart="8dp"
|
||||||
android:layout_marginLeft="8dp"
|
android:layout_marginLeft="8dp"
|
||||||
android:layout_marginBottom="8dp"
|
android:layout_marginBottom="8dp"
|
||||||
android:text="Search options"
|
android:text="Options"
|
||||||
android:textAppearance="@style/TextAppearance.Medium.Body2"
|
android:textAppearance="@style/TextAppearance.Medium.Body2"
|
||||||
app:layout_constraintBottom_toTopOf="@+id/prioritize_chapter_count"
|
app:layout_constraintBottom_toTopOf="@+id/prioritize_chapter_count"
|
||||||
app:layout_constraintStart_toStartOf="parent" />
|
app:layout_constraintStart_toStartOf="parent" />
|
||||||
|
@ -1,83 +1,111 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<FrameLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
<include
|
<android.support.constraint.ConstraintLayout
|
||||||
android:id="@+id/eh_manga_card_from"
|
android:layout_width="match_parent"
|
||||||
layout="@layout/eh_manga_card"
|
android:layout_height="match_parent">
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginStart="16dp"
|
|
||||||
android:layout_marginLeft="16dp"
|
|
||||||
android:layout_marginTop="16dp"
|
|
||||||
android:layout_marginEnd="16dp"
|
|
||||||
android:layout_marginRight="16dp"
|
|
||||||
app:layout_constraintWidth_max="450dp"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
|
||||||
|
|
||||||
<ImageView
|
<include
|
||||||
android:id="@+id/imageView"
|
android:id="@+id/eh_manga_card_from"
|
||||||
android:layout_width="wrap_content"
|
layout="@layout/eh_manga_card"
|
||||||
android:scaleType="center"
|
android:layout_width="0dp"
|
||||||
android:layout_height="50dp"
|
android:layout_height="wrap_content"
|
||||||
android:adjustViewBounds="true"
|
android:layout_marginStart="16dp"
|
||||||
android:contentDescription="migrating to"
|
android:layout_marginLeft="16dp"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
android:layout_marginTop="16dp"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
android:layout_marginEnd="16dp"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/eh_manga_card_from"
|
android:layout_marginRight="16dp"
|
||||||
app:srcCompat="@drawable/eh_ic_arrow_drop_down_white_100dp" />
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:layout_constraintWidth_max="450dp" />
|
||||||
|
|
||||||
<include
|
<ImageView
|
||||||
android:id="@+id/eh_manga_card_to"
|
android:id="@+id/imageView"
|
||||||
layout="@layout/eh_manga_card"
|
android:layout_width="wrap_content"
|
||||||
android:layout_width="0dp"
|
android:layout_height="50dp"
|
||||||
android:layout_height="wrap_content"
|
android:adjustViewBounds="true"
|
||||||
android:layout_marginStart="16dp"
|
android:contentDescription="migrating to"
|
||||||
android:layout_marginLeft="16dp"
|
android:scaleType="center"
|
||||||
android:layout_marginEnd="16dp"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
android:layout_marginRight="16dp"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintTop_toBottomOf="@+id/eh_manga_card_from"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:srcCompat="@drawable/eh_ic_arrow_drop_down_white_100dp" />
|
||||||
app:layout_constraintTop_toBottomOf="@+id/imageView"
|
|
||||||
app:layout_constraintWidth_max="450dp" />
|
|
||||||
|
|
||||||
<Button
|
<include
|
||||||
android:id="@+id/skip_migration"
|
android:id="@+id/eh_manga_card_to"
|
||||||
android:layout_width="wrap_content"
|
layout="@layout/eh_manga_card"
|
||||||
android:layout_height="wrap_content"
|
android:layout_width="0dp"
|
||||||
android:layout_marginEnd="8dp"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginRight="8dp"
|
android:layout_marginStart="16dp"
|
||||||
android:layout_marginBottom="8dp"
|
android:layout_marginLeft="16dp"
|
||||||
android:drawableStart="@drawable/eh_ic_clear_white_24dp"
|
android:layout_marginEnd="16dp"
|
||||||
android:drawablePadding="6dp"
|
android:layout_marginRight="16dp"
|
||||||
android:text="Skip manga"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
android:textColor="#ffffff"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintTop_toBottomOf="@+id/imageView"
|
||||||
app:layout_constraintEnd_toStartOf="@+id/accept_migration"
|
app:layout_constraintWidth_max="450dp" />
|
||||||
app:layout_constraintHorizontal_bias="0.5"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:backgroundTint="#E53935"
|
|
||||||
android:drawableLeft="@drawable/eh_ic_clear_white_24dp" />
|
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/accept_migration"
|
android:id="@+id/skip_migration"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:alpha="0.5"
|
android:layout_marginEnd="8dp"
|
||||||
android:drawableStart="@drawable/eh_ic_check_white_24dp"
|
android:layout_marginRight="8dp"
|
||||||
android:drawableLeft="@drawable/eh_ic_check_white_24dp"
|
android:layout_marginBottom="8dp"
|
||||||
android:drawablePadding="6dp"
|
android:drawableStart="@drawable/eh_ic_clear_white_24dp"
|
||||||
android:enabled="false"
|
android:drawableLeft="@drawable/eh_ic_clear_white_24dp"
|
||||||
android:text="Migrate manga"
|
android:drawablePadding="6dp"
|
||||||
android:textColor="#ffffff"
|
android:text="Skip manga"
|
||||||
app:backgroundTint="#00C853"
|
android:textColor="#ffffff"
|
||||||
app:layout_constraintBottom_toBottomOf="@+id/skip_migration"
|
app:backgroundTint="#E53935"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintHorizontal_bias="0.5"
|
app:layout_constraintEnd_toStartOf="@+id/accept_migration"
|
||||||
app:layout_constraintStart_toEndOf="@+id/skip_migration" />
|
app:layout_constraintHorizontal_bias="0.5"
|
||||||
</android.support.constraint.ConstraintLayout>
|
app:layout_constraintStart_toStartOf="parent" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/accept_migration"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:alpha="0.5"
|
||||||
|
android:drawableStart="@drawable/eh_ic_check_white_24dp"
|
||||||
|
android:drawableLeft="@drawable/eh_ic_check_white_24dp"
|
||||||
|
android:drawablePadding="6dp"
|
||||||
|
android:enabled="false"
|
||||||
|
android:text="Migrate manga"
|
||||||
|
android:textColor="#ffffff"
|
||||||
|
app:backgroundTint="#00C853"
|
||||||
|
app:layout_constraintBottom_toBottomOf="@+id/skip_migration"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintHorizontal_bias="0.5"
|
||||||
|
app:layout_constraintStart_toEndOf="@+id/skip_migration" />
|
||||||
|
|
||||||
|
</android.support.constraint.ConstraintLayout>
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@+id/migrating_frame"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:visibility="gone">
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:id="@+id/migrating_view"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="#E6FFFFFF" />
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
android:id="@+id/migrating_progress"
|
||||||
|
style="?android:attr/progressBarStyle"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center" />
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
|
</FrameLayout>
|
Loading…
x
Reference in New Issue
Block a user