From 2c87bae01a8b8b1d6fb7a6516c3cefa2159ab212 Mon Sep 17 00:00:00 2001 From: Tim Su Date: Sun, 25 Jul 2010 01:14:18 -0700 Subject: [PATCH] Made synchronization notification open RTM preferences, minor fix to locale edit window --- .../astrid/api/SynchronizationProvider.java | 24 ++++--------------- .../astrid/locale/LocaleEditAlerts.java | 6 ++--- .../astrid/rmilk/sync/RTMSyncProvider.java | 14 +++++++++-- 3 files changed, 18 insertions(+), 26 deletions(-) diff --git a/astrid/api-src/com/todoroo/astrid/api/SynchronizationProvider.java b/astrid/api-src/com/todoroo/astrid/api/SynchronizationProvider.java index f01761f1a..0d0ec4b22 100644 --- a/astrid/api-src/com/todoroo/astrid/api/SynchronizationProvider.java +++ b/astrid/api-src/com/todoroo/astrid/api/SynchronizationProvider.java @@ -11,9 +11,7 @@ import java.util.HashMap; import android.app.Activity; import android.app.Notification; -import android.app.PendingIntent; import android.content.Context; -import android.content.Intent; import android.widget.Toast; import com.timsu.astrid.R; @@ -51,12 +49,11 @@ public abstract class SynchronizationProvider { abstract protected void initiate(Context context); /** - * Gets title of the notification bar notification - * + * Updates the text of a notification and the intent to open when tapped * @param context - * @return title of notification + * @param notification */ - abstract protected String getNotificationTitle(Context context); + abstract protected void updateNotification(Context context, Notification notification); /** * Deal with an exception that occurs during synchronization @@ -131,8 +128,6 @@ public abstract class SynchronizationProvider { private ExceptionService exceptionService; private final Notification notification; - private PendingIntent notificationIntent; - private String notificationTitle; public SynchronizationProvider() { DependencyInjectionService.getInstance().inject(this); @@ -157,9 +152,7 @@ public abstract class SynchronizationProvider { } // display notification - notificationTitle = getNotificationTitle(context); - notificationIntent = PendingIntent.getActivity(context, 0, new Intent(), 0); - postUpdate(context, context.getString(R.string.SyP_progress)); + updateNotification(context, notification); final NotificationManager nm = new NotificationManager.AndroidNotificationManager(context); nm.notify(Constants.NOTIFICATION_SYNC, notification); @@ -186,15 +179,6 @@ public abstract class SynchronizationProvider { exceptionService.displayAndReportError(context, message, e); } - /** - * Utility method to update the UI if we're an active sync, or output to - * console if we're a background sync. - */ - protected void postUpdate(Context context, String string) { - notification.setLatestEventInfo(context, - notificationTitle, string, notificationIntent); - } - // --- synchronization logic /** diff --git a/astrid/plugin-src/com/todoroo/astrid/locale/LocaleEditAlerts.java b/astrid/plugin-src/com/todoroo/astrid/locale/LocaleEditAlerts.java index d797cf899..b4341d532 100644 --- a/astrid/plugin-src/com/todoroo/astrid/locale/LocaleEditAlerts.java +++ b/astrid/plugin-src/com/todoroo/astrid/locale/LocaleEditAlerts.java @@ -212,11 +212,9 @@ public final class LocaleEditAlerts extends ExpandableListActivity { if (selected == null) { /* - * Note: many settings will not need to use the RESULT_REMOVE result. This is only needed for settings that have - * an "invalid" state that shouldn't be saved. For example, an saving empty Toast message doesn't make sense. The - * Ringer Volume setting doesn't have such an "invalid" state, and therefore doesn't use this result code + * If nothing is selected, return as if user had canceled */ - setResult(com.twofortyfouram.Intent.RESULT_REMOVE); + setResult(RESULT_CANCELED); } else { diff --git a/astrid/plugin-src/com/todoroo/astrid/rmilk/sync/RTMSyncProvider.java b/astrid/plugin-src/com/todoroo/astrid/rmilk/sync/RTMSyncProvider.java index abeef4883..2746136e0 100644 --- a/astrid/plugin-src/com/todoroo/astrid/rmilk/sync/RTMSyncProvider.java +++ b/astrid/plugin-src/com/todoroo/astrid/rmilk/sync/RTMSyncProvider.java @@ -11,6 +11,8 @@ import java.util.HashSet; import java.util.List; import android.app.Activity; +import android.app.Notification; +import android.app.PendingIntent; import android.content.Context; import android.content.Intent; import android.content.res.Resources; @@ -33,6 +35,7 @@ import com.todoroo.astrid.api.TaskContainer; import com.todoroo.astrid.model.Metadata; import com.todoroo.astrid.model.Task; import com.todoroo.astrid.rmilk.MilkLoginActivity; +import com.todoroo.astrid.rmilk.MilkPreferences; import com.todoroo.astrid.rmilk.Utilities; import com.todoroo.astrid.rmilk.MilkLoginActivity.SyncLoginCallback; import com.todoroo.astrid.rmilk.api.ApplicationInfo; @@ -534,8 +537,15 @@ public class RTMSyncProvider extends SynchronizationProvider { } @Override - protected String getNotificationTitle(Context context) { - return context.getString(R.string.rmilk_notification_title); + protected void updateNotification(Context context, Notification notification) { + String notificationTitle = context.getString(R.string.rmilk_notification_title); + Intent intent = new Intent(context, MilkPreferences.class); + PendingIntent notificationIntent = PendingIntent.getActivity(context, 0, + intent, 0); + notification.setLatestEventInfo(context, + notificationTitle, context.getString(R.string.SyP_progress), + notificationIntent); + return ; } @Override