Skip to content

Repository files navigation

Header

License

AMCalendar - Android Date (Range) Picker

AMCalendar is a fully customisable widget for picking dates and ranges based on the native Calendar.

It's an Android port of the Fastis iOS Calendar Framework by Simla.Tech build from scratch.

Features

  • Flexible customization
  • Shortcuts for dates and ranges
  • Single date and date range modes

Installation

Add this to your root gradle:

allprojects {
repositories {
maven { url "https://www.jitpack.io" }
}
}

Add this to your module's gradle dependencies:

dependencies {
implementation 'com.github.appmonkey8010:amcalendar:[RELEASE]'//e.g.: 1.0.0
}

Usage

Quick Start

importat.appmonkey.amcalendar.base.AMCalendarclassMainActivity : AppCompatActivity() {
AMCalendar.rangeSelect(this, object:RangeSelectionListener {
overridefunonRangeSelect(cal1:Calendar?, cal2:Calendar?) {
...
}
}).shortcuts(TodayRangeShortcut(this), LastWeekRangeShortcut(this))
.show()
}

Single and range modes

If you want to get a single date, you have to use the SingleAMCalendar implementation:

AMCalendar.singleSelect(this, object:SingleSelectionListener {
overridefunonSingleSelect(cal:Calendar?) {
if(cal !=null) {
Log.v("AMCalendar", cal.toString())
}
}
}).preselect(Calendar.getInstance())
.show()

If you want to get a date range, you have to use the RangeAMCalendar implementation:

AMCalendar.rangeSelect(this, object:RangeSelectionListener {
overridefunonRangeSelect(cal1:Calendar?, cal2:Calendar?) {
if(cal1 !=null&& cal2 !=null) {
Log.v("AMCalendar", cal1.toString())
Log.v("AMCalendar", cal2.toString())
}
}
}).preselect(Calendar.getInstance(), Calendar.getInstance())
.show()

Configuration

  • shortcuts- Shortcuts array. The default value is null. See Shortcuts section
  • preselect- An initial value which will be selected by default. The default value is null.

Shortcuts

Using shortcuts allows you to select set dates or date ranges quickly. By default shortcuts is null. The bottom container will be hidden if you don't provide any shortcuts.

In AMCalendar available some prepared shortcuts for each mode:

  • For SingleAMCalendar: TodaySingleShortcut, TomorrowSingleShortcut, YesterdaySingleShortcut
  • For RangeAMCalendar: TodayRangeShortcut, LastWeekRangeShortcut, LastMonthRangeShortcut

Also, you can create your own shortcut:

classCustomRangeShortcut : AMCalendarRangeShortcut() {
init {
cal1 =Calendar.getInstance()
cal2 =null
text ="Today"
}
}
AMCalendar.rangeSelect(...)
.shortcuts(CustomRangeShortcut(), LastWeekRangeShortcut(context))

Customization

AMCalendar's appearance can be customized with resources. Following keys can be overridden:

<!-- colors.xml -->
<colorname="colorAMCalendarBackground">#ffffff</color>
<colorname="colorAMCalendarCancel">#3c72d1</color>
<colorname="colorAMCalendarSelect">#3c72d1</color>
<colorname="colorAMCalendarDisabled">#bebebe</color>
<colorname="colorAMCalendarHeaderDisabled">#bebebe</color>
<colorname="colorAMCalendarHeaderSelected">#000000</color>
<colorname="colorAMCalendarHeaderClear">#4b4b4b</color>
<colorname="colorAMCalendarWeekday">#000000</color>
<colorname="colorAMCalendarWeekdayBackground">#f0f0f6</color>
<colorname="colorAMCalendarMonth">#3c72d1</color>
<colorname="colorAMCalendarDay">#000000</color>
<colorname="colorAMCalendarDaySelected">#FFFFFF</color>
<colorname="colorAMCalendarDaySelectedCircle">#3c72d1</color>
<colorname="colorAMCalendarShortcutBackground">#f0f0f6</color>
<colorname="colorAMCalendarShortcutElementBackground">#FFFFFF</color>
<colorname="colorAMCalendarShortcutElementText">#000000</color>

By default the library provides a light and a dark theme.

<!-- strings.xml -->
<stringname="amcalendar_select">Select</string>
<stringname="amcalendar_please_select_date">Please select date</string>
<stringname="amcalendar_please_select_date_range">Please select date range</string>
<stringname="amcalendar_template_today">Today</string>
<stringname="amcalendar_template_tomorrow">Tomorrow</string>
<stringname="amcalendar_template_yesterday">Yesterday</string>
<stringname="amcalendar_template_last_week">Last week</string>
<stringname="amcalendar_template_last_month">Last month</string>
<stringname="amcalendar_monday_short">MON</string>
<stringname="amcalendar_tuesday_short">TUE</string>
<stringname="amcalendar_wednesday_short">WED</string>
<stringname="amcalendar_thursday_short">THU</string>
<stringname="amcalendar_friday_short">FRI</string>
<stringname="amcalendar_saturday_short">SAT</string>
<stringname="amcalendar_sunday_short">SUN</string>

By default the library provides following languages:

  • English (default)
  • German
Donate with PayPal

License

AMCalendar is released under the MIT license. See LICENSE for details.

About

Fully customizable Calendar/DatePicker for Android/Kotlin

Topics

Resources

Stars

21 stars

Watchers

1 watching

Forks

Releases

Contributors

Languages