Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added font style typerface #924

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
11 changes: 6 additions & 5 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
distributionBase = GRADLE_USER_HOME
distributionPath = wrapper/dists
distributionUrl = https\://services.gradle.org/distributions/gradle-5.1.1-bin.zip
zipStoreBase = GRADLE_USER_HOME
zipStorePath = wrapper/dists
#Sat Feb 02 14:17:50 IST 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.prolificinteractive.materialcalendarview;

import android.graphics.Typeface;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.view.PagerAdapter;
Expand Down Expand Up @@ -42,6 +43,7 @@ abstract class CalendarPagerAdapter<V extends CalendarPagerView> extends PagerAd
private List<DecoratorResult> decoratorResults = null;
private boolean selectionEnabled = true;
boolean showWeekDays;
private Typeface typerface=null;

CalendarPagerAdapter(MaterialCalendarView mcv) {
this.mcv = mcv;
Expand Down Expand Up @@ -85,6 +87,7 @@ public CalendarPagerAdapter<?> migrateStateAndReturn(CalendarPagerAdapter<?> new
newAdapter.color = color;
newAdapter.dateTextAppearance = dateTextAppearance;
newAdapter.weekDayTextAppearance = weekDayTextAppearance;
newAdapter.typerface = typerface;
newAdapter.showOtherDates = showOtherDates;
newAdapter.minDate = minDate;
newAdapter.maxDate = maxDate;
Expand Down Expand Up @@ -151,9 +154,15 @@ public Object instantiateItem(@NonNull ViewGroup container, int position) {
pagerView.setSelectionColor(color);
}
if (dateTextAppearance != null) {
pagerView.setDateTextAppearance(dateTextAppearance);
if (typerface !=null)
pagerView.setDateTextAppearance(dateTextAppearance,typerface);
else
pagerView.setDateTextAppearance(dateTextAppearance);
}
if (weekDayTextAppearance != null) {
if (typerface !=null)
pagerView.setWeekDayTextAppearance(weekDayTextAppearance,typerface);
else
pagerView.setWeekDayTextAppearance(weekDayTextAppearance);
}
pagerView.setShowOtherDates(showOtherDates);
Expand Down Expand Up @@ -213,10 +222,19 @@ public void setDateTextAppearance(int taId) {
}
this.dateTextAppearance = taId;
for (V pagerView : currentViews) {
if (typerface !=null)
pagerView.setDateTextAppearance(taId,typerface);
else
pagerView.setDateTextAppearance(taId);
}
}

public void setDateTextFontAppearance(Typeface typerface)
{
if (typerface!=null)
this.typerface=typerface;
}

public void setShowOtherDates(@ShowOtherDates int showFlags) {
this.showOtherDates = showFlags;
for (V pagerView : currentViews) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.prolificinteractive.materialcalendarview;

import android.graphics.Typeface;
import android.os.Build;
import android.support.annotation.NonNull;
import android.util.AttributeSet;
Expand Down Expand Up @@ -112,6 +113,16 @@ void setDayViewDecorators(List<DecoratorResult> results) {
invalidateDecorators();
}


public void setWeekDayTextAppearance(int taId,Typeface typerface) {
for (WeekDayView weekDayView : weekDayViews) {
weekDayView.setTextAppearance(getContext(), taId);
if (typerface != null) {
weekDayView.setTypeface(typerface);
}
}
}

public void setWeekDayTextAppearance(int taId) {
for (WeekDayView weekDayView : weekDayViews) {
weekDayView.setTextAppearance(getContext(), taId);
Expand All @@ -123,6 +134,14 @@ public void setDateTextAppearance(int taId) {
dayView.setTextAppearance(getContext(), taId);
}
}
public void setDateTextAppearance(int taId,Typeface typerface) {
for (DayView dayView : dayViews) {
dayView.setTextAppearance(getContext(), taId);
if (typerface != null) {
dayView.setTypeface(typerface);
}
}
}

public void setShowOtherDates(@ShowOtherDates int showFlags) {
this.showOtherDates = showFlags;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Color;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Parcel;
Expand Down Expand Up @@ -743,6 +744,10 @@ public void setDateTextAppearance(int resourceId) {
adapter.setDateTextAppearance(resourceId);
}

public void setDateTextFontAppearance(Typeface typerface) {
adapter.setDateTextFontAppearance(typerface);
}

/**
* @param resourceId The text appearance resource id.
*/
Expand Down
2 changes: 1 addition & 1 deletion library/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<style name="TextAppearance.MaterialCalendarWidget.Date"
parent="android:TextAppearance.DeviceDefault.Small">
<item name="android:textSize">12sp</item>
<item name="android:textSize">16sp</item>
<item name="android:textColor">@color/mcv_text_date_light</item>
</style>

Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.prolificinteractive.materialcalendarview.sample;

import android.graphics.Typeface;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.TypedValue;
Expand All @@ -24,12 +25,11 @@ protected void onCreate(Bundle savedInstanceState) {
ButterKnife.bind(this);

widget.setShowOtherDates(MaterialCalendarView.SHOW_ALL);
Typeface typeface = Typeface.createFromAsset(getAssets(),"fonts/shrikhand_regular.ttf");
widget.setDateTextFontAppearance(typeface);
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);
widget.setDateTextAppearance(R.style.CustomTextAppearance);
widget.setTitleFormatter(new MonthArrayTitleFormatter(getResources().getTextArray(R.array.custom_months)));
widget.setWeekDayFormatter(new ArrayWeekDayFormatter(getResources().getTextArray(R.array.custom_weekdays)));
widget.setTileSize((int) TypedValue.applyDimension(
Expand Down
1 change: 0 additions & 1 deletion sample/src/main/res/layout/activity_customization.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
app:mcv_dateTextAppearance="@style/CustomTextAppearance"
app:mcv_firstDayOfWeek="thursday"
app:mcv_headerTextAppearance="@style/CustomTextAppearance"
app:mcv_leftArrow="@drawable/ic_arrow_back"
app:mcv_monthLabels="@array/custom_months"
app:mcv_rightArrow="@drawable/ic_arrow_forward"
app:mcv_selectionColor="?attr/colorPrimary"
Expand Down