diff --git a/collect_app/src/main/java/org/odk/collect/android/activities/FormFillingActivity.java b/collect_app/src/main/java/org/odk/collect/android/activities/FormFillingActivity.java index aa804dd4d7b..0032d3cad8d 100644 --- a/collect_app/src/main/java/org/odk/collect/android/activities/FormFillingActivity.java +++ b/collect_app/src/main/java/org/odk/collect/android/activities/FormFillingActivity.java @@ -156,6 +156,7 @@ import org.odk.collect.android.utilities.ContentUriHelper; import org.odk.collect.android.utilities.ControllableLifecyleOwner; import org.odk.collect.android.utilities.ExternalAppIntentProvider; +import org.odk.collect.android.utilities.FileUtils; import org.odk.collect.android.utilities.FormsRepositoryProvider; import org.odk.collect.android.utilities.InstancesRepositoryProvider; import org.odk.collect.android.utilities.MediaUtils; @@ -545,6 +546,7 @@ private void setupViewModels(FormEntryViewModelFactory formEntryViewModelFactory identityPromptViewModel.isFormEntryCancelled().observe(this, isFormEntryCancelled -> { if (isFormEntryCancelled) { + identityPromptViewModel.exit(); exit(); } }); diff --git a/collect_app/src/main/java/org/odk/collect/android/formentry/audit/IdentityPromptViewModel.java b/collect_app/src/main/java/org/odk/collect/android/formentry/audit/IdentityPromptViewModel.java index 34b0a61ffaa..c1cc079fc9b 100644 --- a/collect_app/src/main/java/org/odk/collect/android/formentry/audit/IdentityPromptViewModel.java +++ b/collect_app/src/main/java/org/odk/collect/android/formentry/audit/IdentityPromptViewModel.java @@ -9,6 +9,7 @@ import androidx.lifecycle.ViewModel; import org.odk.collect.android.javarosawrapper.FormController; +import org.odk.collect.android.utilities.FileUtils; public class IdentityPromptViewModel extends ViewModel { @@ -20,6 +21,7 @@ public class IdentityPromptViewModel extends ViewModel { private String identity = ""; private String formName; + private String instanceFolder; public IdentityPromptViewModel() { updateRequiresIdentity(); @@ -28,6 +30,7 @@ public IdentityPromptViewModel() { public void formLoaded(@NonNull FormController formController) { this.formName = formController.getFormTitle(); this.auditEventLogger = formController.getAuditEventLogger(); + this.instanceFolder = formController.getInstanceFile().getParent(); updateRequiresIdentity(); } @@ -72,4 +75,8 @@ private static boolean userIsValid(String user) { public String getFormTitle() { return formName; } + + public void exit() { + FileUtils.purgeMediaPath(instanceFolder); + } }