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

support for custom fonts #65

Open
wants to merge 5 commits 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
14 changes: 11 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,26 @@ buildscript {
repositories {
jcenter()
mavenCentral()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.4'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
}
}

allprojects {
repositories {
jcenter()
mavenCentral()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}

tasks.withType(Javadoc).all {
Expand Down
12 changes: 6 additions & 6 deletions cosmocalendar/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ ext {
}

android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
compileSdkVersion 28
buildToolsVersion '28.0.3'

defaultConfig {
minSdkVersion 17
targetSdkVersion 25
targetSdkVersion 28
versionCode 5
versionName "1.0.4"
}
Expand All @@ -43,9 +43,9 @@ android {
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:25.3.1'
compile "com.android.support:recyclerview-v7:25.3.1"
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation "com.android.support:recyclerview-v7:28.0.0"
}

// Place it at the end of the file
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ public class DayHolder extends BaseDayHolder {
public DayHolder(View itemView, CalendarView calendarView) {
super(itemView, calendarView);
ctvDay = (CircleAnimationTextView) itemView.findViewById(R.id.tv_day_number);

if(calendarView.getDayTextAppearance() != -1) {
ctvDay.setTextAppearance(calendarView.getContext(), calendarView.getDayTextAppearance());
}
}

public void bind(Day day, BaseSelectionManager selectionManager) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,17 @@ public DayOfWeekHolder(View itemView, CalendarView calendarView) {
super(itemView, calendarView);
tvDay = (TextView) itemView.findViewById(R.id.tv_day_name);
mDayOfWeekFormatter = new SimpleDateFormat(Constants.DAY_NAME_FORMAT, Locale.getDefault());

if(calendarView.getWeekDayTextAppearance() != -1) {
tvDay.setTextAppearance(calendarView.getContext(), calendarView.getWeekDayTextAppearance());
}
}

public void bind(Day day) {
if(calendarView.getWeekDayFormat() != null) {
mDayOfWeekFormatter = new SimpleDateFormat(calendarView.getWeekDayFormat(), Locale.getDefault());
}

tvDay.setText(mDayOfWeekFormatter.format(day.getCalendar().getTime()));
tvDay.setTextColor(calendarView.getWeekDayTitleTextColor());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class MonthHolder extends RecyclerView.ViewHolder {
private TextView tvMonthName;
private View viewLeftLine;
private View viewRightLine;
private View viewHorizontalDivLine;
private MonthView monthView;
private SettingsManager appearanceModel;

Expand All @@ -28,7 +29,12 @@ public MonthHolder(View itemView, SettingsManager appearanceModel) {
tvMonthName = (TextView) itemView.findViewById(R.id.tv_month_name);
viewLeftLine = itemView.findViewById(R.id.view_left_line);
viewRightLine = itemView.findViewById(R.id.view_right_line);
viewHorizontalDivLine = itemView.findViewById(R.id.view_div_line);
this.appearanceModel = appearanceModel;

if(appearanceModel.getMonthTextAppearance() != -1) {
tvMonthName.setTextAppearance(tvMonthName.getContext(), appearanceModel.getMonthTextAppearance());
}
}

public void setDayAdapter(DaysAdapter adapter) {
Expand All @@ -39,8 +45,17 @@ public void bind(Month month) {
tvMonthName.setText(month.getMonthName());
tvMonthName.setTextColor(appearanceModel.getMonthTextColor());

viewLeftLine.setVisibility(appearanceModel.getCalendarOrientation() == OrientationHelper.HORIZONTAL ? View.INVISIBLE : View.VISIBLE);
viewRightLine.setVisibility(appearanceModel.getCalendarOrientation() == OrientationHelper.HORIZONTAL ? View.INVISIBLE : View.VISIBLE);
viewLeftLine.setBackgroundColor(appearanceModel.getBorderColor());
viewRightLine.setBackgroundColor(appearanceModel.getBorderColor());
viewHorizontalDivLine.setBackgroundColor(appearanceModel.getBorderColor());

boolean isLineVisible = appearanceModel.getCalendarOrientation() == OrientationHelper.VERTICAL && appearanceModel.isMonthHorizontalLinesVisible();
boolean isTitleDivVisible = appearanceModel.isMonthTitleBottomDivVisible();

viewLeftLine.setVisibility(isLineVisible ? View.VISIBLE : View.INVISIBLE);
viewRightLine.setVisibility(isLineVisible ? View.VISIBLE : View.INVISIBLE);
viewHorizontalDivLine.setVisibility(isTitleDivVisible ? View.VISIBLE : View.GONE);

llMonthHeader.setBackgroundResource(appearanceModel.getCalendarOrientation() == OrientationHelper.HORIZONTAL ? R.drawable.border_top_bottom : 0);

monthView.initAdapter(month);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ public class OtherDayHolder extends BaseDayHolder {
public OtherDayHolder(View itemView, CalendarView calendarView) {
super(itemView, calendarView);
tvDay = (TextView) itemView.findViewById(R.id.tv_day_number);

if(calendarView.getDayTextAppearance() != -1) {
tvDay.setTextAppearance(calendarView.getContext(), calendarView.getDayTextAppearance());
}
}

public void bind(Day day) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,76 @@ public void setShowDaysOfWeekTitle(boolean showDaysOfWeekTitle) {
calendarView.setShowDaysOfWeekTitle(showDaysOfWeekTitle);
}

@Override
public int getMonthTextAppearance() {
return calendarView.getMonthTextAppearance();
}

@Override
public void setMonthTextAppearance(int monthTextAppearance) {
calendarView.setMonthTextAppearance(monthTextAppearance);
}

@Override
public int getWeekDayTextAppearance() {
return calendarView.getWeekDayTextAppearance();
}

@Override
public void setWeekDayTextAppearance(int weekDayTextAppearance) {
calendarView.setWeekDayTextAppearance(weekDayTextAppearance);
}

@Override
public int getDayTextAppearance() {
return calendarView.getDayTextAppearance();
}

@Override
public void setDayTextAppearance(int dayTextAppearance) {
calendarView.setDayTextAppearance(dayTextAppearance);
}

@Override
public boolean isMonthHorizontalLinesVisible() {
return calendarView.isMonthHorizontalLinesVisible();
}

@Override
public void setMonthHorizontalLinesVisible(boolean monthHorizontalLinesVisible) {
calendarView.setMonthHorizontalLinesVisible(monthHorizontalLinesVisible);
}

@Override
public boolean isMonthTitleBottomDivVisible() {
return calendarView.isMonthTitleBottomDivVisible();
}

@Override
public void setMonthTitleBottomDivVisible(boolean monthTitleBottomDivVisible) {
calendarView.setMonthTitleBottomDivVisible(monthTitleBottomDivVisible);
}

@Override
public String getWeekDayFormat() {
return calendarView.getWeekDayFormat();
}

@Override
public void setWeekDayFormat(String weekDayFormat) {
calendarView.setWeekDayFormat(weekDayFormat);
}

@Override
public int getBorderColor() {
return calendarView.getBorderColor();
}

@Override
public void setBorderColor(int borderColor) {
calendarView.setBorderColor(borderColor);
}

@Override
public Set<Long> getDisabledDays() {
return calendarView.getDisabledDays();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,26 @@
package com.applikeysolutions.cosmocalendar.model;

import com.applikeysolutions.cosmocalendar.utils.Constants;

import java.util.Date;

public class DayOfWeek extends Day {
public enum WeekdayFormat {
SHORT,
MEDIUM;

public String getFormat() {
switch (this) {
case SHORT:
return "E";

case MEDIUM:
return "EEE";
}

return Constants.DAY_NAME_FORMAT;
}
}

public DayOfWeek(Date date) {
super(date);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,76 @@ public void setShowDaysOfWeekTitle(boolean showDaysOfWeekTitle) {
appearanceModel.setShowDaysOfWeekTitle(showDaysOfWeekTitle);
}

@Override
public int getMonthTextAppearance() {
return appearanceModel.getMonthTextAppearance();
}

@Override
public void setMonthTextAppearance(int monthTextAppearance) {
appearanceModel.setMonthTextAppearance(monthTextAppearance);
}

@Override
public int getWeekDayTextAppearance() {
return appearanceModel.getWeekDayTextAppearance();
}

@Override
public void setWeekDayTextAppearance(int weekDayTextAppearance) {
appearanceModel.setWeekDayTextAppearance(weekDayTextAppearance);
}

@Override
public int getDayTextAppearance() {
return appearanceModel.getDayTextAppearance();
}

@Override
public void setDayTextAppearance(int dayTextAppearance) {
appearanceModel.setDayTextAppearance(dayTextAppearance);
}

@Override
public boolean isMonthHorizontalLinesVisible() {
return appearanceModel.isMonthHorizontalLinesVisible();
}

@Override
public void setMonthHorizontalLinesVisible(boolean monthHorizontalLinesVisible) {
appearanceModel.setMonthHorizontalLinesVisible(monthHorizontalLinesVisible);
}

@Override
public boolean isMonthTitleBottomDivVisible() {
return appearanceModel.isMonthTitleBottomDivVisible();
}

@Override
public void setMonthTitleBottomDivVisible(boolean monthTitleBottomDivVisible) {
appearanceModel.setMonthTitleBottomDivVisible(monthTitleBottomDivVisible);
}

@Override
public String getWeekDayFormat() {
return appearanceModel.getWeekDayFormat();
}

@Override
public void setWeekDayFormat(String weekDayFormat) {
appearanceModel.setWeekDayFormat(weekDayFormat);
}

@Override
public int getBorderColor() {
return appearanceModel.getBorderColor();
}

@Override
public void setBorderColor(int borderColor) {
appearanceModel.setBorderColor(borderColor);
}

@Override
public Set<Long> getDisabledDays() {
return calendarListsModel.getDisabledDays();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,27 @@ public interface AppearanceInterface {
void setShowDaysOfWeek(boolean showDaysOfWeek);

void setShowDaysOfWeekTitle(boolean showDaysOfWeekTitle);

int getMonthTextAppearance();

void setMonthTextAppearance(int monthTextAppearance);
int getWeekDayTextAppearance();
void setWeekDayTextAppearance(int weekDayTextAppearance);

int getDayTextAppearance();

void setDayTextAppearance(int dayTextAppearance);

boolean isMonthHorizontalLinesVisible();
void setMonthHorizontalLinesVisible(boolean monthHorizontalLinesVisible);

boolean isMonthTitleBottomDivVisible();

void setMonthTitleBottomDivVisible(boolean monthTitleBottomDivVisible);

String getWeekDayFormat();
void setWeekDayFormat(String weekDayFormat);

int getBorderColor();
void setBorderColor(int borderColor);
}
Loading