diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/DbOpenHelper.kt b/app/src/main/java/eu/kanade/tachiyomi/data/database/DbOpenHelper.kt index 40e5d129a..a1b902a6e 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/database/DbOpenHelper.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/database/DbOpenHelper.kt @@ -17,7 +17,7 @@ class DbOpenHelper(context: Context) /** * Version of the database. */ - const val DATABASE_VERSION = 4 + const val DATABASE_VERSION = 5 } override fun onCreate(db: SQLiteDatabase) = with(db) { @@ -51,6 +51,9 @@ class DbOpenHelper(context: Context) if (oldVersion < 4) { db.execSQL(ChapterTable.bookmarkUpdateQuery) } + if (oldVersion < 5){ + db.execSQL(ChapterTable.addScanlator) + } } override fun onConfigure(db: SQLiteDatabase) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/mappers/ChapterTypeMapping.kt b/app/src/main/java/eu/kanade/tachiyomi/data/database/mappers/ChapterTypeMapping.kt index 0065f5f44..2e903a64b 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/database/mappers/ChapterTypeMapping.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/database/mappers/ChapterTypeMapping.kt @@ -20,6 +20,7 @@ import eu.kanade.tachiyomi.data.database.tables.ChapterTable.COL_LAST_PAGE_READ import eu.kanade.tachiyomi.data.database.tables.ChapterTable.COL_MANGA_ID import eu.kanade.tachiyomi.data.database.tables.ChapterTable.COL_NAME import eu.kanade.tachiyomi.data.database.tables.ChapterTable.COL_READ +import eu.kanade.tachiyomi.data.database.tables.ChapterTable.COL_SCANLATOR import eu.kanade.tachiyomi.data.database.tables.ChapterTable.COL_SOURCE_ORDER import eu.kanade.tachiyomi.data.database.tables.ChapterTable.COL_URL import eu.kanade.tachiyomi.data.database.tables.ChapterTable.TABLE @@ -48,6 +49,7 @@ class ChapterPutResolver : DefaultPutResolver() { put(COL_URL, obj.url) put(COL_NAME, obj.name) put(COL_READ, obj.read) + put(COL_SCANLATOR, obj.scanlator) put(COL_BOOKMARK, obj.bookmark) put(COL_DATE_FETCH, obj.date_fetch) put(COL_DATE_UPLOAD, obj.date_upload) @@ -64,6 +66,7 @@ class ChapterGetResolver : DefaultGetResolver() { manga_id = cursor.getLong(cursor.getColumnIndex(COL_MANGA_ID)) url = cursor.getString(cursor.getColumnIndex(COL_URL)) name = cursor.getString(cursor.getColumnIndex(COL_NAME)) + scanlator = cursor.getString(cursor.getColumnIndex(COL_SCANLATOR)) read = cursor.getInt(cursor.getColumnIndex(COL_READ)) == 1 bookmark = cursor.getInt(cursor.getColumnIndex(COL_BOOKMARK)) == 1 date_fetch = cursor.getLong(cursor.getColumnIndex(COL_DATE_FETCH)) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/models/ChapterImpl.kt b/app/src/main/java/eu/kanade/tachiyomi/data/database/models/ChapterImpl.kt index f7f1d0662..461c943a2 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/database/models/ChapterImpl.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/database/models/ChapterImpl.kt @@ -10,6 +10,8 @@ class ChapterImpl : Chapter { override lateinit var name: String + override var scanlator: String? = null + override var read: Boolean = false override var bookmark: Boolean = false @@ -29,8 +31,8 @@ class ChapterImpl : Chapter { if (other == null || javaClass != other.javaClass) return false val chapter = other as Chapter - - return url == chapter.url + //forces updates on manga if scanlator changes. This will allow existing manga in library with scanlator to update + return url == chapter.url && scanlator == chapter.scanlator } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/tables/ChapterTable.kt b/app/src/main/java/eu/kanade/tachiyomi/data/database/tables/ChapterTable.kt index e28f848cc..7dc99f6fa 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/database/tables/ChapterTable.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/database/tables/ChapterTable.kt @@ -14,6 +14,8 @@ object ChapterTable { const val COL_READ = "read" + const val COL_SCANLATOR ="scanlator" + const val COL_BOOKMARK = "bookmark" const val COL_DATE_FETCH = "date_fetch" @@ -32,6 +34,7 @@ object ChapterTable { $COL_MANGA_ID INTEGER NOT NULL, $COL_URL TEXT NOT NULL, $COL_NAME TEXT NOT NULL, + $COL_SCANLATOR TEXT, $COL_READ BOOLEAN NOT NULL, $COL_BOOKMARK BOOLEAN NOT NULL, $COL_LAST_PAGE_READ INT NOT NULL, @@ -52,4 +55,7 @@ object ChapterTable { val bookmarkUpdateQuery: String get() = "ALTER TABLE $TABLE ADD COLUMN $COL_BOOKMARK BOOLEAN DEFAULT FALSE" + val addScanlator:String + get ()= "ALTER TABLE $TABLE ADD COLUMN $COL_SCANLATOR TEXT DEFAULT" + } diff --git a/app/src/main/java/eu/kanade/tachiyomi/source/model/SChapter.kt b/app/src/main/java/eu/kanade/tachiyomi/source/model/SChapter.kt index a54a36b40..991d24d41 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/source/model/SChapter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/source/model/SChapter.kt @@ -12,11 +12,14 @@ interface SChapter : Serializable { var chapter_number: Float + var scanlator: String? + fun copyFrom(other: SChapter) { name = other.name url = other.url date_upload = other.date_upload chapter_number = other.chapter_number + scanlator = other.scanlator } companion object { diff --git a/app/src/main/java/eu/kanade/tachiyomi/source/model/SChapterImpl.kt b/app/src/main/java/eu/kanade/tachiyomi/source/model/SChapterImpl.kt index 026d437e0..cfc4c3999 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/source/model/SChapterImpl.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/source/model/SChapterImpl.kt @@ -10,4 +10,6 @@ class SChapterImpl : SChapter { override var chapter_number: Float = -1f + override var scanlator: String? = null + } \ No newline at end of file diff --git a/app/src/main/java/eu/kanade/tachiyomi/source/online/english/Batoto.kt b/app/src/main/java/eu/kanade/tachiyomi/source/online/english/Batoto.kt index 08cdc3bd7..ef7cd2f4c 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/source/online/english/Batoto.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/source/online/english/Batoto.kt @@ -197,6 +197,7 @@ class Batoto : ParsedHttpSource(), LoginSource { chapter.date_upload = element.select("td").getOrNull(4)?.let { parseDateFromElement(it) } ?: 0 + chapter.scanlator = element.select("td").getOrNull(2)?.text() return chapter } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChapterHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChapterHolder.kt index aa9ef4179..b5ef25f1a 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChapterHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChapterHolder.kt @@ -6,6 +6,7 @@ import eu.davidea.viewholders.FlexibleViewHolder import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.database.models.Manga import eu.kanade.tachiyomi.data.download.model.Download +import eu.kanade.tachiyomi.util.gone import kotlinx.android.synthetic.main.chapters_item.view.* import java.util.* @@ -43,6 +44,16 @@ class ChapterHolder( chapter_date.text = "" } + //add scanlator if exists + chapter_scanlator.text = chapter.scanlator + //allow longer titles if there is no scanlator (most sources) + if (chapter_scanlator.text.isNullOrBlank()) { + chapter_title.setMaxLines(2) + chapter_scanlator.gone() + } else { + chapter_title.setMaxLines(1) + } + chapter_pages.text = if (!chapter.read && chapter.last_page_read > 0) { context.getString(R.string.chapter_progress, chapter.last_page_read + 1) } else { diff --git a/app/src/main/res/layout/chapters_item.xml b/app/src/main/res/layout/chapters_item.xml index 3aab2d412..e82353564 100644 --- a/app/src/main/res/layout/chapters_item.xml +++ b/app/src/main/res/layout/chapters_item.xml @@ -1,100 +1,101 @@ - - + - + - + - + - - + - - - - - - + android:layout_width="wrap_content" + android:layout_height="wrap_content" + app:srcCompat="@drawable/ic_more_horiz_black_24dp" + app:layout_constraintRight_toLeftOf="@+id/guideline4" + app:layout_constraintTop_toTopOf="parent" + android:paddingStart="12dp" + android:paddingEnd="0dp" + android:paddingBottom="12dp" + android:paddingTop="12dp" + android:contentDescription="@string/description_cover" + /> - + - + + - \ No newline at end of file +