-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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-24248] Android: Ti.Calendar Recurring Events are not clearly exposed #9412
Changes from 5 commits
8d73746
b035750
13cf4e8
9d815b0
9c1bd59
1566aa4
2a144b6
6b17f4e
942f22b
5768e99
10edb32
4edca00
cc7f237
7eb20d6
0e17436
85da3d6
c9c507b
ab209cc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,7 +28,9 @@ | |
import android.provider.CalendarContract.Instances; | ||
|
||
// Columns and value constants taken from android.provider.Calendar in the android source base | ||
@Kroll.proxy(parentModule=CalendarModule.class) | ||
@Kroll.proxy(parentModule=CalendarModule.class, propertyAccessors = { | ||
TiC.PROPERTY_RECURRENCE_RULES | ||
}) | ||
public class EventProxy extends KrollProxy { | ||
public static final String TAG = "EventProxy"; | ||
|
||
|
@@ -47,7 +49,7 @@ public class EventProxy extends KrollProxy { | |
protected int status, visibility; | ||
protected KrollDict extendedProperties = new KrollDict(); | ||
|
||
protected String recurrenceRule, recurrenceDate, recurrenceExceptionRule, recurrenceExceptionDate; | ||
protected String recurrenceDate, recurrenceExceptionRule, recurrenceExceptionDate; | ||
protected Date lastDate; | ||
|
||
public EventProxy() | ||
|
@@ -96,7 +98,8 @@ public static ArrayList<EventProxy> queryEventsBetweenDates(long date1, long dat | |
} | ||
|
||
Cursor eventCursor = contentResolver.query(builder.build(), new String[] { "event_id", "title", "description", | ||
"eventLocation", "begin", "end", "allDay", "hasAlarm", "eventStatus", visibility }, query, queryArgs, | ||
"eventLocation", "begin", "end", "allDay", "hasAlarm", "eventStatus", visibility, Events.RRULE, | ||
Events.CALENDAR_ID }, query, queryArgs, | ||
"startDay ASC, startMinute ASC"); | ||
|
||
if (eventCursor == null) { | ||
|
@@ -117,7 +120,7 @@ public static ArrayList<EventProxy> queryEventsBetweenDates(long date1, long dat | |
event.hasAlarm = !eventCursor.getString(7).equals("0"); | ||
event.status = eventCursor.getInt(8); | ||
event.visibility = eventCursor.getInt(9); | ||
|
||
event.setRecurrenceRules(eventCursor.getString(10), eventCursor.getInt(11)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could this break when pulling up existing events with no recurrence? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Apparently it could. I did not get any exception, but it is documented as "implementation-defined" |
||
events.add(event); | ||
} | ||
|
||
|
@@ -126,6 +129,16 @@ public static ArrayList<EventProxy> queryEventsBetweenDates(long date1, long dat | |
return events; | ||
} | ||
|
||
@Kroll.method | ||
public void save() { | ||
// Currently only saving added recurrenceRules. | ||
String ruleToSave = ((RecurrenceRuleProxy) ((Object[]) getProperty(TiC.PROPERTY_RECURRENCE_RULES))[0]).generateRRULEString(); | ||
ContentValues contentValues = new ContentValues(); | ||
contentValues.put(Events.RRULE, ruleToSave); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not a huge fan of the truncated constant name here: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is an Android constant: |
||
ContentResolver contentResolver = TiApplication.getInstance().getContentResolver(); | ||
contentResolver.update(Events.CONTENT_URI, contentValues, Events._ID+"=?", new String[]{id}); | ||
} | ||
|
||
public static ArrayList<EventProxy> queryEvents(Uri uri, String query, String[] queryArgs, String orderBy) | ||
{ | ||
ArrayList<EventProxy> events = new ArrayList<EventProxy>(); | ||
|
@@ -319,6 +332,10 @@ public ReminderProxy createReminder(KrollDict data) | |
return ReminderProxy.createReminder(this, minutes, method); | ||
} | ||
|
||
@Kroll.method RecurrenceRuleProxy createRecurrenceRule(KrollDict data) { | ||
return new RecurrenceRuleProxy(data); | ||
} | ||
|
||
@Kroll.method @Kroll.getProperty | ||
public AlertProxy[] getAlerts() | ||
{ | ||
|
@@ -404,10 +421,16 @@ public int getVisibility() | |
return visibility; | ||
} | ||
|
||
@Kroll.getProperty @Kroll.method | ||
public String getRecurrenceRule() | ||
public void setRecurrenceRules(String rrule, int calendarID) | ||
{ | ||
return recurrenceRule; | ||
RecurrenceRuleProxy[] result; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe something a little more compact? RecurrenceRuleProxy[] result = new RecurrenceRuleProxy[]{};
if (rrule != null) {
result = new RecurrenceRuleProxy[] { new RecurrenceRuleProxy(rrule, calendarID, begin) };
}
setProperty(TiC.PROPERTY_RECURRENCE_RULES, result); |
||
if (rrule != null) { | ||
result = new RecurrenceRuleProxy[1]; | ||
result[0] = new RecurrenceRuleProxy(rrule, calendarID, begin);; | ||
} else { | ||
result = new RecurrenceRuleProxy[]{}; | ||
} | ||
setProperty(TiC.PROPERTY_RECURRENCE_RULES, result); | ||
} | ||
|
||
@Kroll.getProperty @Kroll.method | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally, I'd prefer
RECURRENCE_FREQUENCY_DAILY
toRECURRENCEFREQUENCY_DAILY
(same goes for the rest)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the way we currently have them for iOS:
https://docs.appcelerator.com/platform/latest/#!/api/Titanium.Calendar-property-RECURRENCEFREQUENCY_DAILY
We can change them in there too - now would be the time because that would be a breaking change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we'd want to "fix" them to match our naming conventions. We'd have to retain the existing definitions and mark them as deprecated for this release, then in 8.0 or later we can remove the ones missing the underscores. So not really a breaking change, but an important deprecation to get in before GA.