Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-10540] Android: Map Calendar methods with Android permissions

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2013-01-25T22:02:27.000+0000
Affected Version/sRelease 3.0.0
Fix Version/sRelease 3.0.2, Release 3.1.0, 2012 Sprint 26 API, 2012 Sprint 26
ComponentsAndroid
Labelsapi, calendar, qe-testadded
ReporterHieu Pham
AssigneeHieu Pham
Created2012-08-21T17:55:40.000+0000
Updated2013-10-07T06:59:05.000+0000

Description

Assign "READ_CALENDAR" and/or "WRITE_CALENDAR" permissions with calendar methods appropriately in builder.py so permissions will be auto generated. Steps to reproduce: 1. Run this code in Titanium Studio
Titanium.UI.setBackgroundColor('#000');
  
var win = Titanium.UI.createWindow({  
    title:'Calendar',
    backgroundColor:'#fff'
});
win.open();
  
function showCalendars(calendars) {
    for (var i = 0; i < calendars.length; i++) {
        Ti.API.info(calendars[i].name);
        Ti.API.info(JSON.stringify(calendars[i]));
    }
}
  
Ti.API.info('ALL CALENDARS:');
showCalendars(Ti.Android.Calendar.allCalendars);
Ti.API.info('SELECTABLE CALENDARS:');
showCalendars(Ti.Android.Calendar.selectableCalendars);
  
// SHOW ALL EVENTS FOR 2010 FOR ONE CALENDAR
var YEAR = 2012;
var TEST_WITH_THIS_CAL_ID = 1;
var calendar = Ti.Android.Calendar.getCalendarById(TEST_WITH_THIS_CAL_ID);
  
var events = calendar.getEventsInYear(YEAR);
if (events && events.length) {
    Ti.API.info(events.length + ' event(s) in ' + YEAR);
  
    for (var i = 0; i < events.length; i++) {
        Ti.API.info(JSON.stringify(events[i]));
  
    }
} else {
    Ti.API.info('No events');
}
  
  
  
var CALENDAR_TO_USE = 1;
var calendar = Ti.Android.Calendar.getCalendarById(CALENDAR_TO_USE);
  
// Create the event
var eventBegins = new Date(2012, 03, 26, 12, 0, 0);
var eventEnds = new Date(2012, 03, 26, 14, 0, 0);
var details = {
    title: 'Do some stuff',
    description: "I'm going to do some stuff at this time.",
    begin: eventBegins,
    end: eventEnds
};
  
var event = calendar.createEvent(details);
  
// Now add a reminder via e-mail for 10 minutes before the event.
var reminderDetails = {
    minutes: 10,
    method: Ti.Android.Calendar.METHOD_EMAIL
};
event.createReminder(reminderDetails);
2.Code should run w/o having to manually insert calendar permissions into tiapp.xml

Comments

  1. Chris Barber 2012-12-22

    Hieu, could you whip up a 3.0.x pull request and I'll review and merge that too?
  2. Hieu Pham 2013-01-18

    Master PR: https://github.com/appcelerator/titanium_mobile/pull/3594
  3. Vishal Duggal 2013-01-21

    Backport Task TIMOB-12343 Backport PR https://github.com/appcelerator/titanium_mobile/pull/3734
  4. Paras Mishra 2013-01-24

    If Calender permissions are not inserted into the tiapp.xml then Error occurs as " Exception occurred at app.js:53: Uncaught Error: Permission Denial: writing com.android.providers.calendar.CalendarProvider2 uri content://com.android.calendar/events from pid=2759, uid=10061 requires android.permission.WRITE_CALENDAR " Error occurs for sdk build : 3.1.0.v20130123144204, 3.0.2.v20130122172624 tested on Google Nexus Android version : 4.0.4
  5. Hieu Pham 2013-01-25

    Master PR: https://github.com/appcelerator/titanium_mobile/pull/3787
  6. Hieu Pham 2013-01-25

    Backport PR: https://github.com/appcelerator/titanium_mobile/pull/3788
  7. Olga Romero 2013-02-05

    Tested with: Titanium Studio, build: 3.0.2.201302011646 Titanium SDK, build: 3.0.2.v20130201161712 Device: Nexus4 Android version 4.2 "READ_CALENDAR" and/or "WRITE_CALENDAR" permissions are auto generated .

JSON Source