Merge Sam's 121009_sb_calendar_assistant branch

pull/14/head
Sam Bosley 13 years ago
commit 759b0f427c

@ -502,6 +502,27 @@
</intent-filter>
</receiver>
<receiver android:name="com.todoroo.astrid.gcal.CalendarStartupReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter>
<action android:name="com.todoroo.astrid.SCHEDULE_CAL_REMINDERS"/>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
<activity android:name="com.todoroo.astrid.gcal.CalendarReminderActivity"
android:theme="@android:style/Theme.Translucent.NoTitleBar">
</activity>
<activity android:name="com.todoroo.astrid.gcal.CalendarAlarmListCreator"
android:theme="@android:style/Theme.Translucent.NoTitleBar">
</activity>
<receiver android:name="com.todoroo.astrid.gcal.CalendarAlarmReceiver" />
<!-- old tasks -->
<activity android:name="com.todoroo.astrid.core.OldTaskPreferences"
android:theme="@android:style/Theme"

@ -69,6 +69,10 @@ public class TagSettingsActivity extends FragmentActivity {
public static final int REQUEST_ACTFM_LOGIN = 3;
public static final String TOKEN_AUTOPOPULATE_MEMBERS = "autopopulateMembers"; //$NON-NLS-1$
public static final String TOKEN_AUTOPOPULATE_NAME = "autopopulateName"; //$NON-NLS-1$
private static final String MEMBERS_IN_PROGRESS = "members"; //$NON-NLS-1$
private TagData tagData;
@ -222,6 +226,18 @@ public class TagSettingsActivity extends FragmentActivity {
}
refreshSettingsPage();
String autopopulateMembers = getIntent().getStringExtra(TOKEN_AUTOPOPULATE_MEMBERS);
if (!TextUtils.isEmpty(autopopulateMembers)) {
updateMembers(autopopulateMembers);
getIntent().removeExtra(TOKEN_AUTOPOPULATE_MEMBERS);
}
String autopopulateName = getIntent().getStringExtra(TOKEN_AUTOPOPULATE_NAME);
if (!TextUtils.isEmpty(autopopulateName)) {
tagName.setText(autopopulateName);
getIntent().removeExtra(TOKEN_AUTOPOPULATE_NAME);
}
}
@SuppressWarnings("nls")

@ -137,6 +137,7 @@ public class TagViewFragment extends TaskListFragment {
Intent intent = new Intent(getActivity(), settingsClass);
intent.putExtra(EXTRA_TAG_DATA, tagData);
startActivityForResult(intent, REQUEST_CODE_SETTINGS);
if (!AstridPreferences.useTabletLayout(activity)) {
AndroidUtilities.callOverridePendingTransition(activity, R.anim.slide_left_in, R.anim.slide_left_out);
}
@ -307,6 +308,8 @@ public class TagViewFragment extends TaskListFragment {
}
protected void setUpMembersGallery() {
if (tagData == null)
return;
LinearLayout membersView = (LinearLayout)getView().findViewById(R.id.shared_with);
membersView.setOnClickListener(settingsListener);
try {

@ -168,8 +168,8 @@ public class MissedCallActivity extends Activity {
ignoreSettingsButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent labsPreferences = new Intent(MissedCallActivity.this, EditPreferences.class);
startActivity(labsPreferences);
Intent editPreferences = new Intent(MissedCallActivity.this, EditPreferences.class);
startActivity(editPreferences);
finish();
}
});

@ -0,0 +1,230 @@
package com.todoroo.astrid.gcal;
import java.util.ArrayList;
import java.util.HashMap;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;
import com.timsu.astrid.R;
import com.todoroo.andlib.data.TodorooCursor;
import com.todoroo.andlib.service.Autowired;
import com.todoroo.andlib.service.DependencyInjectionService;
import com.todoroo.andlib.sql.Query;
import com.todoroo.andlib.utility.AndroidUtilities;
import com.todoroo.astrid.actfm.sync.ActFmPreferenceService;
import com.todoroo.astrid.activity.EditPreferences;
import com.todoroo.astrid.activity.TaskListActivity;
import com.todoroo.astrid.activity.TaskListFragment;
import com.todoroo.astrid.dao.UserDao;
import com.todoroo.astrid.data.TagData;
import com.todoroo.astrid.data.User;
import com.todoroo.astrid.service.TagDataService;
import com.todoroo.astrid.service.ThemeService;
public class CalendarAlarmListCreator extends Activity {
public static final String TOKEN_LIST_NAME = "listName"; //$NON-NLS-1$
@Autowired
private UserDao userDao;
@Autowired
private TagDataService tagDataService;
@Autowired
private ActFmPreferenceService actFmPreferenceService;
private ArrayList<String> names;
private ArrayList<String> emails;
private HashMap<String, User> emailsToUsers;
private String tagName;
private TextView inviteAll;
private TextView moreOptions;
private TextView ignoreButton;
private View dismissButton;
private View ignoreSettingsButton;
private final OnClickListener dismissListener = new OnClickListener() {
@Override
public void onClick(View v) {
TagData tagData = new TagData();
tagData.setValue(TagData.NAME, tagName);
tagDataService.save(tagData);
dismissWithAnimation();
}
};
private void dismissWithAnimation() {
finish();
AndroidUtilities.callOverridePendingTransition(CalendarAlarmListCreator.this, 0, android.R.anim.fade_out);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
DependencyInjectionService.getInstance().inject(this);
setContentView(R.layout.calendar_alarm_list_creator);
Intent intent = getIntent();
tagName = intent.getStringExtra(TOKEN_LIST_NAME);
inviteAll = (TextView) findViewById(R.id.invite_all);
moreOptions = (TextView) findViewById(R.id.list_settings);
ignoreButton = (TextView) findViewById(R.id.ignore);
dismissButton = findViewById(R.id.dismiss);
ignoreSettingsButton = findViewById(R.id.ignore_settings);
emails = intent.getStringArrayListExtra(CalendarReminderActivity.TOKEN_EMAILS);
names = intent.getStringArrayListExtra(CalendarReminderActivity.TOKEN_NAMES);
initializeUserMap();
setupUi();
addListeners();
}
private void initializeUserMap() {
emailsToUsers = new HashMap<String, User>();
TodorooCursor<User> users = userDao.query(Query.select(User.PROPERTIES).where(User.EMAIL.in(emails.toArray(new String[emails.size()]))));
try {
for (users.moveToFirst(); !users.isAfterLast(); users.moveToNext()) {
User u = new User(users);
emailsToUsers.put(u.getValue(User.EMAIL), u);
}
} finally {
users.close();
}
}
private void setupUi() {
TextView dialogView = (TextView) findViewById(R.id.reminder_message);
StringBuilder builder = new StringBuilder(getString(R.string.CRA_created_list_dialog, tagName));
String attendeesString = buildAttendeesString();
int color = ThemeService.getThemeColor();
String title;
if (!TextUtils.isEmpty(attendeesString)) {
builder.append(" ") //$NON-NLS-1$
.append(attendeesString)
.append(" ") //$NON-NLS-1$
.append(getString(R.string.CRA_invitation_prompt));
inviteAll.setBackgroundColor(getResources().getColor(color));
title = getString(R.string.CRA_share_list_title);
} else {
title = getString(R.string.CRA_list_created_title);
moreOptions.setBackgroundColor(getResources().getColor(color));
inviteAll.setVisibility(View.GONE);
ignoreButton.setVisibility(View.GONE);
ignoreSettingsButton.setVisibility(View.GONE);
}
((TextView) findViewById(R.id.reminder_title))
.setText(title);
dialogView.setText(builder.toString());
}
private void addListeners() {
ignoreButton.setOnClickListener(dismissListener);
dismissButton.setOnClickListener(dismissListener);
ignoreSettingsButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent editPreferences = new Intent(CalendarAlarmListCreator.this, EditPreferences.class);
startActivity(editPreferences);
dismissListener.onClick(v);
}
});
inviteAll.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// Set members json and save
if (!actFmPreferenceService.isLoggedIn()) {
moreOptions.performClick();
return;
} else {
JSONArray membersArray = buildMembersArray();
TagData tagData = new TagData();
tagData.setValue(TagData.NAME, tagName);
tagData.setValue(TagData.MEMBERS, membersArray.toString());
tagData.setValue(TagData.MEMBER_COUNT, membersArray.length());
tagDataService.save(tagData);
dismissWithAnimation();
}
}
});
moreOptions.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(CalendarAlarmListCreator.this, TaskListActivity.class);
intent.putExtra(TaskListFragment.TOKEN_NEW_LIST_NAME, tagName);
intent.putExtra(TaskListFragment.TOKEN_NEW_LIST_MEMBERS, buildMembersArray().toString());
intent.putExtra(TaskListFragment.TOKEN_NEW_LIST, true);
startActivity(intent);
dismissWithAnimation();
}
});
}
private String buildAttendeesString() {
if (emails.size() == 0) {
return ""; //$NON-NLS-1$
} else if (emails.size() == 1) {
String displayName = getDisplayName(0);
return getString(R.string.CRA_one_attendee, displayName);
} else { // emails.size() >= 2
String displayName1 = getDisplayName(0);
String displayName2 = getDisplayName(1);
int extras = emails.size() - 2;
if (extras > 0)
return getString(R.string.CRA_many_attendees, displayName1, displayName2, extras);
else
return getString(R.string.CRA_two_attendees, displayName1, displayName2);
}
}
private JSONArray buildMembersArray() {
JSONArray array = new JSONArray();
for (String email : emails) {
JSONObject member = new JSONObject();
try {
member.put("email", email); //$NON-NLS-1$
array.put(member);
} catch (JSONException e) {
Log.e(CalendarAlarmScheduler.TAG, "Error creating json member " + email, e); //$NON-NLS-1$
}
}
return array;
}
private String getDisplayName(int index) {
String name = names.get(index);
if (!TextUtils.isEmpty(name))
return name;
String email = emails.get(index);
if (emailsToUsers.containsKey(email)) {
User u = emailsToUsers.get(email);
String userName = u.getValue(User.NAME);
if (!TextUtils.isEmpty(userName))
return userName;
}
return email;
}
}

@ -0,0 +1,154 @@
package com.todoroo.astrid.gcal;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Set;
import android.accounts.Account;
import android.accounts.AccountManager;
import android.content.BroadcastReceiver;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.text.TextUtils;
import android.util.Log;
import com.timsu.astrid.R;
import com.todoroo.andlib.utility.DateUtilities;
import com.todoroo.andlib.utility.Preferences;
import com.todoroo.astrid.actfm.sync.ActFmPreferenceService;
import com.todoroo.astrid.utility.Constants;
@SuppressWarnings("nls")
public class CalendarAlarmReceiver extends BroadcastReceiver {
public static final int REQUEST_CODE_CAL_REMINDER = 100;
public static final String BROADCAST_CALENDAR_REMINDER = Constants.PACKAGE + ".CALENDAR_EVENT";
private static final String[] EVENTS_PROJECTION = {
Calendars.EVENTS_DTSTART_COL,
Calendars.EVENTS_DTEND_COL,
Calendars.EVENTS_NAME_COL,
};
private static final String[] ATTENDEES_PROJECTION = {
Calendars.ATTENDEES_NAME_COL,
Calendars.ATTENDEES_EMAIL_COL,
};
@Override
public void onReceive(Context context, Intent intent) {
if (!Preferences.getBoolean(R.string.p_calendar_reminders, true))
return;
try {
Uri data = intent.getData();
if (data == null)
return;
String uriString = data.toString();
int pathIndex = uriString.indexOf("://");
if (pathIndex > 0)
pathIndex += 3;
else return;
long eventId = Long.parseLong(uriString.substring(pathIndex));
boolean fromPostpone = CalendarAlarmScheduler.URI_PREFIX_POSTPONE.equals(data.getScheme());
if (eventId > 0) {
showCalReminder(context, eventId, fromPostpone);
}
} catch (IllegalArgumentException e) { // Some cursor read failed, or badly formed uri
e.printStackTrace();
}
}
private void showCalReminder(Context context,
long eventId, boolean fromPostpone) {
ContentResolver cr = context.getContentResolver();
Uri eventUri = Calendars.getCalendarContentUri(Calendars.CALENDAR_CONTENT_EVENTS);
String[] eventArg = new String[] { Long.toString(eventId) };
Cursor event = cr.query(eventUri,
EVENTS_PROJECTION,
Calendars.ID_COLUMN_NAME + " = ?",
eventArg,
null);
try {
if (event.moveToFirst()) {
int dtstartIndex = event.getColumnIndexOrThrow(Calendars.EVENTS_DTSTART_COL);
int dtendIndex = event.getColumnIndexOrThrow(Calendars.EVENTS_DTEND_COL);
int titleIndex = event.getColumnIndexOrThrow(Calendars.EVENTS_NAME_COL);
String title = event.getString(titleIndex);
long startTime = event.getLong(dtstartIndex);
long endTime = event.getLong(dtendIndex);
boolean shouldShowReminder;
if (fromPostpone) {
long timeAfter = DateUtilities.now() - endTime;
shouldShowReminder = (timeAfter > DateUtilities.ONE_MINUTE * 2);
} else {
long timeUntil = startTime - DateUtilities.now();
shouldShowReminder = (timeUntil > 0 && timeUntil < DateUtilities.ONE_MINUTE * 20);
}
if (shouldShowReminder) {
// Get attendees
Cursor attendees = cr.query(Calendars.getCalendarContentUri(Calendars.CALENDAR_CONTENT_ATTENDEES),
ATTENDEES_PROJECTION,
Calendars.ATTENDEES_EVENT_ID_COL + " = ? ",
eventArg,
null);
try {
// Do something with attendees
int emailIndex = attendees.getColumnIndexOrThrow(Calendars.ATTENDEES_EMAIL_COL);
int nameIndex = attendees.getColumnIndexOrThrow(Calendars.ATTENDEES_NAME_COL);
ArrayList<String> names = new ArrayList<String>();
ArrayList<String> emails = new ArrayList<String>();
Account[] accountArray = AccountManager.get(context).getAccounts();
Set<String> phoneAccounts = new HashSet<String>();
for (Account a : accountArray) {
phoneAccounts.add(a.name);
}
String astridUser = ActFmPreferenceService.thisUser().optString("email");
if (!TextUtils.isEmpty(astridUser))
phoneAccounts.add(astridUser);
for (attendees.moveToFirst(); !attendees.isAfterLast(); attendees.moveToNext()) {
String name = attendees.getString(nameIndex);
String email = attendees.getString(emailIndex);
if (!TextUtils.isEmpty(email)) {
if (phoneAccounts.contains(email))
continue;
if (Constants.DEBUG)
Log.w(CalendarAlarmScheduler.TAG, "Attendee: " + name + ", email: " + email);
names.add(name);
emails.add(email);
}
}
if (emails.size() > 0) {
Intent reminderActivity = new Intent(context, CalendarReminderActivity.class);
reminderActivity.putStringArrayListExtra(CalendarReminderActivity.TOKEN_NAMES, names);
reminderActivity.putStringArrayListExtra(CalendarReminderActivity.TOKEN_EMAILS, emails);
reminderActivity.putExtra(CalendarReminderActivity.TOKEN_EVENT_ID, eventId);
reminderActivity.putExtra(CalendarReminderActivity.TOKEN_EVENT_NAME, title);
reminderActivity.putExtra(CalendarReminderActivity.TOKEN_EVENT_START_TIME, startTime);
reminderActivity.putExtra(CalendarReminderActivity.TOKEN_EVENT_END_TIME, endTime);
reminderActivity.putExtra(CalendarReminderActivity.TOKEN_FROM_POSTPONE, fromPostpone);
reminderActivity.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
context.startActivity(reminderActivity);
}
} finally {
attendees.close();
}
}
}
} finally {
event.close();
}
}
}

@ -0,0 +1,81 @@
package com.todoroo.astrid.gcal;
import java.util.Date;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.util.Log;
import com.timsu.astrid.R;
import com.todoroo.andlib.utility.DateUtilities;
import com.todoroo.andlib.utility.Preferences;
import com.todoroo.astrid.utility.Constants;
@SuppressWarnings("nls")
public class CalendarAlarmScheduler {
public static final String TAG = "calendar-alarm";
public static final String URI_PREFIX = "cal-reminder";
public static final String URI_PREFIX_POSTPONE = "cal-postpone";
public static void scheduleAllCalendarAlarms(Context context) {
if (!Preferences.getBoolean(R.string.p_calendar_reminders, true))
return;
ContentResolver cr = context.getContentResolver();
long now = DateUtilities.now();
AlarmManager am = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
Cursor events = cr.query(Calendars.getCalendarContentUri(Calendars.CALENDAR_CONTENT_EVENTS),
new String[] { Calendars.ID_COLUMN_NAME, Calendars.EVENTS_DTSTART_COL },
Calendars.EVENTS_DTSTART_COL + " > ? AND " + Calendars.EVENTS_DTSTART_COL + " < ?",
new String[] { Long.toString(now + DateUtilities.ONE_MINUTE * 20), Long.toString(now + DateUtilities.ONE_DAY) },
null);
try {
if (events.getCount() > 0) {
int idIndex = events.getColumnIndex(Calendars.ID_COLUMN_NAME);
int dtstartIndex = events.getColumnIndexOrThrow(Calendars.EVENTS_DTSTART_COL);
for (events.moveToFirst(); !events.isAfterLast(); events.moveToNext()) {
Intent eventAlarm = new Intent(context, CalendarAlarmReceiver.class);
eventAlarm.setAction(CalendarAlarmReceiver.BROADCAST_CALENDAR_REMINDER);
long start = events.getLong(dtstartIndex);
long id = events.getLong(idIndex);
eventAlarm.setData(Uri.parse(URI_PREFIX + "://" + id));
PendingIntent pendingIntent = PendingIntent.getBroadcast(context,
CalendarAlarmReceiver.REQUEST_CODE_CAL_REMINDER, eventAlarm, 0);
am.cancel(pendingIntent);
long alarmTime = start - DateUtilities.ONE_MINUTE * 15;
am.set(AlarmManager.RTC_WAKEUP, alarmTime, pendingIntent);
if (Constants.DEBUG)
Log.w(TAG, "Scheduling calendar alarm for " + new Date(alarmTime));
}
}
// Schedule alarm to recheck and reschedule calendar alarms in 12 hours
Intent rescheduleAlarm = new Intent(CalendarStartupReceiver.BROADCAST_RESCHEDULE_CAL_ALARMS);
PendingIntent pendingReschedule = PendingIntent.getBroadcast(context, 0,
rescheduleAlarm, 0);
am.cancel(pendingReschedule);
am.set(AlarmManager.RTC, DateUtilities.now() + DateUtilities.ONE_HOUR * 12, pendingReschedule);
} finally {
events.close();
}
}
}

@ -0,0 +1,249 @@
package com.todoroo.astrid.gcal;
import java.util.Date;
import android.app.Activity;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;
import com.timsu.astrid.R;
import com.todoroo.andlib.service.Autowired;
import com.todoroo.andlib.service.DependencyInjectionService;
import com.todoroo.andlib.utility.AndroidUtilities;
import com.todoroo.andlib.utility.DateUtilities;
import com.todoroo.andlib.utility.DialogUtilities;
import com.todoroo.andlib.utility.Preferences;
import com.todoroo.astrid.activity.EditPreferences;
import com.todoroo.astrid.activity.TaskListActivity;
import com.todoroo.astrid.activity.TaskListFragment;
import com.todoroo.astrid.api.FilterWithCustomIntent;
import com.todoroo.astrid.data.TagData;
import com.todoroo.astrid.service.StartupService;
import com.todoroo.astrid.service.TagDataService;
import com.todoroo.astrid.service.ThemeService;
import com.todoroo.astrid.tags.TagFilterExposer;
import com.todoroo.astrid.utility.Constants;
@SuppressWarnings("nls")
public class CalendarReminderActivity extends Activity {
public static final String TOKEN_NAMES = "names";
public static final String TOKEN_EMAILS = "emails";
public static final String TOKEN_EVENT_ID = "eventId";
public static final String TOKEN_EVENT_NAME = "eventName";
public static final String TOKEN_EVENT_START_TIME = "eventStartTime";
public static final String TOKEN_EVENT_END_TIME = "eventEndTime";
public static final String TOKEN_FROM_POSTPONE = "fromPostpone";
private static final String PREF_IGNORE_PRESSES = "calEventsIgnored";
// Prompt user to ignore all missed calls after this many ignore presses
private static final int IGNORE_PROMPT_COUNT = 3;
@Autowired
private TagDataService tagDataService;
private String eventName;
private long startTime;
private long endTime;
private long eventId;
private boolean fromPostpone;
private TextView ignoreButton;
private TextView createListButton;
private TextView postponeButton;
private View dismissButton;
private View ignoreSettingsButton;
private final OnClickListener dismissListener = new OnClickListener() {
@Override
public void onClick(View v) {
finish();
AndroidUtilities.callOverridePendingTransition(CalendarReminderActivity.this, 0, android.R.anim.fade_out);
}
};
private final OnClickListener ignoreListener = new OnClickListener() {
@Override
public void onClick(final View v) {
// Check for number of ignore presses
int ignorePresses = Preferences.getInt(PREF_IGNORE_PRESSES, 0);
ignorePresses++;
if (ignorePresses == IGNORE_PROMPT_COUNT) {
DialogUtilities.okCancelCustomDialog(CalendarReminderActivity.this,
getString(R.string.CRA_ignore_title),
getString(R.string.CRA_ignore_body),
R.string.CRA_ignore_all,
R.string.CRA_ignore_this,
0,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Preferences.setBoolean(R.string.p_calendar_reminders, false);
dismissListener.onClick(v);
}
},
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dismissListener.onClick(v);
}
});
} else {
dismissListener.onClick(v);
}
Preferences.setInt(PREF_IGNORE_PRESSES, ignorePresses);
}
};
@Override
protected void onCreate(Bundle savedInstanceState) {
new StartupService().onStartupApplication(this);
super.onCreate(savedInstanceState);
DependencyInjectionService.getInstance().inject(this);
setContentView(R.layout.calendar_reminder_activity);
Intent intent = getIntent();
fromPostpone = intent.getBooleanExtra(TOKEN_FROM_POSTPONE, false);
eventId = intent.getLongExtra(TOKEN_EVENT_ID, -1);
eventName = intent.getStringExtra(TOKEN_EVENT_NAME);
startTime = intent.getLongExtra(TOKEN_EVENT_START_TIME, DateUtilities.now());
endTime = intent.getLongExtra(TOKEN_EVENT_END_TIME, DateUtilities.now() + DateUtilities.ONE_HOUR);
createListButton = (TextView) findViewById(R.id.create_list);
postponeButton = (TextView) findViewById(R.id.postpone);
ignoreButton = (TextView) findViewById(R.id.ignore);
ignoreSettingsButton = findViewById(R.id.ignore_settings);
dismissButton = findViewById(R.id.dismiss);
setupUi();
addListeners();
}
private void setupUi() {
((TextView) findViewById(R.id.reminder_title))
.setText(getString(R.string.CRA_title));
TextView dialogView = (TextView) findViewById(R.id.reminder_message);
String speechText;
if (fromPostpone)
speechText = getString(R.string.CRA_speech_bubble_end, eventName);
else
speechText = getString(R.string.CRA_speech_bubble_start, eventName);
dialogView.setText(speechText);
createListButton.setBackgroundColor(getResources().getColor(ThemeService.getThemeColor()));
if (fromPostpone)
postponeButton.setVisibility(View.GONE);
}
private void addListeners() {
ignoreButton.setOnClickListener(ignoreListener);
dismissButton.setOnClickListener(dismissListener);
ignoreSettingsButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent editPreferences = new Intent(CalendarReminderActivity.this, EditPreferences.class);
startActivity(editPreferences);
dismissListener.onClick(v);
}
});
if (!fromPostpone)
postponeButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
postpone();
}
});
createListButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
String listName = getString(R.string.CRA_default_list_name, eventName);
TagData existing = tagDataService.getTag(listName, TagData.PROPERTIES);
if (existing != null) {
listExists(existing);
} else {
createNewList(listName);
}
}
});
}
private void listExists(final TagData tag) {
DialogUtilities.okCancelCustomDialog(this,
getString(R.string.CRA_list_exists_title),
getString(R.string.CRA_list_exists_body, tag.getValue(TagData.NAME)),
R.string.CRA_create_new,
R.string.CRA_use_existing,
0,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
createNewList(tag.getValue(TagData.NAME) + " "
+ DateUtilities.getDateStringHideYear(CalendarReminderActivity.this, new Date(startTime)));
}
},
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
FilterWithCustomIntent filter = TagFilterExposer.filterFromTagData(CalendarReminderActivity.this, tag);
Intent listIntent = new Intent(CalendarReminderActivity.this, TaskListActivity.class);
listIntent.putExtra(TaskListFragment.TOKEN_FILTER, filter);
listIntent.putExtras(filter.customExtras);
startActivity(listIntent);
dismissButton.performClick();
}
});
}
private void createNewList(String name) {
Intent newListIntent = new Intent(this, CalendarAlarmListCreator.class);
newListIntent.putStringArrayListExtra(TOKEN_NAMES, getIntent().getStringArrayListExtra(TOKEN_NAMES));
newListIntent.putStringArrayListExtra(TOKEN_EMAILS, getIntent().getStringArrayListExtra(TOKEN_EMAILS));
newListIntent.putExtra(CalendarAlarmListCreator.TOKEN_LIST_NAME, name);
startActivity(newListIntent);
dismissButton.performClick(); // finish with animation
}
private void postpone() {
AlarmManager am = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
Intent eventAlarm = new Intent(this, CalendarAlarmReceiver.class);
eventAlarm.setAction(CalendarAlarmReceiver.BROADCAST_CALENDAR_REMINDER);
eventAlarm.setData(Uri.parse(CalendarAlarmScheduler.URI_PREFIX_POSTPONE + "://" + eventId));
PendingIntent pendingIntent = PendingIntent.getBroadcast(this,
CalendarAlarmReceiver.REQUEST_CODE_CAL_REMINDER, eventAlarm, 0);
am.cancel(pendingIntent);
long alarmTime = endTime + DateUtilities.ONE_MINUTE * 5;
if (Constants.DEBUG)
Log.w(CalendarAlarmScheduler.TAG, "Scheduling calendar alarm for " + new Date(alarmTime));
am.set(AlarmManager.RTC_WAKEUP, alarmTime, pendingIntent);
dismissButton.performClick();
}
}

@ -0,0 +1,33 @@
package com.todoroo.astrid.gcal;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import com.timsu.astrid.R;
import com.todoroo.andlib.service.ContextManager;
import com.todoroo.andlib.utility.Preferences;
import com.todoroo.astrid.api.AstridApiConstants;
public class CalendarStartupReceiver extends BroadcastReceiver {
public static final String BROADCAST_RESCHEDULE_CAL_ALARMS = AstridApiConstants.PACKAGE + ".SCHEDULE_CAL_REMINDERS"; //$NON-NLS-1$
@Override
public void onReceive(Context context, Intent intent) {
ContextManager.setContext(context);
scheduleCalendarAlarms(context);
}
public static void scheduleCalendarAlarms(final Context context) {
if (!Preferences.getBoolean(R.string.p_calendar_reminders, true))
return;
new Thread(new Runnable() {
@Override
public void run() {
CalendarAlarmScheduler.scheduleAllCalendarAlarms(context);
}
}).start();
}
}

@ -27,23 +27,31 @@ public class Calendars {
public static final String CALENDAR_CONTENT_CALENDARS = "calendars";
public static final String CALENDAR_CONTENT_EVENTS = "events";
public static final String CALENDAR_CONTENT_ATTENDEES = "attendees";
private static final String ID_COLUMN_NAME = "_id";
private static final boolean USE_ICS_NAMES = AndroidUtilities.getSdkVersion() >= 14;
private static final String DISPLAY_COLUMN_NAME = (USE_ICS_NAMES ? CalendarContract.Calendars.CALENDAR_DISPLAY_NAME : "displayName");
private static final String ACCES_LEVEL_COLUMN_NAME = (USE_ICS_NAMES ? CalendarContract.Calendars.CALENDAR_ACCESS_LEVEL : "access_level");
public static final String ID_COLUMN_NAME = "_id";
public static final String CALENDARS_DISPLAY_COL = (USE_ICS_NAMES ? CalendarContract.Calendars.CALENDAR_DISPLAY_NAME : "displayName");
public static final String CALENDARS_ACCESS_LEVEL_COL = (USE_ICS_NAMES ? CalendarContract.Calendars.CALENDAR_ACCESS_LEVEL : "access_level");
public static final String EVENTS_DTSTART_COL = (USE_ICS_NAMES ? CalendarContract.Events.DTSTART : "dtstart");
public static final String EVENTS_DTEND_COL = (USE_ICS_NAMES ? CalendarContract.Events.DTEND : "dtend");
public static final String EVENTS_NAME_COL = (USE_ICS_NAMES ? CalendarContract.Events.TITLE : "title");
public static final String ATTENDEES_EVENT_ID_COL = (USE_ICS_NAMES ? CalendarContract.Attendees.EVENT_ID : "event_id");
public static final String ATTENDEES_NAME_COL = (USE_ICS_NAMES ? CalendarContract.Attendees.ATTENDEE_NAME : "attendeeName");
public static final String ATTENDEES_EMAIL_COL = (USE_ICS_NAMES ? CalendarContract.Attendees.ATTENDEE_EMAIL: "attendeeEmail");
private static final String[] CALENDARS_PROJECTION = new String[] {
ID_COLUMN_NAME,
DISPLAY_COLUMN_NAME,
CALENDARS_DISPLAY_COL,
};
// Only show calendars that the user can modify. Access level 500
// corresponds to Calendars.CONTRIBUTOR_ACCESS
private static final String CALENDARS_WHERE = ACCES_LEVEL_COLUMN_NAME + ">= 500";
private static final String CALENDARS_WHERE = CALENDARS_ACCESS_LEVEL_COL + ">= 500";
private static final String CALENDARS_SORT = DISPLAY_COLUMN_NAME + " ASC";
private static final String CALENDARS_SORT = CALENDARS_DISPLAY_COL + " ASC";
// --- api access
@ -66,6 +74,8 @@ public class Calendars {
return CalendarContract.Calendars.CONTENT_URI;
else if (CALENDAR_CONTENT_EVENTS.equals(table))
return CalendarContract.Events.CONTENT_URI;
else if (CALENDAR_CONTENT_ATTENDEES.equals(table))
return CalendarContract.Attendees.CONTENT_URI;
return null;
}
@ -133,7 +143,7 @@ public class Calendars {
// Iterate calendars one by one, and fill up the list preference
int row = 0;
int idColumn = c.getColumnIndex(ID_COLUMN_NAME);
int nameColumn = c.getColumnIndex(DISPLAY_COLUMN_NAME);
int nameColumn = c.getColumnIndex(CALENDARS_DISPLAY_COL);
while (c.moveToNext()) {
String id = c.getString(idColumn);
String name = c.getString(nameColumn);

@ -115,7 +115,7 @@ public class TagFilterExposer extends BroadcastReceiver implements AstridFilterE
}
/** Create a filter from tag data object */
public static Filter filterFromTagData(Context context, TagData tagData) {
public static FilterWithCustomIntent filterFromTagData(Context context, TagData tagData) {
Tag tag = new Tag(tagData);
return filterFromTag(context, tag, TaskCriteria.activeAndVisible());
}

@ -0,0 +1,104 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
** Copyright (c) 2012 Todoroo Inc
**
** See the file "LICENSE" for the full license governing this code.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/reminder_root"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:orientation="vertical"
android:background="@drawable/reminder_dialog_background">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="5dip"
android:layout_marginRight="5dip"
android:layout_marginBottom="15dip"
android:layout_marginLeft="10dip">
<TextView
android:id="@+id/reminder_title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="1dip"
android:textSize="24sp"
android:textColor="@android:color/white"
android:layout_weight="1"
android:text="@string/CRA_share_list_title"/>
<ImageView
android:id="@+id/dismiss"
android:layout_width="25dip"
android:layout_height="25dip"
android:scaleType="fitCenter"
android:src="@drawable/ic_menu_close"/>
</LinearLayout>
<FrameLayout
android:id="@+id/calendar_reminder_speech_bubble"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<include layout="@layout/astrid_speech_bubble" />
</FrameLayout>
<TextView
android:id="@+id/invite_all"
android:layout_width="fill_parent"
android:layout_height="35dip"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:layout_marginBottom="10dip"
android:textColor="@android:color/white"
android:textSize="24sp"
android:gravity="center"
android:text="@string/CRA_invite_attendees"/>
<TextView
android:id="@+id/list_settings"
android:layout_width="fill_parent"
android:layout_height="35dip"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:layout_marginBottom="10dip"
android:textColor="@android:color/white"
android:textSize="24sp"
android:gravity="center"
android:background="#707070"
android:text="@string/CRA_more_options"/>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:layout_marginBottom="10dip">
<TextView
android:id="@+id/ignore"
android:layout_width="fill_parent"
android:layout_height="35dip"
android:textColor="@android:color/white"
android:textSize="24sp"
android:gravity="center"
android:text="@string/CRA_dont_invite"
android:background="#707070"/>
<ImageView
android:id="@+id/ignore_settings"
android:layout_alignParentRight="true"
android:layout_width="35dip"
android:layout_height="35dip"
android:padding="4dip"
android:background="@android:color/transparent"
android:scaleType="fitCenter"
android:src="@drawable/single_gear"/>
</RelativeLayout>
</LinearLayout>

@ -0,0 +1,104 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
** Copyright (c) 2012 Todoroo Inc
**
** See the file "LICENSE" for the full license governing this code.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/reminder_root"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:orientation="vertical"
android:background="@drawable/reminder_dialog_background">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="5dip"
android:layout_marginRight="5dip"
android:layout_marginBottom="15dip"
android:layout_marginLeft="10dip">
<TextView
android:id="@+id/reminder_title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="1dip"
android:textSize="24sp"
android:textColor="@android:color/white"
android:layout_weight="1"
android:text="@string/CRA_title"/>
<ImageView
android:id="@+id/dismiss"
android:layout_width="25dip"
android:layout_height="25dip"
android:scaleType="fitCenter"
android:src="@drawable/ic_menu_close"/>
</LinearLayout>
<FrameLayout
android:id="@+id/calendar_reminder_speech_bubble"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<include layout="@layout/astrid_speech_bubble" />
</FrameLayout>
<TextView
android:id="@+id/create_list"
android:layout_width="fill_parent"
android:layout_height="35dip"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:layout_marginBottom="10dip"
android:textColor="@android:color/white"
android:textSize="24sp"
android:gravity="center"
android:text="@string/CRA_create_list"/>
<TextView
android:id="@+id/postpone"
android:layout_width="fill_parent"
android:layout_height="35dip"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:layout_marginBottom="10dip"
android:textColor="@android:color/white"
android:textSize="24sp"
android:gravity="center"
android:background="#707070"
android:text="@string/CRA_postpone"/>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:layout_marginBottom="10dip">
<TextView
android:id="@+id/ignore"
android:layout_width="fill_parent"
android:layout_height="35dip"
android:textColor="@android:color/white"
android:textSize="24sp"
android:gravity="center"
android:text="@string/CRA_ignore"
android:background="#707070"/>
<ImageView
android:id="@+id/ignore_settings"
android:layout_alignParentRight="true"
android:layout_width="35dip"
android:layout_height="35dip"
android:padding="4dip"
android:background="@android:color/transparent"
android:scaleType="fitCenter"
android:src="@drawable/single_gear"/>
</RelativeLayout>
</LinearLayout>

@ -95,6 +95,7 @@
android:layout_alignParentRight="true"
android:layout_width="35dip"
android:layout_height="35dip"
android:padding="4dip"
android:background="@android:color/transparent"
android:scaleType="fitCenter"
android:src="@drawable/single_gear"/>

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
** Copyright (c) 2012 Todoroo Inc
**
** See the file "LICENSE" for the full license governing this code.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center">
<include layout="@layout/astrid_calendar_list_creator_view"/>
</LinearLayout>

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
** Copyright (c) 2012 Todoroo Inc
**
** See the file "LICENSE" for the full license governing this code.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center">
<include layout="@layout/astrid_calendar_reminder_view"/>
</LinearLayout>

@ -49,6 +49,9 @@
<!-- field missed calls preference -->
<string name="p_field_missed_calls">field_missed_calls</string>
<!-- calendar reminders preference -->
<string name="p_calendar_reminders">p_calendar_reminder</string>
<!-- show friends view preference -->
<string name="p_show_friends_view">show_friends_view</string>

@ -520,6 +520,89 @@
</string-array>
<!-- ======================================= Calendar reminder activity == -->
<!-- Calendar remindeer ignore button -->
<string name="CRA_ignore">Ignore</string>
<!-- Calendar event -->
<string name="CRA_title">Need a meeting list?</string>
<!-- Calendar reminder: dialog to ignore all missed calls title -->
<string name="CRA_ignore_title">Ignore all calendar events?</string>
<!-- Calendar reminder: dialog to ignore all missed calls body -->
<string name="CRA_ignore_body">You\'ve ignored several calendar events. Should Astrid stop asking you about them?</string>
<!-- Calendar reminder: dialog to ignore all missed calls ignore all button -->
<string name="CRA_ignore_all">Ignore all events</string>
<!-- Calendar reminder: dialog to ignore all missed calls ignore just this button -->
<string name="CRA_ignore_this">Ignore this event only</string>
<!-- Calendar reminder: astrid speech bubble when event starting (%s -> event name) -->
<string name="CRA_speech_bubble_start">Looks like %s is starting soon. Want to create a list for action items?</string>
<!-- Calendar reminder: astrid speech bubble when event ending (%s -> event name) -->
<string name="CRA_speech_bubble_end">Looks like you just finished with %s. Want to create a list for action items?</string>
<!-- Calendar reminder: create list button -->
<string name="CRA_create_list">Create list</string>
<!-- Calendar reminder: postpone button -->
<string name="CRA_postpone">Maybe afterwards</string>
<!-- Calendar reminder: list exists dialog title -->
<string name="CRA_list_exists_title">List already exists</string>
<!-- Calendar reminder: list exists dialog body (%s -> list name)-->
<string name="CRA_list_exists_body">A list named %s already exists. Do you want to use the existing list or create a new one for this event?</string>
<!-- Calendar reminder: list exists dialog create new button -->
<string name="CRA_create_new">Create new</string>
<!-- Calendar reminder: list exists dialog use existing button -->
<string name="CRA_use_existing">Use existing</string>
<!-- Calendar remindr: created list (%s -> list name) -->
<string name="CRA_created_list_dialog">I created a list %s.</string>
<!-- Calendar reminder: one attendee (%s -> attendee name or email) -->
<string name="CRA_one_attendee">%s is attending.</string>
<!-- Calendar reminder: two attendees (%s -> attendee name or email) -->
<string name="CRA_two_attendees">%1$s and %2$s are attending.</string>
<!-- Calendar reminder: many attendees (%s -> attendee name or email, %3$d -> how many other people) -->
<string name="CRA_many_attendees">%1$s, %2$s, and %3$d others are attending.</string>
<!-- Calendar reminder: invitation prompt -->
<string name="CRA_invitation_prompt">Want to invite them?</string>
<!-- Calendar reminder: preference title -->
<string name="CRA_calendar_reminders_pref_title">Monitor calendar events</string>
<!-- Calendar reminder: pref description disabled -->
<string name="CRA_calendar_reminders_pref_desc_disabled">Astrid will not remind you about upcoming calendar events</string>
<!-- Calendar reminder: pref description enabled -->
<string name="CRA_calendar_reminders_pref_desc_enabled">Astrid will remind you about upcoming calendar events and prompt you to prepare for them</string>
<!-- Calendar reminder: share list title -->
<string name="CRA_share_list_title">Share the list?</string>
<string name="CRA_invite_attendees">Invite attendees</string>
<string name="CRA_more_options">More options</string>
<string name="CRA_dont_invite">No thank you</string>
<!-- Calendar reminder: share list title when no other attendees exist-->
<string name="CRA_list_created_title">List created!</string>
<!-- Calendar reminder: default new list name (%s -> event title) -->
<string name="CRA_default_list_name">Action Items: %s</string>
<!-- ===================================================== HelpActivity == -->
<!-- Help: Button to get support from our website -->

@ -17,6 +17,10 @@
android:key="@string/p_field_missed_calls"
android:title="@string/MCA_missed_calls_pref_title"/>
<CheckBoxPreference
android:key="@string/p_calendar_reminders"
android:title="@string/CRA_calendar_reminders_pref_title" />
<CheckBoxPreference
android:key="@string/p_third_party_addons"
android:title="@string/EPr_third_party_addons" />

@ -547,6 +547,8 @@ public class EditPreferences extends TodorooPreferenceActivity {
R.string.EPr_ideaAuto_desc_disabled, R.string.EPr_ideaAuto_desc_enabled));
else if (booleanPreference(preference, value, R.string.p_field_missed_calls,
R.string.MCA_missed_calls_pref_desc_disabled, R.string.MCA_missed_calls_pref_desc_enabled));
else if (booleanPreference(preference, value, R.string.p_calendar_reminders,
R.string.CRA_calendar_reminders_pref_desc_disabled, R.string.CRA_calendar_reminders_pref_desc_enabled));
else if (booleanPreference(preference, value, R.string.p_use_contact_picker,
R.string.EPr_use_contact_picker_desc_disabled, R.string.EPr_use_contact_picker_desc_enabled));
else if (booleanPreference(preference, value, R.string.p_third_party_addons,

@ -66,6 +66,7 @@ import com.todoroo.andlib.sql.Join;
import com.todoroo.andlib.utility.AndroidUtilities;
import com.todoroo.andlib.utility.Preferences;
import com.todoroo.astrid.actfm.ActFmLoginActivity;
import com.todoroo.astrid.actfm.TagSettingsActivity;
import com.todoroo.astrid.actfm.TagUpdatesActivity;
import com.todoroo.astrid.actfm.TagViewFragment;
import com.todoroo.astrid.actfm.sync.ActFmPreferenceService;
@ -101,6 +102,7 @@ import com.todoroo.astrid.service.UpgradeService;
import com.todoroo.astrid.subtasks.SubtasksListFragment;
import com.todoroo.astrid.sync.SyncProviderPreferences;
import com.todoroo.astrid.tags.TagService;
import com.todoroo.astrid.tags.TagsPlugin;
import com.todoroo.astrid.taskrabbit.TaskRabbitMetadata;
import com.todoroo.astrid.timers.TimerPlugin;
import com.todoroo.astrid.ui.QuickAddBar;
@ -159,6 +161,11 @@ public class TaskListFragment extends ListFragment implements OnScrollListener,
private static final String TOKEN_EXTRAS = "extras"; //$NON-NLS-1$
/** For indicating the new list screen should be launched at fragment setup time */
public static final String TOKEN_NEW_LIST = "newList"; //$NON-NLS-1$
public static final String TOKEN_NEW_LIST_MEMBERS = "newListMembers"; //$NON-NLS-1$
public static final String TOKEN_NEW_LIST_NAME = "newListName"; //$NON-NLS-1$
// --- instance variables
@Autowired
@ -384,6 +391,11 @@ public class TaskListFragment extends ListFragment implements OnScrollListener,
((AstridActivity) getActivity()).setupActivityFragment(getActiveTagData());
contextMenuExtensionLoader.loadInNewThread(getActivity());
if (extras != null && extras.getBoolean(TOKEN_NEW_LIST, false)) {
extras.remove(TOKEN_NEW_LIST);
newListFromLaunch();
}
}
protected void addSyncRefreshMenuItem(Menu menu, int themeFlags) {
@ -414,6 +426,15 @@ public class TaskListFragment extends ListFragment implements OnScrollListener,
}
}
private void newListFromLaunch() {
Intent intent = TagsPlugin.newTagDialog(getActivity());
intent.putExtra(TagSettingsActivity.TOKEN_AUTOPOPULATE_MEMBERS, extras.getString(TOKEN_NEW_LIST_MEMBERS));
intent.putExtra(TagSettingsActivity.TOKEN_AUTOPOPULATE_NAME, extras.getString(TOKEN_NEW_LIST_NAME));
extras.remove(TOKEN_NEW_LIST_MEMBERS);
extras.remove(TOKEN_NEW_LIST_NAME);
getActivity().startActivityForResult(intent, FilterListFragment.REQUEST_NEW_LIST);
}
/**
* Create options menu (displayed when user presses menu key)
*

@ -49,6 +49,7 @@ import com.todoroo.astrid.dao.Database;
import com.todoroo.astrid.dao.MetadataDao.MetadataCriteria;
import com.todoroo.astrid.data.Metadata;
import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.gcal.CalendarStartupReceiver;
import com.todoroo.astrid.gtasks.GtasksMetadata;
import com.todoroo.astrid.gtasks.GtasksPreferenceService;
import com.todoroo.astrid.gtasks.sync.GtasksSyncService;
@ -124,7 +125,6 @@ public class StartupService {
if(hasStartedUp || context == null)
return;
// sets up context manager
ContextManager.setContext(context);
@ -227,6 +227,7 @@ public class StartupService {
// perform initialization
ReminderStartupReceiver.startReminderSchedulingService(context);
CalendarStartupReceiver.scheduleCalendarAlarms(context);
BackupService.scheduleService(context);
actFmSyncService.initialize();

@ -121,10 +121,14 @@ public class ABTests {
public static final String AB_SIMPLE_TASK_ROW = "android_simple_task_row"; //$NON-NLS-1$
public static final String AB_CALENDAR_REMINDERS = "android_cal_reminders"; //$NON-NLS-1$
private void initialize() {
addTest(AB_SIMPLE_TASK_ROW, new int[] { 1, 1 },
new int[] { 1, 0 }, new String[] { "original-row-style", "simple-row-style" });//$NON-NLS-1$ //$NON-NLS-2$
addTest(AB_CALENDAR_REMINDERS, new int[] { 0, 1 },
new int[] { 0, 1 }, new String[] { "no-cal-reminders", "show-cal-reminders" }); //$NON-NLS-1$ //$NON-NLS-2$
}
}

@ -74,7 +74,8 @@ public class AstridPreferences {
Preferences.setIfUnset(prefs, editor, r, R.string.p_taskRowStyle,
ABChooser.readChoiceForTest(ABTests.AB_SIMPLE_TASK_ROW) != 0);
Preferences.setIfUnset(prefs, editor, r, R.string.p_swipe_lists_enabled, false);
Preferences.setIfUnset(prefs, editor, r, R.string.p_calendar_reminders,
ABChooser.readChoiceForTest(ABTests.AB_CALENDAR_REMINDERS) != 0);
if ("white-blue".equals(Preferences.getStringValue(R.string.p_theme))) { //$NON-NLS-1$ migrate from when white-blue wasn't the default
Preferences.setString(R.string.p_theme, ThemeService.THEME_WHITE);

Loading…
Cancel
Save