First symptom: calendar exits right away.
I did a quick search for google in the calendar source tree:
find src/ -type f | xargs grep -i google
and found that the interesting stuff lives in LaunchActivity:
http://android.git.kernel.org/?p=platform/packages/apps/Calendar.git;a=blob;f=src/com/android/calendar/LaunchActivity.java;h=1f053d76f73e773389e0839281a59ebd3b6960a2;hb=HEAD
(Check the call to finish() on line 107).
Amusingly, in the call to onAccountsLoaded() on line 103, the accounts
parameter doesn't matter (it's ignored), which means that at that
point Calendar only wants to know that there's an account available
(the details of the account don't matter yet).
Going at it with a big hammer, I locally replaced the call to finish()
by onAccountsLoaded(null). Victory, this is enough to get to the
calendar view.
Second symptom: can't create an entry, "You have no calendars" dialog.
I found the resource in question with
find res/ -type f | xargs grep "You have no calendars"
and tracked it down into the code with
find src/ -type f | xargs grep no_calendars_found
which leads to line 450 of EditEvent
http://android.git.kernel.org/?p=platform/packages/apps/Calendar.git;a=blob;f=src/com/android/calendar/EditEvent.java;h=ce545fa437950bf5c595e031f09b6ad6bf3e422e;hb=HEAD#l450
At this point, it looks like the app is happy to display an "empty"
calendar (probably since the query returns no events), but can't
create any new event (since it has no calendar to create into).
I'd guess that the best approach to resolve this would be to detect
(in LaunchActivity?) that there's no account, therefore no calendar,
and to create a default calendar, or something like that.
Ideas, anyone?
JBQ
--
Jean-Baptiste M. "JBQ" Queru
Software Engineer, Android Open-Source Project, Google.
Questions sent directly to me that have no reason for being private
will likely get ignored or forwarded to a public forum with no further
warning.
Jean-Baptiste Queru wrote:
> It's there in Vladimir's email, just with the wrong name.
>
> JBQ
>
> On Tue, Oct 20, 2009 at 9:38 AM, Michael Trimarchi
> <trim...@gandalf.sssup.it> wrote:
>
>> Vladimir wrote:
>>
>>> I think we can (instead of finish() on line 107) insert something like
>>> that:
>>>
>>> String defaultCalendar = "Default";
>>> ContentResolver cr = getContentResolver();
>>> Cursor cursor = cr.query(Calendars.CONTENT_URI,
>>> ACCOUNTS_PROJECTION,
>>> null, null, Calendars.DEFAULT_SORT_ORDER);
>>> if (cursor == null) {
>>> finish;
>>> } else {
>>> if (cursor.getCount() == 0) {
>>> addCalendar(defaultCalendar);
>>>
>>>
>> Sorry but where is defined the addCalendar function?
>> Michael
>>
>>
>
>
>
Sorry I didn't see the other peace of code. You are right
Thanks
Michael