Skip to content

Commit

Permalink
Merge pull request #50 from square/edenman/bugfixes
Browse files Browse the repository at this point in the history
Fix #47 and #49
  • Loading branch information
edenman committed May 25, 2013
2 parents de8a478 + 33657d3 commit ddf82a9
Show file tree
Hide file tree
Showing 12 changed files with 330 additions and 279 deletions.
12 changes: 0 additions & 12 deletions library/res/color/calendar_bg_selector.xml

This file was deleted.

24 changes: 24 additions & 0 deletions library/res/drawable/calendar_bg_selector.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2012 Square, Inc. -->

<selector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item app:state_range_middle="true">
<color android:color="@color/calendar_selected_range_bg"/>
</item>
<item android:state_selected="true">
<color android:color="@color/calendar_selected_day_bg"/>
</item>
<item android:state_pressed="true">
<color android:color="@color/calendar_selected_day_bg"/>
</item>
<item app:state_current_month="false">
<color android:color="@color/calendar_inactive_month_bg"/>
</item>
<item app:state_today="true">
<color android:color="@color/calendar_text_active"/>
</item>
<item>
<color android:color="@color/calendar_active_month_bg"/>
</item>
</selector>
6 changes: 3 additions & 3 deletions library/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<attr name="state_selectable" format="boolean" />
<attr name="state_current_month" format="boolean" />
<attr name="state_today" format="boolean" />
<attr name="state_period_first" format="boolean" />
<attr name="state_period_middle" format="boolean" />
<attr name="state_period_last" format="boolean" />
<attr name="state_range_first" format="boolean" />
<attr name="state_range_middle" format="boolean" />
<attr name="state_range_last" format="boolean" />
</declare-styleable>
</resources>
2 changes: 1 addition & 1 deletion library/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<color name="calendar_divider">#ffbababa</color>
<color name="calendar_inactive_month_bg">#ffd7d9db</color>
<color name="calendar_selected_day_bg">#ff379bff</color>
<color name="calendar_selected_period_bg">#ff96caff</color>
<color name="calendar_selected_range_bg">#ff96caff</color>
<color name="calendar_text_inactive">#40778088</color>
<color name="calendar_text_active">#ff778088</color>
<color name="calendar_text_selected">#ffffffff</color>
Expand Down
2 changes: 1 addition & 1 deletion library/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

<style name="CalendarCell.CalendarDate">
<item name="android:textSize">@dimen/calendar_text_medium</item>
<item name="android:colorBackground">@color/calendar_bg_selector</item>
<item name="android:background">@drawable/calendar_bg_selector</item>
<item name="android:textColor">@color/calendar_text_selector</item>
<item name="android:clickable">true</item>
<item name="android:textStyle">bold</item>
Expand Down
33 changes: 16 additions & 17 deletions library/src/com/squareup/timessquare/CalendarCellView.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@

package com.squareup.timessquare;

import com.squareup.timessquare.MonthCellDescriptor.PeriodState;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.TextView;
import com.squareup.timessquare.MonthCellDescriptor.RangeState;

public class CalendarCellView extends TextView {

Expand All @@ -19,20 +18,20 @@ public class CalendarCellView extends TextView {
private static final int[] STATE_TODAY = {
R.attr.state_today
};
private static final int[] STATE_PERIOD_FIRST = {
R.attr.state_period_first
private static final int[] STATE_RANGE_FIRST = {
R.attr.state_range_first
};
private static final int[] STATE_PERIOD_MIDDLE = {
R.attr.state_period_middle
private static final int[] STATE_RANGE_MIDDLE = {
R.attr.state_range_middle
};
private static final int[] STATE_PERIOD_LAST = {
R.attr.state_period_last
private static final int[] STATE_RANGE_LAST = {
R.attr.state_range_last
};

private boolean isSelectable = false;
private boolean isCurrentMonth = false;
private boolean isToday = false;
private PeriodState periodState = PeriodState.NONE;
private RangeState rangeState = RangeState.NONE;

public CalendarCellView(Context context) {
super(context);
Expand Down Expand Up @@ -61,8 +60,8 @@ public void setToday(boolean isToday) {
refreshDrawableState();
}

public void setPeriodState(PeriodState periodState) {
this.periodState = periodState;
public void setRangeState(MonthCellDescriptor.RangeState rangeState) {
this.rangeState = rangeState;
refreshDrawableState();
}

Expand All @@ -81,12 +80,12 @@ public void setPeriodState(PeriodState periodState) {
mergeDrawableStates(drawableState, STATE_TODAY);
}

if (periodState == PeriodState.FIRST) {
mergeDrawableStates(drawableState, STATE_PERIOD_FIRST);
} else if (periodState == PeriodState.MIDDLE) {
mergeDrawableStates(drawableState, STATE_PERIOD_MIDDLE);
} else if (periodState == PeriodState.LAST) {
mergeDrawableStates(drawableState, STATE_PERIOD_LAST);
if (rangeState == MonthCellDescriptor.RangeState.FIRST) {
mergeDrawableStates(drawableState, STATE_RANGE_FIRST);
} else if (rangeState == MonthCellDescriptor.RangeState.MIDDLE) {
mergeDrawableStates(drawableState, STATE_RANGE_MIDDLE);
} else if (rangeState == RangeState.LAST) {
mergeDrawableStates(drawableState, STATE_RANGE_LAST);
}

return drawableState;
Expand Down
Loading

0 comments on commit ddf82a9

Please sign in to comment.