From d58d9036cbe46c989b81f403b5c00c8f9efdf204 Mon Sep 17 00:00:00 2001 From: inventory69 Date: Fri, 23 Jan 2026 21:39:04 +0100 Subject: [PATCH] =?UTF-8?q?fix:=20offline=20mode=20migration=20bug=20for?= =?UTF-8?q?=20v1.5.0=20=E2=86=92=20v1.6.2=20updates?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Fixes offline mode incorrectly enabled after updating from v1.5.0 - Users with existing server configuration no longer appear as offline - Root cause: KEY_OFFLINE_MODE didn't exist in v1.5.0 - MainViewModel/NoteEditorViewModel used hardcoded default 'true' - Fix: Migration in SimpleNotesApplication.onCreate() detects server config - Version bumped to v1.6.2 (versionCode 16) - F-Droid changelogs added Tested: v1.5.0 → v1.6.2 update successful Migration log: hasServer=true → offlineMode=false ✓ --- android/app/build.gradle.kts | 4 +-- .../simplenotes/SimpleNotesApplication.kt | 34 ++++++++++++++++++- .../metadata/android/de-DE/changelogs/16.txt | 2 ++ .../metadata/android/en-US/changelogs/16.txt | 2 ++ 4 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 fastlane/metadata/android/de-DE/changelogs/16.txt create mode 100644 fastlane/metadata/android/en-US/changelogs/16.txt 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