Made synchronization notification open RTM preferences, minor fix to locale edit window

pull/14/head
Tim Su 14 years ago
parent 9cdba9c17a
commit 2c87bae01a

@ -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<TYPE extends TaskContainer> {
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<TYPE extends TaskContainer> {
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<TYPE extends TaskContainer> {
}
// 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<TYPE extends TaskContainer> {
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
/**

@ -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
{

@ -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<RTMTaskContainer> {
}
@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

Loading…
Cancel
Save