diff --git a/app/build.gradle b/app/build.gradle index 7253edb09..08055058b 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -97,7 +97,7 @@ project.tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all { } ext.lifecycleVersion = "2.2.0" -ext.roomVersion = '2.2.5' +ext.roomVersion = '2.3.0' ext.retrofitVersion = '2.9.0' ext.okhttpVersion = '4.9.0' ext.glideVersion = '4.11.0' diff --git a/app/src/main/java/com/keylesspalace/tusky/db/Converters.kt b/app/src/main/java/com/keylesspalace/tusky/db/Converters.kt index 1b1f94f3d..b81ad63e2 100644 --- a/app/src/main/java/com/keylesspalace/tusky/db/Converters.kt +++ b/app/src/main/java/com/keylesspalace/tusky/db/Converters.kt @@ -18,24 +18,26 @@ package com.keylesspalace.tusky.db import android.text.Spanned import androidx.core.text.parseAsHtml import androidx.core.text.toHtml +import androidx.room.ProvidedTypeConverter import androidx.room.TypeConverter -import com.google.gson.GsonBuilder +import com.google.gson.Gson import com.google.gson.reflect.TypeToken import com.keylesspalace.tusky.TabData import com.keylesspalace.tusky.components.conversation.ConversationAccountEntity import com.keylesspalace.tusky.createTabDataFromId import com.keylesspalace.tusky.entity.* -import com.keylesspalace.tusky.json.SpannedTypeAdapter import com.keylesspalace.tusky.util.trimTrailingWhitespace import java.net.URLDecoder import java.net.URLEncoder import java.util.* +import javax.inject.Inject +import javax.inject.Singleton -class Converters { - - private val gson = GsonBuilder() - .registerTypeAdapter(Spanned::class.java, SpannedTypeAdapter()) - .create() +@ProvidedTypeConverter +@Singleton +class Converters @Inject constructor ( + private val gson: Gson +) { @TypeConverter fun jsonToEmojiList(emojiListJson: String?): List? { diff --git a/app/src/main/java/com/keylesspalace/tusky/di/AppModule.kt b/app/src/main/java/com/keylesspalace/tusky/di/AppModule.kt index 1137b12b0..13266851b 100644 --- a/app/src/main/java/com/keylesspalace/tusky/di/AppModule.kt +++ b/app/src/main/java/com/keylesspalace/tusky/di/AppModule.kt @@ -28,6 +28,7 @@ import com.keylesspalace.tusky.appstore.EventHubImpl import com.keylesspalace.tusky.components.notifications.Notifier import com.keylesspalace.tusky.components.notifications.SystemNotifier import com.keylesspalace.tusky.db.AppDatabase +import com.keylesspalace.tusky.db.Converters import com.keylesspalace.tusky.network.MastodonApi import com.keylesspalace.tusky.network.TimelineCases import com.keylesspalace.tusky.network.TimelineCasesImpl @@ -70,8 +71,9 @@ class AppModule { @Provides @Singleton - fun providesDatabase(appContext: Context): AppDatabase { + fun providesDatabase(appContext: Context, converters: Converters): AppDatabase { return Room.databaseBuilder(appContext, AppDatabase::class.java, "tuskyDB") + .addTypeConverter(converters) .allowMainThreadQueries() .addMigrations(AppDatabase.MIGRATION_2_3, AppDatabase.MIGRATION_3_4, AppDatabase.MIGRATION_4_5, AppDatabase.MIGRATION_5_6, AppDatabase.MIGRATION_6_7, AppDatabase.MIGRATION_7_8,