Skip to content

Commit

Permalink
Remove the empty instance folder when exiting the identity dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
grzesiek2010 committed Nov 18, 2024
1 parent d064a81 commit 8b870f3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,7 @@ private void setupViewModels(FormEntryViewModelFactory formEntryViewModelFactory

identityPromptViewModel.isFormEntryCancelled().observe(this, isFormEntryCancelled -> {
if (isFormEntryCancelled) {
identityPromptViewModel.exit();
exit();
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand All @@ -20,6 +21,7 @@ public class IdentityPromptViewModel extends ViewModel {

private String identity = "";
private String formName;
private String instanceFolder;

public IdentityPromptViewModel() {
updateRequiresIdentity();
Expand All @@ -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();
}

Expand Down Expand Up @@ -72,4 +75,8 @@ private static boolean userIsValid(String user) {
public String getFormTitle() {
return formName;
}

public void exit() {
FileUtils.purgeMediaPath(instanceFolder);
}
}

0 comments on commit 8b870f3

Please sign in to comment.