diff --git a/library/build.gradle b/library/build.gradle index 52ddc7af..b82e1975 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -11,6 +11,8 @@ android { versionCode Integer.parseInt(project.VERSION_CODE) versionName project.VERSION_NAME + + vectorDrawables.useSupportLibrary = true } lintOptions { diff --git a/library/src/main/java/com/prolificinteractive/materialcalendarview/DirectionButton.java b/library/src/main/java/com/prolificinteractive/materialcalendarview/DirectionButton.java index 9c9fffc7..0a96ca02 100644 --- a/library/src/main/java/com/prolificinteractive/materialcalendarview/DirectionButton.java +++ b/library/src/main/java/com/prolificinteractive/materialcalendarview/DirectionButton.java @@ -1,16 +1,15 @@ package com.prolificinteractive.materialcalendarview; import android.content.Context; -import android.graphics.PorterDuff; import android.os.Build; +import android.support.v7.widget.AppCompatImageView; import android.util.TypedValue; -import android.widget.ImageView; /** * An {@linkplain android.widget.ImageView} to pragmatically set the color of arrows * using a {@linkplain android.graphics.ColorFilter} */ -class DirectionButton extends ImageView { +class DirectionButton extends AppCompatImageView { public DirectionButton(Context context) { super(context); @@ -18,10 +17,6 @@ public DirectionButton(Context context) { setBackgroundResource(getThemeSelectableBackgroundId(context)); } - public void setColor(int color) { - setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - } - @Override public void setEnabled(boolean enabled) { super.setEnabled(enabled); diff --git a/library/src/main/java/com/prolificinteractive/materialcalendarview/MaterialCalendarView.java b/library/src/main/java/com/prolificinteractive/materialcalendarview/MaterialCalendarView.java index 2bd7037f..23b688f8 100644 --- a/library/src/main/java/com/prolificinteractive/materialcalendarview/MaterialCalendarView.java +++ b/library/src/main/java/com/prolificinteractive/materialcalendarview/MaterialCalendarView.java @@ -9,6 +9,7 @@ import android.os.Parcel; import android.os.Parcelable; import android.support.annotation.ArrayRes; +import android.support.annotation.DrawableRes; import android.support.annotation.IntDef; import android.support.annotation.NonNull; import android.support.annotation.Nullable; @@ -229,9 +230,6 @@ public void onPageScrolled(int position, float positionOffset, int positionOffse CharSequence calendarContentDescription; private int accentColor = 0; - private int arrowColor = Color.BLACK; - private Drawable leftArrowMask; - private Drawable rightArrowMask; private int tileHeight = INVALID_TILE_DIMENSION; private int tileWidth = INVALID_TILE_DIMENSION; @SelectionMode @@ -341,24 +339,18 @@ public void transformPage(View page, float position) { setTileHeight(tileHeight); } - setArrowColor(a.getColor( - R.styleable.MaterialCalendarView_mcv_arrowColor, - Color.BLACK - )); - Drawable leftMask = a.getDrawable( - R.styleable.MaterialCalendarView_mcv_leftArrowMask + setLeftArrow( + a.getResourceId( + R.styleable.MaterialCalendarView_mcv_leftArrowMask, + R.drawable.mcv_action_previous + ) ); - if (leftMask == null) { - leftMask = getResources().getDrawable(R.drawable.mcv_action_previous); - } - setLeftArrowMask(leftMask); - Drawable rightMask = a.getDrawable( - R.styleable.MaterialCalendarView_mcv_rightArrowMask + setRightArrow( + a.getResourceId( + R.styleable.MaterialCalendarView_mcv_rightArrowMask, + R.drawable.mcv_action_next + ) ); - if (rightMask == null) { - rightMask = getResources().getDrawable(R.drawable.mcv_action_next); - } - setRightArrowMask(rightMask); setSelectionColor( a.getColor( @@ -671,26 +663,6 @@ public void setSelectionColor(int color) { invalidate(); } - /** - * @return color used to draw arrows - */ - public int getArrowColor() { - return arrowColor; - } - - /** - * @param color the new color for the paging arrows - */ - public void setArrowColor(int color) { - if (color == 0) { - return; - } - arrowColor = color; - buttonPast.setColor(color); - buttonFuture.setColor(color); - invalidate(); - } - /** * Set content description for button past * @@ -741,31 +713,29 @@ public void setDayFormatterContentDescription(DayFormatter formatter) { /** * @return icon used for the left arrow */ - public Drawable getLeftArrowMask() { - return leftArrowMask; + public Drawable getLeftArrow() { + return buttonPast.getDrawable(); } /** * @param icon the new icon to use for the left paging arrow */ - public void setLeftArrowMask(Drawable icon) { - leftArrowMask = icon; - buttonPast.setImageDrawable(icon); + public void setLeftArrow(@DrawableRes final int icon) { + buttonPast.setImageResource(icon); } /** * @return icon used for the right arrow */ - public Drawable getRightArrowMask() { - return rightArrowMask; + public Drawable getRightArrow() { + return buttonFuture.getDrawable(); } /** * @param icon the new icon to use for the right paging arrow */ - public void setRightArrowMask(Drawable icon) { - rightArrowMask = icon; - buttonFuture.setImageDrawable(icon); + public void setRightArrow(@DrawableRes final int icon) { + buttonFuture.setImageResource(icon); } /** diff --git a/library/src/main/res/drawable-xxxhdpi/mcv_action_next.png b/library/src/main/res/drawable-xxxhdpi/mcv_action_next.png deleted file mode 100644 index 9a8e5a80..00000000 Binary files a/library/src/main/res/drawable-xxxhdpi/mcv_action_next.png and /dev/null differ diff --git a/library/src/main/res/drawable-xxxhdpi/mcv_action_previous.png b/library/src/main/res/drawable-xxxhdpi/mcv_action_previous.png deleted file mode 100644 index bce26481..00000000 Binary files a/library/src/main/res/drawable-xxxhdpi/mcv_action_previous.png and /dev/null differ diff --git a/library/src/main/res/drawable/mcv_action_next.xml b/library/src/main/res/drawable/mcv_action_next.xml new file mode 100644 index 00000000..9080087f --- /dev/null +++ b/library/src/main/res/drawable/mcv_action_next.xml @@ -0,0 +1,11 @@ + + + diff --git a/library/src/main/res/drawable/mcv_action_previous.xml b/library/src/main/res/drawable/mcv_action_previous.xml new file mode 100644 index 00000000..0b624e03 --- /dev/null +++ b/library/src/main/res/drawable/mcv_action_previous.xml @@ -0,0 +1,11 @@ + + + diff --git a/sample/src/main/java/com/prolificinteractive/materialcalendarview/sample/CustomizeCodeActivity.java b/sample/src/main/java/com/prolificinteractive/materialcalendarview/sample/CustomizeCodeActivity.java index 3bf897b2..2cdbda24 100644 --- a/sample/src/main/java/com/prolificinteractive/materialcalendarview/sample/CustomizeCodeActivity.java +++ b/sample/src/main/java/com/prolificinteractive/materialcalendarview/sample/CustomizeCodeActivity.java @@ -24,9 +24,8 @@ protected void onCreate(Bundle savedInstanceState) { ButterKnife.bind(this); widget.setShowOtherDates(MaterialCalendarView.SHOW_ALL); - widget.setArrowColor(getResources().getColor(R.color.sample_primary)); - widget.setLeftArrowMask(getResources().getDrawable(R.drawable.ic_navigation_arrow_back)); - widget.setRightArrowMask(getResources().getDrawable(R.drawable.ic_navigation_arrow_forward)); + widget.setLeftArrow(R.drawable.ic_arrow_back); + widget.setRightArrow(R.drawable.ic_arrow_forward); widget.setSelectionColor(getResources().getColor(R.color.sample_primary)); widget.setWeekDayTextAppearance(R.style.CustomTextAppearance); widget.setHeaderTextAppearance(R.style.CustomTextAppearance); diff --git a/sample/src/main/java/com/prolificinteractive/materialcalendarview/sample/DynamicSettersActivity.java b/sample/src/main/java/com/prolificinteractive/materialcalendarview/sample/DynamicSettersActivity.java index f0f3c722..516cdd37 100644 --- a/sample/src/main/java/com/prolificinteractive/materialcalendarview/sample/DynamicSettersActivity.java +++ b/sample/src/main/java/com/prolificinteractive/materialcalendarview/sample/DynamicSettersActivity.java @@ -196,7 +196,6 @@ void onColorsClicked() { 1f, 0.75f }); - widget.setArrowColor(color); widget.setSelectionColor(color); } diff --git a/sample/src/main/res/drawable-hdpi/ic_navigation_arrow_back.png b/sample/src/main/res/drawable-hdpi/ic_navigation_arrow_back.png deleted file mode 100755 index 50858679..00000000 Binary files a/sample/src/main/res/drawable-hdpi/ic_navigation_arrow_back.png and /dev/null differ diff --git a/sample/src/main/res/drawable-hdpi/ic_navigation_arrow_forward.png b/sample/src/main/res/drawable-hdpi/ic_navigation_arrow_forward.png deleted file mode 100755 index db50f5b0..00000000 Binary files a/sample/src/main/res/drawable-hdpi/ic_navigation_arrow_forward.png and /dev/null differ diff --git a/sample/src/main/res/drawable-mdpi/ic_navigation_arrow_back.png b/sample/src/main/res/drawable-mdpi/ic_navigation_arrow_back.png deleted file mode 100755 index bc5b848f..00000000 Binary files a/sample/src/main/res/drawable-mdpi/ic_navigation_arrow_back.png and /dev/null differ diff --git a/sample/src/main/res/drawable-mdpi/ic_navigation_arrow_forward.png b/sample/src/main/res/drawable-mdpi/ic_navigation_arrow_forward.png deleted file mode 100755 index 93dc0d48..00000000 Binary files a/sample/src/main/res/drawable-mdpi/ic_navigation_arrow_forward.png and /dev/null differ diff --git a/sample/src/main/res/drawable-xhdpi/ic_navigation_arrow_back.png b/sample/src/main/res/drawable-xhdpi/ic_navigation_arrow_back.png deleted file mode 100755 index 54f15779..00000000 Binary files a/sample/src/main/res/drawable-xhdpi/ic_navigation_arrow_back.png and /dev/null differ diff --git a/sample/src/main/res/drawable-xhdpi/ic_navigation_arrow_forward.png b/sample/src/main/res/drawable-xhdpi/ic_navigation_arrow_forward.png deleted file mode 100755 index 5b4b5c6e..00000000 Binary files a/sample/src/main/res/drawable-xhdpi/ic_navigation_arrow_forward.png and /dev/null differ diff --git a/sample/src/main/res/drawable-xxhdpi/ic_navigation_arrow_back.png b/sample/src/main/res/drawable-xxhdpi/ic_navigation_arrow_back.png deleted file mode 100755 index b8f0584d..00000000 Binary files a/sample/src/main/res/drawable-xxhdpi/ic_navigation_arrow_back.png and /dev/null differ diff --git a/sample/src/main/res/drawable-xxhdpi/ic_navigation_arrow_forward.png b/sample/src/main/res/drawable-xxhdpi/ic_navigation_arrow_forward.png deleted file mode 100755 index 36c399ec..00000000 Binary files a/sample/src/main/res/drawable-xxhdpi/ic_navigation_arrow_forward.png and /dev/null differ diff --git a/sample/src/main/res/drawable/ic_arrow_back.xml b/sample/src/main/res/drawable/ic_arrow_back.xml new file mode 100644 index 00000000..031f901d --- /dev/null +++ b/sample/src/main/res/drawable/ic_arrow_back.xml @@ -0,0 +1,11 @@ + + + diff --git a/sample/src/main/res/drawable/ic_arrow_forward.xml b/sample/src/main/res/drawable/ic_arrow_forward.xml new file mode 100644 index 00000000..60f93ad7 --- /dev/null +++ b/sample/src/main/res/drawable/ic_arrow_forward.xml @@ -0,0 +1,11 @@ + + + diff --git a/sample/src/main/res/layout/activity_customization.xml b/sample/src/main/res/layout/activity_customization.xml index 42a3f022..55568a2d 100644 --- a/sample/src/main/res/layout/activity_customization.xml +++ b/sample/src/main/res/layout/activity_customization.xml @@ -1,13 +1,13 @@ @@ -15,20 +15,20 @@ android:id="@+id/calendarView" android:layout_width="match_parent" android:layout_height="wrap_content" - app:mcv_showOtherDates="all" app:mcv_arrowColor="?attr/colorPrimary" - app:mcv_leftArrowMask="@drawable/ic_navigation_arrow_back" - app:mcv_rightArrowMask="@drawable/ic_navigation_arrow_forward" - app:mcv_selectionColor="?attr/colorPrimary" - app:mcv_headerTextAppearance="@style/CustomTextAppearance" + app:mcv_calendarMode="week" app:mcv_dateTextAppearance="@style/CustomTextAppearance" - app:mcv_weekDayTextAppearance="@style/CustomTextAppearance" - app:mcv_weekDayLabels="@array/custom_weekdays" + app:mcv_firstDayOfWeek="thursday" + app:mcv_headerTextAppearance="@style/CustomTextAppearance" + app:mcv_leftArrowMask="@drawable/ic_arrow_back" app:mcv_monthLabels="@array/custom_months" + app:mcv_rightArrowMask="@drawable/ic_arrow_forward" + app:mcv_selectionColor="?attr/colorPrimary" + app:mcv_showOtherDates="all" app:mcv_tileSize="36dp" - app:mcv_firstDayOfWeek="thursday" - app:mcv_calendarMode="week" app:mcv_titleAnimationOrientation="vertical" + app:mcv_weekDayLabels="@array/custom_weekdays" + app:mcv_weekDayTextAppearance="@style/CustomTextAppearance" />