Standalone Android widget for picking a single date from a calendar view.

Overview

TimesSquare for Android

Standalone Android widget for picking a single date from a calendar view.

Screenshot

Usage

Include CalendarPickerView in your layout XML.

<com.squareup.timessquare.CalendarPickerView
    android:id="@+id/calendar_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    />

This is a fairly large control so it is wise to give it ample space in your layout. On small devices it is recommended to use a dialog, full-screen fragment, or dedicated activity. On larger devices like tablets, displaying full-screen is not recommended. A fragment occupying part of the layout or a dialog is a better choice.

In the onCreate of your activity/dialog or the onCreateView of your fragment, initialize the view with a range of valid dates as well as the currently selected date.

Calendar nextYear = Calendar.getInstance();
nextYear.add(Calendar.YEAR, 1);

CalendarPickerView calendar = (CalendarPickerView) findViewById(R.id.calendar_view);
Date today = new Date();
calendar.init(today, nextYear.getTime())
    .withSelectedDate(today);

The default mode of the view is to have one selectable date. If you want the user to be able to select multiple dates or a date range, use the inMode() method:

calendar.init(today, nextYear.getTime())
    .inMode(RANGE);

Download

The latest version can be downloaded in zip and referenced by your application as a library project.

You can also depend on the library through Maven:

<dependency>
  <groupId>com.squareup</groupId>
  <artifactId>android-times-square</artifactId>
  <version>1.6.5</version>
  <type>apklib</type>
</dependency>

or Gradle:

compile 'com.squareup:android-times-square:1.6.5@aar'

Snapshots of the development version are available in Sonatype's snapshots repository.

License

Copyright 2012 Square, Inc.

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.
Comments
  • Adding views in decorators

    Adding views in decorators

    Adding new views in decorators that depend on the date seems extremely buggy.

    Steps to reproduce: Create a CalendarCellDecorator that adds a TextView to the CellView containing the provided date only if the day of the month is 30.

    Expected behavior: The date is the same as the date shown on the original TextView and the new view only appears the 30th of the month.

    Actual behavior: The date always says 30, but the view appears on dates that are not the 30th of the month.

    opened by magneticflux- 22
  • (1.0.4-SNAPSHOT@aar)android.view.InflateException: Binary XML file line #8: Error inflating class com.squareup.timessquare.CalendarPickerView

    (1.0.4-SNAPSHOT@aar)android.view.InflateException: Binary XML file line #8: Error inflating class com.squareup.timessquare.CalendarPickerView

    Log

    
    FATAL EXCEPTION: main android.view.InflateException: Binary XML file line #8: Error inflating class com.squareup.timessquare.CalendarPickerView
                at android.view.LayoutInflater.createView(LayoutInflater.java:613)
                at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:687)
                at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
                at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
                at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
                at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
                at com.cdasia.cdasiaonline.mobile.ui.fragments.OfflineDocsFragment.createDateView(OfflineDocsFragment.java:383)
                at com.cdasia.cdasiaonline.mobile.ui.fragments.OfflineDocsFragment.initUIComponents(OfflineDocsFragment.java:375)
                at com.cdasia.cdasiaonline.mobile.ui.fragments.OfflineDocsFragment.access$800(OfflineDocsFragment.java:103)
                at com.cdasia.cdasiaonline.mobile.ui.fragments.OfflineDocsFragment$1.run(OfflineDocsFragment.java:339)
                at android.os.Handler.handleCallback(Handler.java:615)
                at android.os.Handler.dispatchMessage(Handler.java:92)
                at android.os.Looper.loop(Looper.java:137)
                at android.app.ActivityThread.main(ActivityThread.java:4895)
                at java.lang.reflect.Method.invokeNative(Native Method)
                at java.lang.reflect.Method.invoke(Method.java:511)
                at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:994)
                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:761)
                at dalvik.system.NativeStart.main(Native Method)
         Caused by: java.lang.reflect.InvocationTargetException
                at java.lang.reflect.Constructor.constructNative(Native Method)
                at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
                at android.view.LayoutInflater.createView(LayoutInflater.java:587)
                at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:687)
                at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
                at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
                at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
                at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
                at com.cdasia.cdasiaonline.mobile.ui.fragments.OfflineDocsFragment.createDateView(OfflineDocsFragment.java:383)
                at com.cdasia.cdasiaonline.mobile.ui.fragments.OfflineDocsFragment.initUIComponents(OfflineDocsFragment.java:375)
                at com.cdasia.cdasiaonline.mobile.ui.fragments.OfflineDocsFragment.access$800(OfflineDocsFragment.java:103)
                at com.cdasia.cdasiaonline.mobile.ui.fragments.OfflineDocsFragment$1.run(OfflineDocsFragment.java:339)
                at android.os.Handler.handleCallback(Handler.java:615)
                at android.os.Handler.dispatchMessage(Handler.java:92)
                at android.os.Looper.loop(Looper.java:137)
                at android.app.ActivityThread.main(ActivityThread.java:4895)
                at java.lang.reflect.Method.invokeNative(Native Method)
                at java.lang.reflect.Method.invoke(Method.java:511)
                at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:994)
                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:761)
                at dalvik.system.NativeStart.main(Native Method)
         Caused by: android.content.res.Resources$NotFoundException: File res/anim/pulltorefresh__slide_in_from_bottom.xml from color state list resource ID #0x7f040001
                at android.content.res.Resources.loadColorStateList(Resources.java:2081)
                at android.content.res.Resources.getColor(Resources.java:761)
                at com.squareup.timessquare.CalendarPickerView.(CalendarPickerView.java:89)
                at java.lang.reflect.Constructor.constructNative(Native Method)
                at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
                at android.view.LayoutInflater.createView(LayoutInflater.java:587)
                at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:687)
                at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
                at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
                at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
                at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
                at com.cdasia.cdasiaonline.mobile.ui.fragments.OfflineDocsFragment.createDateView(OfflineDocsFragment.java:383)
                at com.cdasia.cdasiaonline.mobile.ui.fragments.OfflineDocsFragment.initUIComponents(OfflineDocsFragment.java:375)
                at com.cdasia.cdasiaonline.mobile.ui.fragments.OfflineDocsFragment.access$800(OfflineDocsFragment.java:103)
                at com.cdasia.cdasiaonline.mobile.ui.fragments.OfflineDocsFragment$1.run(OfflineDocsFragment.java:339)
                at android.os.Handler.handleCallback(Handler.java:615)
                at android.os.Handler.dispatchMessage(Handler.java:92)
                at android.os.Looper.loop(Looper.java:137)
                at android.app.ActivityThread.main(ActivityThread.java:4895)
                at java.lang.reflect.Method.invokeNative(Native Method)
                at java.lang.reflect.Method.invoke(Method.java:511)
                at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:994)
                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:761)
                at dalvik.system.NativeStart.main(Native Method)
         Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line #18: invalid drawable tag translate
                at android.content.res.ColorStateList.createFromXmlInner(ColorStateList.java:146)
                at android.content.res.ColorStateList.createFromXml(ColorStateList.java:129)
                at android.content.res.Resources.loadColorStateList(Resources.java:2078)
                at android.content.res.Resources.getColor(Resources.java:761)
                at com.squareup.timessquare.CalendarPickerView.(CalendarPickerView.java:89)
                at java.lang.reflect.Constructor.constructNative(Native Method)
                at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
                at android.view.LayoutInflater.createView(LayoutInflater.java:587)
                at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:687)
                at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
                at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
                at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
                at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
                at com.cdasia.cdasiaonline.mobile.ui.fragments.OfflineDocsFragment.createDateView(OfflineDocsFragment.java:383)
                at com.cdasia.cdasiaonline.mobile.ui.fragments.OfflineDocsFragment.initUIComponents(OfflineDocsFragment.java:375)
                at com.cdasia.cdasiaonline.mobile.ui.fragments.OfflineDocsFragment.access$800(OfflineDocsFragment.java:103)
                at com.cdasia.cdasiaonline.mobile.ui.fragments.OfflineDocsFragment$1.run(OfflineDocsFragment.java:339)
                at android.os.Handler.handleCallback(Handler.java:615)
                at android.os.Handler.dispatchMessage(Handler.java:92)
                at android.os.Looper.loop(Looper.java:137)
                at android.app.ActivityThread.main(ActivityThread.java:4895)
                at java.lang.reflect.Method.invokeNative(Native Method)
                at java.lang.reflect.Method.invoke(Method.java:511)
                at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:994)
                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:761)
                at dalvik.system.NativeStart.main(Native Method)
    

    OfflineDocsFragment.java

    
    private void createDateView() {
            mDatesLayer = (SlidingLayer)mView.findViewById(R.id.sliding_layer_collections);
            LayoutInflater inflater = (LayoutInflater)getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            mDatePickerView = inflater.inflate(R.layout.datepicker__view, null);
            final int bg = getResources().getColor(com.squareup.timessquare.R.color.calendar_bg);
            Log.d(String.valueOf(bg));
            if(mSearchView!=null){
                mDatesLayer.removeAllViews();
                mDatesLayer.addView(mDatePickerView);
                RelativeLayout.LayoutParams rlp = (RelativeLayout.LayoutParams)mDatesLayer.getLayoutParams();
                mDatesLayer.setStickTo(SlidingLayer.STICK_TO_RIGHT);
                if(rlp!=null){
                    rlp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
                    rlp.width = RelativeLayout.LayoutParams.MATCH_PARENT;
                    rlp.height = RelativeLayout.LayoutParams.MATCH_PARENT;
                    mDatesLayer.setLayoutParams(rlp);
                    mDatesLayer.setOffsetWidth(0);
                }
            }
        }
    
    opened by itsmechlark 20
  • Arabic locale for Calendar

    Arabic locale for Calendar

    Wrong displaying Calendar using Arabic locale. In Arabic calendar first day of the week is Saturday, so it causes misalignment between Day Of Week's name and date. So I can make offset for day of week, to adjust it to date, but it will not be properly. Is is possible to make offset for date as I can do for day of weeks?

    opened by AlexIach 18
  • 1.6.3 with new support library 23.0.0 Resource NotFoundException

    1.6.3 with new support library 23.0.0 Resource NotFoundException

    Getting exception when migrating to new version of the lib together with the support library update:

     java.lang.RuntimeException: Unable to start activity ComponentInfo{com.my.Activity}: android.view.InflateException: Binary XML file line #32: Error inflating class com.squareup.timessquare.CalendarPickerView
    ...
                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
         Caused by: android.view.InflateException: Binary XML file line #32: Error inflating class com.squareup.timessquare.CalendarPickerView
                at android.view.LayoutInflater.createView(LayoutInflater.java:633)
                at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743)
                at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
                at android.view.LayoutInflater.parseInclude(LayoutInflater.java:916)
    ...
                at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:257)
                at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:109)
                at com.my.Activity.onCreate(Activity.java:158)
    ...
         Caused by: android.content.res.Resources$NotFoundException: File res/layout/abc_action_bar_up_container.xml from color state list resource ID #0x7f040001
                at android.content.res.Resources.loadColorStateList(Resources.java:2592)
                at android.content.res.Resources.getColor(Resources.java:932)
                at com.squareup.timessquare.CalendarPickerView.<init>(CalendarPickerView.java:114)
                at java.lang.reflect.Constructor.newInstance(Native Method)
                at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
                at android.view.LayoutInflater.createView(LayoutInflater.java:607)
                at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743)
                at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
            Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line #17: invalid drawable tag LinearLayout
                at android.content.res.ColorStateList.createFromXmlInner(ColorStateList.java:148)
                at android.content.res.ColorStateList.createFromXml(ColorStateList.java:131)
                at android.content.res.Resources.loadColorStateList(Resources.java:2588)
                at android.content.res.Resources.getColor(Resources.java:932)
                at com.squareup.timessquare.CalendarPickerView.<init>(CalendarPickerView.java:114)
                at java.lang.reflect.Constructor.newInstance(Native Method)
    

    Tried cleaning, rebuilding with Studio and gradle, invalidating caches. If then return to 1.6.2 and 22.2.1, everything is ok.

    The stack is trimmed.

    opened by khusravsh 12
  • Is it possible to handle cell clicks?

    Is it possible to handle cell clicks?

    Sorry for disturbance caused from my previous questions. I'm using calendar in Multiple-DisplayOnly mode just to show some information. Is it possible to do something when clicking some day? For example, open a Dialog with some information) without highlightening it?

    opened by MasterGroosha 12
  • Calendar resizes itself when date is selected (dialog)

    Calendar resizes itself when date is selected (dialog)

    I am using the Calendar in a dialog and the Calendar grows when a date is selected.

    Before selection:

    After selection:

    Note how the OK/Cancel-buttons suddenly are slightly off-screen. It might be important (I don't know) that I am running my app on a Galaxy Nexus. Larger screens might not have this issue? I did not experience this before I rebased to the latest master (was previously rebased to ddf82a9657759ee2a9c5c19dd924851324918acd)

    The images were taken with slightly different code but was reproducible with this as well (modified from your dialog sample):

    CalendarPickerView dialogView = (CalendarPickerView) layoutInflater
                    .inflate(R.layout.fragment_dialog_calendar_builder, null, false);
    
            final Calendar future = Calendar.getInstance();
            future.add(Calendar.YEAR, 1);
            final Calendar selected = Calendar.getInstance();
            if (mTask != null && mTask.due != null) {
                selected.setTimeInMillis(mTask.due);
            }
    
            dialogView.init(Calendar.getInstance().getTime(), future.getTime(),
                    ActivityHelper.getUserLocale(getActivity())).withSelectedDate(
                    selected.getTime());
            new AlertDialog.Builder(getActivity())
                    .setTitle("I'm a dialog!")
                    // R.string.select_date
                    .setView(dialogView)
                    .setNegativeButton("GET OUT",
                            new DialogInterface.OnClickListener() {
                                @Override
                                public void onClick(
                                        DialogInterface dialogInterface, int i) {
                                    dialogInterface.dismiss();
                                }
                            })
                    .setPositiveButton("POSITIVE",
                            new DialogInterface.OnClickListener() {
                                @Override
                                public void onClick(
                                        DialogInterface dialogInterface, int i) {
                                    dialogInterface.dismiss();
                                }
                            }).create().show();
    

    fragment_dialog_calendar_builder:

    <?xml version="1.0" encoding="utf-8"?>
    <com.squareup.timessquare.CalendarPickerView xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:id="@+id/calendarView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="?CalendarPickerBackground"
        android:clipToPadding="false"
        android:paddingBottom="16dp"
        android:paddingLeft="16dp"
        android:paddingRight="16dp"
        android:scrollbarStyle="outsideOverlay" />
    
    opened by spacecowboy 12
  • .clearHighlightedDates() does not work on a range.

    .clearHighlightedDates() does not work on a range.

    Android 6.0, using com.squareup:android-times-square:1.6.5@aar

    1. Initialize a CalendarPickerView with selection type RANGE.
    2. Set up a 'Clear' button, that when you click it, clears the calendar's selections (mCalendar.clearHighlightedDates()).
    3. Run the application, select some dates (notice they are all highlighted).
    4. Click your Clear button. --> Notice that the dates are still highlighted.

    Debugging shows that the highlightedCells in the CalendarPickerView is empty, so there is nothing to update, so the views stay highlighted. So when the dates / range are selected, shouldn't they also be added to the highlightedCells list?

    Maybe I don't understand what the clearHighlightedDates() function is supposed to do.

    opened by elliott-accolade 11
  • Unable to Initialize CalendarPickerView: IllegalStateException

    Unable to Initialize CalendarPickerView: IllegalStateException

    I'm getting an IllegalStateException stating 'Must have at least one month to display. Did you forget to call init()?' when I add a CalendarPickerView to my fragment. I've tried to trace the issue with Log statements, but the issue seems to occur before my initialization logic even occurs. Here are the following methods associated with my initialization:

    Fragment Methods

        @Override
        public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
            initializeCalendarView(container);
            return super.onCreateView(inflater, container, savedInstanceState);
        }
    
        public void initializeCalendarView(ViewGroup container){
            //This Log Statement Never Occurs
            Log.i("HISTORY-FRAGMENT", "initializeCalendarView");
            Date today = new Date(CustomTimeUtils.today());
            Date lastYear = new Date(CustomTimeUtils.lastYear());
            Date nextMonth = new Date(CustomTimeUtils.nextMonth());
    
            //These Log Statements Never Occur
            Log.d("HISTORY-FRAGMENT", String.format("Today: %s", today.toString()));
            Log.d("HISTORY-FRAGMENT", String.format("Last Year: %s", lastYear.toString()));
            Log.d("HISTORY-FRAGMENT", String.format("Next Month: %s", nextMonth.toString()));
    
            if(container != null) {
                calendarView = (CalendarPickerView) container.findViewById(R.id.calendar_view_history);
                calendarView.init(lastYear, nextMonth, Locale.US)
                        .withSelectedDate(today);
            }
        }
    

    CustomTimeUtils Methods

    public static long getDate(int typeCode, int value){
            Calendar calendar = Calendar.getInstance();
            calendar.add(typeCode, value);
    
            return calendar.getTimeInMillis();
        }
    public static long today(){
            return getDate(Calendar.DATE, 0);
        }
    public static long nextMonth(){
            return getDate(Calendar.MONTH, 1);
        }
    
        public static long lastYear(){
            return getDate(Calendar.YEAR, -1);
        }
    

    I'm stumped as to why this is occurring, as I can't figure out how to trace the problem on my end. Does anybody know why this could be happening, or perhaps a better method to accomplish what I'm trying to do?

    EDIT: Full Stack Trace:

    08-30 16:57:27.431 29638-29638/com.dev.application E/AndroidRuntime: FATAL EXCEPTION: main
                                                                          Process: com.dev.application, PID: 29638
                                                                          java.lang.IllegalStateException: Must have at least one month to display.  Did you forget to call init()?
                                                                              at com.squareup.timessquare.CalendarPickerView.onMeasure(CalendarPickerView.java:449)
                                                                              at android.view.View.measure(View.java:18834)
                                                                              at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5953)
                                                                              at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1465)
                                                                              at android.widget.LinearLayout.measureVertical(LinearLayout.java:748)
                                                                              at android.widget.LinearLayout.onMeasure(LinearLayout.java:630)
                                                                              at android.view.View.measure(View.java:18834)
                                                                              at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5953)
                                                                              at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
                                                                              at android.view.View.measure(View.java:18834)
                                                                              at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:715)
                                                                              at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:461)
                                                                              at android.view.View.measure(View.java:18834)
                                                                              at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5953)
                                                                              at android.support.design.widget.CoordinatorLayout.onMeasureChild(CoordinatorLayout.java:610)
                                                                              at android.support.design.widget.HeaderScrollingViewBehavior.onMeasureChild(HeaderScrollingViewBehavior.java:78)
                                                                              at android.support.design.widget.AppBarLayout$ScrollingViewBehavior.onMeasureChild(AppBarLayout.java:1132)
                                                                              at android.support.design.widget.CoordinatorLayout.onMeasure(CoordinatorLayout.java:675)
                                                                              at android.view.View.measure(View.java:18834)
                                                                              at android.support.v4.widget.DrawerLayout.onMeasure(DrawerLayout.java:940)
                                                                              at android.view.View.measure(View.java:18834)
                                                                              at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5953)
                                                                              at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
                                                                              at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:135)
                                                                              at android.view.View.measure(View.java:18834)
                                                                              at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5953)
                                                                              at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1465)
                                                                              at android.widget.LinearLayout.measureVertical(LinearLayout.java:748)
                                                                              at android.widget.LinearLayout.onMeasure(LinearLayout.java:630)
                                                                              at android.view.View.measure(View.java:18834)
                                                                              at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5953)
                                                                              at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
                                                                              at android.view.View.measure(View.java:18834)
                                                                              at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5953)
                                                                              at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1465)
                                                                              at android.widget.LinearLayout.measureVertical(LinearLayout.java:748)
                                                                              at android.widget.LinearLayout.onMeasure(LinearLayout.java:630)
                                                                              at android.view.View.measure(View.java:18834)
                                                                              at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5953)
                                                                              at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
                                                                              at com.android.internal.policy.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2685)
                                                                              at android.view.View.measure(View.java:18834)
                                                                              at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2131)
                                                                              at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1237)
                                                                              at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1474)
                                                                              at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1125)
                                                                              at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6100)
                                                                              at android.view.Choreographer$CallbackRecord.run(Choreographer.java:858)
                                                                              at android.view.Choreographer.doCallbacks(Choreographer.java:670)
                                                                              at android.view.Choreographer.doFrame(Choreographer.java:606)
                                                                              at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:844)
                                                                              at android.os.Handler.handleCallback(Handler.java:739)
                                                                              at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                              at android.os.Looper.loop(Looper.java:148)
                                                                              at android.app.ActivityThread.main(ActivityThread.java:5525)
                                                                              at java.lang.reflect.Method.invoke(Native Method)
                                                                              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:730)
    
    opened by JRSoftware92 11
  • Build breaks with support library 23.0.0

    Build breaks with support library 23.0.0

    Combining this library with the new support library, fail the build since both libraries declare the attribute titleTextColor Attribute "titleTextColor" has already been defined

    opened by koch-t 11
  • Build with Gradle

    Build with Gradle

    Switches building with Maven to Gradle. Checkstyle is supported, but unit tests are currently ignored. This updates the directory structure recommended for Gradle/Maven. Closes #60

    opened by f2prateek 10
  • Fix - Support Theme Attributes For tsquare_dayTextColor (fixes #509)

    Fix - Support Theme Attributes For tsquare_dayTextColor (fixes #509)

    Work done

    Implement support for theme attributes used in selectors for app:tsquare_dayTextColor.

        app:tsquare_dayTextColor="@color/custom_calendar_text_selector"
    

    with custom_calendar_text_selector.xml

    <selector xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto">
        <item android:color="?textSelected" android:state_selected="true" />
        <item android:color="?textSelected" android:state_pressed="true" />
        <item android:color="?textDisabled" app:tsquare_state_selectable="true" />
        <item android:color="?textDefault" />
    </selector>
    
    

    Fixes #509

    image

    I did not provide an example with selector and custom attributes, but happy to do if necessary, like on this branch.

    opened by quentin41500 9
  • This library crashes the app when running in pseudolocale

    This library crashes the app when running in pseudolocale

    When I turned on pseudolocale for my app and tried to open the calendar picker view I got this crash:

    2021-01-07 20:18:55.204 22755-22755/com.tripactions.internal E/AndroidRuntime: FATAL EXCEPTION: main
        Process: com.tripactions.internal, PID: 22755
        android.view.InflateException: Binary XML file line #89 in com.tripactions.internal:layout/fragment_calendar_date_selector: Binary XML file line #89 in com.tripactions.internal:layout/fragment_calendar_date_selector: Error inflating class com.squareup.timessquare.CalendarPickerView
        Caused by: android.view.InflateException: Binary XML file line #89 in com.tripactions.internal:layout/fragment_calendar_date_selector: Error inflating class com.squareup.timessquare.CalendarPickerView
        Caused by: java.lang.reflect.InvocationTargetException
            at java.lang.reflect.Constructor.newInstance0(Native Method)
            at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
            at android.view.LayoutInflater.createView(LayoutInflater.java:854)
            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:1006)
            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:961)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:1123)
            at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1084)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:682)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:534)
            at com.tripactions.alpha.calendar.fragments.CalendarDateSelectorFragment.onCreateView(CalendarDateSelectorFragment.kt:138)
            at androidx.fragment.app.Fragment.performCreateView(Fragment.java:2699)
            at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:320)
            at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1199)
            at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1368)
            at androidx.fragment.app.FragmentManager.moveFragmentToExpectedState(FragmentManager.java:1446)
            at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1509)
            at androidx.fragment.app.BackStackRecord.executeOps(BackStackRecord.java:447)
            at androidx.fragment.app.FragmentManager.executeOps(FragmentManager.java:2181)
            at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:2004)
            at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:1959)
            at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:1861)
            at androidx.fragment.app.FragmentManager$4.run(FragmentManager.java:413)
            at android.os.Handler.handleCallback(Handler.java:883)
            at android.os.Handler.dispatchMessage(Handler.java:100)
            at android.os.Looper.loop(Looper.java:237)
            at android.app.ActivityThread.main(ActivityThread.java:8167)
            at java.lang.reflect.Method.invoke(Native Method)
            at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:496)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1100)
         Caused by: java.lang.IllegalArgumentException: Illegal pattern character 'o'
            at java.text.SimpleDateFormat.compile(SimpleDateFormat.java:932)
            at java.text.SimpleDateFormat.initialize(SimpleDateFormat.java:718)
            at java.text.SimpleDateFormat.<init>(SimpleDateFormat.java:689)
            at com.squareup.timessquare.CalendarPickerView.<init>(CalendarPickerView.java:139)
            at java.lang.reflect.Constructor.newInstance0(Native Method) 
            at java.lang.reflect.Constructor.newInstance(Constructor.java:343) 
            at android.view.LayoutInflater.createView(LayoutInflater.java:854) 
            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:1006) 
            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:961) 
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:1123) 
            at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1084) 
            at android.view.LayoutInflater.inflate(LayoutInflater.java:682) 
            at android.view.LayoutInflater.inflate(LayoutInflater.java:534) 
            at com.tripactions.alpha.calendar.fragments.CalendarDateSelectorFragment.onCreateView(CalendarDateSelectorFragment.kt:138) 
            at androidx.fragment.app.Fragment.performCreateView(Fragment.java:2699) 
            at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:320) 
            at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1199) 
            at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1368) 
            at androidx.fragment.app.FragmentManager.moveFragmentToExpectedState(FragmentManager.java:1446) 
            at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1509) 
            at androidx.fragment.app.BackStackRecord.executeOps(BackStackRecord.java:447) 
            at androidx.fragment.app.FragmentManager.executeOps(FragmentManager.java:2181) 
            at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:2004) 
            at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:1959) 
            at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:1861) 
            at androidx.fragment.app.FragmentManager$4.run(FragmentManager.java:413) 
            at android.os.Handler.handleCallback(Handler.java:883) 
            at android.os.Handler.dispatchMessage(Handler.java:100) 
            at android.os.Looper.loop(Looper.java:237) 
            at android.app.ActivityThread.main(ActivityThread.java:8167) 
            at java.lang.reflect.Method.invoke(Native Method) 
            at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:496) 
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1100)
    
    

    Solution is to set the date strings to not be translatable:

    <string name="month_name_format" translatable="false">MMMM yyyy</string>
    <string name="month_only_name_format" translatable="false">MMMM</string>
    <string name="year_only_format" translatable="false">yyyy</string>
    
    opened by KarimFikani 2
  • Android 10 (API 28) - ScrollToDate(Date) & ScrollTo(0, position): don't work

    Android 10 (API 28) - ScrollToDate(Date) & ScrollTo(0, position): don't work

    ScrollToDate(Date oneOfSelectedDates) doesn't do anything. Calendar stays at scroll position 0, at the earliest date. Android 9 and earlier - works fine.

    SmoothScrollToPosition does work, but if your earliest date is, say 5 years ago, scroll animation takes a long time.

    Reproduction steps (just a sample, assume undeclared variables having valid values):

    CalendarPickerView tsCal = findViewById(R.id.tsCal);
    
    Calendar earliestDate = Calendar.getInstance();
    Calendar latestDate = Calendar.getInstance();
    earliestDate.add(Calendar.YEAR, -5);
    latestDate.add(Calendar.HOUR, 1);
    
    tsCal.init(earliestDate.getTime(), latestDate.getTime())
                    .inMode(mode)
                    .withSelectedDates(someArrayListOfDates);
    
    // works only in Android 9 and earlier:
    tsCal.scrollTo(0, intAnyValidPosition);
    tsCal.scrollBy(0, intAnyValidPosition);
    tsCal.scrollToDate(someArrayListOfDates.get(0))
    
    // works on any version I've tested, but isn't a valid solution due to time spent scrolling:
    tsCal.smoothScrollToPosition(intAnyValidPosition);
    
    opened by DarkDvr 1
  • change the start date to be the min date

    change the start date to be the min date

    i want to change the start date which be the day of today to be the min date i send to fun init so that the start date be the first date in range i putted not the date of past or future

    opened by AbdelrahmanSalahDeveloper 0
  • Range Selection

    Range Selection

    Hi, I am trying to make a booking application where number of days will be mentioned, and I need to display those number of days after selecting the start date with RANGE, can we do it ? if so please help me for this

    opened by glrakesh 2
Owner
Square
Square
Android calendar view inspired by Sunrise calendar and iOS7 stock calendar

SilkCal Android calendar view inspired by Sunrise calendar and iOS7 stock calendar. Usage Add compile 'me.nlmartian.silkcal:library:0.1.1' to your dep

JunGuan Zhu 385 Nov 25, 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
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
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
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
Pick a date or time on Android in style

Material DateTime Picker - Select a time/date in style Material DateTime Picker tries to offer you the date and time pickers as shown in the Material

null 4.7k Jan 4, 2023
A date time range picker for android written in Kotlin

DateTimeRangePicker A date time range picker for android Usage Firstly, grab latest release of the library via JitPack. And note that, it utilizes Jod

SkedGo 501 Dec 31, 2022
An android app that can calculate the minutes from the date the user entered, till today.

AgeInMinutesApp An android app that can calculate the minutes from the date the user entered, till today. If user tap Select Date button, Calender dia

Gurkan 0 Mar 16, 2022
A material Date Range Picker based on wdullaers MaterialDateTimePicker

Material Date and Time Picker with Range Selection Credits to the original amazing material date picker library by wdullaer - https://github.com/wdull

Supratim 1.3k Dec 14, 2022
A material Date Range Picker based on wdullaers MaterialDateTimePicker

Material Date and Time Picker with Range Selection Credits to the original amazing material date picker library by wdullaer - https://github.com/wdull

Supratim 1.3k Dec 14, 2022
Time-DatePicker - A Simple Time Date Picker With Kotlin

Time-DatePicker Time.DatePicker.mp4

Faysal Hossain 0 Jan 19, 2022
Material3 themed Jetpack Compose date & time pickers.

Compose material3 Date1 and Time pickers Highly customizable Jetpack Compose components with material3 support for date & time picking. Contents Lates

Maroš Šeleng 35 Jan 31, 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 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