Add migrate option from manga info view (closes #1903)
Cette révision appartient à :
Parent
b8ffb87f01
révision
035038a0b6
3 fichiers modifiés avec 68 ajouts et 8 suppressions
|
@ -4,6 +4,9 @@ import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.text.TextUtils
|
import android.text.TextUtils
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
|
import android.view.Menu
|
||||||
|
import android.view.MenuInflater
|
||||||
|
import android.view.MenuItem
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
|
@ -27,6 +30,7 @@ import eu.kanade.tachiyomi.ui.library.ChangeMangaCategoriesDialog
|
||||||
import eu.kanade.tachiyomi.ui.library.LibraryController
|
import eu.kanade.tachiyomi.ui.library.LibraryController
|
||||||
import eu.kanade.tachiyomi.ui.main.MainActivity
|
import eu.kanade.tachiyomi.ui.main.MainActivity
|
||||||
import eu.kanade.tachiyomi.ui.manga.MangaController
|
import eu.kanade.tachiyomi.ui.manga.MangaController
|
||||||
|
import eu.kanade.tachiyomi.ui.migration.SearchController
|
||||||
import eu.kanade.tachiyomi.ui.recent.history.HistoryController
|
import eu.kanade.tachiyomi.ui.recent.history.HistoryController
|
||||||
import eu.kanade.tachiyomi.ui.recent.updates.UpdatesController
|
import eu.kanade.tachiyomi.ui.recent.updates.UpdatesController
|
||||||
import eu.kanade.tachiyomi.ui.webview.WebViewActivity
|
import eu.kanade.tachiyomi.ui.webview.WebViewActivity
|
||||||
|
@ -66,6 +70,11 @@ class MangaInfoController(private val fromSource: Boolean = false) :
|
||||||
|
|
||||||
private var initialLoad: Boolean = true
|
private var initialLoad: Boolean = true
|
||||||
|
|
||||||
|
init {
|
||||||
|
setHasOptionsMenu(true)
|
||||||
|
setOptionsMenuHidden(true)
|
||||||
|
}
|
||||||
|
|
||||||
override fun createPresenter(): MangaInfoPresenter {
|
override fun createPresenter(): MangaInfoPresenter {
|
||||||
val ctrl = parentController as MangaController
|
val ctrl = parentController as MangaController
|
||||||
return MangaInfoPresenter(
|
return MangaInfoPresenter(
|
||||||
|
@ -115,7 +124,10 @@ class MangaInfoController(private val fromSource: Boolean = false) :
|
||||||
|
|
||||||
binding.mangaFullTitle.longClicks()
|
binding.mangaFullTitle.longClicks()
|
||||||
.onEach {
|
.onEach {
|
||||||
activity?.copyToClipboard(view.context.getString(R.string.title), binding.mangaFullTitle.text.toString())
|
activity?.copyToClipboard(
|
||||||
|
view.context.getString(R.string.title),
|
||||||
|
binding.mangaFullTitle.text.toString()
|
||||||
|
)
|
||||||
}
|
}
|
||||||
.launchIn(scope)
|
.launchIn(scope)
|
||||||
|
|
||||||
|
@ -127,7 +139,10 @@ class MangaInfoController(private val fromSource: Boolean = false) :
|
||||||
|
|
||||||
binding.mangaArtist.longClicks()
|
binding.mangaArtist.longClicks()
|
||||||
.onEach {
|
.onEach {
|
||||||
activity?.copyToClipboard(binding.mangaArtistLabel.text.toString(), binding.mangaArtist.text.toString())
|
activity?.copyToClipboard(
|
||||||
|
binding.mangaArtistLabel.text.toString(),
|
||||||
|
binding.mangaArtist.text.toString()
|
||||||
|
)
|
||||||
}
|
}
|
||||||
.launchIn(scope)
|
.launchIn(scope)
|
||||||
|
|
||||||
|
@ -139,7 +154,10 @@ class MangaInfoController(private val fromSource: Boolean = false) :
|
||||||
|
|
||||||
binding.mangaAuthor.longClicks()
|
binding.mangaAuthor.longClicks()
|
||||||
.onEach {
|
.onEach {
|
||||||
activity?.copyToClipboard(binding.mangaAuthor.text.toString(), binding.mangaAuthor.text.toString())
|
activity?.copyToClipboard(
|
||||||
|
binding.mangaAuthor.text.toString(),
|
||||||
|
binding.mangaAuthor.text.toString()
|
||||||
|
)
|
||||||
}
|
}
|
||||||
.launchIn(scope)
|
.launchIn(scope)
|
||||||
|
|
||||||
|
@ -151,17 +169,34 @@ class MangaInfoController(private val fromSource: Boolean = false) :
|
||||||
|
|
||||||
binding.mangaSummary.longClicks()
|
binding.mangaSummary.longClicks()
|
||||||
.onEach {
|
.onEach {
|
||||||
activity?.copyToClipboard(view.context.getString(R.string.description), binding.mangaSummary.text.toString())
|
activity?.copyToClipboard(
|
||||||
|
view.context.getString(R.string.description),
|
||||||
|
binding.mangaSummary.text.toString()
|
||||||
|
)
|
||||||
}
|
}
|
||||||
.launchIn(scope)
|
.launchIn(scope)
|
||||||
|
|
||||||
binding.mangaCover.longClicks()
|
binding.mangaCover.longClicks()
|
||||||
.onEach {
|
.onEach {
|
||||||
activity?.copyToClipboard(view.context.getString(R.string.title), presenter.manga.title)
|
activity?.copyToClipboard(
|
||||||
|
view.context.getString(R.string.title),
|
||||||
|
presenter.manga.title
|
||||||
|
)
|
||||||
}
|
}
|
||||||
.launchIn(scope)
|
.launchIn(scope)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
|
||||||
|
inflater.inflate(R.menu.manga_info, menu)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||||
|
when (item.itemId) {
|
||||||
|
R.id.action_migrate -> migrateManga()
|
||||||
|
}
|
||||||
|
return super.onOptionsItemSelected(item)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if manga is initialized.
|
* Check if manga is initialized.
|
||||||
* If true update view with manga information,
|
* If true update view with manga information,
|
||||||
|
@ -297,7 +332,8 @@ class MangaInfoController(private val fromSource: Boolean = false) :
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun toggleMangaInfo(context: Context) {
|
private fun toggleMangaInfo(context: Context) {
|
||||||
val isExpanded = binding.mangaInfoToggle.text == context.getString(R.string.manga_info_collapse)
|
val isExpanded =
|
||||||
|
binding.mangaInfoToggle.text == context.getString(R.string.manga_info_collapse)
|
||||||
|
|
||||||
binding.mangaInfoToggle.text =
|
binding.mangaInfoToggle.text =
|
||||||
if (isExpanded) {
|
if (isExpanded) {
|
||||||
|
@ -407,8 +443,12 @@ class MangaInfoController(private val fromSource: Boolean = false) :
|
||||||
// Set the Favorite drawable to the correct one.
|
// Set the Favorite drawable to the correct one.
|
||||||
// Border drawable if false, filled drawable if true.
|
// Border drawable if false, filled drawable if true.
|
||||||
binding.btnFavorite.apply {
|
binding.btnFavorite.apply {
|
||||||
icon = ContextCompat.getDrawable(context, if (isFavorite) R.drawable.ic_favorite_24dp else R.drawable.ic_favorite_border_24dp)
|
icon = ContextCompat.getDrawable(
|
||||||
text = context.getString(if (isFavorite) R.string.in_library else R.string.add_to_library)
|
context,
|
||||||
|
if (isFavorite) R.drawable.ic_favorite_24dp else R.drawable.ic_favorite_border_24dp
|
||||||
|
)
|
||||||
|
text =
|
||||||
|
context.getString(if (isFavorite) R.string.in_library else R.string.add_to_library)
|
||||||
isChecked = isFavorite
|
isChecked = isFavorite
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -510,6 +550,15 @@ class MangaInfoController(private val fromSource: Boolean = false) :
|
||||||
presenter.moveMangaToCategories(manga, categories)
|
presenter.moveMangaToCategories(manga, categories)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initiates source migration for the specific manga.
|
||||||
|
*/
|
||||||
|
private fun migrateManga() {
|
||||||
|
val controller = SearchController(presenter.manga)
|
||||||
|
controller.targetController = this
|
||||||
|
parentController!!.router.pushController(controller.withFadeTransaction())
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Perform a global search using the provided query.
|
* Perform a global search using the provided query.
|
||||||
*
|
*
|
||||||
|
|
10
app/src/main/res/menu/manga_info.xml
Fichier normal
10
app/src/main/res/menu/manga_info.xml
Fichier normal
|
@ -0,0 +1,10 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/action_migrate"
|
||||||
|
android:title="@string/action_migrate"
|
||||||
|
app:showAsAction="never" />
|
||||||
|
|
||||||
|
</menu>
|
|
@ -78,6 +78,7 @@
|
||||||
<string name="action_move">Move</string>
|
<string name="action_move">Move</string>
|
||||||
<string name="action_open_in_browser">Open in browser</string>
|
<string name="action_open_in_browser">Open in browser</string>
|
||||||
<string name="action_open_in_web_view">Open in WebView</string>
|
<string name="action_open_in_web_view">Open in WebView</string>
|
||||||
|
<string name="action_migrate">Migrate</string>
|
||||||
<string name="action_display_mode">Display mode</string>
|
<string name="action_display_mode">Display mode</string>
|
||||||
<string name="action_display">Display</string>
|
<string name="action_display">Display</string>
|
||||||
<string name="action_display_grid">Grid</string>
|
<string name="action_display_grid">Grid</string>
|
||||||
|
|
Référencer dans un nouveau ticket