150f34d14f6dd3411fdbdb6a7b8b285c2b8fdbf5cSvetoslav Ganov/* 250f34d14f6dd3411fdbdb6a7b8b285c2b8fdbf5cSvetoslav Ganov * Copyright (C) 2010 The Android Open Source Project 350f34d14f6dd3411fdbdb6a7b8b285c2b8fdbf5cSvetoslav Ganov * 450f34d14f6dd3411fdbdb6a7b8b285c2b8fdbf5cSvetoslav Ganov * Licensed under the Apache License, Version 2.0 (the "License"); 550f34d14f6dd3411fdbdb6a7b8b285c2b8fdbf5cSvetoslav Ganov * you may not use this file except in compliance with the License. 650f34d14f6dd3411fdbdb6a7b8b285c2b8fdbf5cSvetoslav Ganov * You may obtain a copy of the License at 750f34d14f6dd3411fdbdb6a7b8b285c2b8fdbf5cSvetoslav Ganov * 850f34d14f6dd3411fdbdb6a7b8b285c2b8fdbf5cSvetoslav Ganov * http://www.apache.org/licenses/LICENSE-2.0 950f34d14f6dd3411fdbdb6a7b8b285c2b8fdbf5cSvetoslav Ganov * 1050f34d14f6dd3411fdbdb6a7b8b285c2b8fdbf5cSvetoslav Ganov * Unless required by applicable law or agreed to in writing, software 1150f34d14f6dd3411fdbdb6a7b8b285c2b8fdbf5cSvetoslav Ganov * distributed under the License is distributed on an "AS IS" BASIS, 1250f34d14f6dd3411fdbdb6a7b8b285c2b8fdbf5cSvetoslav Ganov * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1350f34d14f6dd3411fdbdb6a7b8b285c2b8fdbf5cSvetoslav Ganov * See the License for the specific language governing permissions and 1450f34d14f6dd3411fdbdb6a7b8b285c2b8fdbf5cSvetoslav Ganov * limitations under the License. 1550f34d14f6dd3411fdbdb6a7b8b285c2b8fdbf5cSvetoslav Ganov */ 1650f34d14f6dd3411fdbdb6a7b8b285c2b8fdbf5cSvetoslav Ganov 1750f34d14f6dd3411fdbdb6a7b8b285c2b8fdbf5cSvetoslav Ganovpackage android.widget; 1850f34d14f6dd3411fdbdb6a7b8b285c2b8fdbf5cSvetoslav Ganov 1968763be41cffbcb4883a0a6293fc1aa9e17a3957Alan Viveretteimport com.android.internal.R; 2068763be41cffbcb4883a0a6293fc1aa9e17a3957Alan Viverette 21b097321719e5a657ffa5f0db775a0fa03aaf42cdAlan Viveretteimport android.annotation.AttrRes; 2280756e38882720860db52f1fcc21fa1505a02abfTor Norbyeimport android.annotation.ColorInt; 237b9c912f536925ac6ec43935d6e97506851b33d6Tor Norbyeimport android.annotation.DrawableRes; 24b097321719e5a657ffa5f0db775a0fa03aaf42cdAlan Viveretteimport android.annotation.NonNull; 25b097321719e5a657ffa5f0db775a0fa03aaf42cdAlan Viveretteimport android.annotation.Nullable; 260ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viveretteimport android.annotation.StyleRes; 27e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganovimport android.annotation.Widget; 2850f34d14f6dd3411fdbdb6a7b8b285c2b8fdbf5cSvetoslav Ganovimport android.content.Context; 29f5926962cc665d4a2e6464f9ba9e3e9788496a6fSvetoslav Ganovimport android.content.res.Configuration; 3050f34d14f6dd3411fdbdb6a7b8b285c2b8fdbf5cSvetoslav Ganovimport android.content.res.TypedArray; 3150f34d14f6dd3411fdbdb6a7b8b285c2b8fdbf5cSvetoslav Ganovimport android.graphics.drawable.Drawable; 3268763be41cffbcb4883a0a6293fc1aa9e17a3957Alan Viveretteimport android.icu.util.Calendar; 3368763be41cffbcb4883a0a6293fc1aa9e17a3957Alan Viveretteimport android.icu.util.TimeZone; 3450f34d14f6dd3411fdbdb6a7b8b285c2b8fdbf5cSvetoslav Ganovimport android.util.AttributeSet; 35e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganovimport android.util.Log; 361442da620c117910e7628b36efc32ff962be02b2Svetoslav Ganov 374612740ddc76b3518dc6d189d5f8b5b7f60e9d64Alan Viveretteimport java.text.DateFormat; 38e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganovimport java.text.ParseException; 39e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganovimport java.text.SimpleDateFormat; 400ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viveretteimport java.util.Date; 4150f34d14f6dd3411fdbdb6a7b8b285c2b8fdbf5cSvetoslav Ganovimport java.util.Locale; 4250f34d14f6dd3411fdbdb6a7b8b285c2b8fdbf5cSvetoslav Ganov 4350f34d14f6dd3411fdbdb6a7b8b285c2b8fdbf5cSvetoslav Ganov/** 44b097321719e5a657ffa5f0db775a0fa03aaf42cdAlan Viverette * This class is a calendar widget for displaying and selecting dates. The 45b097321719e5a657ffa5f0db775a0fa03aaf42cdAlan Viverette * range of dates supported by this calendar is configurable. 46b097321719e5a657ffa5f0db775a0fa03aaf42cdAlan Viverette * <p> 47b097321719e5a657ffa5f0db775a0fa03aaf42cdAlan Viverette * The exact appearance and interaction model of this widget may vary between 48b097321719e5a657ffa5f0db775a0fa03aaf42cdAlan Viverette * OS versions and themes (e.g. Holo versus Material), but in general a user 49b097321719e5a657ffa5f0db775a0fa03aaf42cdAlan Viverette * can select a date by tapping on it and can scroll or fling the calendar to a 50b097321719e5a657ffa5f0db775a0fa03aaf42cdAlan Viverette * desired date. 51e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov * 52e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov * @attr ref android.R.styleable#CalendarView_showWeekNumber 53e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov * @attr ref android.R.styleable#CalendarView_firstDayOfWeek 54e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov * @attr ref android.R.styleable#CalendarView_minDate 55e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov * @attr ref android.R.styleable#CalendarView_maxDate 56e51f94cfe9f97e13dad0e564dfc92b22e70c296dSvetoslav Ganov * @attr ref android.R.styleable#CalendarView_shownWeekCount 57e51f94cfe9f97e13dad0e564dfc92b22e70c296dSvetoslav Ganov * @attr ref android.R.styleable#CalendarView_selectedWeekBackgroundColor 58e51f94cfe9f97e13dad0e564dfc92b22e70c296dSvetoslav Ganov * @attr ref android.R.styleable#CalendarView_focusedMonthDateColor 59e51f94cfe9f97e13dad0e564dfc92b22e70c296dSvetoslav Ganov * @attr ref android.R.styleable#CalendarView_unfocusedMonthDateColor 60e51f94cfe9f97e13dad0e564dfc92b22e70c296dSvetoslav Ganov * @attr ref android.R.styleable#CalendarView_weekNumberColor 61e51f94cfe9f97e13dad0e564dfc92b22e70c296dSvetoslav Ganov * @attr ref android.R.styleable#CalendarView_weekSeparatorLineColor 62e51f94cfe9f97e13dad0e564dfc92b22e70c296dSvetoslav Ganov * @attr ref android.R.styleable#CalendarView_selectedDateVerticalBar 63e51f94cfe9f97e13dad0e564dfc92b22e70c296dSvetoslav Ganov * @attr ref android.R.styleable#CalendarView_weekDayTextAppearance 64e51f94cfe9f97e13dad0e564dfc92b22e70c296dSvetoslav Ganov * @attr ref android.R.styleable#CalendarView_dateTextAppearance 6550f34d14f6dd3411fdbdb6a7b8b285c2b8fdbf5cSvetoslav Ganov */ 66e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov@Widget 67e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganovpublic class CalendarView extends FrameLayout { 684612740ddc76b3518dc6d189d5f8b5b7f60e9d64Alan Viverette private static final String LOG_TAG = "CalendarView"; 6950f34d14f6dd3411fdbdb6a7b8b285c2b8fdbf5cSvetoslav Ganov 704612740ddc76b3518dc6d189d5f8b5b7f60e9d64Alan Viverette private static final int MODE_HOLO = 0; 714612740ddc76b3518dc6d189d5f8b5b7f60e9d64Alan Viverette private static final int MODE_MATERIAL = 1; 72e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov 734612740ddc76b3518dc6d189d5f8b5b7f60e9d64Alan Viverette private final CalendarViewDelegate mDelegate; 74f5926962cc665d4a2e6464f9ba9e3e9788496a6fSvetoslav Ganov 75f5926962cc665d4a2e6464f9ba9e3e9788496a6fSvetoslav Ganov /** 7650f34d14f6dd3411fdbdb6a7b8b285c2b8fdbf5cSvetoslav Ganov * The callback used to indicate the user changes the date. 7750f34d14f6dd3411fdbdb6a7b8b285c2b8fdbf5cSvetoslav Ganov */ 78e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov public interface OnDateChangeListener { 7950f34d14f6dd3411fdbdb6a7b8b285c2b8fdbf5cSvetoslav Ganov 8050f34d14f6dd3411fdbdb6a7b8b285c2b8fdbf5cSvetoslav Ganov /** 8150f34d14f6dd3411fdbdb6a7b8b285c2b8fdbf5cSvetoslav Ganov * Called upon change of the selected day. 8250f34d14f6dd3411fdbdb6a7b8b285c2b8fdbf5cSvetoslav Ganov * 8350f34d14f6dd3411fdbdb6a7b8b285c2b8fdbf5cSvetoslav Ganov * @param view The view associated with this listener. 8450f34d14f6dd3411fdbdb6a7b8b285c2b8fdbf5cSvetoslav Ganov * @param year The year that was set. 8550f34d14f6dd3411fdbdb6a7b8b285c2b8fdbf5cSvetoslav Ganov * @param month The month that was set [0-11]. 8650f34d14f6dd3411fdbdb6a7b8b285c2b8fdbf5cSvetoslav Ganov * @param dayOfMonth The day of the month that was set. 8750f34d14f6dd3411fdbdb6a7b8b285c2b8fdbf5cSvetoslav Ganov */ 88b097321719e5a657ffa5f0db775a0fa03aaf42cdAlan Viverette void onSelectedDayChange(@NonNull CalendarView view, int year, int month, int dayOfMonth); 8950f34d14f6dd3411fdbdb6a7b8b285c2b8fdbf5cSvetoslav Ganov } 9050f34d14f6dd3411fdbdb6a7b8b285c2b8fdbf5cSvetoslav Ganov 91b097321719e5a657ffa5f0db775a0fa03aaf42cdAlan Viverette public CalendarView(@NonNull Context context) { 9250f34d14f6dd3411fdbdb6a7b8b285c2b8fdbf5cSvetoslav Ganov this(context, null); 9350f34d14f6dd3411fdbdb6a7b8b285c2b8fdbf5cSvetoslav Ganov } 9450f34d14f6dd3411fdbdb6a7b8b285c2b8fdbf5cSvetoslav Ganov 95b097321719e5a657ffa5f0db775a0fa03aaf42cdAlan Viverette public CalendarView(@NonNull Context context, @Nullable AttributeSet attrs) { 96617feb99a06e7ffb3894e86a286bf30e085f321aAlan Viverette this(context, attrs, R.attr.calendarViewStyle); 9750f34d14f6dd3411fdbdb6a7b8b285c2b8fdbf5cSvetoslav Ganov } 9850f34d14f6dd3411fdbdb6a7b8b285c2b8fdbf5cSvetoslav Ganov 99b097321719e5a657ffa5f0db775a0fa03aaf42cdAlan Viverette public CalendarView(@NonNull Context context, @Nullable AttributeSet attrs, 100b097321719e5a657ffa5f0db775a0fa03aaf42cdAlan Viverette @AttrRes int defStyleAttr) { 101617feb99a06e7ffb3894e86a286bf30e085f321aAlan Viverette this(context, attrs, defStyleAttr, 0); 102617feb99a06e7ffb3894e86a286bf30e085f321aAlan Viverette } 103617feb99a06e7ffb3894e86a286bf30e085f321aAlan Viverette 104b097321719e5a657ffa5f0db775a0fa03aaf42cdAlan Viverette public CalendarView(@NonNull Context context, @Nullable AttributeSet attrs, 105b097321719e5a657ffa5f0db775a0fa03aaf42cdAlan Viverette @AttrRes int defStyleAttr, @StyleRes int defStyleRes) { 106617feb99a06e7ffb3894e86a286bf30e085f321aAlan Viverette super(context, attrs, defStyleAttr, defStyleRes); 10750f34d14f6dd3411fdbdb6a7b8b285c2b8fdbf5cSvetoslav Ganov 1084612740ddc76b3518dc6d189d5f8b5b7f60e9d64Alan Viverette final TypedArray a = context.obtainStyledAttributes( 1094612740ddc76b3518dc6d189d5f8b5b7f60e9d64Alan Viverette attrs, R.styleable.CalendarView, defStyleAttr, defStyleRes); 1104612740ddc76b3518dc6d189d5f8b5b7f60e9d64Alan Viverette final int mode = a.getInt(R.styleable.CalendarView_calendarViewMode, MODE_HOLO); 1114612740ddc76b3518dc6d189d5f8b5b7f60e9d64Alan Viverette a.recycle(); 1124612740ddc76b3518dc6d189d5f8b5b7f60e9d64Alan Viverette 1134612740ddc76b3518dc6d189d5f8b5b7f60e9d64Alan Viverette switch (mode) { 1144612740ddc76b3518dc6d189d5f8b5b7f60e9d64Alan Viverette case MODE_HOLO: 1154612740ddc76b3518dc6d189d5f8b5b7f60e9d64Alan Viverette mDelegate = new CalendarViewLegacyDelegate( 1164612740ddc76b3518dc6d189d5f8b5b7f60e9d64Alan Viverette this, context, attrs, defStyleAttr, defStyleRes); 1174612740ddc76b3518dc6d189d5f8b5b7f60e9d64Alan Viverette break; 1184612740ddc76b3518dc6d189d5f8b5b7f60e9d64Alan Viverette case MODE_MATERIAL: 1194612740ddc76b3518dc6d189d5f8b5b7f60e9d64Alan Viverette mDelegate = new CalendarViewMaterialDelegate( 1204612740ddc76b3518dc6d189d5f8b5b7f60e9d64Alan Viverette this, context, attrs, defStyleAttr, defStyleRes); 1214612740ddc76b3518dc6d189d5f8b5b7f60e9d64Alan Viverette break; 1224612740ddc76b3518dc6d189d5f8b5b7f60e9d64Alan Viverette default: 1234612740ddc76b3518dc6d189d5f8b5b7f60e9d64Alan Viverette throw new IllegalArgumentException("invalid calendarViewMode attribute"); 1244612740ddc76b3518dc6d189d5f8b5b7f60e9d64Alan Viverette } 12550f34d14f6dd3411fdbdb6a7b8b285c2b8fdbf5cSvetoslav Ganov } 12650f34d14f6dd3411fdbdb6a7b8b285c2b8fdbf5cSvetoslav Ganov 127ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov /** 128ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov * Sets the number of weeks to be shown. 129ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov * 130ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov * @param count The shown week count. 131414efc3b5f50e2784f4f7c2be3f2c096aef0c6b4Svetoslav Ganov * 132414efc3b5f50e2784f4f7c2be3f2c096aef0c6b4Svetoslav Ganov * @attr ref android.R.styleable#CalendarView_shownWeekCount 1330ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette * @deprecated No longer used by Material-style CalendarView. 134ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov */ 1350ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette @Deprecated 136ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov public void setShownWeekCount(int count) { 137c6afe76dfe641afa32dab6e0b4740d780072d2c6Fabrice Di Meglio mDelegate.setShownWeekCount(count); 138ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov } 139ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov 140ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov /** 141ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov * Gets the number of weeks to be shown. 142ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov * 143ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov * @return The shown week count. 144414efc3b5f50e2784f4f7c2be3f2c096aef0c6b4Svetoslav Ganov * 145414efc3b5f50e2784f4f7c2be3f2c096aef0c6b4Svetoslav Ganov * @attr ref android.R.styleable#CalendarView_shownWeekCount 1460ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette * @deprecated No longer used by Material-style CalendarView. 147ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov */ 1480ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette @Deprecated 149ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov public int getShownWeekCount() { 150c6afe76dfe641afa32dab6e0b4740d780072d2c6Fabrice Di Meglio return mDelegate.getShownWeekCount(); 151ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov } 152ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov 153ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov /** 154ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov * Sets the background color for the selected week. 155ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov * 156ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov * @param color The week background color. 157414efc3b5f50e2784f4f7c2be3f2c096aef0c6b4Svetoslav Ganov * 158414efc3b5f50e2784f4f7c2be3f2c096aef0c6b4Svetoslav Ganov * @attr ref android.R.styleable#CalendarView_selectedWeekBackgroundColor 1590ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette * @deprecated No longer used by Material-style CalendarView. 160ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov */ 1610ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette @Deprecated 16280756e38882720860db52f1fcc21fa1505a02abfTor Norbye public void setSelectedWeekBackgroundColor(@ColorInt int color) { 163c6afe76dfe641afa32dab6e0b4740d780072d2c6Fabrice Di Meglio mDelegate.setSelectedWeekBackgroundColor(color); 164ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov } 165ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov 166ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov /** 167ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov * Gets the background color for the selected week. 168ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov * 169ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov * @return The week background color. 170414efc3b5f50e2784f4f7c2be3f2c096aef0c6b4Svetoslav Ganov * 171414efc3b5f50e2784f4f7c2be3f2c096aef0c6b4Svetoslav Ganov * @attr ref android.R.styleable#CalendarView_selectedWeekBackgroundColor 1720ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette * @deprecated No longer used by Material-style CalendarView. 173ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov */ 17480756e38882720860db52f1fcc21fa1505a02abfTor Norbye @ColorInt 1750ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette @Deprecated 176ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov public int getSelectedWeekBackgroundColor() { 177c6afe76dfe641afa32dab6e0b4740d780072d2c6Fabrice Di Meglio return mDelegate.getSelectedWeekBackgroundColor(); 178ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov } 179ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov 180ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov /** 181ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov * Sets the color for the dates of the focused month. 182ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov * 183ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov * @param color The focused month date color. 184414efc3b5f50e2784f4f7c2be3f2c096aef0c6b4Svetoslav Ganov * 185414efc3b5f50e2784f4f7c2be3f2c096aef0c6b4Svetoslav Ganov * @attr ref android.R.styleable#CalendarView_focusedMonthDateColor 1860ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette * @deprecated No longer used by Material-style CalendarView. 187ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov */ 1880ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette @Deprecated 18980756e38882720860db52f1fcc21fa1505a02abfTor Norbye public void setFocusedMonthDateColor(@ColorInt int color) { 190c6afe76dfe641afa32dab6e0b4740d780072d2c6Fabrice Di Meglio mDelegate.setFocusedMonthDateColor(color); 191ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov } 192ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov 193ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov /** 194ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov * Gets the color for the dates in the focused month. 195ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov * 196ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov * @return The focused month date color. 197414efc3b5f50e2784f4f7c2be3f2c096aef0c6b4Svetoslav Ganov * 198414efc3b5f50e2784f4f7c2be3f2c096aef0c6b4Svetoslav Ganov * @attr ref android.R.styleable#CalendarView_focusedMonthDateColor 1990ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette * @deprecated No longer used by Material-style CalendarView. 200ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov */ 20180756e38882720860db52f1fcc21fa1505a02abfTor Norbye @ColorInt 2020ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette @Deprecated 203ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov public int getFocusedMonthDateColor() { 204c6afe76dfe641afa32dab6e0b4740d780072d2c6Fabrice Di Meglio return mDelegate.getFocusedMonthDateColor(); 205ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov } 206ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov 207ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov /** 208ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov * Sets the color for the dates of a not focused month. 209ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov * 210ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov * @param color A not focused month date color. 211414efc3b5f50e2784f4f7c2be3f2c096aef0c6b4Svetoslav Ganov * 212414efc3b5f50e2784f4f7c2be3f2c096aef0c6b4Svetoslav Ganov * @attr ref android.R.styleable#CalendarView_unfocusedMonthDateColor 2130ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette * @deprecated No longer used by Material-style CalendarView. 214ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov */ 2150ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette @Deprecated 21680756e38882720860db52f1fcc21fa1505a02abfTor Norbye public void setUnfocusedMonthDateColor(@ColorInt int color) { 217c6afe76dfe641afa32dab6e0b4740d780072d2c6Fabrice Di Meglio mDelegate.setUnfocusedMonthDateColor(color); 218ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov } 219ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov 220ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov /** 221ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov * Gets the color for the dates in a not focused month. 222ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov * 223ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov * @return A not focused month date color. 224414efc3b5f50e2784f4f7c2be3f2c096aef0c6b4Svetoslav Ganov * 225414efc3b5f50e2784f4f7c2be3f2c096aef0c6b4Svetoslav Ganov * @attr ref android.R.styleable#CalendarView_unfocusedMonthDateColor 2260ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette * @deprecated No longer used by Material-style CalendarView. 227ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov */ 22880756e38882720860db52f1fcc21fa1505a02abfTor Norbye @ColorInt 2290ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette @Deprecated 230ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov public int getUnfocusedMonthDateColor() { 231c6afe76dfe641afa32dab6e0b4740d780072d2c6Fabrice Di Meglio return mDelegate.getUnfocusedMonthDateColor(); 232ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov } 233ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov 234ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov /** 235ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov * Sets the color for the week numbers. 236ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov * 237ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov * @param color The week number color. 238414efc3b5f50e2784f4f7c2be3f2c096aef0c6b4Svetoslav Ganov * 239414efc3b5f50e2784f4f7c2be3f2c096aef0c6b4Svetoslav Ganov * @attr ref android.R.styleable#CalendarView_weekNumberColor 2400ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette * @deprecated No longer used by Material-style CalendarView. 241ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov */ 2420ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette @Deprecated 24380756e38882720860db52f1fcc21fa1505a02abfTor Norbye public void setWeekNumberColor(@ColorInt int color) { 244c6afe76dfe641afa32dab6e0b4740d780072d2c6Fabrice Di Meglio mDelegate.setWeekNumberColor(color); 245ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov } 246ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov 247ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov /** 248ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov * Gets the color for the week numbers. 249ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov * 250ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov * @return The week number color. 251414efc3b5f50e2784f4f7c2be3f2c096aef0c6b4Svetoslav Ganov * 252414efc3b5f50e2784f4f7c2be3f2c096aef0c6b4Svetoslav Ganov * @attr ref android.R.styleable#CalendarView_weekNumberColor 2530ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette * @deprecated No longer used by Material-style CalendarView. 254ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov */ 25580756e38882720860db52f1fcc21fa1505a02abfTor Norbye @ColorInt 2560ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette @Deprecated 257ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov public int getWeekNumberColor() { 258c6afe76dfe641afa32dab6e0b4740d780072d2c6Fabrice Di Meglio return mDelegate.getWeekNumberColor(); 259ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov } 260ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov 261ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov /** 262ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov * Sets the color for the separator line between weeks. 263ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov * 264ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov * @param color The week separator color. 265414efc3b5f50e2784f4f7c2be3f2c096aef0c6b4Svetoslav Ganov * 266414efc3b5f50e2784f4f7c2be3f2c096aef0c6b4Svetoslav Ganov * @attr ref android.R.styleable#CalendarView_weekSeparatorLineColor 2670ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette * @deprecated No longer used by Material-style CalendarView. 268ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov */ 2690ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette @Deprecated 27080756e38882720860db52f1fcc21fa1505a02abfTor Norbye public void setWeekSeparatorLineColor(@ColorInt int color) { 271c6afe76dfe641afa32dab6e0b4740d780072d2c6Fabrice Di Meglio mDelegate.setWeekSeparatorLineColor(color); 272ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov } 273ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov 274ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov /** 275ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov * Gets the color for the separator line between weeks. 276ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov * 277ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov * @return The week separator color. 278414efc3b5f50e2784f4f7c2be3f2c096aef0c6b4Svetoslav Ganov * 279414efc3b5f50e2784f4f7c2be3f2c096aef0c6b4Svetoslav Ganov * @attr ref android.R.styleable#CalendarView_weekSeparatorLineColor 2800ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette * @deprecated No longer used by Material-style CalendarView. 281ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov */ 28280756e38882720860db52f1fcc21fa1505a02abfTor Norbye @ColorInt 2830ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette @Deprecated 284ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov public int getWeekSeparatorLineColor() { 285c6afe76dfe641afa32dab6e0b4740d780072d2c6Fabrice Di Meglio return mDelegate.getWeekSeparatorLineColor(); 286ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov } 287ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov 288ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov /** 289ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov * Sets the drawable for the vertical bar shown at the beginning and at 290ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov * the end of the selected date. 291ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov * 292ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov * @param resourceId The vertical bar drawable resource id. 293414efc3b5f50e2784f4f7c2be3f2c096aef0c6b4Svetoslav Ganov * 294414efc3b5f50e2784f4f7c2be3f2c096aef0c6b4Svetoslav Ganov * @attr ref android.R.styleable#CalendarView_selectedDateVerticalBar 2950ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette * @deprecated No longer used by Material-style CalendarView. 296ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov */ 2970ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette @Deprecated 2987b9c912f536925ac6ec43935d6e97506851b33d6Tor Norbye public void setSelectedDateVerticalBar(@DrawableRes int resourceId) { 299c6afe76dfe641afa32dab6e0b4740d780072d2c6Fabrice Di Meglio mDelegate.setSelectedDateVerticalBar(resourceId); 300ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov } 301ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov 302ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov /** 303ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov * Sets the drawable for the vertical bar shown at the beginning and at 304ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov * the end of the selected date. 305ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov * 306ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov * @param drawable The vertical bar drawable. 307414efc3b5f50e2784f4f7c2be3f2c096aef0c6b4Svetoslav Ganov * 308414efc3b5f50e2784f4f7c2be3f2c096aef0c6b4Svetoslav Ganov * @attr ref android.R.styleable#CalendarView_selectedDateVerticalBar 3090ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette * @deprecated No longer used by Material-style CalendarView. 310ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov */ 3110ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette @Deprecated 312ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov public void setSelectedDateVerticalBar(Drawable drawable) { 313c6afe76dfe641afa32dab6e0b4740d780072d2c6Fabrice Di Meglio mDelegate.setSelectedDateVerticalBar(drawable); 314ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov } 315ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov 316ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov /** 317ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov * Gets the drawable for the vertical bar shown at the beginning and at 318ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov * the end of the selected date. 319ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov * 320ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov * @return The vertical bar drawable. 3210ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette * @deprecated No longer used by Material-style CalendarView. 322ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov */ 3230ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette @Deprecated 324ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov public Drawable getSelectedDateVerticalBar() { 325c6afe76dfe641afa32dab6e0b4740d780072d2c6Fabrice Di Meglio return mDelegate.getSelectedDateVerticalBar(); 326ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov } 327ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov 328ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov /** 329ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov * Sets the text appearance for the week day abbreviation of the calendar header. 330ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov * 331ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov * @param resourceId The text appearance resource id. 332414efc3b5f50e2784f4f7c2be3f2c096aef0c6b4Svetoslav Ganov * 333414efc3b5f50e2784f4f7c2be3f2c096aef0c6b4Svetoslav Ganov * @attr ref android.R.styleable#CalendarView_weekDayTextAppearance 334ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov */ 335b097321719e5a657ffa5f0db775a0fa03aaf42cdAlan Viverette public void setWeekDayTextAppearance(@StyleRes int resourceId) { 336c6afe76dfe641afa32dab6e0b4740d780072d2c6Fabrice Di Meglio mDelegate.setWeekDayTextAppearance(resourceId); 337ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov } 338ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov 339ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov /** 340ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov * Gets the text appearance for the week day abbreviation of the calendar header. 341ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov * 342ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov * @return The text appearance resource id. 343414efc3b5f50e2784f4f7c2be3f2c096aef0c6b4Svetoslav Ganov * 344414efc3b5f50e2784f4f7c2be3f2c096aef0c6b4Svetoslav Ganov * @attr ref android.R.styleable#CalendarView_weekDayTextAppearance 345ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov */ 346b097321719e5a657ffa5f0db775a0fa03aaf42cdAlan Viverette public @StyleRes int getWeekDayTextAppearance() { 347c6afe76dfe641afa32dab6e0b4740d780072d2c6Fabrice Di Meglio return mDelegate.getWeekDayTextAppearance(); 348ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov } 349ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov 350ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov /** 351ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov * Sets the text appearance for the calendar dates. 352ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov * 353ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov * @param resourceId The text appearance resource id. 354414efc3b5f50e2784f4f7c2be3f2c096aef0c6b4Svetoslav Ganov * 355414efc3b5f50e2784f4f7c2be3f2c096aef0c6b4Svetoslav Ganov * @attr ref android.R.styleable#CalendarView_dateTextAppearance 356ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov */ 357b097321719e5a657ffa5f0db775a0fa03aaf42cdAlan Viverette public void setDateTextAppearance(@StyleRes int resourceId) { 358c6afe76dfe641afa32dab6e0b4740d780072d2c6Fabrice Di Meglio mDelegate.setDateTextAppearance(resourceId); 359ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov } 360ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov 361ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov /** 362ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov * Gets the text appearance for the calendar dates. 363ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov * 364ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov * @return The text appearance resource id. 365414efc3b5f50e2784f4f7c2be3f2c096aef0c6b4Svetoslav Ganov * 366414efc3b5f50e2784f4f7c2be3f2c096aef0c6b4Svetoslav Ganov * @attr ref android.R.styleable#CalendarView_dateTextAppearance 367ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov */ 368b097321719e5a657ffa5f0db775a0fa03aaf42cdAlan Viverette public @StyleRes int getDateTextAppearance() { 369c6afe76dfe641afa32dab6e0b4740d780072d2c6Fabrice Di Meglio return mDelegate.getDateTextAppearance(); 370ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov } 371ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov 37250f34d14f6dd3411fdbdb6a7b8b285c2b8fdbf5cSvetoslav Ganov /** 373e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov * Gets the minimal date supported by this {@link CalendarView} in milliseconds 374e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov * since January 1, 1970 00:00:00 in {@link TimeZone#getDefault()} time 375e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov * zone. 376e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov * <p> 377e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov * Note: The default minimal date is 01/01/1900. 378e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov * <p> 379e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov * 380e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov * @return The minimal supported date. 381414efc3b5f50e2784f4f7c2be3f2c096aef0c6b4Svetoslav Ganov * 382414efc3b5f50e2784f4f7c2be3f2c096aef0c6b4Svetoslav Ganov * @attr ref android.R.styleable#CalendarView_minDate 383e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov */ 384e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov public long getMinDate() { 385c6afe76dfe641afa32dab6e0b4740d780072d2c6Fabrice Di Meglio return mDelegate.getMinDate(); 386e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov } 387e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov 388e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov /** 389e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov * Sets the minimal date supported by this {@link CalendarView} in milliseconds 390e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov * since January 1, 1970 00:00:00 in {@link TimeZone#getDefault()} time 391e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov * zone. 39250f34d14f6dd3411fdbdb6a7b8b285c2b8fdbf5cSvetoslav Ganov * 393e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov * @param minDate The minimal supported date. 394414efc3b5f50e2784f4f7c2be3f2c096aef0c6b4Svetoslav Ganov * 395414efc3b5f50e2784f4f7c2be3f2c096aef0c6b4Svetoslav Ganov * @attr ref android.R.styleable#CalendarView_minDate 396e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov */ 397e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov public void setMinDate(long minDate) { 398c6afe76dfe641afa32dab6e0b4740d780072d2c6Fabrice Di Meglio mDelegate.setMinDate(minDate); 399e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov } 400e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov 401e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov /** 402e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov * Gets the maximal date supported by this {@link CalendarView} in milliseconds 403e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov * since January 1, 1970 00:00:00 in {@link TimeZone#getDefault()} time 404e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov * zone. 405e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov * <p> 406e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov * Note: The default maximal date is 01/01/2100. 407e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov * <p> 408e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov * 409e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov * @return The maximal supported date. 410414efc3b5f50e2784f4f7c2be3f2c096aef0c6b4Svetoslav Ganov * 411414efc3b5f50e2784f4f7c2be3f2c096aef0c6b4Svetoslav Ganov * @attr ref android.R.styleable#CalendarView_maxDate 412e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov */ 413e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov public long getMaxDate() { 414c6afe76dfe641afa32dab6e0b4740d780072d2c6Fabrice Di Meglio return mDelegate.getMaxDate(); 415e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov } 41628104e1de5595a22a6987181b13ddeb192739afdSvetoslav Ganov 417e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov /** 418e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov * Sets the maximal date supported by this {@link CalendarView} in milliseconds 419e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov * since January 1, 1970 00:00:00 in {@link TimeZone#getDefault()} time 420e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov * zone. 421e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov * 422e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov * @param maxDate The maximal supported date. 423414efc3b5f50e2784f4f7c2be3f2c096aef0c6b4Svetoslav Ganov * 424414efc3b5f50e2784f4f7c2be3f2c096aef0c6b4Svetoslav Ganov * @attr ref android.R.styleable#CalendarView_maxDate 425e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov */ 426e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov public void setMaxDate(long maxDate) { 427c6afe76dfe641afa32dab6e0b4740d780072d2c6Fabrice Di Meglio mDelegate.setMaxDate(maxDate); 428e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov } 42928104e1de5595a22a6987181b13ddeb192739afdSvetoslav Ganov 430e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov /** 431e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov * Sets whether to show the week number. 432e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov * 433e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov * @param showWeekNumber True to show the week number. 4347cf1586ce49a52dbdffa07702fdfc74b42821970Kirill Grouchnikov * @deprecated No longer used by Material-style CalendarView. 435414efc3b5f50e2784f4f7c2be3f2c096aef0c6b4Svetoslav Ganov * 436414efc3b5f50e2784f4f7c2be3f2c096aef0c6b4Svetoslav Ganov * @attr ref android.R.styleable#CalendarView_showWeekNumber 437e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov */ 4387cf1586ce49a52dbdffa07702fdfc74b42821970Kirill Grouchnikov @Deprecated 439e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov public void setShowWeekNumber(boolean showWeekNumber) { 440c6afe76dfe641afa32dab6e0b4740d780072d2c6Fabrice Di Meglio mDelegate.setShowWeekNumber(showWeekNumber); 441e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov } 44228104e1de5595a22a6987181b13ddeb192739afdSvetoslav Ganov 443e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov /** 444e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov * Gets whether to show the week number. 445e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov * 446e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov * @return True if showing the week number. 4477cf1586ce49a52dbdffa07702fdfc74b42821970Kirill Grouchnikov * @deprecated No longer used by Material-style CalendarView. 448414efc3b5f50e2784f4f7c2be3f2c096aef0c6b4Svetoslav Ganov * 449414efc3b5f50e2784f4f7c2be3f2c096aef0c6b4Svetoslav Ganov * @attr ref android.R.styleable#CalendarView_showWeekNumber 450e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov */ 4517cf1586ce49a52dbdffa07702fdfc74b42821970Kirill Grouchnikov @Deprecated 452e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov public boolean getShowWeekNumber() { 453c6afe76dfe641afa32dab6e0b4740d780072d2c6Fabrice Di Meglio return mDelegate.getShowWeekNumber(); 454e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov } 455e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov 456e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov /** 457e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov * Gets the first day of week. 458e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov * 459e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov * @return The first day of the week conforming to the {@link CalendarView} 460e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov * APIs. 461e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov * @see Calendar#MONDAY 462e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov * @see Calendar#TUESDAY 463e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov * @see Calendar#WEDNESDAY 464e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov * @see Calendar#THURSDAY 465e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov * @see Calendar#FRIDAY 466e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov * @see Calendar#SATURDAY 467e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov * @see Calendar#SUNDAY 468414efc3b5f50e2784f4f7c2be3f2c096aef0c6b4Svetoslav Ganov * 469414efc3b5f50e2784f4f7c2be3f2c096aef0c6b4Svetoslav Ganov * @attr ref android.R.styleable#CalendarView_firstDayOfWeek 470e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov */ 471e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov public int getFirstDayOfWeek() { 472c6afe76dfe641afa32dab6e0b4740d780072d2c6Fabrice Di Meglio return mDelegate.getFirstDayOfWeek(); 473e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov } 474e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov 475e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov /** 476e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov * Sets the first day of week. 477e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov * 478e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov * @param firstDayOfWeek The first day of the week conforming to the 479e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov * {@link CalendarView} APIs. 480e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov * @see Calendar#MONDAY 481e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov * @see Calendar#TUESDAY 482e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov * @see Calendar#WEDNESDAY 483e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov * @see Calendar#THURSDAY 484e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov * @see Calendar#FRIDAY 485e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov * @see Calendar#SATURDAY 486e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov * @see Calendar#SUNDAY 487414efc3b5f50e2784f4f7c2be3f2c096aef0c6b4Svetoslav Ganov * 488414efc3b5f50e2784f4f7c2be3f2c096aef0c6b4Svetoslav Ganov * @attr ref android.R.styleable#CalendarView_firstDayOfWeek 489e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov */ 490e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov public void setFirstDayOfWeek(int firstDayOfWeek) { 491c6afe76dfe641afa32dab6e0b4740d780072d2c6Fabrice Di Meglio mDelegate.setFirstDayOfWeek(firstDayOfWeek); 49250f34d14f6dd3411fdbdb6a7b8b285c2b8fdbf5cSvetoslav Ganov } 49350f34d14f6dd3411fdbdb6a7b8b285c2b8fdbf5cSvetoslav Ganov 49450f34d14f6dd3411fdbdb6a7b8b285c2b8fdbf5cSvetoslav Ganov /** 495e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov * Sets the listener to be notified upon selected date change. 49650f34d14f6dd3411fdbdb6a7b8b285c2b8fdbf5cSvetoslav Ganov * 497e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov * @param listener The listener to be notified. 49850f34d14f6dd3411fdbdb6a7b8b285c2b8fdbf5cSvetoslav Ganov */ 499e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov public void setOnDateChangeListener(OnDateChangeListener listener) { 500c6afe76dfe641afa32dab6e0b4740d780072d2c6Fabrice Di Meglio mDelegate.setOnDateChangeListener(listener); 50150f34d14f6dd3411fdbdb6a7b8b285c2b8fdbf5cSvetoslav Ganov } 50250f34d14f6dd3411fdbdb6a7b8b285c2b8fdbf5cSvetoslav Ganov 50350f34d14f6dd3411fdbdb6a7b8b285c2b8fdbf5cSvetoslav Ganov /** 504e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov * Gets the selected date in milliseconds since January 1, 1970 00:00:00 in 505e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov * {@link TimeZone#getDefault()} time zone. 50650f34d14f6dd3411fdbdb6a7b8b285c2b8fdbf5cSvetoslav Ganov * 507e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov * @return The selected date. 50850f34d14f6dd3411fdbdb6a7b8b285c2b8fdbf5cSvetoslav Ganov */ 509e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov public long getDate() { 510c6afe76dfe641afa32dab6e0b4740d780072d2c6Fabrice Di Meglio return mDelegate.getDate(); 51150f34d14f6dd3411fdbdb6a7b8b285c2b8fdbf5cSvetoslav Ganov } 51250f34d14f6dd3411fdbdb6a7b8b285c2b8fdbf5cSvetoslav Ganov 51350f34d14f6dd3411fdbdb6a7b8b285c2b8fdbf5cSvetoslav Ganov /** 514e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov * Sets the selected date in milliseconds since January 1, 1970 00:00:00 in 515e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov * {@link TimeZone#getDefault()} time zone. 516e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov * 517e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov * @param date The selected date. 518e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov * 519e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov * @throws IllegalArgumentException of the provided date is before the 520e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov * minimal or after the maximal date. 52150f34d14f6dd3411fdbdb6a7b8b285c2b8fdbf5cSvetoslav Ganov * 522e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov * @see #setDate(long, boolean, boolean) 52351c52edad7d40697d7fb2a091f850506fa897643Svetoslav Ganov * @see #setMinDate(long) 52451c52edad7d40697d7fb2a091f850506fa897643Svetoslav Ganov * @see #setMaxDate(long) 52550f34d14f6dd3411fdbdb6a7b8b285c2b8fdbf5cSvetoslav Ganov */ 526e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov public void setDate(long date) { 527c6afe76dfe641afa32dab6e0b4740d780072d2c6Fabrice Di Meglio mDelegate.setDate(date); 52850f34d14f6dd3411fdbdb6a7b8b285c2b8fdbf5cSvetoslav Ganov } 52950f34d14f6dd3411fdbdb6a7b8b285c2b8fdbf5cSvetoslav Ganov 53050f34d14f6dd3411fdbdb6a7b8b285c2b8fdbf5cSvetoslav Ganov /** 531e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov * Sets the selected date in milliseconds since January 1, 1970 00:00:00 in 532e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov * {@link TimeZone#getDefault()} time zone. 53350f34d14f6dd3411fdbdb6a7b8b285c2b8fdbf5cSvetoslav Ganov * 534e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov * @param date The date. 535e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov * @param animate Whether to animate the scroll to the current date. 536e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov * @param center Whether to center the current date even if it is already visible. 537e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov * 538e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov * @throws IllegalArgumentException of the provided date is before the 539e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov * minimal or after the maximal date. 540e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov * 54151c52edad7d40697d7fb2a091f850506fa897643Svetoslav Ganov * @see #setMinDate(long) 54251c52edad7d40697d7fb2a091f850506fa897643Svetoslav Ganov * @see #setMaxDate(long) 543e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov */ 544e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov public void setDate(long date, boolean animate, boolean center) { 545c6afe76dfe641afa32dab6e0b4740d780072d2c6Fabrice Di Meglio mDelegate.setDate(date, animate, center); 546c6afe76dfe641afa32dab6e0b4740d780072d2c6Fabrice Di Meglio } 547c6afe76dfe641afa32dab6e0b4740d780072d2c6Fabrice Di Meglio 548c6afe76dfe641afa32dab6e0b4740d780072d2c6Fabrice Di Meglio @Override 549c6afe76dfe641afa32dab6e0b4740d780072d2c6Fabrice Di Meglio protected void onConfigurationChanged(Configuration newConfig) { 550c6afe76dfe641afa32dab6e0b4740d780072d2c6Fabrice Di Meglio super.onConfigurationChanged(newConfig); 551c6afe76dfe641afa32dab6e0b4740d780072d2c6Fabrice Di Meglio mDelegate.onConfigurationChanged(newConfig); 552e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov } 553e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov 554c6afe76dfe641afa32dab6e0b4740d780072d2c6Fabrice Di Meglio @Override 555a7bb6fbeab933326d58aa806d8194b7b13239d34Dianne Hackborn public CharSequence getAccessibilityClassName() { 556a7bb6fbeab933326d58aa806d8194b7b13239d34Dianne Hackborn return CalendarView.class.getName(); 557ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov } 558ff37505cb13f96ddec09594517ad6f4fa2fd1defSvetoslav Ganov 559e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov /** 560c6afe76dfe641afa32dab6e0b4740d780072d2c6Fabrice Di Meglio * A delegate interface that defined the public API of the CalendarView. Allows different 561c6afe76dfe641afa32dab6e0b4740d780072d2c6Fabrice Di Meglio * CalendarView implementations. This would need to be implemented by the CalendarView delegates 562c6afe76dfe641afa32dab6e0b4740d780072d2c6Fabrice Di Meglio * for the real behavior. 563f5926962cc665d4a2e6464f9ba9e3e9788496a6fSvetoslav Ganov */ 564c6afe76dfe641afa32dab6e0b4740d780072d2c6Fabrice Di Meglio private interface CalendarViewDelegate { 565c6afe76dfe641afa32dab6e0b4740d780072d2c6Fabrice Di Meglio void setShownWeekCount(int count); 566c6afe76dfe641afa32dab6e0b4740d780072d2c6Fabrice Di Meglio int getShownWeekCount(); 567f5926962cc665d4a2e6464f9ba9e3e9788496a6fSvetoslav Ganov 5680ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette void setSelectedWeekBackgroundColor(@ColorInt int color); 569b097321719e5a657ffa5f0db775a0fa03aaf42cdAlan Viverette @ColorInt int getSelectedWeekBackgroundColor(); 570f5926962cc665d4a2e6464f9ba9e3e9788496a6fSvetoslav Ganov 5710ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette void setFocusedMonthDateColor(@ColorInt int color); 572b097321719e5a657ffa5f0db775a0fa03aaf42cdAlan Viverette @ColorInt int getFocusedMonthDateColor(); 573f5926962cc665d4a2e6464f9ba9e3e9788496a6fSvetoslav Ganov 5740ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette void setUnfocusedMonthDateColor(@ColorInt int color); 575b097321719e5a657ffa5f0db775a0fa03aaf42cdAlan Viverette @ColorInt int getUnfocusedMonthDateColor(); 576f5926962cc665d4a2e6464f9ba9e3e9788496a6fSvetoslav Ganov 5770ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette void setWeekNumberColor(@ColorInt int color); 578b097321719e5a657ffa5f0db775a0fa03aaf42cdAlan Viverette @ColorInt int getWeekNumberColor(); 579e9730bf3d2dcbea1879f24c18aaf9810ac57084cSvetoslav Ganov 5800ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette void setWeekSeparatorLineColor(@ColorInt int color); 581b097321719e5a657ffa5f0db775a0fa03aaf42cdAlan Viverette @ColorInt int getWeekSeparatorLineColor(); 58250f34d14f6dd3411fdbdb6a7b8b285c2b8fdbf5cSvetoslav Ganov 5830ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette void setSelectedDateVerticalBar(@DrawableRes int resourceId); 584c6afe76dfe641afa32dab6e0b4740d780072d2c6Fabrice Di Meglio void setSelectedDateVerticalBar(Drawable drawable); 585c6afe76dfe641afa32dab6e0b4740d780072d2c6Fabrice Di Meglio Drawable getSelectedDateVerticalBar(); 58650f34d14f6dd3411fdbdb6a7b8b285c2b8fdbf5cSvetoslav Ganov 5870ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette void setWeekDayTextAppearance(@StyleRes int resourceId); 588b097321719e5a657ffa5f0db775a0fa03aaf42cdAlan Viverette @StyleRes int getWeekDayTextAppearance(); 58950f34d14f6dd3411fdbdb6a7b8b285c2b8fdbf5cSvetoslav Ganov 5900ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette void setDateTextAppearance(@StyleRes int resourceId); 591b097321719e5a657ffa5f0db775a0fa03aaf42cdAlan Viverette @StyleRes int getDateTextAppearance(); 592c6afe76dfe641afa32dab6e0b4740d780072d2c6Fabrice Di Meglio 593c6afe76dfe641afa32dab6e0b4740d780072d2c6Fabrice Di Meglio void setMinDate(long minDate); 594c6afe76dfe641afa32dab6e0b4740d780072d2c6Fabrice Di Meglio long getMinDate(); 595c6afe76dfe641afa32dab6e0b4740d780072d2c6Fabrice Di Meglio 596c6afe76dfe641afa32dab6e0b4740d780072d2c6Fabrice Di Meglio void setMaxDate(long maxDate); 597c6afe76dfe641afa32dab6e0b4740d780072d2c6Fabrice Di Meglio long getMaxDate(); 598c6afe76dfe641afa32dab6e0b4740d780072d2c6Fabrice Di Meglio 599c6afe76dfe641afa32dab6e0b4740d780072d2c6Fabrice Di Meglio void setShowWeekNumber(boolean showWeekNumber); 600c6afe76dfe641afa32dab6e0b4740d780072d2c6Fabrice Di Meglio boolean getShowWeekNumber(); 601c6afe76dfe641afa32dab6e0b4740d780072d2c6Fabrice Di Meglio 602c6afe76dfe641afa32dab6e0b4740d780072d2c6Fabrice Di Meglio void setFirstDayOfWeek(int firstDayOfWeek); 603c6afe76dfe641afa32dab6e0b4740d780072d2c6Fabrice Di Meglio int getFirstDayOfWeek(); 604c6afe76dfe641afa32dab6e0b4740d780072d2c6Fabrice Di Meglio 605c6afe76dfe641afa32dab6e0b4740d780072d2c6Fabrice Di Meglio void setDate(long date); 606c6afe76dfe641afa32dab6e0b4740d780072d2c6Fabrice Di Meglio void setDate(long date, boolean animate, boolean center); 607c6afe76dfe641afa32dab6e0b4740d780072d2c6Fabrice Di Meglio long getDate(); 608c6afe76dfe641afa32dab6e0b4740d780072d2c6Fabrice Di Meglio 609c6afe76dfe641afa32dab6e0b4740d780072d2c6Fabrice Di Meglio void setOnDateChangeListener(OnDateChangeListener listener); 610c6afe76dfe641afa32dab6e0b4740d780072d2c6Fabrice Di Meglio 611c6afe76dfe641afa32dab6e0b4740d780072d2c6Fabrice Di Meglio void onConfigurationChanged(Configuration newConfig); 61250f34d14f6dd3411fdbdb6a7b8b285c2b8fdbf5cSvetoslav Ganov } 61350f34d14f6dd3411fdbdb6a7b8b285c2b8fdbf5cSvetoslav Ganov 61450f34d14f6dd3411fdbdb6a7b8b285c2b8fdbf5cSvetoslav Ganov /** 615c6afe76dfe641afa32dab6e0b4740d780072d2c6Fabrice Di Meglio * An abstract class which can be used as a start for CalendarView implementations 61650f34d14f6dd3411fdbdb6a7b8b285c2b8fdbf5cSvetoslav Ganov */ 617c6afe76dfe641afa32dab6e0b4740d780072d2c6Fabrice Di Meglio abstract static class AbstractCalendarViewDelegate implements CalendarViewDelegate { 6184612740ddc76b3518dc6d189d5f8b5b7f60e9d64Alan Viverette /** The default minimal date. */ 6194612740ddc76b3518dc6d189d5f8b5b7f60e9d64Alan Viverette protected static final String DEFAULT_MIN_DATE = "01/01/1900"; 6204612740ddc76b3518dc6d189d5f8b5b7f60e9d64Alan Viverette 6214612740ddc76b3518dc6d189d5f8b5b7f60e9d64Alan Viverette /** The default maximal date. */ 6224612740ddc76b3518dc6d189d5f8b5b7f60e9d64Alan Viverette protected static final String DEFAULT_MAX_DATE = "01/01/2100"; 62350f34d14f6dd3411fdbdb6a7b8b285c2b8fdbf5cSvetoslav Ganov 6244612740ddc76b3518dc6d189d5f8b5b7f60e9d64Alan Viverette protected CalendarView mDelegator; 6254612740ddc76b3518dc6d189d5f8b5b7f60e9d64Alan Viverette protected Context mContext; 626c6afe76dfe641afa32dab6e0b4740d780072d2c6Fabrice Di Meglio protected Locale mCurrentLocale; 627156f20919b3d5f298f8851215adbf65f8b4dc61bSvetoslav Ganov 628c6afe76dfe641afa32dab6e0b4740d780072d2c6Fabrice Di Meglio AbstractCalendarViewDelegate(CalendarView delegator, Context context) { 629c6afe76dfe641afa32dab6e0b4740d780072d2c6Fabrice Di Meglio mDelegator = delegator; 630c6afe76dfe641afa32dab6e0b4740d780072d2c6Fabrice Di Meglio mContext = context; 63150f34d14f6dd3411fdbdb6a7b8b285c2b8fdbf5cSvetoslav Ganov 632c6afe76dfe641afa32dab6e0b4740d780072d2c6Fabrice Di Meglio // Initialization based on locale 633c6afe76dfe641afa32dab6e0b4740d780072d2c6Fabrice Di Meglio setCurrentLocale(Locale.getDefault()); 634c6afe76dfe641afa32dab6e0b4740d780072d2c6Fabrice Di Meglio } 635c6afe76dfe641afa32dab6e0b4740d780072d2c6Fabrice Di Meglio 636c6afe76dfe641afa32dab6e0b4740d780072d2c6Fabrice Di Meglio protected void setCurrentLocale(Locale locale) { 637c6afe76dfe641afa32dab6e0b4740d780072d2c6Fabrice Di Meglio if (locale.equals(mCurrentLocale)) { 638c6afe76dfe641afa32dab6e0b4740d780072d2c6Fabrice Di Meglio return; 63950f34d14f6dd3411fdbdb6a7b8b285c2b8fdbf5cSvetoslav Ganov } 640c6afe76dfe641afa32dab6e0b4740d780072d2c6Fabrice Di Meglio mCurrentLocale = locale; 64150f34d14f6dd3411fdbdb6a7b8b285c2b8fdbf5cSvetoslav Ganov } 64250f34d14f6dd3411fdbdb6a7b8b285c2b8fdbf5cSvetoslav Ganov 6430ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette @Override 6440ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette public void setShownWeekCount(int count) { 6450ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette // Deprecated. 6460ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette } 6470ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette 6480ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette @Override 6490ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette public int getShownWeekCount() { 6500ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette // Deprecated. 6510ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette return 0; 6520ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette } 6530ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette 6540ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette @Override 6550ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette public void setSelectedWeekBackgroundColor(@ColorInt int color) { 6560ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette // Deprecated. 6570ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette } 6580ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette 6590ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette @ColorInt 6600ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette @Override 6610ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette public int getSelectedWeekBackgroundColor() { 6620ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette return 0; 6630ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette } 6640ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette 6650ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette @Override 6660ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette public void setFocusedMonthDateColor(@ColorInt int color) { 6670ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette // Deprecated. 6680ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette } 6690ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette 6700ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette @ColorInt 6710ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette @Override 6720ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette public int getFocusedMonthDateColor() { 6730ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette return 0; 6740ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette } 6750ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette 6760ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette @Override 6770ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette public void setUnfocusedMonthDateColor(@ColorInt int color) { 6780ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette // Deprecated. 6790ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette } 6800ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette 6810ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette @ColorInt 6820ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette @Override 6830ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette public int getUnfocusedMonthDateColor() { 6840ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette return 0; 6850ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette } 6860ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette 6870ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette @Override 6880ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette public void setWeekNumberColor(@ColorInt int color) { 6890ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette // Deprecated. 6900ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette } 6910ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette 6920ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette @ColorInt 6930ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette @Override 6940ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette public int getWeekNumberColor() { 6950ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette // Deprecated. 6960ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette return 0; 6970ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette } 6980ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette 6990ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette @Override 7000ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette public void setWeekSeparatorLineColor(@ColorInt int color) { 7010ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette // Deprecated. 7020ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette } 7030ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette 7040ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette @ColorInt 7050ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette @Override 7060ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette public int getWeekSeparatorLineColor() { 7070ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette // Deprecated. 7080ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette return 0; 7090ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette } 7100ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette 7110ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette @Override 7120ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette public void setSelectedDateVerticalBar(@DrawableRes int resId) { 7130ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette // Deprecated. 7140ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette } 7150ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette 7160ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette @Override 7170ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette public void setSelectedDateVerticalBar(Drawable drawable) { 7180ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette // Deprecated. 7190ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette } 7200ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette 7210ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette @Override 7220ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette public Drawable getSelectedDateVerticalBar() { 7230ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette // Deprecated. 7240ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette return null; 7250ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette } 7260ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette 7270ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette @Override 7280ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette public void setShowWeekNumber(boolean showWeekNumber) { 7290ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette // Deprecated. 7300ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette } 7310ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette 7320ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette @Override 7330ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette public boolean getShowWeekNumber() { 7340ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette // Deprecated. 7350ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette return false; 7360ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette } 7370ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette 7380ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette @Override 7390ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette public void onConfigurationChanged(Configuration newConfig) { 7400ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette // Nothing to do here, configuration changes are already propagated 7410ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette // by ViewGroup. 74250f34d14f6dd3411fdbdb6a7b8b285c2b8fdbf5cSvetoslav Ganov } 74350f34d14f6dd3411fdbdb6a7b8b285c2b8fdbf5cSvetoslav Ganov } 744c6afe76dfe641afa32dab6e0b4740d780072d2c6Fabrice Di Meglio 7450ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette /** String for parsing dates. */ 7460ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette private static final String DATE_FORMAT = "MM/dd/yyyy"; 7470ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette 7480ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette /** Date format for parsing dates. */ 7490ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette private static final DateFormat DATE_FORMATTER = new SimpleDateFormat(DATE_FORMAT); 7500ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette 7510ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette /** 7520ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette * Utility method for the date format used by CalendarView's min/max date. 7530ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette * 7540ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette * @hide Use only as directed. For internal use only. 7550ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette */ 7560ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette public static boolean parseDate(String date, Calendar outDate) { 7570ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette if (date == null || date.isEmpty()) { 7580ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette return false; 7590ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette } 7600ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette 7610ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette try { 7620ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette final Date parsedDate = DATE_FORMATTER.parse(date); 7630ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette outDate.setTime(parsedDate); 7640ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette return true; 7650ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette } catch (ParseException e) { 7660ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette Log.w(LOG_TAG, "Date: " + date + " not in format: " + DATE_FORMAT); 7670ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette return false; 7680ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette } 7690ef59ac0e57e9b99d174d4a53f7d9639357743acAlan Viverette } 77050f34d14f6dd3411fdbdb6a7b8b285c2b8fdbf5cSvetoslav Ganov} 771