diff --git a/android/app/build.gradle.kts b/android/app/build.gradle.kts index c5bbd22..5c0ef64 100644 --- a/android/app/build.gradle.kts +++ b/android/app/build.gradle.kts @@ -20,8 +20,8 @@ android { applicationId = "dev.dettmer.simplenotes" minSdk = 24 targetSdk = 36 - versionCode = 15 // 🔧 v1.6.1: Lint-Cleanup detekt and ktlint - versionName = "1.6.1" // 🔧 v1.6.1: Lint-Cleanup detekt and ktlint + versionCode = 16 // 🔧 v1.6.2: Hotfix offline mode migration bug + versionName = "1.6.2" // 🔧 v1.6.2: Hotfix offline mode migration bug testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" } diff --git a/android/app/src/main/java/dev/dettmer/simplenotes/SimpleNotesApplication.kt b/android/app/src/main/java/dev/dettmer/simplenotes/SimpleNotesApplication.kt index 71401f5..239f1c7 100644 --- a/android/app/src/main/java/dev/dettmer/simplenotes/SimpleNotesApplication.kt +++ b/android/app/src/main/java/dev/dettmer/simplenotes/SimpleNotesApplication.kt @@ -18,8 +18,14 @@ class SimpleNotesApplication : Application() { override fun onCreate() { super.onCreate() - // File-Logging ZUERST aktivieren (damit alle Logs geschrieben werden!) val prefs = getSharedPreferences(Constants.PREFS_NAME, Context.MODE_PRIVATE) + + // 🔧 Hotfix v1.6.2: Migrate offline mode setting BEFORE any ViewModel initialization + // This prevents the offline mode bug where users updating from v1.5.0 incorrectly + // appear as offline even though they have a configured server + migrateOfflineModeSetting(prefs) + + // File-Logging ZUERST aktivieren (damit alle Logs geschrieben werden!) if (prefs.getBoolean("file_logging_enabled", false)) { Logger.enableFileLogging(this) Logger.d(TAG, "📝 File logging enabled at Application startup") @@ -50,4 +56,30 @@ class SimpleNotesApplication : Application() { // WorkManager läuft weiter auch nach onTerminate! // Nur bei deaktiviertem Auto-Sync stoppen wir es } + + /** + * 🔧 Hotfix v1.6.2: Migrate offline mode setting for updates from v1.5.0 + * + * Problem: KEY_OFFLINE_MODE didn't exist in v1.5.0, but MainViewModel + * and NoteEditorViewModel use `true` as default, causing existing users + * with configured servers to appear in offline mode after update. + * + * Fix: Set the key BEFORE any ViewModel is initialized based on whether + * a server was already configured. + */ + private fun migrateOfflineModeSetting(prefs: android.content.SharedPreferences) { + if (!prefs.contains(Constants.KEY_OFFLINE_MODE)) { + val serverUrl = prefs.getString(Constants.KEY_SERVER_URL, null) + val hasServerConfig = !serverUrl.isNullOrEmpty() && + serverUrl != "http://" && + serverUrl != "https://" + + // If server was configured → offlineMode = false (continue syncing) + // If no server → offlineMode = true (new users / offline users) + val offlineModeValue = !hasServerConfig + prefs.edit().putBoolean(Constants.KEY_OFFLINE_MODE, offlineModeValue).apply() + + Logger.i(TAG, "🔄 Migrated offline_mode_enabled: hasServer=$hasServerConfig → offlineMode=$offlineModeValue") + } + } } diff --git a/fastlane/metadata/android/de-DE/changelogs/16.txt b/fastlane/metadata/android/de-DE/changelogs/16.txt new file mode 100644 index 0000000..ba25268 --- /dev/null +++ b/fastlane/metadata/android/de-DE/changelogs/16.txt @@ -0,0 +1,2 @@ +• Behebt Offline-Modus Problem nach Update von v1.5.0 +• Nutzer mit konfiguriertem Server werden nicht mehr fälschlicherweise als offline angezeigt diff --git a/fastlane/metadata/android/en-US/changelogs/16.txt b/fastlane/metadata/android/en-US/changelogs/16.txt new file mode 100644 index 0000000..546dd6c --- /dev/null +++ b/fastlane/metadata/android/en-US/changelogs/16.txt @@ -0,0 +1,2 @@ +• Fixes offline mode issue after updating from v1.5.0 +• Users with configured servers are no longer incorrectly shown as offline