LightCalendarView


Source link: https://github.com/recruit-mp/LightCalendarView

Light Calendar View

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

Requirements

  • Target SDK version: 23
  • Minimum SDK version: 15

Usage

  1. Add these settings to your app-level build.gradle.
dependencies {

  compile 'jp.co.recruit_mp:LightCalendarView:1.0.1' 
}
  1. Add LightCalendarView into your layouts or view hierarchy.
<layout xmlns:android="http://schemas.android.com/apk/res/android">
  ...

<jp.co.recruit_mp.android.lightcalendarview.LightCalendarView

 android:id="@+id/calendarView"

 android:layout_width="match_parent"

 android:layout_height="wrap_content" />
  ... </layout>

Customization

Options

Lightweight Calendar View can be easily customized by setting properties in the layout XML file.

 <jp.co.recruit_mp.android.lightcalendarview.LightCalendarView

android:id="@+id/calendarView"

android:layout_width="match_parent"

android:layout_height="wrap_content"

app:lcv_weekDayTextSize="18sp"

app:lcv_dayTextSize="18sp"

app:lcv_textColor="@color/calendar_day_text"

app:lcv_selectionColor="@color/calendar_selection"

app:lcv_accentColor="@color/calendar_accent"/>

The following properties are available:

property name type description
app:lcv_weekDayTextSize dimension The text size of weekdays
app:lcv_dayTextSize dimension The text size of days
app:lcv_textColor color or resource The text color of weekdays and days
app:lcv_selectionColor color or resource The background color of selections
app:lcv_accentColor color or resource The color of accents
app:lcv_firstDayOfWeek integer The first day of the week (0 = Sunday, 1 = Monday, ..., 6 = Friday)

The customizations of text colors of selected days or today are done by setting <selector /> color resources to app:lcv_textColor, app:lcv_selectionColor, or app:lcv_accentColor with the following resource files for example.

NOTE that in all of the color resources, android:state_* are used to distinguish the state of each day view as follows:

state description
android:state_active indicates whether the day view is for today ( true) or other days ( false)
android:state_selected indicates whether the day view is selected ( true) or not ( false)

/res/color/calendar_day_text.xml

<selector xmlns:android="http://schemas.android.com/apk/res/android">
  <!-- the color of today when selected -->
  <item android:color="#ffd2d2" android:state_active="true" android:state_selected="true" />

<!-- the color of today -->
  <item android:color="#c417ce" android:state_active="true" />

<!-- the color of the selected day -->
  <item android:color="#ffffff" android:state_selected="true" />

<!-- the color of other days -->
  <item android:color="#7c7c7c" /> </selector>

/res/color/calendar_selection.xml

<selector xmlns:android="http://schemas.android.com/apk/res/android">
  <!-- the background color of today when selected -->
  <item android:color="#3944ba" android:state_active="true" android:state_selected="true" />

<!-- the background color of the other days when selected -->
  <item android:color="#565656" android:state_selected="true" /> </selector>

/res/color/calendar_accent.xml

<selector xmlns:android="http://schemas.android.com/apk/res/android">
  <!-- the color of accents in today when selected -->
  <item android:color="#ffd2d2" android:state_active="true" android:state_selected="true" />

<!-- the color of accents in today -->
  <item android:color="#c417ce" android:state_active="true" />

<!-- the color of accents in other days when selected -->
  <item android:color="#ffffff" android:state_selected="true" />

<!-- the color of accents in other days -->
  <item android:color="#7c7c7c" /> </selector>

OnCalendarStateUpdatedListener

Add OnCalendarStateUpdatedListener to the calendar view to detect and handle the following events:

  • onSelectMonth(): the user swipes and changes the month
  • onSelectDay(): the user clicks one day in a month view

See the example implementation in MainActivity.kt of this listener on github.

Decorations

Use MonthView#setAccents(Date, Collection<Accent>) or MonthView#setAccents(Map<Date, Collection<Accent>>) to add decorations to each day.

Example:

calendarView.setOnStateUpdatedListener(object : LightCalendarView.OnStateUpdatedListener {

  override fun onMonthSelected(date: Date, view: MonthView) {

val cal = Calendar.getInstance().apply {
 time = date 
}

val monthEvents: Map<Date, List<Event>> = someApi.getMonthEvents(cal[Calendar.YEAR], cal[Calendar.MONTH])

val monthAccents: Map<Date, List<Accent>> = monthEvents.mapValues {
 event -> DotAccent(radius = 10f, color = event.color, key = event) 
}

view.setAccents(monthAccents)
  
}
 
}

Coloring Day of The Week

Use LightCalendarView#setWeekDayFilterColor(weekDay: WeekDay, color: Int?) and LightCalendarView#setDayFilterColor(weekDay: WeekDay, color: Int?) to set the color scheme of day of the week in WeekDayView (e.g. Sunday, Monday, ...) and DayView (e.g. 1, 2, ...) respectively.

// coloring "sunday" (day of the week) in red calendarView.setWeekDayFilterColor(WeekDay.SUNDAY, Color.RED)  // coloring sundays (days) in red calendarView.setDayFilterColor(WeekDay.SUNDAY, Color.RED)

Note the library internally uses these color as ColorFilter, meaning it is overlayed on top of the text color set through LightCalendarView#setTextColor(color: Int).

Further Customizations

See the Wiki for more information and descriptions on futher customizations.

Contributing

Contributions to this library, including bug-reporting, bug-fixes, and enhancements are always welcomed. Just create an issue, fork us and send a pull request.

License

Copyright 2016 RECRUIT MARKETING PARTNERS CO., LTD.  Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License. You may obtain a copy of the License at
  http://www.apache.org/licenses/LICENSE-2.0  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 

Maintainers

Light Calendar View is owned and maintained by Recruit Marketing Partners Co., Ltd, and was originally created by

Resources

BlurKit is an extraordinarily easy to use utility to get live blurring just like on iOS.

A Kotlin library for Android allowing writing asynchronous code in synchronous style using async/await approach.

WeatherView is an Android Library that helps you make a cool weather animation for your app.

Triad is a tiny Android library which enables use of the Model-View-Presenter pattern in an easy way. It uses custom Views to replace the dreaded Fragments, and introduces Presenter classes to separate business logic from view logic. Since the Presenters are plain Java objects, tests for these classes can run blazingly fast on a local JVM.

Soot is a Java optimization framework. It provides four intermediate representations for analyzing and transforming Java bytecode:

  • Baf: a streamlined representation of bytecode which is simple to manipulate.
  • Jimple: a typed 3-address intermediate representation suitable for optimization.
  • Shimple: an SSA variation of Jimple.
  • Grimp: an aggregated version of Jimple suitable for decompilation and code inspection.
  • 3D Style PageFlip like iBooks.
  • Implemented by pure Java.
  • Based on OpenGL 2.0.
  • Supports single page and double pages flip.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes