CustomizableCalendar is a library that allows you to create your calendar, customizing UI and behaviour

Overview

CustomizableCalendar

This library allows you to create a completely customizable calendar.
You can use CustomizableCalendar to create your calendar, customizing UI and behaviour.

Features

  • Custom header (should be implemented by the user);
  • Custom sub view (month name by default);
  • Custom weekly days view;
  • Custom date view;
  • Possibility to implement selection on day click;
  • Possibility to implement weekly day calculation;
  • Receive updates of Calendar (with AUCalendar);
  • Every change to AUCalendar is notified and automatically refreshes UI;

Limitations

  • Only portrait orientation is supported

Gradle

allprojects {
  repositories {
    ...
    maven { url "https://jitpack.io" }
  }
}
dependencies {
  compile 'com.github.MOLO17:CustomizableCalendar:v0.1.4'
}

Dependencies

Usage

Add to your layout

XML

Add CustomizableCalendar to your layout

<com.molo17.customizablecalendar.library.components.CustomizableCalendar
        android:id="@+id/customizable_calendar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

Java

First of all you should create a class that implements ViewInteractor interface (you can find the explanation in the How to customize > Java section).

After that go in the Activity/Fragment where you added the CustomizableCalendar View; here you should specify the first month and the last month, to do this, create a Calendar (located in com.molo17.customizablecalendar.library.model) object.

An example of CustomizableCalendar init is the following:

...

@BindView(R.id.customizable_calendar)
CustomizableCalendar customizableCalendar;

private CompositeDisposable subscriptions;

...

@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);
  ButterKnife.bind(this);

  DateTime today = new DateTime();

  // setting up first and last month that must be showed in the calendar
  DateTime firstMonth = today.withDayOfMonth(1);
  DateTime lastMonth = today.plusMonths(3).withDayOfMonth(1);

  // create the Calendar obj and setting it up with some configs like:
  // - first selected day
  // - last selected day
  // - multiple selection

  final Calendar calendar = new Calendar(firstMonth, lastMonth);
  calendar.setFirstSelectedDay(today.plusDays(4));

  // if you don't want the multiple selection mode just skip the 2 lines below
  calendar.setLastSelectedDay(today.plusDays(6));
  calendar.setMultipleSelection(true);

  // create a ViewInteractor obj needed to interact with the CustomizableCalendar
  final YourViewInteractorClass calendarViewInteractor = new YourViewInteractorClass();

  // create an AUCalendar object (a Calendar wrapper that operates as a singleton and provides all the updates)
  AUCalendar auCalendar = AUCalendar.getInstance(calendar);

  // this is needed to receives all Calendar updates (using RxJava 2)
  subscriptions.add(
    auCalendar.observeChangesOnCalendar().subscribe(new Consumer<AUCalendar.ChangeSet>() {
      @Override
      public void accept(AUCalendar.ChangeSet changeSet) throws Exception {
          // with ChangeSet you can be aware of which Calendar fields are changed
          // you can use changeSet.isFieldChanged(...) passing the name of the field;
          // name of the fields can be retrieved using CalendarFields interface;
          // AUCalendar is already updated because it's a singleton,
          // so for retrieving the updated data you can just use AUCalendar getters
      }
    })
  );

  // injecting the ViewInteractor to the CustomizableCalendar View
  customizableCalendar.injectViewInteractor(calendarViewInteractor)
}

@Override
protected void onDestroy() {
    super.onDestroy();
    subscriptions.clear();
}

...

How to customize

XML

If you want to customize the components you should create a separeted layout and add the reference to the customizable_calendar View with the tag app:layout="@layout/your_layout"

An example of a custom layout is the following:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginEnd="30dp"
    android:layout_marginStart="30dp"
    android:orientation="vertical">

    <com.molo17.customizablecalendar.library.components.HeaderView
        android:id="@android:id/primary"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

    <com.molo17.customizablecalendar.library.components.SubView
        android:id="@android:id/text2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="30dp" />

    <com.molo17.customizablecalendar.library.components.WeekDaysView
        android:id="@android:id/text1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:layout_marginTop="30dp" />

    <com.molo17.customizablecalendar.library.components.CalendarRecyclerView
        android:id="@android:id/content"
        android:layout_width="match_parent"
        android:layout_height="@dimen/customizable_calendar_height"
        android:layout_marginTop="15dp" />

</LinearLayout>

NOTE that ids must not be different from the ones above, so:

  • @android:id/primary for HeaderView;
  • @android:id/text1 for WeekDaysView;
  • @android:id/text2 for SubView;
  • @android:id/content for CalendarRecyclerView;

HeaderView

First (red) rectangle of the screenshot above.
It's a RelativeLayout, you should create your own layout.

WeekDaysView

Third (light blue) rectangle of the screenshot above.
It's a RecyclerView, the ViewHolder item is already implemented.
You can create your own ViewHolder layout using a RelativeLayout with a TextView that has @android:id/summary as id.

SubView

Second (green) rectangle of the screenshot above.
It's a RelativeLayout, implemented by default with the name of the month centered.
If you want to create your own layout make sure to have a TextView with id @android:id/summary.

CalendarRecyclerView

Fourth (blue) rectangle of the screenshot above.
It's a RelativeLayout, implemented by default with a LinearLayout (with a GridLayout inside) for the month and a RelativeLayout for the day.
If you want to create your own month layout you can specify app:month_layout="@layout/your_layout" for the month and app:cell_layout="@layout/your_layout" for the day.
Make sure to use @android:id/widget_frame as id for the GridView and @android:id/background, @android:id/startSelectingText, @android:id/stopSelectingText, @android:id/title respectively for single selection background, first day selection background (in multiple selection mode), last day selection background (in multiple selection mode) and the TextView where the day is displayed.

Java

All code customization can be applied using the ViewInteractor.

Here are listed all of the methods with a small description:

  • void onCustomizableCalendarBindView(View view)
    Here you can customize the CustomizableCalendar View.
    This method is called after customizableCalendar.injectViewInteractor(...).

  • void onHeaderBindView(ViewGroup view)
    Here you can customize the HeaderView View, inflating your layout etc...
    This method is called after headerView.injectViewInteractor(...).

  • void onWeekDaysBindView(View view)
    Here you can customize the WeekDays View.
    This method is called after weekDays.injectViewInteractor(...).

  • void onWeekDayBindView(WeekDaysViewAdapter.WeekDayVH holder, String weekDay)
    Here you can customize the WeekDayVH ViewHolder.
    This method is called after onBindViewHolder of WeekDaysViewAdapter.

  • void onSubViewBindView(View view, String month)
    Here you can customize the SubView View.
    This method is called after onMonthChanged.

  • void onCalendarBindView(View view)
    Here you can customize the CalendarRecyclerView View.
    This method is called after calendarRecyclerView.injectViewInteractor(...).

  • void onMonthBindView(View view)
    Here you can customize the MonthGridView View.
    This method is called after onCreateViewHolder of CalendarViewAdapter.

  • View onMonthCellBindView(View view, CalendarItem currentItem)
    Here you can customize the GridViewCell View.
    This method is called in the getView of MonthAdapter, you must return the customized view.

  • boolean hasImplementedMonthCellBinding()
    Here you should return true if you have implemented the above method (onMonthCellBindView).
    This method is called in the getView method of MonthAdapter.

  • List<CalendarItem> calculateDays(int year, int month, int firstDayOfMonth, int lastDayOfMonth)
    Here you can calculate the days of the month (if you want for example to include Saturday and Sunday)
    This method is called in the getView of MonthAdapter.

  • boolean hasImplementedDayCalculation()
    Here you should return true if you have implemented the above method (calculateDays).
    This method is called in the refreshDays method of MonthAdapter.

  • int setSelected(boolean multipleSelection, DateTime dateSelected)
    Here you can calculate the selection of the day.
    This method is called in the setSelected method of MonthAdapter.
    You must return 0, 1 or -1 respectively for first selection, last selection and no selection.

  • boolean hasImplementedSelection()
    Here you should return true if you have implemented the above method (setSelected).
    This method is called in the setSelected method of MonthAdapter.

  • String formatWeekDayName(String nameOfDay);
    Here you can format the name of the week day.
    This method is called after injectViewInteractor method of WeekDaysView.
    You should return the formatted name of the week day.

  • boolean hasImplementedWeekDayNameFormat()
    Here you should return true if you have implemented the above method (formatWeekDayName).
    This method is called after injectViewInteractor method of WeekDaysView.

  • View getMonthGridView(View rootView)
    Here you can create your customized MonthGridView.
    You should return a MonthGridView.
    This method is called in the onCreateViewHolder method of CalendarViewAdapter.

Getting Help

To report a specific problem or feature request, open a new issue here on Github. For questions, suggestions, or anything else, email us at [email protected].

Comments
  • Invoke-customs are only supported starting with Android O

    Invoke-customs are only supported starting with Android O

    Getting this error , Invoke-customs are only supported starting with Android O (--min-api 26) Message{kind=ERROR, text=Invoke-customs are only supported starting with Android O (--min-api 26), sources=[Unknown source file], tool name=Optional.of(D8)}

    opened by vivekpchrome 4
  • Unable to sync the gradle

    Unable to sync the gradle

    Hi ,

    I'm unable to sync the project because I'm getting Manifest merge error

    Kindly check the error log

    Manifest merger failed : Attribute application@allowBackup value=(false) from AndroidManifest.xml:15:9-36 is also present at [com.github.MOLO17:CustomizableCalendar:v0.1.4] AndroidManifest.xml:12:9-35 value=(true). Suggestion: add 'tools:replace="android:allowBackup"' to <application> element at AndroidManifest.xml:13:5-160:19 to override.

    Additional Info : I can able to sync the gradle if I used android:allowBackup="true" in my app manifest. but I need to set allowBackup as false

    Thanks in advance

    opened by rajasekaranm 2
  • Error when build proyect

    Error when build proyect

    I have cloned your github project and updated the dependencies to the latest versions, but when I run the sample I skip this error:

    Error:Execution failed for task ':library:transformClassesWithRetrolambdaForDebug'.

    Missing javaCompileTask for variant: debug/0 from output dir: /Users/juangra/Proyectos/Proyectos_pruebas/CustomizableCalendar-master/library/build/intermediates/transforms/retrolambda/debug/0

    My pc is mac and Android studio is 3.0. Help me please.

    opened by jgcorrales 1
  • Need help implementing a vertical calendar view

    Need help implementing a vertical calendar view

    Hey, I need help implementing a vertically scrollable version of the calendar view. I've set the layout manager of the recycler view as vertical. this got me a vertically scrollable implementation, however on scrolling up and down the view is breaking and not rendering as required. can you help me with this? attached screenshots, ignore other customisations i've added. irrelevant here.

    screenshot_1505905215

    after scolling

    screenshot_1505905219

    opened by akul1994 1
  • alignment

    alignment

    Hi , I have implement Customizable calendar in my project, and it works fine.

    But there seems to be some alignment mismatch with week days and date, can u help me sort out this issue.

    Capture

    opened by karthiaitech 1
  • NullPointerException: At   customizableCalendar.injectViewInteractor(calendarViewInteractor);

    NullPointerException: At customizableCalendar.injectViewInteractor(calendarViewInteractor);

    I am getting Error

    Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.molo17.customizablecalendar.library.components.CustomizableCalendar.injectViewInteractor(com.molo17.customizablecalendar.library.interactors.ViewInteractor)' on a null object reference

    opened by ymane 2
  • Error: duplicate value for resource 'attr/font' with config ''.

    Error: duplicate value for resource 'attr/font' with config ''.

    Hi. When I am trying to compile my project with your library I get the following errors:

    error: duplicate value for resource 'attr/font' with config ''. Message{kind=ERROR, text=error: resource previously defined here., sources=[...\.gradle\caches\transforms-1\files-1.1\appcompat-v7-26.1.0.aar\1ef06ebeb346cde48963bebb42b7dd7b\res\values\values.xml:246:5-69], original message=, tool name=Optional.of(AAPT)}

    and

    error: resource previously defined here. Message{kind=ERROR, text=error: resource previously defined here., sources=[...\.gradle\caches\transforms-1\files-1.1\appcompat-v7-26.1.0.aar\1ef06ebeb346cde48963bebb42b7dd7b\res\values\values.xml:246:5-69], original message=, tool name=Optional.of(AAPT)}

    In my project I use 25.2.0 version of support library.

    opened by vedmedenko 0
  • When fast scroll month doesn't changes

    When fast scroll month doesn't changes

    Hey I really like your library and wanted to use it in my application. But I have found one issue If we swipe fast through the months sometimes months doesn't change and it shows previous or earlier month.

    opened by abhimaniCodal 0
Releases(v0.1.5)
Owner
MOLO17
MOLO17
📅 Minimal Calendar - This calendar library is built with jetpack compose. Easy, simple, and minimal.

?? Minimal Calendar This calendar library is built with jetpack compose. Easy, simple, and minimal. Latest version The stable version of the library i

Minjae Kim 16 Sep 14, 2022
Kmpcalendar - A calendar library and views written for kotlin multiplatform

KMPCalendarView Minimal Kotlin Multiplatform project with SwiftUI, Jetpack Compo

Anmol Verma 2 Oct 7, 2022
An android library which provides a compact calendar view much like the one used in google calenders.

CompactCalendarView CompactCalendarView is a simple calendar view which provides scrolling between months. It's based on Java's Date and Calendar clas

SundeepK 1.5k Jan 7, 2023
A Jetpack Compose library for handling calendar component rendering.

Compose Calendar Compose Calendar is a composable handling all complexity of rendering calendar component and date selection. Due to flexibility provi

Bogusz Pawłowski 181 Dec 22, 2022
📅 CosmoCalendar is a fully customizable calendar with a wide variety of features and displaying modes.

CosmoCalendar Made by Applikey Solutions Usage Customization Common Selection Current day Navigation buttons Weekend days Connected days Disabled days

Applikey Solutions 1.6k Dec 22, 2022
A simple calendar with events, customizable widgets and no ads.

Simple Calendar A simple calendar with events and a customizable widget. A simple calendar with optional CalDAV synchronization. You can easily create

Simple Mobile Tools 3k Jan 4, 2023
A better calendar for Android

Caldroid Caldroid is a fragment that display calendar with dates in a month. Caldroid can be used as embedded fragment, or as dialog fragment. User ca

Roomorama 1.4k Nov 29, 2022
Standalone Android widget for picking a single date from a calendar view.

TimesSquare for Android Standalone Android widget for picking a single date from a calendar view. Usage Include CalendarPickerView in your layout XML.

Square 4.4k Dec 20, 2022
Demo app for a horizontal schedule(event) calendar

This is a demo project that showcases a horizontally laid out calendar that shows events in a timeline fashion. It is not a library, just a reference implementation for curious developers.

Halil Ozercan 188 Dec 26, 2022
Android open source calendar

Etar Calendar Etar (from Arabic: إِيتَار) is an open source material designed calendar made for everyone! Why? Well, I wanted a simple, material desig

null 1.5k Jan 4, 2023
Solutions for Muetzilla's Advent Calendar

Solutions for Muetzilla's Advent Calendar Link To the Advents Calendar Content Solutions for Muetzilla's Advent Calendar Content Problem 1 Problem 2 P

Marc Andri Fuchs 1 Mar 23, 2022
Calendar - A component for compose desktop

日历 一个用于compose-desktop的日历组件。 截图 feature DayPicker的动画 月份选择器错误提示 点击非本月的时间会跳到上个月 to

wwalkingg 1 Feb 7, 2022
MinutesAliveApp - Basic Android App that ask for your date of birth and shows your age in minutes

MinutesAliveApp Basic Android App that ask for your date of birth and shows your

JestorDev 0 Jan 30, 2022
A simple library which gives you custom design CalendarView with dialog functionality and event handlers.

CalendarView A simple library which gives you custom design CalendarView with dialog functionality and event handlers. 1: CalendarView Demo Screen 1.1

Shahzad Afridi (Opriday) 49 Oct 28, 2022
Asimov-flagz-kt - Feature flags library based on Togglz library

Asimov Flagz Feature flags library based on Togglz library. Installation Gradle

Nicolas Bottarini 1 Jan 8, 2022
Multiplatform Date and time library for Kotlin

Klock is a Date & Time library for Multiplatform Kotlin. It is designed to be as allocation-free as possible using Kotlin inline classes, to be consis

null 681 Dec 19, 2022
A Kotlin Multiplatform library for working with dates and times

Island Time A Kotlin Multiplatform library for working with dates and times, heavily inspired by the java.time library. Features: A full set of date-t

Erik Christensen 71 Dec 28, 2022
Joda-Time library with Android specialization

Android has built-in date and time handling - why bother with a library? If you've worked with Java's Date and Calendar classes you can probably answer this question yourself, but if not, check out Joda-Time's list of benefits.

Daniel Lew 2.6k Dec 9, 2022
Android NTP time library. Get the true current time impervious to device clock time changes

TrueTime for Android Make sure to check out our counterpart too: TrueTime, an NTP library for Swift. NTP client for Android. Calculate the date and ti

Instacart 1.3k Jan 4, 2023