📅 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
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
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
Gallery: an Android app developed for displaying images from unsplash website

Gallery App Gallery is an Android app developed for displaying images from unspl

Mohab Ezzat 0 Dec 30, 2021
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
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 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
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 Dec 9, 2022
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
📅 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
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
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 customizable, easy-to-use, and functional circular time range picker library for Android

A customizable, easy-to-use, and functional circular time range picker library for Android. Use this library to mimic Apple's iOS or Samsung's bedtime picker.

Joery Droppers 251 Dec 30, 2022
Amazing Dynamic Time UI :clock1030: :hourglass: and More

FlatTimeCollection Amazing Dynamic Time UI ?? ⌛ for Android To help you design your Layout. it is Not just a UI, But it contains a CountDownTimer with

Anas Altair 72 Apr 28, 2022
Android interval timer app using compose + compose navigation, dagger hilt, room, kotlin coroutines + flow and mvvm design pattern.

What's InTime? ⏳ InTime is an interval timer application using android jetpack components and a long running service. The purpose of this project is t

P. 46 Oct 10, 2022
Android DatePicker with month and year build with Compose UI

Compose Date Picker - Select month and year Compose Date Picker tries to offer you the year and month pickers which you can customize for your require

Doğuş Teknoloji 48 Jan 7, 2023
Appleader707 1 Aug 9, 2022
Android Compose wheel picker library based on LazyColumn in vertical and LazyRow in horizontal.

About Android Compose wheel picker library based on LazyColumn in vertical and LazyRow in horizontal. Gradle Sample Default Item size Unfocused count

null 6 Dec 22, 2022
Nepali Date Picker library in Jetpack compose for android with Date conversion from BS to AD and vice-versa

Nepali Date picker Converter - Re in Compose This is a re-work of Nepali Date Picker Converter in jetpack compose and kotlin. English Locale Nepali Lo

Kiran Gyawali 4 Dec 23, 2022