Skip to content

Commit c265c9d

Browse files
committed
Add getter and setter for new attributes
1 parent 3a97dfe commit c265c9d

File tree

3 files changed

+110
-6
lines changed

3 files changed

+110
-6
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,15 @@ You can customize the look of the `WeekView` in xml. Use the following attribute
117117
- `textSize`
118118
- `todayBackgroundColor`
119119
- `todayHeaderTextColor`
120+
- `showDistinctPastFutureColor`
121+
- `futureBackgroundColor`
122+
- `pastBackgroundColor`
123+
- `showDistinctWeekendColor`
124+
- `futureWeekendBackgroundColor`
125+
- `pastWeekendBackgroundColor`
126+
- `showNowLine`
127+
- `nowLineColor`
128+
- `nowLineThickness`
120129

121130
Interfaces
122131
----------

library/src/main/java/com/alamkanak/weekview/WeekView.java

Lines changed: 97 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,6 @@ public class WeekView extends View {
123123
private Calendar mScrollToDay = null;
124124
private double mScrollToHour = -1;
125125
private int mEventCornerRadius = 0;
126-
private boolean mUseDifferentPastBackgroundColor = false;
127-
private boolean mUseDifferentFutureWeekendBackgroundColor = false;
128126
private boolean mShowDistinctWeekendColor = false;
129127
private boolean mShowNowLine = false;
130128
private boolean mShowDistinctPastFutureColor = false;
@@ -1515,6 +1513,103 @@ public float getXScrollingSpeed() {
15151513
public void setXScrollingSpeed(float xScrollingSpeed) {
15161514
this.mXScrollingSpeed = xScrollingSpeed;
15171515
}
1516+
1517+
/**
1518+
* Whether weekends should have a background color different from the normal day background
1519+
* color. The weekend background colors are defined by the attributes
1520+
* `futureWeekendBackgroundColor` and `pastWeekendBackgroundColor`.
1521+
* @return True if weekends should have different background colors.
1522+
*/
1523+
public boolean isShowDistinctWeekendColor() {
1524+
return mShowDistinctWeekendColor;
1525+
}
1526+
1527+
/**
1528+
* Set whether weekends should have a background color different from the normal day background
1529+
* color. The weekend background colors are defined by the attributes
1530+
* `futureWeekendBackgroundColor` and `pastWeekendBackgroundColor`.
1531+
* @param showDistinctWeekendColor True if weekends should have different background colors.
1532+
*/
1533+
public void setShowDistinctWeekendColor(boolean showDistinctWeekendColor) {
1534+
this.mShowDistinctWeekendColor = showDistinctWeekendColor;
1535+
invalidate();
1536+
}
1537+
1538+
/**
1539+
* Whether past and future days should have two different background colors. The past and
1540+
* future day colors are defined by the attributes `futureBackgroundColor` and
1541+
* `pastBackgroundColor`.
1542+
* @return True if past and future days should have two different background colors.
1543+
*/
1544+
public boolean isShowDistinctPastFutureColor() {
1545+
return mShowDistinctPastFutureColor;
1546+
}
1547+
1548+
/**
1549+
* Set whether weekends should have a background color different from the normal day background
1550+
* color. The past and future day colors are defined by the attributes `futureBackgroundColor`
1551+
* and `pastBackgroundColor`.
1552+
* @param showDistinctPastFutureColor True if past and future should have two different
1553+
* background colors.
1554+
*/
1555+
public void setShowDistinctPastFutureColor(boolean showDistinctPastFutureColor) {
1556+
this.mShowDistinctPastFutureColor = showDistinctPastFutureColor;
1557+
invalidate();
1558+
}
1559+
1560+
/**
1561+
* Get whether "now" line should be displayed. "Now" line is defined by the attributes
1562+
* `nowLineColor` and `nowLineThickness`.
1563+
* @return True if "now" line should be displayed.
1564+
*/
1565+
public boolean isShowNowLine() {
1566+
return mShowNowLine;
1567+
}
1568+
1569+
/**
1570+
* Set whether "now" line should be displayed. "Now" line is defined by the attributes
1571+
* `nowLineColor` and `nowLineThickness`.
1572+
* @param showNowLine True if "now" line should be displayed.
1573+
*/
1574+
public void setShowNowLine(boolean showNowLine) {
1575+
this.mShowNowLine = showNowLine;
1576+
invalidate();
1577+
}
1578+
1579+
/**
1580+
* Get the "now" line color.
1581+
* @return The color of the "now" line.
1582+
*/
1583+
public int getNowLineColor() {
1584+
return mNowLineColor;
1585+
}
1586+
1587+
/**
1588+
* Set the "now" line color.
1589+
* @param nowLineColor The color of the "now" line.
1590+
*/
1591+
public void setNowLineColor(int nowLineColor) {
1592+
this.mNowLineColor = nowLineColor;
1593+
invalidate();
1594+
}
1595+
1596+
/**
1597+
* Get the "now" line thickness.
1598+
* @return The thickness of the "now" line.
1599+
*/
1600+
public int getNowLineThickness() {
1601+
return mNowLineThickness;
1602+
}
1603+
1604+
/**
1605+
* Set the "now" line thickness.
1606+
* @param nowLineThickness The thickness of the "now" line.
1607+
*/
1608+
public void setNowLineThickness(int nowLineThickness) {
1609+
this.mNowLineThickness = nowLineThickness;
1610+
invalidate();
1611+
}
1612+
15181613
/////////////////////////////////////////////////////////////////
15191614
//
15201615
// Functions related to scrolling.

library/src/main/res/values/attrs.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@
2222
<attr name="noOfVisibleDays" format="integer"/>
2323
<attr name="headerRowBackgroundColor" format="color"/>
2424
<attr name="dayBackgroundColor" format="color"/>
25-
<attr name="futureBackgroundColor" format="color"/>
26-
<attr name="pastBackgroundColor" format="color"/>
27-
<attr name="futureWeekendBackgroundColor" format="color"/>
28-
<attr name="pastWeekendBackgroundColor" format="color"/>
2925
<attr name="hourSeparatorColor" format="color"/>
3026
<attr name="todayBackgroundColor" format="color"/>
3127
<attr name="todayHeaderTextColor" format="color"/>
@@ -43,6 +39,10 @@
4339
<attr name="eventCornerRadius" format="dimension"/>
4440
<attr name="showDistinctPastFutureColor" format="boolean"/>
4541
<attr name="showDistinctWeekendColor" format="boolean"/>
42+
<attr name="futureBackgroundColor" format="color"/>
43+
<attr name="pastBackgroundColor" format="color"/>
44+
<attr name="futureWeekendBackgroundColor" format="color"/>
45+
<attr name="pastWeekendBackgroundColor" format="color"/>
4646
<attr name="showNowLine" format="boolean"/>
4747
<attr name="nowLineColor" format="color"/>
4848
<attr name="nowLineThickness" format="dimension"/>

0 commit comments

Comments
 (0)