Merge branch 'master' into devel

This commit is contained in:
Koitharu
2020-05-21 21:20:39 +03:00
6 changed files with 23 additions and 3 deletions

View File

@@ -17,7 +17,7 @@ android {
minSdkVersion 21 minSdkVersion 21
targetSdkVersion 29 targetSdkVersion 29
versionCode gitCommits versionCode gitCommits
versionName '0.3.2' versionName '0.4'
buildConfigField 'String', 'GIT_BRANCH', "\"${gitBranch}\"" buildConfigField 'String', 'GIT_BRANCH', "\"${gitBranch}\""

View File

@@ -16,6 +16,7 @@ import org.koin.android.ext.koin.androidContext
import org.koin.android.ext.koin.androidLogger import org.koin.android.ext.koin.androidLogger
import org.koin.core.context.startKoin import org.koin.core.context.startKoin
import org.koin.dsl.module import org.koin.dsl.module
import org.koitharu.kotatsu.core.db.DatabasePrePopulateCallback
import org.koitharu.kotatsu.core.db.MangaDatabase import org.koitharu.kotatsu.core.db.MangaDatabase
import org.koitharu.kotatsu.core.db.migrations.* import org.koitharu.kotatsu.core.db.migrations.*
import org.koitharu.kotatsu.core.local.CbzFetcher import org.koitharu.kotatsu.core.local.CbzFetcher
@@ -125,4 +126,5 @@ class KotatsuApp : Application() {
MangaDatabase::class.java, MangaDatabase::class.java,
"kotatsu-db" "kotatsu-db"
).addMigrations(Migration1To2, Migration2To3, Migration3To4, Migration4To5, Migration5To6) ).addMigrations(Migration1To2, Migration2To3, Migration3To4, Migration4To5, Migration5To6)
.addCallback(DatabasePrePopulateCallback(resources))
} }

View File

@@ -0,0 +1,16 @@
package org.koitharu.kotatsu.core.db
import android.content.res.Resources
import androidx.room.RoomDatabase
import androidx.sqlite.db.SupportSQLiteDatabase
import org.koitharu.kotatsu.R
class DatabasePrePopulateCallback(private val resources: Resources) : RoomDatabase.Callback() {
override fun onCreate(db: SupportSQLiteDatabase) {
db.execSQL(
"INSERT INTO favourite_categories (created_at, sort_key, title) VALUES (?,?,?)",
arrayOf(System.currentTimeMillis(), 1, resources.getString(R.string.read_later))
)
}
}

View File

@@ -128,7 +128,7 @@ open class MangaLibRepository(loaderContext: MangaLoaderContext) :
tags = info.getElementsMatchingOwnText("Жанры")?.firstOrNull() tags = info.getElementsMatchingOwnText("Жанры")?.firstOrNull()
?.nextElementSibling()?.select("a")?.mapNotNull { a -> ?.nextElementSibling()?.select("a")?.mapNotNull { a ->
MangaTag( MangaTag(
title = a.text(), title = a.text().capitalize(),
key = a.attr("href").substringAfterLast('='), key = a.attr("href").substringAfterLast('='),
source = source source = source
) )
@@ -182,7 +182,7 @@ open class MangaLibRepository(loaderContext: MangaLoaderContext) :
result += MangaTag( result += MangaTag(
source = source, source = source,
key = x.getInt("id").toString(), key = x.getInt("id").toString(),
title = x.getString("name") title = x.getString("name").capitalize()
) )
} }
return result return result

View File

@@ -134,4 +134,5 @@
<string name="done">Готово</string> <string name="done">Готово</string>
<string name="all_favourites">Всё избранное</string> <string name="all_favourites">Всё избранное</string>
<string name="favourites_category_empty">В этой категории ничего нет</string> <string name="favourites_category_empty">В этой категории ничего нет</string>
<string name="read_later">Прочитать позже</string>
</resources> </resources>

View File

@@ -135,4 +135,5 @@
<string name="done">Done</string> <string name="done">Done</string>
<string name="all_favourites">All favourites</string> <string name="all_favourites">All favourites</string>
<string name="favourites_category_empty">This category is empty</string> <string name="favourites_category_empty">This category is empty</string>
<string name="read_later">Read later</string>
</resources> </resources>