Forráskód Böngészése

Moved debug servers to properties

Vadik Sirekanyan 2 éve
szülő
commit
cead09f077

+ 1 - 0
.gitignore

@@ -3,3 +3,4 @@
 /build
 /app/build
 /local.properties
+/debug.properties

+ 11 - 0
app/build.gradle.kts

@@ -1,4 +1,5 @@
 import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.util.archivesName
+import java.util.Properties
 
 plugins {
     id("com.android.application")
@@ -23,6 +24,16 @@ android {
         }
     }
     buildTypes {
+        debug {
+            val props = Properties().also {
+                it.load(File("debug.properties").also(File::createNewFile).inputStream())
+            }
+            isDebuggable = props.getProperty("DEBUGGABLE").toBoolean()
+            buildConfigField("boolean", "DEBUG", "true")
+            listOf("DEBUG_SERVER1", "DEBUG_SERVER2").forEach { key ->
+                buildConfigField("String", key, props.getProperty(key)?.let { "\"$it\"" } ?: "null")
+            }
+        }
         release {
             isMinifyEnabled = true
             isShrinkResources = true

+ 7 - 5
app/src/debug/kotlin/org/sirekanyan/outline/db/DebugDaoImpl.kt

@@ -1,6 +1,7 @@
 package org.sirekanyan.outline.db
 
-import org.sirekanyan.outline.api.model.createServerEntity
+import org.sirekanyan.outline.BuildConfig
+import org.sirekanyan.outline.db.model.ServerEntity
 import org.sirekanyan.outline.isDebugBuild
 
 class DebugDaoImpl(private val database: OutlineDatabase) : DebugDao {
@@ -18,10 +19,11 @@ class DebugDaoImpl(private val database: OutlineDatabase) : DebugDao {
         database.transaction {
             keyQueries.truncate()
             serverQueries.truncate()
-            listOf<String>(
-                // add your debug servers here
-            ).forEach { url ->
-                serverQueries.insert(createServerEntity(url, insecure = true))
+            listOfNotNull(
+                BuildConfig.DEBUG_SERVER1,
+                BuildConfig.DEBUG_SERVER2,
+            ).forEachIndexed { index, url ->
+                serverQueries.insert(ServerEntity(url, true, "Server ${index + 1}", null))
             }
         }
     }