Search in sources :

Example 1 with DatePickerDetails

use of org.odk.collect.android.logic.DatePickerDetails in project collect by opendatakit.

the class DateTimeUtilsTest method setUp.

@Before
public void setUp() {
    gregorian = new DatePickerDetails(DatePickerDetails.DatePickerType.GREGORIAN, DatePickerDetails.DatePickerMode.CALENDAR);
    gregorianSpinners = new DatePickerDetails(DatePickerDetails.DatePickerType.GREGORIAN, DatePickerDetails.DatePickerMode.SPINNERS);
    gregorianMonthYear = new DatePickerDetails(DatePickerDetails.DatePickerType.GREGORIAN, DatePickerDetails.DatePickerMode.MONTH_YEAR);
    gregorianYear = new DatePickerDetails(DatePickerDetails.DatePickerType.GREGORIAN, DatePickerDetails.DatePickerMode.YEAR);
    ethiopian = new DatePickerDetails(DatePickerDetails.DatePickerType.ETHIOPIAN, DatePickerDetails.DatePickerMode.SPINNERS);
    ethiopianMonthYear = new DatePickerDetails(DatePickerDetails.DatePickerType.ETHIOPIAN, DatePickerDetails.DatePickerMode.MONTH_YEAR);
    ethiopianYear = new DatePickerDetails(DatePickerDetails.DatePickerType.ETHIOPIAN, DatePickerDetails.DatePickerMode.YEAR);
    coptic = new DatePickerDetails(DatePickerDetails.DatePickerType.COPTIC, DatePickerDetails.DatePickerMode.SPINNERS);
    copticMonthYear = new DatePickerDetails(DatePickerDetails.DatePickerType.COPTIC, DatePickerDetails.DatePickerMode.MONTH_YEAR);
    copticYear = new DatePickerDetails(DatePickerDetails.DatePickerType.COPTIC, DatePickerDetails.DatePickerMode.YEAR);
    islamic = new DatePickerDetails(DatePickerDetails.DatePickerType.ISLAMIC, DatePickerDetails.DatePickerMode.SPINNERS);
    islamicMonthYear = new DatePickerDetails(DatePickerDetails.DatePickerType.ISLAMIC, DatePickerDetails.DatePickerMode.MONTH_YEAR);
    islamicYear = new DatePickerDetails(DatePickerDetails.DatePickerType.ISLAMIC, DatePickerDetails.DatePickerMode.YEAR);
}
Also used : DatePickerDetails(org.odk.collect.android.logic.DatePickerDetails) Before(org.junit.Before)

Example 2 with DatePickerDetails

use of org.odk.collect.android.logic.DatePickerDetails in project collect by opendatakit.

the class DateTimeUtilsTest method setUp.

@Before
public void setUp() {
    gregorianDatePickerDetails = new DatePickerDetails(DatePickerDetails.DatePickerType.GREGORIAN, DatePickerDetails.DatePickerMode.CALENDAR);
    ethiopianDatePickerDetails = new DatePickerDetails(DatePickerDetails.DatePickerType.ETHIOPIAN, DatePickerDetails.DatePickerMode.SPINNERS);
    copticDatePickerDetails = new DatePickerDetails(DatePickerDetails.DatePickerType.COPTIC, DatePickerDetails.DatePickerMode.SPINNERS);
    islamicDatePickerDetails = new DatePickerDetails(DatePickerDetails.DatePickerType.ISLAMIC, DatePickerDetails.DatePickerMode.SPINNERS);
    bikramSambatDatePickerDetails = new DatePickerDetails(DatePickerDetails.DatePickerType.BIKRAM_SAMBAT, DatePickerDetails.DatePickerMode.SPINNERS);
    myanmarDatePickerDetails = new DatePickerDetails(DatePickerDetails.DatePickerType.MYANMAR, DatePickerDetails.DatePickerMode.SPINNERS);
    persianDatePickerDetails = new DatePickerDetails(DatePickerDetails.DatePickerType.PERSIAN, DatePickerDetails.DatePickerMode.SPINNERS);
    context = Collect.getInstance();
    defaultLocale = Locale.getDefault();
    defaultTimezone = TimeZone.getDefault();
}
Also used : DatePickerDetails(org.odk.collect.android.logic.DatePickerDetails) Before(org.junit.Before)

Example 3 with DatePickerDetails

use of org.odk.collect.android.logic.DatePickerDetails in project collect by opendatakit.

the class DialogFragmentHelpers method setUpDatePickerDetails.

public static DatePickerDetails setUpDatePickerDetails(DatePickerDetails.DatePickerType datePickerType) {
    DatePickerDetails datePickerDetails = mock(DatePickerDetails.class);
    when(datePickerDetails.getDatePickerType()).thenReturn(datePickerType);
    when(datePickerDetails.isSpinnerMode()).thenReturn(true);
    when(datePickerDetails.isMonthYearMode()).thenReturn(false);
    when(datePickerDetails.isYearMode()).thenReturn(false);
    return datePickerDetails;
}
Also used : DatePickerDetails(org.odk.collect.android.logic.DatePickerDetails)

Example 4 with DatePickerDetails

use of org.odk.collect.android.logic.DatePickerDetails in project collect by opendatakit.

the class DateWidgetTest method whenPromptHasAnswer_answerTextViewShowsCorrectDate.

@Test
public void whenPromptHasAnswer_answerTextViewShowsCorrectDate() {
    FormEntryPrompt prompt = promptWithQuestionDefAndAnswer(questionDef, new DateData(dateAnswer.toDate()));
    DatePickerDetails datePickerDetails = DateTimeWidgetUtils.getDatePickerDetails(prompt.getQuestion().getAppearanceAttr());
    DateWidget widget = createWidget(prompt);
    assertEquals(widget.binding.dateAnswerText.getText(), DateTimeWidgetUtils.getDateTimeLabel(dateAnswer.toDate(), datePickerDetails, false, widget.getContext()));
}
Also used : FormEntryPrompt(org.javarosa.form.api.FormEntryPrompt) DateData(org.javarosa.core.model.data.DateData) DatePickerDetails(org.odk.collect.android.logic.DatePickerDetails) Test(org.junit.Test)

Example 5 with DatePickerDetails

use of org.odk.collect.android.logic.DatePickerDetails in project collect by opendatakit.

the class DateTimeWidgetTest method setDateData_updatesValueShownInDateAnswerTextView.

@Test
public void setDateData_updatesValueShownInDateAnswerTextView() {
    FormEntryPrompt prompt = promptWithQuestionDefAndAnswer(questionDef, null);
    DatePickerDetails datePickerDetails = DateTimeWidgetUtils.getDatePickerDetails(prompt.getQuestion().getAppearanceAttr());
    DateTimeWidget widget = createWidget(prompt);
    widget.setData(new LocalDateTime().withDate(2010, 5, 12));
    assertEquals(widget.binding.dateWidget.dateAnswerText.getText(), DateTimeWidgetUtils.getDateTimeLabel(localDateTime.toDate(), datePickerDetails, false, widget.getContext()));
}
Also used : LocalDateTime(org.joda.time.LocalDateTime) FormEntryPrompt(org.javarosa.form.api.FormEntryPrompt) DatePickerDetails(org.odk.collect.android.logic.DatePickerDetails) Test(org.junit.Test)

Aggregations

DatePickerDetails (org.odk.collect.android.logic.DatePickerDetails)8 FormEntryPrompt (org.javarosa.form.api.FormEntryPrompt)4 Test (org.junit.Test)4 Before (org.junit.Before)3 LocalDateTime (org.joda.time.LocalDateTime)2 DateData (org.javarosa.core.model.data.DateData)1 DateTimeData (org.javarosa.core.model.data.DateTimeData)1 WidgetTestActivity (org.odk.collect.android.support.WidgetTestActivity)1