Skip to content

Commit

Permalink
Merge pull request #2835 from dimagi/doNotSaveReadOnlyForms
Browse files Browse the repository at this point in the history
Do not save read only forms
  • Loading branch information
shubham1g5 authored Sep 5, 2024
2 parents 729c49b + 199b1fa commit 824da79
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions app/assets/locales/android_translatable_strings.txt
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ form.entry.incomplete.save.success=Form saved as incomplete
form.entry.save.error=Sorry, form save failed. Please contact CommCare Support to look into the issue.
form.entry.save.invalid.unicode=Could not save '${0}' text in form.
form.entry.finish.button=FINISH
form.entry.exit.button=EXIT
form.entry.restart.after.expiration=You were logged out due to session expiration. The form you were in the middle of has been saved and resumed.

login.attempt.badcred=Username or password are incorrect. Please try again.
Expand Down
4 changes: 4 additions & 0 deletions app/src/org/commcare/activities/FormEntryActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -820,6 +820,10 @@ private void saveDataToDisk(boolean exit, boolean complete, String updatedSaveNa
return;
}

if (mFormController.isFormReadOnly()) {
return;
}

// save current answer; if headless, don't evaluate the constraints
// before doing so.
boolean wasScreenSaved =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public class FormEntryActivityUIController implements CommCareActivityUIControll
private boolean formRelevanciesUpdateInProgress = false;

private static final String KEY_LAST_CHANGED_WIDGET = "index-of-last-changed-widget";
private TextView finishText;

enum AnimationType {
LEFT, RIGHT, FADE
Expand All @@ -103,7 +104,7 @@ public void setupUI() {

View finishButton = activity.findViewById(R.id.nav_btn_finish);

TextView finishText = finishButton.findViewById(R.id.nav_btn_finish_text);
finishText = finishButton.findViewById(R.id.nav_btn_finish_text);
finishText.setText(Localization.get("form.entry.finish.button").toUpperCase());

nextButton.setOnClickListener(v -> {
Expand Down Expand Up @@ -199,6 +200,10 @@ protected void refreshCurrentView(boolean animateLastView) {
QuestionsView current = createView();
showView(current, AnimationType.FADE, animateLastView);
}

if (finishText != null && FormEntryActivity.mFormController.isFormReadOnly()) {
finishText.setText(Localization.get("form.entry.exit.button").toUpperCase());
}
}

/**
Expand Down

0 comments on commit 824da79

Please sign in to comment.