Fixes for local manga and others for custom manga info
This commit is contained in:
parent
c92b2bb203
commit
bf919e7949
5 changed files with 35 additions and 48 deletions
|
@ -32,44 +32,26 @@ interface SManga : Serializable {
|
|||
return splitTitle.last()
|
||||
}
|
||||
|
||||
fun currentGenres(): String? {
|
||||
val splitGenre = genre?.split(splitter) ?: return null
|
||||
return splitGenre.first()
|
||||
}
|
||||
fun currentGenres() = split(genre, true)
|
||||
|
||||
fun originalGenres(): String? {
|
||||
val splitGenre = genre?.split(splitter) ?: return null
|
||||
return splitGenre.last()
|
||||
}
|
||||
fun originalGenres() = split(genre, false)
|
||||
|
||||
fun currentDesc(): String? {
|
||||
val splitDesc = description?.split(splitter) ?: return null
|
||||
return splitDesc.first()
|
||||
}
|
||||
fun currentDesc() = split(description, true)
|
||||
|
||||
fun originalDesc(): String? {
|
||||
val splitDesc = description?.split(splitter) ?: return null
|
||||
return splitDesc.last()
|
||||
}
|
||||
fun originalDesc() = split(description, false)
|
||||
|
||||
fun currentAuthor(): String? {
|
||||
val splitAuth = author?.split(splitter) ?: return null
|
||||
return splitAuth.first()
|
||||
}
|
||||
fun currentAuthor() = split(author, true)
|
||||
|
||||
fun originalAuthor(): String? {
|
||||
val splitAuth = author?.split(splitter) ?: return null
|
||||
return splitAuth.last()
|
||||
}
|
||||
fun originalAuthor() = split(author, false)
|
||||
|
||||
fun currentArtist(): String? {
|
||||
val splitArtist = artist?.split(splitter) ?: return null
|
||||
return splitArtist.first()
|
||||
}
|
||||
fun currentArtist() = split(artist, true)
|
||||
|
||||
fun originalArtist(): String? {
|
||||
val splitArtist = artist?.split(splitter) ?: return null
|
||||
return splitArtist.last()
|
||||
fun originalArtist() = split(artist, false)
|
||||
|
||||
private fun split(string: String?, first: Boolean):String? {
|
||||
val split = string?.split(splitter) ?: return null
|
||||
val s = if (first) split.first() else split.last()
|
||||
return if (s.isBlank()) null else s
|
||||
}
|
||||
|
||||
fun copyFrom(other: SManga) {
|
||||
|
|
|
@ -102,7 +102,7 @@ class EditMangaDialog : DialogController {
|
|||
changeCover()
|
||||
}
|
||||
|
||||
if (manga.currentArtist() != manga.originalArtist())
|
||||
if (manga.currentDesc() != manga.originalDesc())
|
||||
view.manga_description.append(manga.currentDesc())
|
||||
if (!manga.originalDesc().isNullOrBlank())
|
||||
view.manga_description.hint = "${resources?.getString(R.string.description)}: ${manga
|
||||
|
@ -114,7 +114,7 @@ class EditMangaDialog : DialogController {
|
|||
}
|
||||
|
||||
private fun resetTags() {
|
||||
if (manga.originalGenres().isNullOrBlank() || manga.originalGenres() == "null")
|
||||
if (manga.originalGenres().isNullOrBlank())
|
||||
dialogView?.manga_genres_tags?.setTags(emptyList())
|
||||
else
|
||||
dialogView?.manga_genres_tags?.setTags(manga.originalGenres()?.split(", "))
|
||||
|
|
|
@ -293,6 +293,7 @@ class MangaInfoController : NucleusController<MangaInfoPresenter>(),
|
|||
if (manga.currentGenres().isNullOrBlank().not()) {
|
||||
manga_genres_tags.setTags(manga.currentGenres()?.split(", "))
|
||||
}
|
||||
else manga_genres_tags.setTags(emptyList())
|
||||
|
||||
// Update description TextView.
|
||||
manga_summary.text = if (manga.currentDesc().isNullOrBlank()) {
|
||||
|
|
|
@ -204,6 +204,7 @@ class MangaInfoPresenter(
|
|||
fun updateManga(title:String?, author:String?, artist: String?, uri: Uri?,
|
||||
description: String?, tags: Array<String>?) {
|
||||
var changed = false
|
||||
val title = title?.trim()
|
||||
if (title.isNullOrBlank() && manga.currentTitle() != manga.originalTitle()) {
|
||||
manga.title = manga.originalTitle()
|
||||
changed = true
|
||||
|
@ -212,27 +213,30 @@ class MangaInfoPresenter(
|
|||
changed = true
|
||||
}
|
||||
|
||||
val author = author?.trim()
|
||||
if (author.isNullOrBlank() && manga.currentAuthor() != manga.originalAuthor()) {
|
||||
manga.author = manga.originalAuthor()
|
||||
changed = true
|
||||
} else if (!author.isNullOrBlank() && author != manga.currentAuthor()) {
|
||||
manga.author = "${author}${SManga.splitter}${manga.originalAuthor()}"
|
||||
manga.author = "${author}${SManga.splitter}${manga.originalAuthor() ?: ""}"
|
||||
changed = true
|
||||
}
|
||||
|
||||
val artist = artist?.trim()
|
||||
if (artist.isNullOrBlank() && manga.currentArtist() != manga.currentArtist()) {
|
||||
manga.artist = manga.originalArtist()
|
||||
changed = true
|
||||
} else if (!artist.isNullOrBlank() && artist != manga.currentArtist()) {
|
||||
manga.artist = "${artist}${SManga.splitter}${manga.originalArtist()}"
|
||||
manga.artist = "${artist}${SManga.splitter}${manga.originalArtist() ?: ""}"
|
||||
changed = true
|
||||
}
|
||||
|
||||
val description = description?.trim()
|
||||
if (description.isNullOrBlank() && manga.currentDesc() != manga.originalDesc()) {
|
||||
manga.description = manga.originalDesc()
|
||||
changed = true
|
||||
} else if (!description.isNullOrBlank() && description != manga.currentDesc()) {
|
||||
manga.description = "${description}${SManga.splitter}${manga.originalDesc()}"
|
||||
manga.description = "${description}${SManga.splitter}${manga.originalDesc() ?: ""}"
|
||||
changed = true
|
||||
}
|
||||
|
||||
|
@ -242,13 +246,12 @@ class MangaInfoPresenter(
|
|||
changed = true
|
||||
} else if (!tagsString.isNullOrBlank() && tagsString != manga.currentGenres()) {
|
||||
tagsString = tags?.joinToString(", ") { it.capitalize() }
|
||||
manga.genre = "${tagsString}${SManga.splitter}${manga.originalGenres()}"
|
||||
manga.genre = "${tagsString}${SManga.splitter}${manga.originalGenres() ?: ""}"
|
||||
changed = true
|
||||
}
|
||||
|
||||
if (uri != null) editCoverWithStream(uri)
|
||||
|
||||
|
||||
if (changed) db.updateMangaInfo(manga).executeAsBlocking()
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:adjustViewBounds="true"
|
||||
android:layout_height="150dp"
|
||||
android:contentDescription="@string/description_cover"
|
||||
android:background="@drawable/image_border_background"
|
||||
android:src="@mipmap/ic_launcher"/>
|
||||
|
||||
|
@ -66,6 +67,16 @@
|
|||
android:inputType="text"
|
||||
android:maxLines="1"/>
|
||||
|
||||
<EditText
|
||||
android:id="@+id/manga_description"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:hint="@string/description"
|
||||
android:inputType="text|textMultiLine"
|
||||
android:scrollHorizontally="false" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/reset_tags"
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -94,16 +105,6 @@
|
|||
app:atg_borderColor="@color/md_blue_A400"
|
||||
app:atg_textColor="@color/md_blue_A400" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/manga_description"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/description"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:inputType="text|textMultiLine"
|
||||
android:scrollHorizontally="false"/>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
|
|
Reference in a new issue