📅 CosmoCalendar is a fully customizable calendar with a wide variety of features and displaying modes.

Overview

CosmoCalendar

GitHub license

Made by Applikey Solutions

Usage

compile 'com.github.applikeysolutions:cosmocalendar:1.0.4'

Customization

Common

  • calendarOrientation - Possible values: HORIZONTAL, VERTICAL
  • calendarBackgroundColor
  • monthTextColor
  • otherDayTextColor
  • dayTextColor
  • firstDayOfTheWeek
  • weekDayTitleTextColo
  • showDaysOfWeek - Defines if we need to display week day titles for every month
  • showDaysOfWeekTitle - Defines if we need to display week day title for whole calendar

Selection

  • selectionType - Possible values: SINGLE, MULTIPLE, RANGE, NONE
  • selectedDayTextColor
  • selectedDayBackgroundColor
  • selectedDayBackgroundStartColor - Background color of START day from selected range
  • selectedDayBackgroundEndColor - Background color of END day from selected range
  • selectionBarMonthTextColor

Current day

  • currentDayTextColor
  • currentDayIconRes
  • currentDaySelectedIconRes

Navigation buttons

  • previousMonthIconRes
  • nextMonthIconRes

Weekend days

  • weekendDays
calendarView.setWeekendDays(new HashSet(){{
          add(Calendar.THURSDAY);
          add(Calendar.TUESDAY);
}});
  • weekendDayTextColor

Connected days

You can add some days for example holidays:

//Set days you want to connect
Calendar calendar = Calendar.getInstance();
Set<Long> days = new TreeSet<>();
days.add(calendar.getTimeInMillis());
...

//Define colors
int textColor = Color.parseColor("#ff0000");
int selectedTextColor = Color.parseColor("#ff4000");
int disabledTextColor = Color.parseColor("#ff8000");
ConnectedDays connectedDays = new ConnectedDays(days, textColor, selectedTextColor, disabledTextColor);

//Connect days to calendar
calendarView.addConnectedDays(connectedDays);

and customize them:

  • connectedDayIconRes;
  • connectedDaySelectedIconRes;
  • connectedDayIconPosition (TOP/BOTTOM);
calendarView.setConnectedDayIconPosition(ConnectedDayIconPosition.TOP);

Disabled days

You can add days so that you can not select them:

Set<Long> disabledDaysSet = new HashSet<>();
disabledDaysSet.add(System.currentTimeMillis());
calendarView.setDisabledDays(disabledDaysSet);

Disabled days criteria

  • month criteria range:
//from 1st to 5th day of the month
calendarView.setDisabledDaysCriteria(new DisabledDaysCriteria(1, 5, DisabledDaysCriteriaType.DAYS_OF_MONTH)); 
  • week criteria range:
//from Monday to Friday
DisabledDaysCriteria criteria = new DisabledDaysCriteria(Calendar.MONDAY, Calendar.FRIDAY, DisabledDaysCriteriaType.DAYS_OF_WEEK);
calendarView.setDisabledDaysCriteria(criteria);
  • disabledDayTextColor - Text color of disabled day

Month change listener

calendarView.setOnMonthChangeListener(new OnMonthChangeListener() {
          @Override
          public void onMonthChanged(Month month) {
              
          }
      });

Calendar dialog

new CalendarDialog(this, new OnDaysSelectionListener() {
         @Override
         public void onDaysSelected(List<Day> selectedDays) {
             
         }
     }).show();

Demo

Single Choice Multiple
Range Customized

Release Notes

1.0.0

  • Release version.

1.0.1

  • Functionality optimization
  • Added disabled days criteria feature
  • Added more customization for connected days (selected/unselected icon, top/bottom position for icon)

1.0.2

  • Added "NONE" selection type
  • The functionality of creating months is optimized
  • Added OnMonthChangeListener

1.0.3

  • Fixed crash on swipe
  • Connected days logic changed. Now you can add multiple connected day lists!

1.0.4

  • Fixed small bugs

Contact Us

You can always contact us via [email protected] We are open for any inquiries regarding our libraries and controls, new open-source projects and other ways of contributing to the community. If you have used our component in your project we would be extremely happy if you write us your feedback and let us know about it!

License

MIT License

Copyright (c) 2017 Applikey Solutions

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
  • How can I select days in calendar without clicking on a date in the calender view?

    How can I select days in calendar without clicking on a date in the calender view?

    Hi,

    I have a webservice that need to get a list of dates. I need to parse those dates and show them in the selected state in the calendarview. But I didn't find any method that sets a day in the selected state without clicking on the day.

    So far I've tried the following,

    public class ShiftSelectionManager extends BaseCriteriaSelectionManager {
        
        private Context context;
        private Set<Day> days = new HashSet<>();
        CustomDelegate delegate;
        static Day selectedDay;
    
        public ShiftSelectionManager(Context context, CustomDelegate delegate,  OnDaySelectedListener onDaySelectedListener) {
            this.context = context;
            this.onDaySelectedListener = onDaySelectedListener;
            this.delegate = delegate;
        }
    
        @Override
        public void toggleDay(@NonNull Day day) {
            this.selectedDay =day;
            Calendar cal = day.getCalendar();
            Log.v("CAL", cal.getTime()+"");
            if (cal.getTime().equals(new Date()) || cal.getTime().before(new Date())) {
                Utils.customAlert(context, "Oops!", "You cannot choose a shift that is today or in the past shifts.", null);
            }else{
                if (days.contains(day)) {
                    ((ScheduleCalendarActivity)context).lnrCalendarSheet.setVisibility(View.VISIBLE);
                } else {
                    ((ScheduleCalendarActivity)context).lnrCalendarSheet.setVisibility(View.GONE);
    
                    Intent intent = new Intent(context, SelectShiftActivity.class);
                    SelectShiftActivity.delegate = delegate;
                    intent.putExtra("Calendar", cal);
                    context.startActivity(intent);
                }
    
            }
        }
    
        @Override
        public boolean isDaySelected(@NonNull Day day) {
            return days.contains(day);
        }
    
        @Override
        public void clearSelections() {
            days.clear();
        }
    
        public void removeDay(Day day) {
            days.remove(day);
            //((ScheduleCalendarActivity)context).calendar.update();
            //onDaySelectedListener.onDaySelected();
        }
       //Add single day
        public void addDay(){
            days.add(selectedDay);
            isDaySelected(selectedDay);
        }
    
        public void addAllDays(Set<Day> days){
                this.days = days;   
        }
    }
    

    And on my activity I did the following,

    //Setup the Calendar View
    
    void setupCalendar() {
            calendar.setCalendarOrientation(OrientationHelper.HORIZONTAL);
            calendar.setSelectionType(SelectionType.MULTIPLE);
            calendar.setSelectedDayBackgroundColor(Color.parseColor(Theme.PRIMARYCOLOR));
    
    
            calendar.setSelectionManager(new ShiftSelectionManager(this, myDelegate, new OnDaySelectedListener() {
                @Override
                public void onDaySelected() {
    
                }
            }));
        }
    
    //Get Date From API
    void setupSchedule() {
            AppPrefs prefs = new AppPrefs(this);
            Map<String, String> map= new HashMap<>();
            map.put("Authorization","Bearer "+prefs.getStringFromKey(Sharedkey.accessTokenKey));
    
            ApiRequests.HttpGetShiftList(this,map,"/v11/shift/get/myshift", new IHttpListener() {
                @Override
                public void OnSuccess(Object obj) {
                    try {
                        JSONObject feedObj = new JSONObject((String) obj);
                        JSONArray feedObjJSONArray = feedObj.getJSONArray("shift");
                        for (int i = 0; i < feedObjJSONArray.length(); i++) {
                            JSONObject singleFeedObj = feedObjJSONArray.getJSONObject(i);
                            Schedule schedule = new Gson().fromJson(singleFeedObj.toString(), Schedule.class);
                            myShiftList.add(schedule);
                            daySet.add(new Day(Utils.toFormattedDate(schedule.getDateOfShift())));
                        }
    if (calendar.getSelectionManager() instanceof ShiftSelectionManager) {
                ((ShiftSelectionManager) calendar.getSelectionManager()).addAllDays(daySet);
            }
            calendar.update();
    
                    } catch (Exception e) {
    
                    }
                }
    
                @Override
                public void OnError(String error) {
    
                }
            });
        }
     
    
    opened by shafayatb 7
  • Disable day within selected range

    Disable day within selected range

    Should the user be allowed to select a range date, when within it, there is a disabled (or more than one) disabled day ?

    For instance: screenshot_1507162832

    October 4th is disabled

    I'd gladly drop a PR fixing it (if it's a bug)

    opened by leonardo2204 5
  • Request feature: Mark special Days

    Request feature: Mark special Days

    Add posibility mark days how to special days, for fix holidays in calendar, chistmas...

    My suggestion...

    Simple method: setHolidayDays... holydayDayTextColor disabledHolidayDayTextColor (priority color, if don't set, get disabledDayTextColor)

    Other case In the future you may want to support seasons, so you can see if you are selecting a high season day, low ...

    seasonDays , seasonColor , seasonColorDisable (optional)

    //High Season
    Set<Long> seasonHighDaysSet = new HashSet<>();
    calendarView.setSeasonDays(seasonHighDaysSet,Color.Green);
    calendarView.setSeasonDays(seasonHighDaysSet,Color.Green,Color.LightGreen);
    
    //Low season
    Set<Long> seasonLowDaysSet = new HashSet<>();
    calendarView.setSeasonDays(seasonLowDaysSet ,Color.Blue);
    calendarView.setSeasonDays(seasonLowDaysSet ,Color.Blue,Color.LightBllue);
    
    //Winter season
    Set<Long> seasonWinterDaysSet = new HashSet<>();
    calendarView.setSeasonDays(seasonWinterDaysSet ,Color.Orange);
    calendarView.setSeasonDays(seasonWinterDaysSet ,Color.Blue,Color.LightOrange);
    
    ...
    
    

    seasonColorDisable (priority color, if don't set, get disabledDayTextColor)

    opened by webserveis 3
  • Selected Date text bold is setting bold on another date as well

    Selected Date text bold is setting bold on another date as well

    Did anyone come across this problem?

    Like bolding, the text of selected date is also bolding a random date without the circle. I think the recycler view is having a spread over issue. Can someone help me with this

    opened by nasreekar 1
  • There might be two current date icon

    There might be two current date icon

    for example, today is November 28, 2017, will be the date of the arrow marked today, I just click on a date in radio mode, then, on November 3, 2017 will also be marked as the current date, mean there will be two current date, however, the problem is not inevitable

    opened by liupengandroid 1
  •  ConcurrentModificationException

    ConcurrentModificationException

    Hi,

    Thanks for putting together this very useful library.

    I encountered this error when rapidly scrolling through months with the calendar in horizontal configuration and the selection type set to multiple. To be honest this was more of a stress test, but i ended up with this exception...

    java.util.ConcurrentModificationException · Raw ArrayList.java:573java.util.ArrayList$ArrayListIterator.next CalendarView.java:573com.applikeysolutions.cosmocalendar.view.CalendarView.getSelectedDays CalendarView.java:628com.applikeysolutions.cosmocalendar.view.CalendarView.onDaySelected MultipleSelectionManager.java:38com.applikeysolutions.cosmocalendar.selection.MultipleSelectionManager.toggleDay DayDelegate.java:38com.applikeysolutions.cosmocalendar.view.delegate.DayDelegate$1.onClick View.java:5226android.view.View.performClick View.java:21266android.view.View$PerformClick.run Handler.java:739android.os.Handler.handleCallback Handler.java:95android.os.Handler.dispatchMessage Looper.java:168android.os.Looper.loop ActivityThread.java:5845android.app.ActivityThread.main Method.java:-2java.lang.reflect.Method.invoke ZygoteInit.java:797com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run ZygoteInit.java:687com.android.internal.os.ZygoteInit.main

    There is also noticeable lag when scrolling quickly through the months - i wondered if it's possible to set a limit on how far in the future/past the user is able to scroll? For example, can I limit the calendar to scroll no further than 1 year in the future?

    Many thanks in advance

    opened by mg931 1
  • Unable to resolve dependency

    Unable to resolve dependency

    Hello. When I add to my dependencies, I get an error ERROR: Unable to resolve dependency for ':app@gebDebug/compileClasspath': Could not resolve com.github.applikeysolutions:cosmocalendar:1.0.4.

    opened by Khodanovich 0
  • wrong end range in RANGE selection type

    wrong end range in RANGE selection type

    When I choose range day, end range always return one day after start range

    this is my code :

    CalendarDialog cal = new CalendarDialog(getActivity()); cal.setOnDaysSelectionListener(new OnDaysSelectionListener() { @Override public void onDaysSelected(List selectedDays) { if (selectedDays.size()>0) { checkin_date = selectedDays.get(0).getCalendar().getTime(); checkin_string_date = formatMonth.format(checkin_date)+"/"+formatDay.format(checkin_date)+"/"+formatYear.format(checkin_date); tanggalin.setText(ExtradateFormatForMonth.format(checkin_date));

                    if (selectedDays.size()>1)
                    {
                        checkout_date = selectedDays.get(1).getCalendar().getTime();
                        checkout_string_date = formatMonth.format(checkout_date)+"/"+formatDay.format(checkout_date)+"/"+formatYear.format(checkout_date);
                        tanggalout.setText(ExtradateFormatForMonth.format(checkout_date));
                    }
    
                }
            }
        });
    

    cal.show(); cal.setSelectionType(SelectionType.RANGE);

    opened by yasfdany 0
  • Adding Marker in Calendar using Connected Days for events, task, note, etc.

    Adding Marker in Calendar using Connected Days for events, task, note, etc.

    ### SOLUTION TO ADD EVENTS

    Screenshot_1622012396

    I was searching for a way to add marker on particular dates, but didn't find any. However as you can see in above image, I have managed to add marker to Calendar dates. I have used addConnectedDays() provided by Cosmo Calendar. Markers can be added on TOP & BOTTOM of date. Sharing code I used:

                        Set<Long> days = new TreeSet<>();
                        e.g. 
                        String date1 = "05-18-2021";
                        String date2 = "05-09-2021";
                        //........
    
                        SimpleDateFormat sdf1 = new SimpleDateFormat("MM-dd-yyyy");
                        try {
                            Date mDate1 = sdf1.parse(date1);
                            long timeInMilliseconds1 = mDate1.getTime();
    
                            
                            Date mDate2 = sdf1.parse(date2);
                            long timeInMilliseconds2 = mDate2.getTime();
    
                            days.add(timeInMilliseconds1);
                            days.add(timeInMilliseconds2);
                            // can add more days to set
    
                        } catch (Exception e) {
                            Log.e("DateException", e.getMessage());
                        }
              
                    int textColor = Color.parseColor("#0063B0");
                    int selectedTextColor = Color.parseColor("#FFFFFF");
                    int disabledTextColor = Color.parseColor("#ff8000");
                    ConnectedDays connectedDays = new ConnectedDays(days, textColor, selectedTextColor, disabledTextColor);
    
                    //Add Connect days to calendar
                    calendarView.addConnectedDays(connectedDays);
    
                    calendarView.setConnectedDayIconRes(R.drawable.ic_baseline_star_24);   // Drawable
                    calendarView.setConnectedDayIconPosition(ConnectedDayIconPosition.TOP);// TOP & BOTTOM
                    calendarView.update();
    
    opened by abdulrahmankazi 3
  • I want to mark few dates as selected and rest as disabled. How can i do this.

    I want to mark few dates as selected and rest as disabled. How can i do this.

    I want to mark few dates as selected and rest as disabled. How can i do this.

    Example:-

    I want to mark 19-02-2021 and 20-02-2021 as selected and rest as disabled.

    opened by vipin10 0
Owner
Applikey Solutions
We’re a professional services company focused on mobile app and web development 🚀
Applikey Solutions
📅 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
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
CustomizableCalendar is a library that allows you to create your calendar, customizing UI and behaviour

CustomizableCalendar This library allows you to create a completely customizable calendar. You can use CustomizableCalendar to create your calendar, c

MOLO17 216 Dec 6, 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
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
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
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
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
Calendar - A component for compose desktop

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

wwalkingg 1 Feb 7, 2022
Asimov-time-kt - Useful time and date related functions and extensions

asimov/time Useful time and date related functions and extensions. Installation

Nicolas Bottarini 1 Jan 7, 2022
Tanya Gupta 1 Aug 16, 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
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
Compose Date Picker - Select month and year

Android DatePicker with month and year build with Compose UI

Doğuş Teknoloji 47 Dec 15, 2022
A simple Cupcake Ordering App, choose flavor, pickup on a date, get order summary and send order via any other app.

Cupcake app This app contains an order flow for cupcakes with options for quantity, flavor, and pickup date. The order details get displayed on an ord

Akshat Khandelwal 0 Dec 23, 2021