Skip to content

Commit

Permalink
changes date picker to return months from 1 to 12
Browse files Browse the repository at this point in the history
Change-Id: I96c3fde7fc14bb4bff9ac8320e4aa394202ec5e3
  • Loading branch information
josmas committed May 25, 2014
1 parent f3c9942 commit c806171
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 67 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
public class DatePicker extends ButtonBase {

private DatePickerDialog date;
private int year, month, day;
//month is the property that AI devs see, and it's always javaMonth + 1; month is 0-based in Java
private int year, month, javaMonth, day;
private String [] localizedMonths = new DateFormatSymbols().getMonths();

/**
Expand All @@ -44,9 +45,11 @@ public DatePicker(ComponentContainer container) {
//Set the current date on creation
final Calendar c = Calendar.getInstance();
year = c.get(Calendar.YEAR);
month = c.get(Calendar.MONTH);
javaMonth = c.get(Calendar.MONTH);
month = javaMonth + 1;
day = c.get(Calendar.DAY_OF_MONTH);
date = new DatePickerDialog(this.container.$context(), datePickerListener, year, month, day);
date = new DatePickerDialog(this.container.$context(), datePickerListener, year, javaMonth,
day);
}

/**
Expand All @@ -64,7 +67,7 @@ public int Year() {
* @return the year in numeric format
*/
@SimpleProperty(description = "the number of the Month that was last picked using the " +
"DatePicker. Note that months start in 0 = January, 11 = December.",
"DatePicker. Note that months start in 1 = January, 12 = December.",
category = PropertyCategory.APPEARANCE)
public int Month() {
return month;
Expand All @@ -78,7 +81,7 @@ public int Month() {
"DatePicker, in textual format.",
category = PropertyCategory.APPEARANCE)
public String MonthInText() {
return localizedMonths[month];
return localizedMonths[javaMonth];
}

/**
Expand Down Expand Up @@ -108,9 +111,10 @@ public void click() {
public void onDateSet(android.widget.DatePicker datePicker, int selectedYear,
int selectedMonth, int selectedDay) {
year = selectedYear;
month = selectedMonth;
javaMonth = selectedMonth;
month = javaMonth + 1;
day = selectedDay;
date.updateDate(year, month, day);
date.updateDate(year, javaMonth, day);
AfterDateSet();
}
};
Expand Down
124 changes: 64 additions & 60 deletions appinventor/docs/reference/components/userinterface.html
Original file line number Diff line number Diff line change
Expand Up @@ -648,66 +648,70 @@ <h3> Methods </h3>
<dd> Text describing time time of an instant </dd>
</dl>

<h2 id="DatePicker">DatePicker</h2>

<p><p>A button that, when clicked on, launches a popup dialog to allow the user to select a date.</p></p>

<h3>Properties</h3>
<dl>
<dt><code>BackgroundColor</code></dt>
<dd>Returns the button's background color</dd>
<dt><code><em>Day</em></code></dt>
<dd>the Day of the month that was last picked using the DatePicker.</dd>
<dt><code>Enabled</code></dt>
<dd></dd>
<dt><code>FontBold</code> (designer only)</dt>
<dd></dd>
<dt><code>FontItalic</code> (designer only)</dt>
<dd></dd>
<dt><code>FontSize</code> (designer only)</dt>
<dd></dd>
<dt><code>FontTypeface</code> (designer only)</dt>
<dd></dd>
<dt><code>Height</code></dt>
<dd></dd>
<dt><code>Image</code></dt>
<dd>Specifies the path of the button's image. If there is both an Image and a BackgroundColor, only the Image will be visible.</dd>
<dt><code><em>Month</em></code></dt>
<dd>the number of the Month that was last picked using the DatePicker. Note that months start in 0 = January, 11 = December.</dd>
<dt><code><em>MonthInText</em></code></dt>
<dd>Returns the name of the Month that was last picked using the DatePicker, in textual format.</dd>
<dt><code>Shape</code> (designer only)</dt>
<dd>Specifies the button's shape (default, rounded, rectangular, oval). The shape will not be visible if an Image is being displayed.</dd>
<dt><code>ShowFeedback</code></dt>
<dd>Specifies if a visual feedback should be shown for a button that as an image as background.</dd>
<dt><code>Text</code></dt>
<dd></dd>
<dt><code>TextAlignment</code> (designer only)</dt>
<dd></dd>
<dt><code>TextColor</code></dt>
<dd></dd>
<dt><code>Visible</code></dt>
<dd>Specifies whether the component should be visible on the screen. Value is true if the component is showing and false if hidden.</dd>
<dt><code>Width</code></dt>
<dd></dd>
<dt><code><em>Year</em></code></dt>
<dd>the Year that was last picked using the DatePicker</dd>
</dl>

<h3>Events</h3>
<dl>
<dt><code>AfterDateSet()</code></dt>
<dd>Event that runs after the user chooses a Date in the dialog</dd>
<dt><code>GotFocus()</code></dt>
<dd>Indicates the cursor moved over the button so it is now possible
to click it.</dd>
<dt><code>LostFocus()</code></dt>
<dd>Indicates the cursor moved away from the button so it is now no
longer possible to click it.</dd>
</dl>

<h3>Methods</h3>
none
<h2 id="DatePicker">DatePicker</h2>

<p><p>A button that, when clicked on, launches a popup dialog to allow the user to select a date.</p></p>

<h3>Properties</h3>
<dl>
<dt><code>BackgroundColor</code></dt>
<dd>Returns the button's background color</dd>
<dt><code><em>Day</em></code></dt>
<dd>the Day of the month that was last picked using the DatePicker.</dd>
<dt><code>Enabled</code></dt>
<dd></dd>
<dt><code>FontBold</code></dt>
<dd></dd>
<dt><code>FontItalic</code></dt>
<dd></dd>
<dt><code>FontSize</code></dt>
<dd></dd>
<dt><code>FontTypeface</code> (designer only)</dt>
<dd></dd>
<dt><code>Height</code></dt>
<dd></dd>
<dt><code>Image</code></dt>
<dd>Specifies the path of the button's image. If there is both an Image and a BackgroundColor, only the Image will be visible.</dd>
<dt><code><em>Month</em></code></dt>
<dd>the number of the Month that was last picked using the DatePicker. Note that months start in 1 = January, 12 = December.</dd>
<dt><code><em>MonthInText</em></code></dt>
<dd>Returns the name of the Month that was last picked using the DatePicker, in textual format.</dd>
<dt><code>Shape</code> (designer only)</dt>
<dd>Specifies the button's shape (default, rounded, rectangular, oval). The shape will not be visible if an Image is being displayed.</dd>
<dt><code>ShowFeedback</code></dt>
<dd>Specifies if a visual feedback should be shown for a button that as an image as background.</dd>
<dt><code>Text</code></dt>
<dd></dd>
<dt><code>TextAlignment</code> (designer only)</dt>
<dd></dd>
<dt><code>TextColor</code></dt>
<dd></dd>
<dt><code>Visible</code></dt>
<dd>Specifies whether the component should be visible on the screen. Value is true if the component is showing and false if hidden.</dd>
<dt><code>Width</code></dt>
<dd></dd>
<dt><code><em>Year</em></code></dt>
<dd>the Year that was last picked using the DatePicker</dd>
</dl>

<h3>Events</h3>
<dl>
<dt><code>AfterDateSet()</code></dt>
<dd>Event that runs after the user chooses a Date in the dialog</dd>
<dt><code>GotFocus()</code></dt>
<dd>Indicates the cursor moved over the button so it is now possible
to click it.</dd>
<dt><code>LostFocus()</code></dt>
<dd>Indicates the cursor moved away from the button so it is now no
longer possible to click it.</dd>
<dt><code>TouchDown()</code></dt>
<dd>Indicates when a button is touch down</dd>
<dt><code>TouchUp()</code></dt>
<dd>Indicates when a button touch ends</dd>
</dl>

<h3>Methods</h3>
none

<h2 id="Image">Image</h2>

Expand Down

0 comments on commit c806171

Please sign in to comment.