From e399924e6e0ae5ba09e594a8ea54af11257dc97d Mon Sep 17 00:00:00 2001 From: Grzegorz Orczykowski Date: Thu, 3 Oct 2024 14:36:35 +0200 Subject: [PATCH 01/50] Updated ChangeLock interface --- .../org/odk/collect/shared/locks/ChangeLock.kt | 7 ++++++- .../shared/locks/ReentrantLockChangeLock.kt | 12 ++++++++++++ .../odk/collect/testshared/BooleanChangeLock.kt | 16 ++++++++++++---- 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/shared/src/main/java/org/odk/collect/shared/locks/ChangeLock.kt b/shared/src/main/java/org/odk/collect/shared/locks/ChangeLock.kt index 3a76b9804a7..2667a5689bd 100644 --- a/shared/src/main/java/org/odk/collect/shared/locks/ChangeLock.kt +++ b/shared/src/main/java/org/odk/collect/shared/locks/ChangeLock.kt @@ -3,11 +3,16 @@ package org.odk.collect.shared.locks import java.util.function.Function interface ChangeLock { - /** * @param function some work to be executed after attempting to acquire the lock. The function * will be passed `true` if the lock was acquired and `false` if not. The * function return value will be returned from the call to this method. */ fun withLock(function: Function): T + + fun isLocked(): Boolean + + fun lock() + + fun unlock() } diff --git a/shared/src/main/java/org/odk/collect/shared/locks/ReentrantLockChangeLock.kt b/shared/src/main/java/org/odk/collect/shared/locks/ReentrantLockChangeLock.kt index a12e2ae1f85..46693aecfbe 100644 --- a/shared/src/main/java/org/odk/collect/shared/locks/ReentrantLockChangeLock.kt +++ b/shared/src/main/java/org/odk/collect/shared/locks/ReentrantLockChangeLock.kt @@ -17,4 +17,16 @@ class ReentrantLockChangeLock : ChangeLock { } } } + + override fun isLocked(): Boolean { + return lock.isLocked + } + + override fun lock() { + lock.tryLock() + } + + override fun unlock() { + lock.unlock() + } } diff --git a/test-shared/src/main/java/org/odk/collect/testshared/BooleanChangeLock.kt b/test-shared/src/main/java/org/odk/collect/testshared/BooleanChangeLock.kt index b8dbbd70212..76ce60b8734 100644 --- a/test-shared/src/main/java/org/odk/collect/testshared/BooleanChangeLock.kt +++ b/test-shared/src/main/java/org/odk/collect/testshared/BooleanChangeLock.kt @@ -4,13 +4,21 @@ import org.odk.collect.shared.locks.ChangeLock import java.util.function.Function class BooleanChangeLock : ChangeLock { - private var locked = false + private var isLocked = false override fun withLock(function: Function): T { - return function.apply(!locked) + return function.apply(!isLocked) } - fun lock() { - locked = true + override fun isLocked(): Boolean { + return isLocked + } + + override fun lock() { + isLocked = true + } + + override fun unlock() { + isLocked = false } } From 7b16896ec9d27f313db89c4129eec52513e2d3e2 Mon Sep 17 00:00:00 2001 From: Grzegorz Orczykowski Date: Thu, 3 Oct 2024 14:40:32 +0200 Subject: [PATCH 02/50] Added a new error message --- strings/src/main/res/values/strings.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/strings/src/main/res/values/strings.xml b/strings/src/main/res/values/strings.xml index 235cf96f2e9..06121a27352 100644 --- a/strings/src/main/res/values/strings.xml +++ b/strings/src/main/res/values/strings.xml @@ -1161,6 +1161,8 @@ --> Show details Errors + + The form cannot be opened because forms update is being applied in the background. This process may take a few minutes. Please try again later. @@ -184,10 +183,6 @@ Invalid RSA public key. %s Form has not been saved as finalized. - - Bad URI: %s - - Unrecognized URI: %s Form can\'t be used @@ -203,9 +198,6 @@ Recording disabled. Enable in %s - - Filled form has been deleted! - Failure trying to update values. This is generally because of incorrect usage of calculations in the form design.\n\nIf you keep having this problem, report it to the person who asked you to collect data. @@ -1086,7 +1078,6 @@ Could not delete \'%s\'. Please delete the file manually and re-download the form. Could not create media folder \'%s\'. Could not copy \'%1$s\' over \'%2$s\'. Reason: %3$s - You have downloaded two different forms with the same form ID and version. Maybe they were the same form uploaded at different times or to different servers. In any case, you should delete one. Select ODK Shortcut This form records the audio from your device\'s microphone.\n\nYou can use the volume indicator to make sure the microphone is close enough to the sound you need to record.\n\nTo stop the recording please exit this form.\n\nFor more information please contact the person who asked you to collect data. @@ -1149,11 +1140,6 @@ Try a demo Scan configuration QR code - - To open this form, you must first open ODK Collect and switch to the project that contains it. - - ODK Collect has not been configured. Try to open ODK Collect and configure it.\n\nIf you tapped on a shortcut, you might need to recreate it after configuring ODK Collect. - Show details Errors - + + + + To open this form, you must first open ODK Collect and switch to the project that contains it. + + ODK Collect has not been configured. Try to open ODK Collect and configure it.\n\nIf you tapped on a shortcut, you might need to recreate it after configuring ODK Collect. + + Unrecognized URI: %s + + Bad URI: %s + + Filled form has been deleted! + + Unable to edit this draft because the corresponding blank form is not present or was deleted.\n\nForm ID: %1$s + + You have downloaded two different forms with the same form ID and version. Maybe they were the same form uploaded at different times or to different servers. In any case, you should delete one. + The form cannot be opened because forms update is being applied in the background. This process may take a few minutes. Please try again later. You have downloaded two different forms with the same form ID and version. Maybe they were the same form uploaded at different times or to different servers. In any case, you should delete one. - The form cannot be opened because forms update is being applied in the background. This process may take a few minutes. Please try again later. + This form cannot be opened right now because forms are being updated. Please try again shortly.