Add dev live-reload tooling

DevPlugin (native + TS) lets the running app switch its webview to a
Vite dev server via DEV_URL, toggled from a hidden DevMenu (5 taps on
the app title).
This commit is contained in:
2026-08-12 11:54:39 +02:00
parent 0188d5210e
commit 6c9df23659
3 changed files with 105 additions and 0 deletions
@@ -3,10 +3,26 @@ package com.tiptoisync.app
import android.os.Bundle
import androidx.core.view.WindowCompat
import com.getcapacitor.BridgeActivity
import com.getcapacitor.CapConfig
class MainActivity : BridgeActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
// Dev-URL aus SharedPreferences lesen, bevor die Bridge initialisiert wird.
// "CapacitorStorage" ist der von @capacitor/preferences genutzte SharedPreferences-Name.
val devUrl = getSharedPreferences("CapacitorStorage", MODE_PRIVATE)
.getString("devServerUrl", null)
if (devUrl != null) {
// CapConfig mit der Dev-Server-URL überschreiben die Bridge lädt dann
// direkt vom Vite Dev-Server und injiziert die Bridge trotzdem korrekt.
config = CapConfig.Builder(this)
.setServerUrl(devUrl)
.setAllowMixedContent(true)
.create()
}
registerPlugin(TiptoiPlugin::class.java)
registerPlugin(DevPlugin::class.java)
super.onCreate(savedInstanceState)
WindowCompat.setDecorFitsSystemWindows(window, false)
}