Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-10540

Android: Map Calendar methods with Android permissions

    Details

      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

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                hpham Hieu Pham
                Reporter:
                hpham Hieu Pham
              • Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Backbone Issue Sync

                  • Titanium SDK/CLI <> Titanium Mobile
                    Synced with:
                    TIMOB-5800
                    Sync status:
                    ERROR
                    Last received:
                    Last sent:

                    Git Integration