-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(android): added new methods in Ti.Calendar.Calendar module for b…
…ulk operations (#14149) * feat(android): added new methods in CalendarProxy for bulk operations * chore: use constant properties * fix: add missing properties of `scrolling` event * chore(android): add docs to new methods for Ti.Calendar.Calendar module * fix(android): set exitOnClose defaults to true on root window if not set already * Revert "fix(android): set exitOnClose defaults to true on root window if not set already" This reverts commit e2c4bb9. * fix: fix docs formatting * Update android/modules/calendar/src/java/ti/modules/titanium/calendar/CalendarProxy.java Co-authored-by: Michael Gangolf <m1ga@users.noreply.github.com> * Update android/modules/calendar/src/java/ti/modules/titanium/calendar/CalendarProxy.java Co-authored-by: Michael Gangolf <m1ga@users.noreply.github.com> * Update android/modules/calendar/src/java/ti/modules/titanium/calendar/CalendarProxy.java Co-authored-by: Michael Gangolf <m1ga@users.noreply.github.com> * fix: fix docs --------- Co-authored-by: Michael Gangolf <m1ga@users.noreply.github.com> Co-authored-by: Hans Knöchel <hansemannn@users.noreply.github.com>
- Loading branch information
1 parent
5457ee8
commit dfb6a82
Showing
5 changed files
with
322 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
android/modules/calendar/src/java/ti/modules/titanium/calendar/CalendarUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
package ti.modules.titanium.calendar; | ||
|
||
import android.content.ContentValues; | ||
import android.provider.CalendarContract; | ||
import android.text.TextUtils; | ||
|
||
import org.appcelerator.kroll.KrollDict; | ||
import org.appcelerator.titanium.TiC; | ||
import org.appcelerator.titanium.util.TiConvert; | ||
|
||
import java.util.Collections; | ||
import java.util.Date; | ||
|
||
public class CalendarUtils | ||
{ | ||
public static final String TAG = "CalendarUtils"; | ||
|
||
// Build the selection string for IN clause. | ||
public static String prepareQuerySelection(String columnName, int limit) | ||
{ | ||
return columnName + " IN (" + TextUtils.join(", ", Collections.nCopies(limit, "?")) + ")"; | ||
} | ||
|
||
// Creates String[] for selectionArgs. | ||
public static String[] prepareQueryArguments(Object[] data) | ||
{ | ||
String[] queryArgs = new String[data.length]; | ||
for (int i = 0; i < data.length; i++) { | ||
queryArgs[i] = String.valueOf(data[i]); | ||
} | ||
return queryArgs; | ||
} | ||
|
||
public static ContentValues createContentValues(CalendarProxy calendar, KrollDict data, EventProxy event) | ||
{ | ||
if (!data.containsKey(TiC.PROPERTY_TITLE)) { | ||
return null; | ||
} | ||
|
||
ContentValues contentValues = new ContentValues(); | ||
contentValues.put("hasAlarm", 1); | ||
contentValues.put("hasExtendedProperties", 1); | ||
|
||
event.title = TiConvert.toString(data, TiC.PROPERTY_TITLE); | ||
contentValues.put(TiC.PROPERTY_TITLE, event.title); | ||
contentValues.put("calendar_id", calendar.getId()); | ||
contentValues.put(CalendarContract.Events.EVENT_TIMEZONE, new Date().toString()); | ||
|
||
if (data.containsKey(TiC.PROPERTY_LOCATION)) { | ||
event.location = TiConvert.toString(data, TiC.PROPERTY_LOCATION); | ||
contentValues.put(CalendarModule.EVENT_LOCATION, event.location); | ||
} | ||
|
||
if (data.containsKey(TiC.PROPERTY_DESCRIPTION)) { | ||
event.description = TiConvert.toString(data, TiC.PROPERTY_DESCRIPTION); | ||
contentValues.put(TiC.PROPERTY_DESCRIPTION, event.description); | ||
} | ||
|
||
if (data.containsKey("begin")) { | ||
event.begin = TiConvert.toDate(data, "begin"); | ||
if (event.begin != null) { | ||
contentValues.put("dtstart", event.begin.getTime()); | ||
} | ||
} | ||
|
||
if (data.containsKey(TiC.PROPERTY_END)) { | ||
event.end = TiConvert.toDate(data, TiC.PROPERTY_END); | ||
if (event.end != null) { | ||
contentValues.put("dtend", event.end.getTime()); | ||
} | ||
} | ||
|
||
if (data.containsKey("allDay")) { | ||
event.allDay = TiConvert.toBoolean(data, "allDay"); | ||
contentValues.put("allDay", event.allDay ? 1 : 0); | ||
} | ||
|
||
if (data.containsKey("hasExtendedProperties")) { | ||
event.hasExtendedProperties = TiConvert.toBoolean(data, "hasExtendedProperties"); | ||
contentValues.put("hasExtendedProperties", event.hasExtendedProperties ? 1 : 0); | ||
} | ||
|
||
if (data.containsKey("hasAlarm")) { | ||
event.hasAlarm = TiConvert.toBoolean(data, "hasAlarm"); | ||
contentValues.put("hasAlarm", event.hasAlarm ? 1 : 0); | ||
} | ||
|
||
return contentValues; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.