From 5f39050f26e4b2e5bbb47e6d22498a4f1e112fc1 Mon Sep 17 00:00:00 2001 From: Quentin Colle Date: Mon, 6 Aug 2018 16:51:39 -0400 Subject: [PATCH] Feature - Vectors (#840) --- library/build.gradle | 2 + .../materialcalendarview/DirectionButton.java | 9 +-- .../MaterialCalendarView.java | 68 +++++------------- .../res/drawable-xxxhdpi/mcv_action_next.png | Bin 518 -> 0 bytes .../drawable-xxxhdpi/mcv_action_previous.png | Bin 522 -> 0 bytes .../src/main/res/drawable/mcv_action_next.xml | 11 +++ .../main/res/drawable/mcv_action_previous.xml | 11 +++ .../sample/CustomizeCodeActivity.java | 5 +- .../sample/DynamicSettersActivity.java | 1 - .../ic_navigation_arrow_back.png | Bin 402 -> 0 bytes .../ic_navigation_arrow_forward.png | Bin 395 -> 0 bytes .../ic_navigation_arrow_back.png | Bin 276 -> 0 bytes .../ic_navigation_arrow_forward.png | Bin 266 -> 0 bytes .../ic_navigation_arrow_back.png | Bin 504 -> 0 bytes .../ic_navigation_arrow_forward.png | Bin 502 -> 0 bytes .../ic_navigation_arrow_back.png | Bin 758 -> 0 bytes .../ic_navigation_arrow_forward.png | Bin 742 -> 0 bytes .../src/main/res/drawable/ic_arrow_back.xml | 11 +++ .../main/res/drawable/ic_arrow_forward.xml | 11 +++ .../res/layout/activity_customization.xml | 24 +++---- 20 files changed, 81 insertions(+), 72 deletions(-) delete mode 100644 library/src/main/res/drawable-xxxhdpi/mcv_action_next.png delete mode 100644 library/src/main/res/drawable-xxxhdpi/mcv_action_previous.png create mode 100644 library/src/main/res/drawable/mcv_action_next.xml create mode 100644 library/src/main/res/drawable/mcv_action_previous.xml delete mode 100755 sample/src/main/res/drawable-hdpi/ic_navigation_arrow_back.png delete mode 100755 sample/src/main/res/drawable-hdpi/ic_navigation_arrow_forward.png delete mode 100755 sample/src/main/res/drawable-mdpi/ic_navigation_arrow_back.png delete mode 100755 sample/src/main/res/drawable-mdpi/ic_navigation_arrow_forward.png delete mode 100755 sample/src/main/res/drawable-xhdpi/ic_navigation_arrow_back.png delete mode 100755 sample/src/main/res/drawable-xhdpi/ic_navigation_arrow_forward.png delete mode 100755 sample/src/main/res/drawable-xxhdpi/ic_navigation_arrow_back.png delete mode 100755 sample/src/main/res/drawable-xxhdpi/ic_navigation_arrow_forward.png create mode 100644 sample/src/main/res/drawable/ic_arrow_back.xml create mode 100644 sample/src/main/res/drawable/ic_arrow_forward.xml 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 9a8e5a801822843b824ed1cf64e685aeb7edfb3e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 518 zcmV+h0{Q)kP)@<#B@GW;9a;pTWX7&tr^PdroUho zGZdff#WeF7O0bLn_yW5!M8B`e$1t!SE)s&@WbpeC{GfmzW$=d$_~Q`#ferpl0e|X& zKbOH@9Kc^~z&0Fb2#e=KEq#L3(uZ~}ou_E&)J#ifqsq;f$q9JS?#?i5hjS$Uiae!! zix1!dd<+mvm$T&ST=LenQg#8;AsK+FkSxG7NG4zkBpZ+pnE^u9n{J@iB{f=weo33E1w6+XKF5B zLRP{9Ov>vxfQgy$K49|Q!X9Ay#m5fd18^z#^5=f=0RA_?AJtN7U1}#N*Z=?k07*qo IM6N<$g1XxBwg3PC 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 bce2648176a8b6b171f0476dc895b71e19546ae9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 522 zcmV+l0`>igP)_H2WL;tE_&9+MG=r8TQzs--``K8APG>pw~sQtN%xy{SJM6O)boUXN6_#6 zc^i80U>s2i9+8~0s}v7NBc$@9tJ)QHT9t^F7@?h0-mxq8pU1c-qY#qxS&JM=)-}l( zNj4ba>LJ^Rr~DH`w1+RlPO;eK4Gx$(9%AYgfT^<{`sQWlL_e}K8jkHuhMb)#jq<4m z^zjh<11$JQZ17J3;Ga{#KS_aq)&u`E3jTQ+{1ZL+pB%vdC<5Mw0!#g23C@xD)G6sl zd;kw%N_Q&{!140P-c~X22QTRzL~d zHb5!d7C;SLIG`3T6wm?}255x~oI%VEXon2m#h4vX54kCmV0J(` + + 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 50858679858085c3203c7d569cf205b12c1cf438..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 402 zcmV;D0d4+?P)$w0Way!0{z8t!cMre33y3&7N}oZUeaFDolRhqB|S~kJ%B5cyX<+UgOAw9BlMYM z!KYoR;4^GNz5}=>`H>|~12152N$#_-<#STND%cdT61F*54cio~h;0T|#Wn#eW5dBS z*mC5&065ehJtQA$YlMPluo3-z*B}{kgoYF;T@43bK=-?(Pit?em)3tkhwb6>Hds$;x_3S3#RUHQ3Y;f>E<;po>xk!Q=a>Bs_l`H3jP`PqWST2&_hK5V{3*>=_Jt1+y*#H0l07*qoM6N<$f)4+x@Bjb+ 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 db50f5b07dd9a8b3706fac1e21352ff101093491..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 395 zcmV;60d)R}P)BWTp!m(i+UaSL-^kPE&({iL8>BTxAi8RT#-pAJ3OLafXfd}mK0DZ59E(Ioe z2jCmP)0x>)=u+SgN%9`RhYGqJSPd-!Rzk~w&!E2mJXU?vQs4po0N}Fb9dCcpMV?1>W)25=5_Rh`7}tzaVK8aUFWnQLr#W_yvj+i;{yGuPPg%=RL4x8X>aX0EZ} pne9d9Zo`o-&0J%{Guw;I{Rc7=c0DddW@!Kb002ovPDHLkV1l7rv(Eqk 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 bc5b848f849150b0b783aee6a43c8b5f7f1dd80d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 276 zcmV+v0qg#WP)MBLIsjd^N@NYVyeA@ft0|7tAD3bcrdO#-N<8VN>%Y69wfbTATB6Hw=; a@8B0-7g#CKRL%SV00007<@zaPnF&OheD9KzlgXoD^3f*eLjctsioqCE4XFLe zU<|4T)P8FQNnRG9*4kMG`}ErYN$vnV0c-(WU63}wWyK`-03J?AE8qx7JKzd=0C0Dh z90IsP9s%4`$YFpk$TA>F3Rg(^bpIb<#U4pHhh>AkfDX9#tJFJTrHToepDU_AyomVvNyy zn0d2WNZtFjatWi1pg!+|6&0Ec?#H;APRYWbed_sJ~qM%~h^4R^x%_k^Z1lT|eYHgFnA1IB-!gn4zy{23tYM zk&p&urDe=}ntmv}T>9+jz0b3zG}J4|sm`rBbj40v_W|2Sw@b-y8>`}{OKmVeHt#v( l4)@&6j6?+z-cbF=di>Ugz!v7e2Z1rl;OXk;vd$@?2>?Vv&7=ST 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 5b4b5c6ecd14d70ecdea3f6b9c1f3bb9b0db908e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 502 zcmeAS@N?(olHy`uVBq!ia0vp^0U*r51|<6gKdoh8VBG8J;uum9_x9F7ufqW%Ee|KR zzW!y9b>F98A$Mz2{}Q`99;aeOMP@0Uo%5mmZsyMT=S7!h`y4$jG-Hj)L#7Klj13I4 zn9}C3F=cSgD3sz@pqX$iQ=ws5gXHo?q9k^tJ9xhT{A*cemGSkRQ8wEenctVL`J*gq zC=_tXJ9MsImT>0`t{)Mh_d`qP_epSCEcVQ5l;FO>YACgVImsr$DvA3*;|~+I(~6lJ zwlKR_04 zJNbOW>h14qZe;&sn0-t&w=VInm;vMZT;|{pQA}zNw=(-2&SurlheKSkGASvRn``cx)oz5PYELvIB!J jqp=?|Q4$we{;+;}HZRa>o>LkyJ{de+{an^LB{Ts508`Cy 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 b8f0584dda428f03bb7bd2f2370088819649dbb3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 758 zcmeAS@N?(olHy`uVBq!ia0vp^6(G#P1|%(0%q}r7FzxkpaSW-5dwVC)>#&1J>%*N2 zI~2?p+!o?)VijMhz+w0M0h89mX<@U?j5VF!+3!E^Sat5Yac-7jm;DPirn%<|ToZmw zc1UP^$a~=NPC8PSyg6pG+k;M(x~#ESc~1Rh+QH~M%X4L4$4%JH@UMAy^{Mj49(KFN z-OhD=9o3%-d)ek4kd3+TrD-ns(bM%9Q~0BMZbz&|%TKhjh?W1Ja+IALcA)^#p* zckij!UkN|7%gD4q^^>>eQ$3|!E`IzvpMDCnGwOWGOySvZ;_(TMgo*tV3lAv$cXMOv z-s66Z$y|Z|zuU|1((ku93s^sCDP0S>qbOc=P`Ezp$m23*n@vyj3U)KuIqd7|aR0Qi yX2#lX{FPNq;vR#|JZ}0@_sp-jadq(RT^0*W&kUZfelF{r5}E)9vP~2K 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 36c399ece6a6b9ebcbdb4abf146f493198d5b8b6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 742 zcmeAS@N?(olHy`uVBq!ia0vp^6(G#P1|%(0%q}r7Fs=1;aSW-5dwb`g*Xslk*N2lQ zD%Uc)27J&hUGjdZ#kF)RA>Tl+UM0tW>-NsM=l%Zf@6&m+XOwBxU*Pq5QPQT}_>jHv z0MlXVhU3Kt=|>eyy?FQA@~nw(`J9l~o=IYR9^BI_wOOLz&hY->JHDSBDK;O>cNm_? zc<|0{^{VNsc12b$b<&sQwOL&Dy)x8xnbPCN%M+CwCQnRm2%fmOL3rZhhRYL_8z)al zZWMpgy{c;6D(zR5MJ6AbY9d4ZL!MM5SZz9Ry12MpdAiPr>EiK9n+{aJUzc%$NxtH@ zkCWJs*`JlUHXYDbKfv5%DD_^X1-p z#5cFcy#MX{&tCN3{rb8k2M*hszQ5DP{O>(;*4z7^O)^z_d;jaR+)=<->sm ztZnh_ViNymt292`&n+fVXWo85Uf$37-m1ryAD*l8Kfj%}KKx!Df3@Ia^W_{H#jS$u z!lXFoG)e!In$sf9KBrBZbxwyg^PDbe#yLIR?C;)PURCA$w@udOgUp8A&)4hM{O>!( zZ0}wxc$iyu{`Fb>ijNDG#r9aA`aVsjQJVG7)0e+gp3Y8t+))2{mg{fpiPslpc4Sww pv}JSa80=xJuo0&l#lv35EOz%@<)ztce*n`jgQu&X%Q~loCIFDNLn{CP 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" />