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

Display days of previous and current months #114

Conversation

JulienArzul
Copy link
Contributor

Hi,

I've added the possibility on a given month to display the days of the previous and next month as explained in the issue #46

The code is pretty straightforward. I've added two attributes to keep it optional (one to use the feature and one to set the color of the text) and it's disabled by default to keep retro-compatibility.

@JulienArzul JulienArzul changed the title Added attribute to choose if we want to draw the days of the previous… Display days of previous and current months Oct 17, 2016
@SundeepK
Copy link
Owner

Thanks for the pull request, please refer to the comments on #117 for now.

… and next months in the current month grid

Added an attribute to choose the text color of the days of the other months
@JulienArzul JulienArzul force-pushed the @enhancement/#46_display_days_of_other_months branch from bc8b335 to b693591 Compare October 18, 2016 08:18
@JulienArzul
Copy link
Contributor Author

I've rebased your changes from master on my branch. It's ready for review.

@SundeepK
Copy link
Owner

SundeepK commented Nov 1, 2016

Thanks for the changes. I think they look good to me. I don't think it's documented anywhere but there are some screenshot tests here: https://github.com/SundeepK/CompactCalendarView/blob/master/sample/src/androidTest/java/sundeepk/github/com/sample/ApplicationTest.java

It's based on the sample application and provides a way todo regression tests. To make sure things don't break in the future. It uses facebook screenshot-tests-for-android:
https://github.com/facebook/screenshot-tests-for-android

That repo has some prerequisites before you can run the tests. But it's all documented in the github readme. Then in the root of the project you can run:

./gradlew verifyMode pullScreenshotsFromDirectory
to run the tests.

./gradlew recordMode pullScreenshotsFromDirectory
to add a new screenshot.

First you will need to run recordMode to record and save your screenshot and commit that single screenshot and then verifyMode to run the tests.

It would be good to get a few tests for this, i.e. set the date and enable this feature to see the previous/next month days. Maybe we can add for 2 different month to make sure we cover different months with different amount of days, like Feb and Dec, etc.

You should also pull from master once again.

@SundeepK
Copy link
Owner

SundeepK commented Nov 8, 2016

Hi @JulienArzul will you be implementing the tests? If not I am more than happy to do them and merge them to master if not.

@JulienArzul
Copy link
Contributor Author

Hey, sorry I didn't answer earlier. I don't have much time to work on this right now so you can go ahead and implement them if it's not too much of a bother for you. Otherwise, I'll probably be able to do this in a few weeks.

@SundeepK
Copy link
Owner

SundeepK commented Nov 8, 2016

@JulienArzul Many thanks, I'll pull your changes and add some tests and merge to master. Then I'll close this pull request.

@neryortez
Copy link

neryortez commented Nov 21, 2016

Maybe we can add the option to support when the user taps on a day out of the current month, on the onSingleTapUp function:

...
else if (dayOfMonth < 0 && displayOtherMonthDays){
            tempPreviousMonthCalendar.setTimeInMillis(currentCalender.getTimeInMillis());
            tempPreviousMonthCalendar.add(Calendar.MONTH, -1);
            int maximumPreviousMonthDay = tempPreviousMonthCalendar.getActualMaximum(Calendar.DAY_OF_MONTH);
            tempPreviousMonthCalendar.set(Calendar.DATE, maximumPreviousMonthDay+dayOfMonth+1);
            setCurrentDate(tempPreviousMonthCalendar.getTime());
            performMonthScrollCallback();
        } else if (dayOfMonth > calendarWithFirstDayOfMonth.getActualMaximum(Calendar.DAY_OF_MONTH) && displayOtherMonthDays){
            tempPreviousMonthCalendar.set(Calendar.MONTH, currentCalender.get(Calendar.MONTH) + 1);
            tempPreviousMonthCalendar.set(Calendar.DATE, dayOfMonth + 1 - calendarWithFirstDayOfMonth.getActualMaximum(Calendar.DAY_OF_MONTH));
            setCurrentDate(tempPreviousMonthCalendar.getTime());
            performMonthScrollCallback();
        }

I know I´m using tempPreviousMonthCalendar but I didn´t want to create more variables, and even made sense to use tempPreviousMonthCalendar on the previous days. That´s just an idea. You can change it, I won´t get mad. xD
Hope that´ll be of use

@neryortez
Copy link

I just realized that there`s a bug on my piece of code. If you tap on the headers of the view it takes it as a day of the previous month.
The workaround would be:

...
else if ((dayRow >0) && (dayOfMonth < 0) && (displayOtherMonthDays)){
...

@JulienArzul
Copy link
Contributor Author

I'm not sure the library should let the user click on days out of the current month. Or if it does, it should probably scroll the calendar to the clicked month and then select the day.
In my opinion, it'd be awkward to select the 30th of October while we're displaying the november month.

@SundeepK SundeepK merged commit e353bd4 into SundeepK:master Nov 22, 2016
@SundeepK
Copy link
Owner

SundeepK commented Nov 22, 2016

@rathn I think for that we shoud disscuss that in another issue if possible. Since this is specific to just showing those extra days.

@SundeepK
Copy link
Owner

Merged, will release sometime soon. Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants