Skip to content

Commit

Permalink
Merge pull request getodk#6 from meletis/master
Browse files Browse the repository at this point in the history
SurveyCTO: Fix for issue 1169
  • Loading branch information
mitchellsundt committed Oct 13, 2015
2 parents bc242a1 + a86573c commit 706be8a
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

package org.odk.collect.android.widgets;

import android.content.res.Resources;
import org.javarosa.core.model.data.DateTimeData;
import org.javarosa.core.model.data.IAnswerData;
import org.javarosa.form.api.FormEntryPrompt;
Expand Down Expand Up @@ -189,32 +190,36 @@ private void hideDayFieldIfNotInFormat(FormEntryPrompt prompt) {
}

if ( hideMonth || hideDay ) {
for (Field datePickerDialogField : this.mDatePicker.getClass().getDeclaredFields()) {
if ("mDayPicker".equals(datePickerDialogField.getName()) ||
"mDaySpinner".equals(datePickerDialogField.getName())) {
datePickerDialogField.setAccessible(true);
Object dayPicker = new Object();
try {
dayPicker = datePickerDialogField.get(this.mDatePicker);
} catch (Exception e) {
e.printStackTrace();
}
((View) dayPicker).setVisibility(View.GONE);
}
if ( hideMonth ) {
if ("mMonthPicker".equals(datePickerDialogField.getName()) ||
"mMonthSpinner".equals(datePickerDialogField.getName())) {
datePickerDialogField.setAccessible(true);
Object monthPicker = new Object();
try {
monthPicker = datePickerDialogField.get(this.mDatePicker);
} catch (Exception e) {
e.printStackTrace();
}
((View) monthPicker).setVisibility(View.GONE);
}
}
}
mDatePicker.findViewById(Resources.getSystem().getIdentifier("day", "id", "android")).setVisibility(View.GONE);
if (hideMonth) {
mDatePicker.findViewById(Resources.getSystem().getIdentifier("month", "id", "android")).setVisibility(View.GONE);
}
// for (Field datePickerDialogField : this.mDatePicker.getClass().getDeclaredFields()) {
// if ("mDayPicker".equals(datePickerDialogField.getName()) ||
// "mDaySpinner".equals(datePickerDialogField.getName())) {
// datePickerDialogField.setAccessible(true);
// Object dayPicker = new Object();
// try {
// dayPicker = datePickerDialogField.get(this.mDatePicker);
// } catch (Exception e) {
// e.printStackTrace();
// }
// ((View) dayPicker).setVisibility(View.GONE);
// }
// if ( hideMonth ) {
// if ("mMonthPicker".equals(datePickerDialogField.getName()) ||
// "mMonthSpinner".equals(datePickerDialogField.getName())) {
// datePickerDialogField.setAccessible(true);
// Object monthPicker = new Object();
// try {
// monthPicker = datePickerDialogField.get(this.mDatePicker);
// } catch (Exception e) {
// e.printStackTrace();
// }
// ((View) monthPicker).setVisibility(View.GONE);
// }
// }
// }
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import java.util.Calendar;
import java.util.Date;

import android.content.res.Resources;
import org.javarosa.core.model.data.DateData;
import org.javarosa.core.model.data.IAnswerData;
import org.javarosa.form.api.FormEntryPrompt;
Expand Down Expand Up @@ -166,32 +167,36 @@ private void hideDayFieldIfNotInFormat(FormEntryPrompt prompt) {
}

if ( hideMonth || hideDay ) {
for (Field datePickerDialogField : this.mDatePicker.getClass().getDeclaredFields()) {
if ("mDayPicker".equals(datePickerDialogField.getName()) ||
"mDaySpinner".equals(datePickerDialogField.getName())) {
datePickerDialogField.setAccessible(true);
Object dayPicker = new Object();
try {
dayPicker = datePickerDialogField.get(this.mDatePicker);
} catch (Exception e) {
e.printStackTrace();
}
((View) dayPicker).setVisibility(View.GONE);
}
if ( hideMonth ) {
if ("mMonthPicker".equals(datePickerDialogField.getName()) ||
"mMonthSpinner".equals(datePickerDialogField.getName())) {
datePickerDialogField.setAccessible(true);
Object monthPicker = new Object();
try {
monthPicker = datePickerDialogField.get(this.mDatePicker);
} catch (Exception e) {
e.printStackTrace();
}
((View) monthPicker).setVisibility(View.GONE);
}
}
}
mDatePicker.findViewById(Resources.getSystem().getIdentifier("day", "id", "android")).setVisibility(View.GONE);
if (hideMonth) {
mDatePicker.findViewById(Resources.getSystem().getIdentifier("month", "id", "android")).setVisibility(View.GONE);
}
// for (Field datePickerDialogField : this.mDatePicker.getClass().getDeclaredFields()) {
// if ("mDayPicker".equals(datePickerDialogField.getName()) ||
// "mDaySpinner".equals(datePickerDialogField.getName())) {
// datePickerDialogField.setAccessible(true);
// Object dayPicker = new Object();
// try {
// dayPicker = datePickerDialogField.get(this.mDatePicker);
// } catch (Exception e) {
// e.printStackTrace();
// }
// ((View) dayPicker).setVisibility(View.GONE);
// }
// if ( hideMonth ) {
// if ("mMonthPicker".equals(datePickerDialogField.getName()) ||
// "mMonthSpinner".equals(datePickerDialogField.getName())) {
// datePickerDialogField.setAccessible(true);
// Object monthPicker = new Object();
// try {
// monthPicker = datePickerDialogField.get(this.mDatePicker);
// } catch (Exception e) {
// e.printStackTrace();
// }
// ((View) monthPicker).setVisibility(View.GONE);
// }
// }
// }
}
}

Expand Down

0 comments on commit 706be8a

Please sign in to comment.