Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not save read only forms #2835

Merged
merged 2 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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