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

Release 1.4.0 #333

Merged
merged 40 commits into from
Jun 1, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
0817c10
Refactor using State builder
May 13, 2016
6807bb4
Merge branch 'future-1.x' of https://github.com/prolificinteractive/m…
May 13, 2016
a32645b
Cleanup
May 13, 2016
c123024
cleanup
May 13, 2016
aa2e93f
Update README.md
ekchang May 16, 2016
d36b74f
Merge pull request #301 from prolificinteractive/refactor_using_builder
ekchang May 16, 2016
deda25c
Added travis to project
May 17, 2016
5cf05ad
Cleanup script
May 17, 2016
741763b
Merge pull request #307 from prolificinteractive/travis_setup
quentin41500 May 18, 2016
3aaf78f
Documentation updated for future release
May 20, 2016
6e915e3
Update links and added entry point for documentation in Readme
May 20, 2016
50380e7
Add select range functionality
papageorgiouk May 20, 2016
2ce7551
Merge branch 'range-select' of https://github.com/papageorgiouk/mater…
May 21, 2016
483e3aa
Cleanup, mark days between range as selected, added range in sample app
May 21, 2016
3e497f1
Cleanup
May 21, 2016
c0512d4
Update travis
May 23, 2016
2d3b14e
Merge pull request #310 from prolificinteractive/update_doc
ekchang May 23, 2016
4fddc65
Cleanup
May 23, 2016
b0cb278
Merge pull request #315 from prolificinteractive/select_range
ekchang May 23, 2016
3800a6c
Update CUSTOMIZATION.md
quentin41500 May 23, 2016
529984b
Merge pull request #317 from prolificinteractive/select_range_docs
ekchang May 24, 2016
83533f8
Update changelog and gradle properties for upcoming release
ekchang May 24, 2016
9890fef
Update README with 1.4 changes
ekchang May 24, 2016
1f5953d
Merge pull request #319 from prolificinteractive/update_changelog
ekchang May 25, 2016
b456670
Change DateFormatTitleFormatter to use LLLL instead of MMMM for month…
ekchang May 25, 2016
075f5f6
Incorrect min date used when calculating num week difference
ekchang May 26, 2016
a02418a
Merge pull request #321 from prolificinteractive/ec/month_formatter
ekchang May 26, 2016
70183cd
Shields update
quentin41500 May 26, 2016
77d0257
Update README.md
quentin41500 May 26, 2016
11fb8e2
Merge pull request #322 from prolificinteractive/ec/partial_max_week_fix
ekchang May 26, 2016
4db2604
Merge pull request #323 from prolificinteractive/shields_update
ekchang May 26, 2016
53a83fd
Fix for an issue when a wrong week is selected when switching between…
levaja May 30, 2016
3bd8a55
Merge pull request #327 from levaja/future-1.x
ekchang May 31, 2016
21f239e
Fix current month not updating if min date is set to a month after th…
ekchang May 31, 2016
3a8177c
Merge pull request #331 from prolificinteractive/ec/fix_min_date
ekchang Jun 1, 2016
6574859
Update CHANGELOG
ekchang Jun 1, 2016
4e0dc75
Prepare for release
ekchang Jun 1, 2016
98262a9
Update README
ekchang Jun 1, 2016
6d7fbf7
Merge branch 'future-1.x' of https://github.com/prolificinteractive/m…
ekchang Jun 1, 2016
0bab627
Update README/build.gradle to reference 1.4.0
ekchang Jun 1, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
language: android

jdk:
- oraclejdk8

android:
components:
- tools
- platform-tools
- build-tools-23.0.3
- android-23
- extra-android-m2repository
- extra-google-m2repository

script:
- ./gradlew clean check assemble -Dpre-dex=false

notifications:
email: false

sudo: false

cache:
directories:
- $HOME/.gradle
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
Change Log
==========
Version 1.4.0 *(TBD)*
----------------------------
* New: Add select range functionality. Use `setSelectionMode(MaterialCalendarView.SELECTION_MODE_RANGE)` and `setOnRangeSelectedListener`
* Breaking Change: `setFirstDayOfWeek`, `setMin/MaxDate`, and `setCalendarDisplayMode` are moved to a `State` object. Call `mcv.state().edit()` to edit them and commit the changes with `commit`. See [CUSTOMIZATION_BUILDER](docs/CUSTOMIZATION_BUILDER.md) for usage details.
* Change: Updated documentation regarding 1.3.0 additions
* Fix: Current month and title pager updates correctly if minDate is set after the current month
* Fix: Week number difference calculation correctly accounts for DST offsets. Thanks Igor Levaja!
* Fix: Date formatter uses L instead of M for month (standalone instead of context sensitive)

Version 1.3.0 *(2016-05-16)*
----------------------------

Expand Down Expand Up @@ -69,7 +78,7 @@ where the view will try and take up as much space as necessary,
but we base it on tile size instead of an aspect ratio.
The exception being that if a `tileSize` is set,
that will override everything and set the view to that size.
* Fix: Use more efficent method for indexing months
* Fix: Use more efficient method for indexing months

Version 0.7.0 *(2015-07-09)*
----------------------------
Expand Down
41 changes: 34 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<img src="/images/hero.png"/>

Material Calendar View [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-Material%20Calendar%20View-blue.svg?style=flat)](https://android-arsenal.com/details/1/1531)
Material Calendar View
======================
[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-Material%20Calendar%20View-blue.svg?style=flat)](https://android-arsenal.com/details/1/1531) [![Maven Central](https://img.shields.io/maven-central/v/com.prolificinteractive/material-calendarview.svg?maxAge=2592000)](http://search.maven.org/#search%7Cga%7C1%7Ca%3A%22material-calendarview%22) [![Travis branch](https://img.shields.io/travis/prolificinteractive/material-calendarview.svg?maxAge=2592000)](https://travis-ci.org/prolificinteractive/material-calendarview)

A Material design back port of Android's CalendarView. The goal is to have a Material look
and feel, rather than 100% parity with the platform's implementation.
Expand All @@ -11,7 +12,7 @@ and feel, rather than 100% parity with the platform's implementation.
Usage
-----

1. Add `compile 'com.prolificinteractive:material-calendarview:1.3.0'` to your dependencies.
1. Add `compile 'com.prolificinteractive:material-calendarview:1.4.0'` to your dependencies.
2. Add `MaterialCalendarView` into your layouts or view hierarchy.
3. Set a `OnDateSelectedListener` or call `MaterialCalendarView.getSelectedDates()` when you need it.

Expand All @@ -22,10 +23,10 @@ Example:

```xml
<com.prolificinteractive.materialcalendarview.MaterialCalendarView
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/calendarView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
app:mcv_showOtherDates="all"
app:mcv_selectionColor="#00F"
/>
Expand All @@ -35,15 +36,35 @@ Example:
marked `@Experimental` are subject to change quickly and should not be used in production code. They
are allowed for testing and feedback.

Major Change in 1.4.0
---------------------
* Breaking Change: `setFirstDayOfWeek`, `setMin/MaxDate`, and `setCalendarDisplayMode` are moved to a `State` object. This was necessary because it was unclear that these were not simple setters--individually, they were side effecting and triggered full adapter/date range recalculations. Typical usage of the view involves setting all these invariants up front during `onCreate` and it was unknown to the user that setting all 4 of these would create a lot of waste. Not to mention certain things were side effecting--some would reset the current day or selected date. As a result, the same 4 methods called in a different order could result in a different state, which is bad.

For most cases you will simply need to replace setting those invariants with:
```java
mcv.state().edit()
.setFirstDayOfWeek(Calendar.WEDNESDAY)
.setMinimumDate(CalendarDay.from(2016, 4, 3))
.setMaximumDate(CalendarDay.from(2016, 5, 12))
.setCalendarDisplayMode(CalendarMode.WEEKS)
.commit();
```

`mcv.state().edit()` will retain previously set values; `mcv.newState()` will create a new state using default values. Calling `commit` will trigger the rebuild of adapters and date ranges. It is recommended these state changes occur as the first modification to MCV (before configuring anything else like current date or selected date); we make no guarantee those modifications will be retained when the state is modified.

See [CUSTOMIZATION_BUILDER](docs/CUSTOMIZATION_BUILDER.md) for usage details.
* New: `setSelectionMode(SELECTION_MODE_RANGE)` was added to allow 2 dates to be selected and have the entire range of dates selected. Much thanks to [papageorgiouk](https://github.com/papageorgiouk) for his work on this feature.

See other changes in the [CHANGELOG](/CHANGELOG.md).

Major Change in 1.3.0
---------------------
* Breaking change: `getTileSize` is deprecated. Use `getTileWidth` or `getTileHeight`.
* Added `goToNext` and `goToPrevious` API to programmatically trigger paging
* Allow users to click on dates outside of current month with `setAllowClickDaysOutsideCurrentMonth`
* Set tile width/height separately rather than single tile size with `setTileWidth` and `setTileHeight`
* Attributes: mcv_tileWidth, mcv_tileHeight, mcv_calendarMode

See other changes in the [CHANGELOG](/CHANGELOG.md).
* TalkBack APIs: `setContentDescriptionArrowPast`, `ArrowFuture`, `Calendar`

Major Change in 1.2.0
---------------------
Expand All @@ -70,6 +91,11 @@ but we base it on tile size instead of an aspect ratio.
The exception being that if a `tileSize` is set,
that will override everything and set the view to that size.

Documentation
-------------

Make sure to check all the documentation available [here](docs/README.md).

Customization
-------------

Expand All @@ -78,11 +104,12 @@ One of the aims of this library is to be customizable. The many options include:
* [Define the view's width and height in terms of tile size](docs/CUSTOMIZATION.md#tile-size)
* [Single or Multiple date selection, or disabling selection entirely](docs/CUSTOMIZATION.md#date-selection)
* [Showing dates from other months or those out of range](docs/CUSTOMIZATION.md#showing-other-dates)
* [Setting the first day of the week](docs/CUSTOMIZATION.md#first-day-of-the-week)
* [Show only a range of dates](docs/CUSTOMIZATION.md#date-ranges)
* [Setting the first day of the week](docs/CUSTOMIZATION_BUILDER.md#first-day-of-the-week)
* [Show only a range of dates](docs/CUSTOMIZATION_BUILDER.md#date-ranges)
* [Customize the top bar](docs/CUSTOMIZATION.md#topbar-options)
* [Custom labels for the header, weekdays, or individual days](docs/CUSTOMIZATION.md#custom-labels)


### Events, Highlighting, Custom Selectors, and More!

All of this and more can be done via the decorator api. Please check out the [decorator documentation](docs/DECORATORS.md).
Expand Down
31 changes: 12 additions & 19 deletions docs/CUSTOMIZATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ Customization Options

```xml
<com.prolificinteractive.materialcalendarview.MaterialCalendarView
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/calendarView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
app:mcv_showOtherDates="boolean"
app:mcv_arrowColor="color"
app:mcv_selectionColor="color"
Expand All @@ -16,9 +16,12 @@ Customization Options
app:mcv_weekDayLabels="array"
app:mcv_monthLabels="array"
app:mcv_tileSize="dimension"
app:mcv_tileWidth="dimension"
app:mcv_tileHeight="dimension"
app:mcv_firstDayOfWeek="enum"
app:mcv_leftArrowMask="drawable"
app:mcv_rightArrowMask="drawable"
app:mcv_calendarMode="mode"
/>
```

Expand All @@ -34,15 +37,19 @@ If a tileSize is set, that will override the `layout_width` and `layout_height`

The view is 7 tiles wide and 8 tiles high (with the top bar visible).

### Width and Height

You also have the possibility to use `tileWidth` and `tileHeight` separately. I would recommend using either `tileSize` or, `tileWidth` and `tileHeight`.


## Date Selection

We support three modes of selection: single, multiple, or none. The default is single selection.
The mode can be changed by calling `setSelectionMode()` and passing the appropriate constant (`SELECTION_MODE_NONE`, `SELECTION_MODE_SINGLE`, or `SELECTION_MODE_MULTIPLE`).
We support four modes of selection: single, multiple, range or none. The default is single selection.
The mode can be changed by calling `setSelectionMode()` and passing the appropriate constant (`SELECTION_MODE_NONE`, `SELECTION_MODE_SINGLE`, `SELECTION_MODE_RANGE` or `SELECTION_MODE_MULTIPLE`).
If you change to single selection, all selected days except the last selected will be cleared.
If you change to none, all selected days will be cleared.
If you change to none or range, all selected days will be cleared.

You can set an `OnDateSelectedListener` to listen for selections, make sure to take into account multiple calls for the same date and state.
You can set an `OnDateSelectedListener` to listen for selections, make sure to take into account multiple calls for the same date and state. In case of range selection, use `OnRangeSelectedListener` which returns the list of date from the range including first and last.
You can manually select or deselect dates by calling `setDateSelected()`.
Use `setSelectedDate()` to clear the current selection(s) and select the provided date.

Expand Down Expand Up @@ -76,20 +83,6 @@ You can provide a custom color by setting `mcv_selectionColor` in xml, or by cal
If you want more control than just color, you can use the [decorator api](DECORATORS.md) to set a [custom selector](CUSTOM_SELECTORS.md).


## First Day Of The Week

The default first day of the week is Sunday. You can set a custom day of the week by setting `mcv_firstDayOfWeek` in xml, or by calling `setFirstDayOfWeek()`.
The xml attribute is an enum of `sunday` through `saturday` and `setFirstDayOfWeek()` accepts values from `java.util.Calendar` such as `Calendar.MONDAY`.


## Date Ranges

By default, the calendar displays months for 200 years before today and 200 years after.
You can specify different minimum and maximum dates by calling `setMinimumDate(CalendarDay)` and `setMaximumDate(CalendarDay)`.
Passing `null` will reset back to the default 200 years.
There are also convenience methods that accept a `Calendar` or a `Date` object and convert them to a `CalendarDay` using the relevant `CalendarDay.from()` factory method.


## Topbar Options

### Visibility
Expand Down
50 changes: 50 additions & 0 deletions docs/CUSTOMIZATION_BUILDER.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
State builder
=============

Certain parameters are only modifiable using the state builder of the `MaterialCalendarView`.
Using the builder prevents from updating the view each time one of the setters is called. The view is updated when calling `Builder#commit()` and that improve performances.
Previously, the fields could be customize using casual setters.

Here is a concrete example of how to use the builder:

```java
mcv.state().edit()
.setFirstDayOfWeek(Calendar.WEDNESDAY)
.setMinimumDate(CalendarDay.from(2016, 4, 3))
.setMaximumDate(CalendarDay.from(2016, 5, 12))
.setCalendarDisplayMode(CalendarMode.WEEKS)
.commit();
```

## state.edit() vs newState()

Using `mcv.state().edit()` will preserve the current state of the `MaterialCalendarView` while `mcv.newState()` will initialize the builder with new parameters.
Only the fields that are modifiable using the builder can be reset or edit. Here is the list of the fields:

- First Day Of Week
- Minimum Date
- Maximum Date
- Calendar Display Mode

As an example, if you are setting `firstDayOfWeek` inside your xml, and you want to preserve the field when using the builder, you should use `state.edit()`.
However if you don't want to preserve any current parameters from the list above, use `newState()`. In most cases `state.edit()` should be the right method to use.

### First Day Of The Week

The default first day of the week is Sunday. You can set a custom day of the week by setting `mcv_firstDayOfWeek` in xml, or by calling `setFirstDayOfWeek()`.
The xml attribute is an enum of `sunday` through `saturday` and `setFirstDayOfWeek()` accepts values from `java.util.Calendar` such as `Calendar.MONDAY`.


### Date Ranges

By default, the calendar displays months for 200 years before today and 200 years after.
You can specify different minimum and maximum dates by calling `setMinimumDate(CalendarDay)` and `setMaximumDate(CalendarDay)`.
Passing `null` will reset back to the default 200 years.
There are also convenience methods that accept a `Calendar` or a `Date` object and convert them to a `CalendarDay` using the relevant `CalendarDay.from()` factory method.

### Calendar Display Mode

`MaterialCalendarView` propose two display modes: weekly and monthly. You can set the display mode in your xml using the attribute `mcv_calendarMode` with `month` for monthly mode, or `week` for weekly mode.
You can also use the builder `setCalendarDisplayMode(CalendarMode)` parameter.

It is **important** to note that the `CalendarMode.WEEKS` is still experimental.
3 changes: 2 additions & 1 deletion docs/CUSTOM_SELECTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ Here's an example for a dark theme and a dark selector:
<style name="CustomTextAppearance" parent="TextAppearance.MaterialCalendarWidget.Date">
<item name="android:textColor">@color/my_date_text_color</item>
</style>

```
```xml
<!-- In res/color/my_date_text_color.xml -->
<selector xmlns:android="http://schemas.android.com/apk/res/android">

Expand Down
16 changes: 15 additions & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@ This is where in depth documentation will be going.

Check out most of the customization options [here](CUSTOMIZATION.md).

## Customization using state builder

Some of the customization can be made using a builder. Using a builder for those parameters helps preventing bugs and improves performances.
Those parameters are:

- [First Day Of Week](CUSTOMIZATION_BUILDER.md#first-day-of-the-week)
- [Minimum Date](CUSTOMIZATION_BUILDER.md#date-ranges)
- [Maximum Date](CUSTOMIZATION_BUILDER.md#date-ranges)
- [Calendar Display Mode](CUSTOMIZATION_BUILDER.md#calendar-display-mode)

The documentation is available [here](CUSTOMIZATION_BUILDER.md).

## Events, Highlighting, Custom Selectors, and More!

All of this and more can be done via the decorator api. Please check out the [decorator documentation](DECORATORS.md).
Expand All @@ -18,4 +30,6 @@ Check out the [documentation for custom states](CUSTOM_SELECTORS.md).

## TODO

Write and organize the documentation. Focus on customizability with real world scenarios.
- Write and organize the documentation. Focus on customization with real world scenarios.
- Improve performances.
- Add test cases.
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
# org.gradle.parallel=true

GROUP=com.prolificinteractive
VERSION_NAME=1.3.0
VERSION_CODE=14
VERSION_NAME=1.4.0
VERSION_CODE=15

POM_PACKAGING=aar
POM_NAME=Material CalendarView
Expand Down
2 changes: 1 addition & 1 deletion library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ apply plugin: 'signing'

android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
buildToolsVersion "23.0.3"

defaultConfig {
minSdkVersion 14
Expand Down
Loading