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

[TIMOB-12539] added a new property calendarViewShown #4328

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.appcelerator.kroll.common.AsyncResult;
import org.appcelerator.kroll.common.TiMessenger;
import org.appcelerator.titanium.TiApplication;
import org.appcelerator.titanium.TiC;
import org.appcelerator.titanium.TiContext;
import org.appcelerator.titanium.proxy.TiViewProxy;
import org.appcelerator.titanium.util.TiConvert;
Expand All @@ -40,8 +41,9 @@
import android.widget.DatePicker;
import android.widget.TimePicker;

@Kroll.proxy(creatableInModule=UIModule.class, propertyAccessors={
"locale", "visibleItems", "value"
@Kroll.proxy(creatableInModule = UIModule.class, propertyAccessors = { "locale", "visibleItems", "value",
TiC.PROPERTY_CALENDAR_VIEW_SHOWN

})
public class PickerProxy extends TiViewProxy implements PickerColumnListener
{
Expand All @@ -62,6 +64,9 @@ public class PickerProxy extends TiViewProxy implements PickerColumnListener
public PickerProxy()
{
super();

defaultValues.put(TiC.PROPERTY_CALENDAR_VIEW_SHOWN, false);

}

public PickerProxy(TiContext tiContext)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@
import org.appcelerator.kroll.KrollDict;
import org.appcelerator.kroll.KrollProxy;
import org.appcelerator.kroll.common.Log;
import org.appcelerator.titanium.TiC;
import org.appcelerator.titanium.proxy.TiViewProxy;
import org.appcelerator.titanium.util.TiConvert;
import org.appcelerator.titanium.util.TiUIHelper;
import org.appcelerator.titanium.view.TiUIView;

import android.app.Activity;
import android.os.Build;
import android.widget.DatePicker;
import android.widget.DatePicker.OnDateChangedListener;

Expand Down Expand Up @@ -82,6 +85,9 @@ public void processProperties(KrollDict d) {

this.maxDate = maxDateCalendar.getTime();
}
if (d.containsKey(TiC.PROPERTY_CALENDAR_VIEW_SHOWN)) {
setCalendarView(TiConvert.toBoolean(d, TiC.PROPERTY_CALENDAR_VIEW_SHOWN));
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This whole block is formatted incorrectly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will correct.

if (d.containsKey("minuteInterval")) {
int mi = d.getInt("minuteInterval");
if (mi >= 1 && mi <= 30 && mi % 60 == 0) {
Expand Down Expand Up @@ -110,11 +116,14 @@ public void processProperties(KrollDict d) {
public void propertyChanged(String key, Object oldValue, Object newValue,
KrollProxy proxy)
{
if (key.equals("value"))
{
Date date = (Date)newValue;
if (key.equals("value")) {
Date date = (Date) newValue;
setValue(date.getTime());
}
if (key.equals(TiC.PROPERTY_CALENDAR_VIEW_SHOWN)) {
setCalendarView(TiConvert.toBoolean(newValue));
}

super.propertyChanged(key, oldValue, newValue, proxy);
}

Expand Down Expand Up @@ -160,4 +169,13 @@ public void setValue(long value, boolean suppressEvent)
.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH));
suppressChangeEvent = false;
}

public void setCalendarView(boolean value)
{
if (Build.VERSION.SDK_INT >= 11) {
DatePicker picker = (DatePicker) getNativeView();
picker.setCalendarViewShown(value);
}
}

}
7 changes: 6 additions & 1 deletion android/titanium/src/java/org/appcelerator/titanium/TiC.java
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,12 @@ public class TiC
* @module.api
*/
public static final String PROPERTY_BYTE_ORDER = "byteOrder";


/**
* @module.api
*/
public static final String PROPERTY_CALENDAR_VIEW_SHOWN = "calendarViewShown";

/**
* @module.api
*/
Expand Down