diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 007619c..b38fc3f 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -30,6 +30,14 @@ android { vectorDrawables { useSupportLibrary = true } + javaCompileOptions { + annotationProcessorOptions { + arguments += mapOf( + "room.schemaLocation" to "$projectDir/schemas", + "room.incremental" to "true" + ) + } + } } buildTypes { diff --git a/app/src/main/java/com/zaneschepke/wireguardautotunnel/repository/AppDatabase.kt b/app/src/main/java/com/zaneschepke/wireguardautotunnel/repository/AppDatabase.kt index 9e3d162..f24a87e 100644 --- a/app/src/main/java/com/zaneschepke/wireguardautotunnel/repository/AppDatabase.kt +++ b/app/src/main/java/com/zaneschepke/wireguardautotunnel/repository/AppDatabase.kt @@ -6,7 +6,7 @@ import androidx.room.TypeConverters import com.zaneschepke.wireguardautotunnel.repository.model.Settings import com.zaneschepke.wireguardautotunnel.repository.model.TunnelConfig -@Database(entities = [Settings::class, TunnelConfig::class], version = 1) +@Database(entities = [Settings::class, TunnelConfig::class], version = 1, exportSchema = true) @TypeConverters(DatabaseListConverters::class) abstract class AppDatabase : RoomDatabase() { abstract fun settingDao(): SettingsDoa diff --git a/app/src/main/java/com/zaneschepke/wireguardautotunnel/service/tile/TunnelControlTile.kt b/app/src/main/java/com/zaneschepke/wireguardautotunnel/service/tile/TunnelControlTile.kt index 0dc9479..a3f3c0b 100644 --- a/app/src/main/java/com/zaneschepke/wireguardautotunnel/service/tile/TunnelControlTile.kt +++ b/app/src/main/java/com/zaneschepke/wireguardautotunnel/service/tile/TunnelControlTile.kt @@ -81,13 +81,18 @@ class TunnelControlTile : TileService() { private suspend fun determineTileTunnel() : TunnelConfig? { var tunnelConfig : TunnelConfig? = null; val settings = settingsRepo.getAll() - if (!settings.isNullOrEmpty()) { + if (settings.isNotEmpty()) { val setting = settings.first() tunnelConfig = if (setting.defaultTunnel != null) { TunnelConfig.from(setting.defaultTunnel!!); } else { - val config = configRepo.getAll()?.first(); - config; + val configs = configRepo.getAll(); + val config = if(configs.isNotEmpty()) { + configs.first(); + } else { + null + } + config } } return tunnelConfig; @@ -97,7 +102,7 @@ class TunnelControlTile : TileService() { private fun attemptWatcherServiceToggle(tunnelConfig : String) { scope.launch { val settings = settingsRepo.getAll() - if (!settings.isNullOrEmpty()) { + if (settings.isNotEmpty()) { val setting = settings.first() if(setting.isAutoTunnelEnabled) { ServiceManager.toggleWatcherServiceForeground(this@TunnelControlTile, tunnelConfig)