@@ -805,40 +805,34 @@ public void updateProgressBar(ODKView odkv) {
805805 event = mFormController .stepToPreviousEvent ();
806806 }
807807
808- boolean onCurrentScreen = false ;
809- FormIndex currentScreenExit = null ;
810808 while (event != FormEntryController .EVENT_END_OF_FORM ) {
811809 int comparison = mFormController .getFormIndex ().compareTo (currentFormIndex );
812810
813- if (comparison == 0 ) {
814- onCurrentScreen = true ;
815- mFormController .stepToNextEvent (true );
816- currentScreenExit = mFormController .getFormIndex ();
817- mFormController .stepToPreviousEvent ();
818- }
819- if (onCurrentScreen && mFormController .getFormIndex ().equals (currentScreenExit )) {
820- onCurrentScreen = false ;
821- }
822-
823811 if (event == FormEntryController .EVENT_QUESTION ) {
824- FormEntryPrompt [] prompts = mFormController .getQuestionPrompts ();
825- totalQuestions += prompts .length ;
826- // Current questions are complete only if they're answered.
827- // Past questions are always complete.
828- // Future questions are never complete.
829- if (onCurrentScreen ) {
830- for (FormEntryPrompt prompt : prompts ) {
831- if (prompt .getAnswerValue () != null || prompt .getDataType () == Constants .DATATYPE_NULL ) {
832- completedQuestions ++;
833- }
834- }
812+ totalQuestions ++;
813+
814+ // Questions are counted as complete if any of the following are true:
815+ // - User has already passed the question, regardless of if it's been answered
816+ // - User is currently looking at the question, and it's been answered
817+ // - User is currently looking at a group containing the question, and it's been answered
818+ if (comparison < 0 ) {
819+ completedQuestions ++;
835820 }
836- else if (comparison < 0 ) {
837- // For previous questions, consider all "complete"
838- completedQuestions += prompts .length ;
821+ else {
822+ FormEntryPrompt prompt = mFormController .getQuestionPrompt ();
823+ if (prompt .getAnswerValue () != null || prompt .getDataType () == Constants .DATATYPE_NULL ) {
824+ if (comparison == 0 ) {
825+ completedQuestions ++;
826+ }
827+ else if (FormIndex .isSubElement (currentFormIndex , mFormController .getFormIndex ())) {
828+ completedQuestions ++;
829+ }
830+ }
839831 }
840832 }
841- event = mFormController .stepToNextEvent (false );
833+
834+ // Make sure we visit every question inside every group
835+ event = mFormController .stepToNextEvent (FormController .STEP_INTO_GROUP , false );
842836 }
843837
844838 // Set form back to correct state & actually update bar
@@ -1345,7 +1339,7 @@ private void showNextView(boolean resuming) {
13451339 try {
13461340
13471341 group_skip : do {
1348- event = mFormController .stepToNextEvent (FormController .STEP_INTO_GROUP );
1342+ event = mFormController .stepToNextEvent (FormController .STEP_OVER_GROUP );
13491343 switch (event ) {
13501344 case FormEntryController .EVENT_QUESTION :
13511345 case FormEntryController .EVENT_END_OF_FORM :
0 commit comments