Skip to content

Commit

Permalink
Merge pull request #2197 from dimagi/fix-saved-form-navigation
Browse files Browse the repository at this point in the history
Fix for navigation of saved form
  • Loading branch information
shubham1g5 authored Mar 24, 2020
2 parents c5d7f49 + 252cca1 commit 92c9774
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 15 deletions.
18 changes: 9 additions & 9 deletions app/src/org/commcare/activities/FormEntryActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ public void onActivityResultSessionSafe(int requestCode, int resultCode, Intent
case FormEntryConstants.LOCATION_CAPTURE:
String sl = intent.getStringExtra(FormEntryConstants.LOCATION_RESULT);
uiController.questionsView.setBinaryData(sl, mFormController);
saveAnswersForCurrentScreen(FormEntryConstants.DO_NOT_EVALUATE_CONSTRAINTS);
saveAnswersForCurrentScreen(false);
break;
case FormEntryConstants.HIERARCHY_ACTIVITY:
case FormEntryConstants.HIERARCHY_ACTIVITY_FIRST_START:
Expand All @@ -351,7 +351,7 @@ private void resetPendingCalloutIndex() {

public void saveImageWidgetAnswer(String imagePath) {
uiController.questionsView.setBinaryData(imagePath, mFormController);
saveAnswersForCurrentScreen(FormEntryConstants.DO_NOT_EVALUATE_CONSTRAINTS);
saveAnswersForCurrentScreen(false);
onExternalAttachmentUpdated();
uiController.refreshView();
}
Expand All @@ -370,7 +370,7 @@ private void processChooserResponse(Intent intent) {
} else {
uiController.questionsView.setBinaryData(media, mFormController);
}
saveAnswersForCurrentScreen(FormEntryConstants.DO_NOT_EVALUATE_CONSTRAINTS);
saveAnswersForCurrentScreen(false);
onExternalAttachmentUpdated();
uiController.refreshView();
}
Expand Down Expand Up @@ -500,7 +500,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
return true;
case FormEntryConstants.MENU_HIERARCHY_VIEW:
if (currentPromptIsQuestion()) {
saveAnswersForCurrentScreen(FormEntryConstants.DO_NOT_EVALUATE_CONSTRAINTS);
saveAnswersForCurrentScreen(false);
}
Intent i = new Intent(this, FormHierarchyActivity.class);
startActivityForResult(i, FormEntryConstants.HIERARCHY_ACTIVITY);
Expand Down Expand Up @@ -648,7 +648,7 @@ public Object onRetainCustomNonConfigurationInstance() {

// mFormEntryController is static so we don't need to pass it.
if (mFormController != null && currentPromptIsQuestion() && uiController.questionsView != null) {
saveAnswersForCurrentScreen(FormEntryConstants.DO_NOT_EVALUATE_CONSTRAINTS);
saveAnswersForCurrentScreen(false);
}
return null;
}
Expand Down Expand Up @@ -746,7 +746,7 @@ private void saveDataToDisk(boolean exit, boolean complete, String updatedSaveNa
// save current answer; if headless, don't evaluate the constraints
// before doing so.
boolean wasScreenSaved =
saveAnswersForCurrentScreen(FormEntryConstants.DO_NOT_EVALUATE_CONSTRAINTS, complete, headless);
saveAnswersForCurrentScreen(false, complete, headless);
if (!wasScreenSaved) {
return;
}
Expand Down Expand Up @@ -782,7 +782,7 @@ public void setFormLanguage(String[] languages, int index) {
mFormController.setLanguage(languages[index]);
dismissAlertDialog();
if (currentPromptIsQuestion()) {
saveAnswersForCurrentScreen(FormEntryConstants.DO_NOT_EVALUATE_CONSTRAINTS);
saveAnswersForCurrentScreen(false);
}
uiController.refreshView();
invalidateOptionsMenu();
Expand Down Expand Up @@ -819,7 +819,7 @@ protected void onPause() {
super.onPause();

if (!isFinishing() && uiController.questionsView != null && currentPromptIsQuestion()) {
saveAnswersForCurrentScreen(FormEntryConstants.DO_NOT_EVALUATE_CONSTRAINTS);
saveAnswersForCurrentScreen(false);
}

if (mLocationServiceIssueReceiver != null) {
Expand Down Expand Up @@ -1151,7 +1151,7 @@ public void savingComplete(SaveToDiskTask.SaveStatus saveStatus, String errorMes
// an answer constraint was violated, so try to save the
// current question to trigger the constraint violation message
uiController.refreshView();
saveAnswersForCurrentScreen(FormEntryConstants.EVALUATE_CONSTRAINTS);
saveAnswersForCurrentScreen(true);
return;
case SAVE_ERROR:
if (!CommCareApplication.instance().isConsumerApp()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ protected void showPreviousView(boolean showSwipeAnimation) {

// The answer is saved on a back swipe, but question constraints are ignored.
if (activity.currentPromptIsQuestion()) {
activity.saveAnswersForCurrentScreen(FormEntryConstants.DO_NOT_EVALUATE_CONSTRAINTS);
activity.saveAnswersForCurrentScreen(false);
}

// Any info stored about the last changed widget is useless when we move to a new view
Expand Down Expand Up @@ -392,7 +392,7 @@ private void showNextView(boolean resuming) {
}

if (activity.currentPromptIsQuestion()) {
if (!activity.saveAnswersForCurrentScreen(FormEntryConstants.EVALUATE_CONSTRAINTS)) {
if (!activity.saveAnswersForCurrentScreen(!activity.mFormController.isFormReadOnly())) {
// A constraint was violated so a dialog should be showing.
return;
}
Expand Down Expand Up @@ -717,7 +717,7 @@ protected void updateFormRelevancies() {
ArrayList<String> oldQuestionTexts =
FormRelevancyUpdating.getOldQuestionTextsForEachWidget(oldWidgets);

activity.saveAnswersForCurrentScreen(FormEntryConstants.DO_NOT_EVALUATE_CONSTRAINTS);
activity.saveAnswersForCurrentScreen(false);

FormEntryPrompt[] newValidPrompts;
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ public class FormEntryConstants {
// Defines for FormEntryActivity
public static final boolean EXIT = true;
public static final boolean DO_NOT_EXIT = false;
public static final boolean EVALUATE_CONSTRAINTS = true;
public static final boolean DO_NOT_EVALUATE_CONSTRAINTS = false;

// Request codes for returning data from specified intent.
public static final int IMAGE_CAPTURE = 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public static void createClearDialog(final FormEntryActivity activity,
switch (i) {
case DialogInterface.BUTTON_POSITIVE:
activity.clearAnswer(qw);
activity.saveAnswersForCurrentScreen(FormEntryConstants.DO_NOT_EVALUATE_CONSTRAINTS);
activity.saveAnswersForCurrentScreen(false);
break;
case DialogInterface.BUTTON_NEGATIVE:
break;
Expand Down

0 comments on commit 92c9774

Please sign in to comment.