An android library which provides a compact calendar view much like the one used in google calenders.

Overview

CompactCalendarView Build Status

CompactCalendarView is a simple calendar view which provides scrolling between months. It's based on Java's Date and Calendar classes. It provides a simple api to query for dates and listeners for specific events. For example, when the calendar has scrolled to a new month or a day has been selected. Still under active development.

Contributing

Please raise an issue of the requirement so that a discussion can take before any code is written, even if you intend to raise a pull request. Please see setup for testing.

Testing

CompactCalendarView makes use of screenshot-tests-for-android (https://github.com/facebook/screenshot-tests-for-android). This is for UI testing. Since screenshot-tests-for-android takes screenshots, we need a way to ensure images can be reproduced consistently. To do this, a specific emulator is used to run tests. Unfortunately, an older emulator is used for now. New pull requests which change functionality some how should aim to create new screenshot tests or unit tests if possible. To run this locally, run the below commands:

Pre-requisite (Also refer to .travis.yml):

  • Python
  • Python pillow installed
  • Install android-19 (can be done through android sdk manager or command line).

Android 19 emulator is used because it seems to be a fast enough on travis-ci and because x86 emulators are not supported on travis-ci. Newer android version is possible but build times will increase.

Install the abi and accept:

$ $ANDROID_HOME/tools/bin/sdkmanager 'system-images;android-22;default;armeabi-v7a'

Create the emulator:

$ echo no | $ANDROID_HOME/tools/bin/avdmanager create avd --force -n testCompactCalendarEmulator -k "system-images;android-22;default;armeabi-v7a"

Create sd card (creating in current dir): Any problems with sdcard are best solved by deleting and trying again

$ mksdcard -l sdcard 100M sdcard

Run emulator (with out audio and window):

$ $ANDROID_HOME/emulator/emulator -avd testCompactCalendarEmulator -no-audio -no-window -sdcard sdcard &

Run emulator and watch(with audio and window):

$ $ANDROID_HOME/emulator/emulator -avd testCompactCalendarEmulator -sdcard sdcard 

Running the tests to verify that the current tests pass and to check which tests are not producing the same screenshot:

$ ./gradlew verifyMode screenshotTests 

To generate new screenshots if new tests have been added:

$ ./gradlew recordMode screenshotTests 

Run the unit tests like below:

$ ./gradlew test

Android studio emulator

It's possible to test using android studio emulator. However, it must be android 19 and and 480x800 screen resolution. One example is the Nexus S emulator. Just start the emulator and execute the gradle commands to run the tests. Emulator should be found automatically.

Open/Close animations

The library supports opening/closing with or without animations.

ScreenShot

Example usage

It is possible to change the appearance of the view via a few properties. This includes the background color, text color, textsize color of the current day and the color of the first day of the month.

    <com.github.sundeepk.compactcalendarview.CompactCalendarView
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:id="@+id/compactcalendar_view"
        android:layout_width="fill_parent"
        android:paddingRight="10dp"
        android:paddingLeft="10dp"
        android:layout_height="250dp"
        app:compactCalendarTargetHeight="250dp"
        app:compactCalendarTextSize="12sp"
        app:compactCalendarBackgroundColor="#ffe95451"
        app:compactCalendarTextColor="#fff"
        app:compactCalendarCurrentSelectedDayBackgroundColor="#E57373"
        app:compactCalendarCurrentDayBackgroundColor="#B71C1C"
        app:compactCalendarMultiEventIndicatorColor="#fff"
        />

Please see Sample app for full example.

    // ... code omitted for brevity         
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        final CompactCalendarView compactCalendarView = (CompactCalendarView) findViewById(R.id.compactcalendar_view);
        // Set first day of week to Monday, defaults to Monday so calling setFirstDayOfWeek is not necessary
        // Use constants provided by Java Calendar class
        compactCalendarView.setFirstDayOfWeek(Calendar.MONDAY);
       
        // Add event 1 on Sun, 07 Jun 2015 18:20:51 GMT
        Event ev1 = new Event(Color.GREEN, 1433701251000L, "Some extra data that I want to store.");
        compactCalendar.addEvent(ev1);

        // Added event 2 GMT: Sun, 07 Jun 2015 19:10:51 GMT
        Event ev2 = new Event(Color.GREEN, 1433704251000L);
        compactCalendar.addEvent(ev2);

        // Query for events on Sun, 07 Jun 2015 GMT. 
        // Time is not relevant when querying for events, since events are returned by day. 
        // So you can pass in any arbitary DateTime and you will receive all events for that day.
        List<Event> events = compactCalendar.getEvents(1433701251000L); // can also take a Date object
        
        // events has size 2 with the 2 events inserted previously
        Log.d(TAG, "Events: " + events);

        // define a listener to receive callbacks when certain events happen.
        compactCalendarView.setListener(new CompactCalendarView.CompactCalendarViewListener() {
            @Override
            public void onDayClick(Date dateClicked) {
                List<Event> events = compactCalendarView.getEvents(dateClicked);
                Log.d(TAG, "Day was clicked: " + dateClicked + " with events " + events);
            }

            @Override
            public void onMonthScroll(Date firstDayOfNewMonth) {
                Log.d(TAG, "Month was scrolled to: " + firstDayOfNewMonth);
            }
        });
    }

You can modify indicators using a preset of styles, below is an example, but few other combinations are also possible:

ScreenShot

Note that the calendar makes no attempt to de-duplicate events for the same exact DateTime. This is something that you must handle your self if it is important to your use case.

Locale specific settings

It's possible to set the locale so that weekday column names are automatically set by the calendar.

        CompactCalendarView compactCalendarView = (CompactCalendarView) findViewById(R.id.compactcalendar_view);
        compactCalendarView.setLocale(Locale.CHINESE);
        compactCalendarView.setUseThreeLetterAbbreviation(true);

dependencies {
    compile 'com.github.sundeepk:compact-calendar-view:3.0.0'
}
The MIT License (MIT)

Copyright (c) [2018] [Sundeepk]

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Comments
  • Mutliple dots for multiple events on the same day

    Mutliple dots for multiple events on the same day

    Love this library ! Currently using it in my app :)

    Would be great to add the capability of having multiple dots when there's multiple events for a day. See image example image below.

    Thank you !

    enhancement 
    opened by csbenz 72
  • Show Event indicators to currently selected day

    Show Event indicators to currently selected day

    While Adding events to current date, the background color overlaps and the small indicators are not displayed. I tried to change the app:compactCalendarCurrentDayBackgroundColor="#2bb573" to transparent but its not working either. Is there any way to display small indicators on current day?

    enhancement 
    opened by VishnuTB 39
  • How can i change current day to surrounded circle instead of background color

    How can i change current day to surrounded circle instead of background color

    Hi there! Thank you for awesome lib! I need to change current day view to rounded circle with white border instead of bg color. How can i do it.Thanks in advance default

    enhancement 
    opened by nAkhmedov 28
  • Current day not displayed on activity load

    Current day not displayed on activity load

    Hi,

    Sorry by advance, english isn't my natural language and I'm new!

    So, my problem is when I call another activity with your calendar implemented, I need to touch the calendar to display the selected current day. I currently add only the xml and not other (except findViewById programmatically).

    I wanted to display the current day selected when the activity load, it's possible? Did I make a mistake or I forgot something?

    Thanks by advance! AerWyn81

    help wanted 
    opened by AerWyn81 26
  • onMonthScroll scrolling fast damages the year of the parameter firstDayOfMonth

    onMonthScroll scrolling fast damages the year of the parameter firstDayOfMonth

    Hi. I just realized that when you scroll kind of fast between months till another and another year, the date given in the onMonthScroll argument starts to give the wrong year. I scrolled till December 2018 and then went back to December of the last year (2017) and it shows 2020 or any other year not even close.

    If I keep scrolling between months, the year of the Date gets even more wrong.

    I tried my best to explain this and I know its not very common to scroll like that but it is still an issue. Hope you can solve it soon.

    bug 
    opened by carlastabile 13
  • Multiple event indicators not showing up

    Multiple event indicators not showing up

    Hi @SundeepK the library is too awesome. I just added the dependency of the library version 1.9.7 and used calendar view in xml. Created new events and added them to the calendarView. event indicators are maintained same as large_fill and small_fill but the dots do not show up under the dates. Any idea of what needs to be changed?

    help wanted 
    opened by preyesm 12
  • Display days of previous and current months

    Display days of previous and current months

    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.

    opened by JulienArzul 11
  • horizontal scroll problems in collapsing toolbar

    horizontal scroll problems in collapsing toolbar

    I have the calendar view in a collapsing toolbar. The problema I have, is that horizontal scrolling (to change between months) is not smooth, meaning that it gets interrupted by the vertical scroll of the RecyclerView/CollapsingToolbar. I am not sure where the problema comes from, but probably from this library, because I did not observe this with other calendar views. (If somebody knows how to fix this but has no time, I probably can try to do it. I just do not know where to start.)

    bug 
    opened by mzilian 11
  • How to show current month; event dot appearing on delay

    How to show current month; event dot appearing on delay

    Hello I have two questions:

    First, I would like to display the current month's name inside the calendar. Right now you can scroll between months but there is no idicator of what month you are actually seeing. I looked in the source but could not find any method to retrieve current visible month. Also how do I change the week days' abbreviations in uperrcase? Right now is showing l,m,m,g,v,s,d which are the week days in my locale. I want them to be L,M,M,G,V,S,D in uppercase.

    Screen

    Second, I noticed that if I add a new event the dot under the day number does not appear until i click again the calendar (in any place). This is frustrating since one might not know that he actually added the event.Code I use to add the event:

    new DialogInterface.OnClickListener()
                {
                    public void onClick(DialogInterface dialog, int id)
                    {
                        List<Event> events = compactCalendarView.getEvents(dateClicked.getTime());
                        if(events.size() == 0){
                            Event ev1 = new Event(Color.GREEN
                                    , dateClicked.getTime()
                                    , "completed_true");
                            compactCalendarView.addEvent(ev1, true);
                        }
                    }
                });
    

    Thank you in advance.

    opened by fermatijoe 10
  • remove all events at once in calendar with no events

    remove all events at once in calendar with no events

    is there any way to remove events (dots under date ) all at once rather than using below removeEvent method

    compactCalendarView.removeEvent(new CalendarDayEvent(dateClicked.getTime(), Color.argb(255, 169, 68, 65)), true); adapter.notifyDataSetChanged();

    enhancement 
    opened by kprathap23 10
  • cannot select current day

    cannot select current day

    I cannot select the current day. The DayCircleIndicator are drawn in priority for the currentDay instead of the currentSelectedDay.

    Don't you think the selected day should prevail ?

    enhancement 
    opened by gaultierq 9
  • How to pass Calendar as argument?

    How to pass Calendar as argument?

    Hi! I'm developing an android aplication and I'm using this library to customize a calendar by adding events through different fragments/activities to the same calendar instance, but I can't pass it as an argument as it's not a parceable/serializable object. Is there any way to do it?

    opened by alejandropalaci0 0
  • use Gradle Daemon

    use Gradle Daemon

    Gradle daemon. The Daemon is a long-lived process that help to avoid the cost of JVM startup for every build. Since Gradle 3.0, Gradle daemon is enabled by default. For an older version, you should enable it by setting org.gradle.daemon=true.

    opened by shisheng-1 0
  • How to remove the selected current date background when month is scrolled?

    How to remove the selected current date background when month is scrolled?

    Whenever month is changed, always first day is selected.

    For example, I selected 5th Mar. But after month is scrolled, and back to return Mar, It is selected 1st Mar. Of course 1st Apr is selected for Apr. How to remove this ? And how to keep the selected date?

    opened by fullstact69 0
  • Adding Events to CompactCalendar  from api call

    Adding Events to CompactCalendar from api call

    In my code, I have calenderFragment (where the main compactCalnder is) and a DayActivity. When a day in the calendar is clicked, the DayActivity is started. What I'm trying to do is, when 'submit' button in DayActivity is pressed an event with the day's date should be created and a dot under the day should appear. However, that doesn't happen. It works when I manually create an event using hardcoded dates and call the addEvent method on the calendar. Am I missing something? I'm relatively new to Android

    calenderFragment.java:

            compactCalendar.setListener(new CompactCalendarView.CompactCalendarViewListener() {
    
            @Override
            public void onDayClick(Date dateClicked) {
               
                String fullDateStr = dateFormatForFullDate.format(dateClicked); 
                try {
                    Date fullDate = dateFormatForFullDate.parse(fullDateStr);
                    timeInMillis = fullDate.getTime();
    
                } catch (ParseException e) {
                    e.printStackTrace();
                }
    
                Intent intent = new Intent(getActivity(),DayActivity.class);
             
                intent.putExtra("dateInMills", timeInMillis);  // here I'm just passing the days date in milliseconds to DayActivity
                startActivity(intent);
            }
    

    <...>

    DayActivity.java: <...>

         Intent intent = getIntent();
        long dateInMills = intent.getLongExtra("dateInMills", 0);
        dateTv.setText(date);
    
        doneBt.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
    
            //                Event ev = new Event(Color.parseColor("#613DC1"), dateInMills, "Cried");
           //                compactCalendar.addEvent(ev);
          //                this part doesn't work
    
             //   Toast.makeText(getApplicationContext(), "date: " + dateInMills, Toast.LENGTH_SHORT).show();
                //  date passed is correct
            }
    
    opened by RamintaMisiunaite 0
Owner
SundeepK
SundeepK
A TimelineView that will help you create event timelines in apps just like the Google Calendar DayView

TimelineView A TimelineView that will help you create event timelines in apps just like the Google Calendar DayView A library that allows you to creat

Amit Krishna A 10 May 12, 2022
Kalendar - A calendar to integrate Calendar with Custom design in your jetpack compose project

Kalendar - An Elementary Compose Calendar. This is a calendar to integrate Calen

Himanshu Singh 494 Jan 2, 2023
Android calendar view (like card)

android-calendar-card (Google Play Demo) Android calendar view (like card) Simple and easy to modify Author: Michał Szwarc #CalendarCardPager License

Michał Szwarc 473 Nov 10, 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
A lightweight monthly calendar view for Android, fully written in Kotlin. Designed to meet the minimum demands for typical calendars.

Light Calendar View A lightweight monthly calendar view for Android, fully written in Kotlin. Designed to meet the minimum demands for typical calenda

Recruit Marketing Partners Co.,Ltd 444 Dec 9, 2022
Android Week View is an android library to display calendars (week view or day view) within the app. It supports custom styling.

Android Week View Android Week View is an android library to display calendars (week view or day view) within the app. It supports custom styling. Fea

Raquib-ul Alam (Kanak) 3.4k Jan 3, 2023
Appleader707 1 Aug 9, 2022
JetCalendarView - A calendar library for Jetpack Compose

JetCalendar WIP 2022 Hit Refresh! Calendar view ❤️ Jetpack Compose License Copyr

Anmol Verma 8 Aug 17, 2022
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 Jan 5, 2023
CalEF (Calendar Entry Formatter) : Select an entry in Android-Kalender and send/share the entry's content as human readable text.

CalEF (Calendar Entry Formatter) Select an entry in Android-Kalender and send/share the entry's content as human readable text. Usually calendar entri

k3b 6 Aug 17, 2022
Fully customizable Calendar/DatePicker for Android/Kotlin

AMCalendar - Android Date (Range) Picker AMCalendar is a fully customisable widget for picking dates and ranges based on the native Calendar. It's an

null 6 Oct 18, 2022
📅 Material Design Calendar compatible with API 11+

> Prettier and simpler Material Design CalendarView MaterialCalendarView is a prettier and simpler, material design calendar that allows full customiz

BlackBox Vision 365 Nov 21, 2022
📅 Material Design Calendar compatible with API 11+

> Prettier and simpler Material Design CalendarView MaterialCalendarView is a prettier and simpler, material design calendar that allows full customiz

BlackBox Vision 366 Jan 1, 2023
Wheel-like spinner widget for Android

Update Dec 2016 Library is discontinued There's still a lot of wheel libraries out there. Update Oct 2014 I am thinking of rewriting this control. Upd

Dimitri Fedorov 641 Jan 2, 2023
Jetlime - A simple library for TimeLine view in Android

JetLime ⏱️ A simple yet highly customizable library for showing a TimeLine view

Pushpal Roy 107 Dec 6, 2022
A material-styled android view that provisions picking of a date, time & recurrence option, all from a single user-interface.

SublimePicker A customizable view that provisions picking of a date, time & recurrence option, all from a single user-interface. You can also view 'Su

Vikram 2.3k Jan 4, 2023
Color-My-View-App - Layouts - ColorMyViews app

Layouts - ColorMyViews app This is the second toy app for lesson 2 of the Androi

null 0 Jan 7, 2022
[NO LONGER MAINTAINED] Android library for better Picker DialogFragments

/!\ This Project is no longer maintained /!\ DialogFragments modeled after the AOSP Clock and Calendar apps to improve UX for picking time, date, numb

Code-Troopers 2.7k Dec 29, 2022
FlipTimerView library for Android

FlipTimerView Preview FlipTimerView library for Android Getting started Add it in your root build.gradle at the end of repositories: allprojects { re

Anu S Pillai 314 Dec 28, 2022