diff --git a/app/build.gradle b/app/build.gradle index 094476d48..8c3caa64b 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -118,7 +118,7 @@ dependencies { implementation 'com.android.support.constraint:constraint-layout:1.1.2' - implementation 'com.android.support:multidex:1.0.2' + implementation 'com.android.support:multidex:1.0.3' standardImplementation 'com.google.firebase:firebase-core:11.8.0' @@ -161,7 +161,8 @@ dependencies { implementation 'com.github.gabrielemariotti.changeloglib:changelog:2.1.0' // Database - implementation "com.pushtorefresh.storio:sqlite:1.13.0" + implementation 'eu.kanade.storio:storio:1.13.0' + implementation 'io.requery:sqlite-android:3.25.2' // Model View Presenter final nucleus_version = '3.0.0' diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/DatabaseHelper.kt b/app/src/main/java/eu/kanade/tachiyomi/data/database/DatabaseHelper.kt index 239a75990..6148e49ae 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/database/DatabaseHelper.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/database/DatabaseHelper.kt @@ -1,10 +1,12 @@ package eu.kanade.tachiyomi.data.database +import android.arch.persistence.db.SupportSQLiteOpenHelper import android.content.Context import com.pushtorefresh.storio.sqlite.impl.DefaultStorIOSQLite import eu.kanade.tachiyomi.data.database.mappers.* import eu.kanade.tachiyomi.data.database.models.* import eu.kanade.tachiyomi.data.database.queries.* +import io.requery.android.database.sqlite.RequerySQLiteOpenHelperFactory /** * This class provides operations to manage the database through its interfaces. @@ -12,8 +14,13 @@ import eu.kanade.tachiyomi.data.database.queries.* open class DatabaseHelper(context: Context) : MangaQueries, ChapterQueries, TrackQueries, CategoryQueries, MangaCategoryQueries, HistoryQueries { + private val configuration = SupportSQLiteOpenHelper.Configuration.builder(context) + .name(DbOpenCallback.DATABASE_NAME) + .callback(DbOpenCallback()) + .build() + override val db = DefaultStorIOSQLite.builder() - .sqliteOpenHelper(DbOpenHelper(context)) + .sqliteOpenHelper(RequerySQLiteOpenHelperFactory().create(configuration)) .addTypeMapping(Manga::class.java, MangaTypeMapping()) .addTypeMapping(Chapter::class.java, ChapterTypeMapping()) .addTypeMapping(Track::class.java, TrackTypeMapping()) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/DbOpenHelper.kt b/app/src/main/java/eu/kanade/tachiyomi/data/database/DbOpenCallback.kt similarity index 84% rename from app/src/main/java/eu/kanade/tachiyomi/data/database/DbOpenHelper.kt rename to app/src/main/java/eu/kanade/tachiyomi/data/database/DbOpenCallback.kt index 5bdbfa779..cf65b6a1d 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/database/DbOpenHelper.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/database/DbOpenCallback.kt @@ -1,12 +1,13 @@ package eu.kanade.tachiyomi.data.database +import android.arch.persistence.db.SupportSQLiteDatabase +import android.arch.persistence.db.SupportSQLiteOpenHelper import android.content.Context import android.database.sqlite.SQLiteDatabase import android.database.sqlite.SQLiteOpenHelper import eu.kanade.tachiyomi.data.database.tables.* -class DbOpenHelper(context: Context) -: SQLiteOpenHelper(context, DATABASE_NAME, null, DATABASE_VERSION) { +class DbOpenCallback : SupportSQLiteOpenHelper.Callback(DATABASE_VERSION) { companion object { /** @@ -20,7 +21,7 @@ class DbOpenHelper(context: Context) const val DATABASE_VERSION = 8 } - override fun onCreate(db: SQLiteDatabase) = with(db) { + override fun onCreate(db: SupportSQLiteDatabase) = with(db) { execSQL(MangaTable.createTableQuery) execSQL(ChapterTable.createTableQuery) execSQL(TrackTable.createTableQuery) @@ -36,7 +37,7 @@ class DbOpenHelper(context: Context) execSQL(HistoryTable.createChapterIdIndexQuery) } - override fun onUpgrade(db: SQLiteDatabase, oldVersion: Int, newVersion: Int) { + override fun onUpgrade(db: SupportSQLiteDatabase, oldVersion: Int, newVersion: Int) { if (oldVersion < 2) { db.execSQL(ChapterTable.sourceOrderUpdateQuery) @@ -68,7 +69,7 @@ class DbOpenHelper(context: Context) } } - override fun onConfigure(db: SQLiteDatabase) { + override fun onConfigure(db: SupportSQLiteDatabase) { db.setForeignKeyConstraintsEnabled(true) } diff --git a/build.gradle b/build.gradle index 87a7724de..09b0d46cf 100644 --- a/build.gradle +++ b/build.gradle @@ -7,7 +7,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:3.2.0' + classpath 'com.android.tools.build:gradle:3.2.1' classpath 'com.github.ben-manes:gradle-versions-plugin:0.17.0' classpath 'com.github.zellius:android-shortcut-gradle-plugin:0.1.2' classpath 'com.google.gms:google-services:3.2.0' @@ -22,5 +22,6 @@ allprojects { jcenter() maven { url "https://jitpack.io" } maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } + maven { url "https://dl.bintray.com/inorichi/maven" } } }