Skip to content

Commit

Permalink
.....
Browse files Browse the repository at this point in the history
  • Loading branch information
Ali.Sardari committed Sep 4, 2018
1 parent 49b45ed commit a2174d3
Show file tree
Hide file tree
Showing 3 changed files with 170 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public void onRangeDateSelected(PersianCalendar startDate, PersianCalendar endDa
}
});

// datePickerDialog.setAcceptButtonColor(ContextCompat.getColor(this, R.color.colorAccent));
datePickerDialog.showDialog();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public class DateRangeCalendarView extends LinearLayout {
private PersianCalendar currentCalendarMonth, minSelectedDate, maxSelectedDate;
private ArrayList<Integer> selectedDatesRange = new ArrayList<>();
private Typeface typeface;
private RelativeLayout rlHeaderCalendar;

private static final int STRIP_TYPE_NONE = 0;
private static final int STRIP_TYPE_LEFT = 1;
Expand Down Expand Up @@ -122,7 +123,7 @@ private void setDefaultValues() {
todayColor = ContextCompat.getColor(mContext, R.color.today_date_color);
}

private void setAttributes() {
public void setAttributes() {
TypedArray ta = mContext.obtainStyledAttributes(attrs, R.styleable.DateRangeCalendarView, 0, 0);
try {
shouldEnabledTime = ta.getBoolean(R.styleable.DateRangeCalendarView_enable_time_selection, false);
Expand Down Expand Up @@ -165,8 +166,7 @@ private void init() {
imgVNavLeft = mainView.findViewById(R.id.imgVNavLeft);
imgVNavRight = mainView.findViewById(R.id.imgVNavRight);

RelativeLayout rlHeaderCalendar = mainView.findViewById(R.id.rlHeaderCalendar);
rlHeaderCalendar.setBackgroundColor(headerBackgroundColor);
rlHeaderCalendar = mainView.findViewById(R.id.rlHeaderCalendar);

setListeners();

Expand Down Expand Up @@ -717,10 +717,9 @@ public void setTypeface(Typeface typeface) {
//---------------------------------------------------------------------------------------------
//region Properties
public void build() {

drawCalendarForMonth(getCurrentMonth(currentDate));

setWeekTitleColor();
rlHeaderCalendar.setBackgroundColor(headerBackgroundColor);
}

//region selectionMode -> Getter/Setter
Expand Down Expand Up @@ -814,120 +813,120 @@ public void setMessageEnterEndDate(String messageEnterEndDate) {
}

//endregion

public boolean isShouldEnabledTime() {
return shouldEnabledTime;
}

public void setShouldEnabledTime(boolean shouldEnabledTime) {
this.shouldEnabledTime = shouldEnabledTime;
}

//--------------------------------------------------------------------------------------------
//region theme
public int getHeaderBackgroundColor() {
return headerBackgroundColor;
}

public void setHeaderBackgroundColor(int headerBackgroundColor) {
this.headerBackgroundColor = headerBackgroundColor;
this.headerBackgroundColor = headerBackgroundColor != 0 ? headerBackgroundColor : this.headerBackgroundColor;
}

public int getWeekColor() {
return weekColor;
}

public void setWeekColor(int weekColor) {
this.weekColor = weekColor;
this.weekColor = weekColor != 0 ? weekColor : this.weekColor;
}

public int getRangeStripColor() {
return rangeStripColor;
}

public void setRangeStripColor(int rangeStripColor) {
this.rangeStripColor = rangeStripColor;
this.rangeStripColor = rangeStripColor != 0 ? rangeStripColor : this.rangeStripColor;
}

public int getSelectedDateCircleColor() {
return selectedDateCircleColor;
}

public void setSelectedDateCircleColor(int selectedDateCircleColor) {
this.selectedDateCircleColor = selectedDateCircleColor;
this.selectedDateCircleColor = selectedDateCircleColor != 0 ? selectedDateCircleColor : this.selectedDateCircleColor;
}

public int getSelectedDateColor() {
return selectedDateColor;
}

public void setSelectedDateColor(int selectedDateColor) {
this.selectedDateColor = selectedDateColor;
this.selectedDateColor = selectedDateColor != 0 ? selectedDateColor : this.selectedDateColor;
}

public int getDefaultDateColor() {
return defaultDateColor;
}

public void setDefaultDateColor(int defaultDateColor) {
this.defaultDateColor = defaultDateColor;
this.defaultDateColor = defaultDateColor != 0 ? defaultDateColor : this.defaultDateColor;
}

public int getDisableDateColor() {
return disableDateColor;
}

public void setDisableDateColor(int disableDateColor) {
this.disableDateColor = disableDateColor;
this.disableDateColor = disableDateColor != 0 ? disableDateColor : this.disableDateColor;
}

public int getRangeDateColor() {
return rangeDateColor;
}

public void setRangeDateColor(int rangeDateColor) {
this.rangeDateColor = rangeDateColor;
this.rangeDateColor = rangeDateColor != 0 ? rangeDateColor : this.rangeDateColor;
}

public int getHolidayColor() {
return holidayColor;
}

public void setHolidayColor(int holidayColor) {
this.holidayColor = holidayColor;

setAttributes();
this.holidayColor = holidayColor != 0 ? holidayColor : this.holidayColor;
}

public int getTodayColor() {
return todayColor;
}

public void setTodayColor(int todayColor) {
this.todayColor = todayColor;
this.todayColor = todayColor != 0 ? todayColor : this.todayColor;
}

public boolean isShouldEnabledTime() {
return shouldEnabledTime;
}

public void setShouldEnabledTime(boolean shouldEnabledTime) {
this.shouldEnabledTime = shouldEnabledTime;
}

public float getTextSizeTitle() {
return textSizeTitle;
}

public void setTextSizeTitle(float textSizeTitle) {
this.textSizeTitle = textSizeTitle;
this.textSizeTitle = textSizeTitle != 0 ? textSizeTitle : this.textSizeTitle;
}

public float getTextSizeWeek() {
return textSizeWeek;
}

public void setTextSizeWeek(float textSizeWeek) {
this.textSizeWeek = textSizeWeek;
this.textSizeWeek = textSizeWeek != 0 ? textSizeWeek : this.textSizeWeek;
}

public float getTextSizeDate() {
return textSizeDate;
}

public void setTextSizeDate(float textSizeDate) {
this.textSizeDate = textSizeDate;
this.textSizeDate = textSizeDate != 0 ? textSizeDate : this.textSizeDate;
}

//endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import android.app.Dialog;
import android.content.Context;
import android.graphics.Typeface;
import android.support.v4.content.ContextCompat;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
Expand Down Expand Up @@ -47,6 +48,8 @@ private void initView() {
setContentView(R.layout.dialog_date_picker);

btn_Accept = findViewById(R.id.btn_Accept);

acceptButtonColor = ContextCompat.getColor(mContext, R.color.buttonBackgroundColor);
// calendar = findViewById(R.id.calendar);
//endregion
}
Expand Down Expand Up @@ -106,6 +109,7 @@ public void onClick(View v) {
}
});

//config
calendar.setSelectionMode(selectionMode.getValue());
calendar.setDisableDaysAgo(disableDaysAgo);
calendar.setTypeface(typeface);
Expand All @@ -115,6 +119,23 @@ public void onClick(View v) {
calendar.setShowGregorianDate(showGregorianDate);
calendar.setShouldEnabledTime(enableTimePicker);

//theme
calendar.setHeaderBackgroundColor(headerBackgroundColor);
calendar.setSelectedDateCircleColor(selectedDateCircleColor);
calendar.setWeekColor(weekColor);
calendar.setRangeStripColor(rangeStripColor);
calendar.setSelectedDateColor(selectedDateColor);
calendar.setDefaultDateColor(defaultDateColor);
calendar.setDisableDateColor(disableDateColor);
calendar.setRangeDateColor(rangeDateColor);
calendar.setHolidayColor(holidayColor);
calendar.setTodayColor(todayColor);
calendar.setTextSizeTitle(textSizeTitle);
calendar.setTextSizeWeek(textSizeWeek);
calendar.setTextSizeDate(textSizeDate);

//init
calendar.setAttributes();
calendar.build();

ViewGroup insertPoint = findViewById(R.id.content);
Expand All @@ -125,6 +146,8 @@ public void onClick(View v) {
btn_Accept.setVisibility(View.GONE);
}

btn_Accept.setBackgroundColor(acceptButtonColor);

this.show();
}

Expand Down Expand Up @@ -251,6 +274,126 @@ public void setOnRangeDateSelectedListener(OnRangeDateSelectedListener onRangeDa
}
//endregion
//endregion


//region theme
private int acceptButtonColor, headerBackgroundColor, weekColor, rangeStripColor, selectedDateCircleColor, selectedDateColor, defaultDateColor, disableDateColor, rangeDateColor, holidayColor, todayColor;
private float textSizeTitle, textSizeWeek, textSizeDate;

public int getAcceptButtonColor() {
return acceptButtonColor;
}

public void setAcceptButtonColor(int acceptButtonColor) {
this.acceptButtonColor = acceptButtonColor;
}

public int getHeaderBackgroundColor() {
return headerBackgroundColor;
}

public void setHeaderBackgroundColor(int headerBackgroundColor) {
this.headerBackgroundColor = headerBackgroundColor;
}

public int getWeekColor() {
return weekColor;
}

public void setWeekColor(int weekColor) {
this.weekColor = weekColor;
}

public int getRangeStripColor() {
return rangeStripColor;
}

public void setRangeStripColor(int rangeStripColor) {
this.rangeStripColor = rangeStripColor;
}

public int getSelectedDateCircleColor() {
return selectedDateCircleColor;
}

public void setSelectedDateCircleColor(int selectedDateCircleColor) {
this.selectedDateCircleColor = selectedDateCircleColor;
}

public int getSelectedDateColor() {
return selectedDateColor;
}

public void setSelectedDateColor(int selectedDateColor) {
this.selectedDateColor = selectedDateColor;
}

public int getDefaultDateColor() {
return defaultDateColor;
}

public void setDefaultDateColor(int defaultDateColor) {
this.defaultDateColor = defaultDateColor;
}

public int getDisableDateColor() {
return disableDateColor;
}

public void setDisableDateColor(int disableDateColor) {
this.disableDateColor = disableDateColor;
}

public int getRangeDateColor() {
return rangeDateColor;
}

public void setRangeDateColor(int rangeDateColor) {
this.rangeDateColor = rangeDateColor;
}

public int getHolidayColor() {
return holidayColor;
}

public void setHolidayColor(int holidayColor) {
this.holidayColor = holidayColor;
}

public int getTodayColor() {
return todayColor;
}

public void setTodayColor(int todayColor) {
this.todayColor = todayColor;
}

public float getTextSizeTitle() {
return textSizeTitle;
}

public void setTextSizeTitle(float textSizeTitle) {
this.textSizeTitle = textSizeTitle;
}

public float getTextSizeWeek() {
return textSizeWeek;
}

public void setTextSizeWeek(float textSizeWeek) {
this.textSizeWeek = textSizeWeek;
}

public float getTextSizeDate() {
return textSizeDate;
}

public void setTextSizeDate(float textSizeDate) {
this.textSizeDate = textSizeDate;
}

//endregion

//endregion

//region Listeners -> Interface
Expand Down

0 comments on commit a2174d3

Please sign in to comment.