Can start sync intent with any kind of action. Created two new manifest actions for starting sync from third party apps like Tasker

pull/14/head
Tim Su 14 years ago
parent 22cd64bda9
commit 93ac196557

@ -253,7 +253,12 @@
<category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.DEFAULT" />
</intent-filter> </intent-filter>
</activity> </activity>
<service android:name="com.todoroo.astrid.gtasks.GtasksBackgroundService"/> <service android:name="com.todoroo.astrid.gtasks.GtasksBackgroundService">
<intent-filter>
<action android:name="com.todoroo.astrid.gtasks.SYNC" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</service>
<receiver android:name="com.todoroo.astrid.gtasks.GtasksSyncActionExposer"> <receiver android:name="com.todoroo.astrid.gtasks.GtasksSyncActionExposer">
<intent-filter> <intent-filter>
<action android:name="com.todoroo.astrid.REQUEST_SYNC_ACTIONS" /> <action android:name="com.todoroo.astrid.REQUEST_SYNC_ACTIONS" />
@ -437,7 +442,12 @@
</activity> </activity>
<activity android:name="com.todoroo.astrid.producteev.ProducteevLoginActivity" <activity android:name="com.todoroo.astrid.producteev.ProducteevLoginActivity"
android:theme="@style/Theme" /> android:theme="@style/Theme" />
<service android:name="com.todoroo.astrid.producteev.ProducteevBackgroundService"/> <service android:name="com.todoroo.astrid.producteev.ProducteevBackgroundService">
<intent-filter>
<action android:name="com.todoroo.astrid.producteev.SYNC" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</service>
<receiver android:name="com.todoroo.astrid.producteev.ProducteevStartupReceiver"> <receiver android:name="com.todoroo.astrid.producteev.ProducteevStartupReceiver">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" /> <action android:name="android.intent.action.BOOT_COMPLETED" />

@ -15,7 +15,6 @@ import com.todoroo.andlib.service.DependencyInjectionService;
import com.todoroo.astrid.api.AstridApiConstants; import com.todoroo.astrid.api.AstridApiConstants;
import com.todoroo.astrid.api.SyncAction; import com.todoroo.astrid.api.SyncAction;
import com.todoroo.astrid.service.AstridDependencyInjector; import com.todoroo.astrid.service.AstridDependencyInjector;
import com.todoroo.astrid.sync.SyncBackgroundService;
/** /**
* Exposes sync action * Exposes sync action
@ -38,7 +37,7 @@ public class GtasksSyncActionExposer extends BroadcastReceiver {
if(!gtasksPreferenceService.isLoggedIn()) if(!gtasksPreferenceService.isLoggedIn())
return; return;
Intent syncIntent = new Intent(SyncBackgroundService.SYNC_ACTION, null, Intent syncIntent = new Intent(null, null,
context, GtasksBackgroundService.class); context, GtasksBackgroundService.class);
PendingIntent pendingIntent = PendingIntent.getService(context, 0, syncIntent, PendingIntent.FLAG_UPDATE_CURRENT); PendingIntent pendingIntent = PendingIntent.getService(context, 0, syncIntent, PendingIntent.FLAG_UPDATE_CURRENT);
SyncAction syncAction = new SyncAction(context.getString(R.string.gtasks_GPr_header), SyncAction syncAction = new SyncAction(context.getString(R.string.gtasks_GPr_header),

@ -49,7 +49,6 @@ import com.todoroo.astrid.gtasks.GtasksBackgroundService;
import com.todoroo.astrid.gtasks.GtasksPreferenceService; import com.todoroo.astrid.gtasks.GtasksPreferenceService;
import com.todoroo.astrid.service.AstridDependencyInjector; import com.todoroo.astrid.service.AstridDependencyInjector;
import com.todoroo.astrid.service.StatisticsService; import com.todoroo.astrid.service.StatisticsService;
import com.todoroo.astrid.sync.SyncBackgroundService;
import com.todoroo.gtasks.GoogleConnectionManager; import com.todoroo.gtasks.GoogleConnectionManager;
import com.todoroo.gtasks.GoogleLoginException; import com.todoroo.gtasks.GoogleLoginException;
import com.todoroo.gtasks.GoogleTasksException; import com.todoroo.gtasks.GoogleTasksException;
@ -172,7 +171,7 @@ public class GtasksLoginActivity extends Activity {
* Perform synchronization * Perform synchronization
*/ */
protected void synchronize() { protected void synchronize() {
startService(new Intent(SyncBackgroundService.SYNC_ACTION, null, startService(new Intent(null, null,
this, GtasksBackgroundService.class)); this, GtasksBackgroundService.class));
finish(); finish();
} }

@ -47,7 +47,6 @@ import com.todoroo.astrid.gtasks.GtasksTaskListUpdater;
import com.todoroo.astrid.gtasks.auth.GtasksLoginActivity; import com.todoroo.astrid.gtasks.auth.GtasksLoginActivity;
import com.todoroo.astrid.service.AstridDependencyInjector; import com.todoroo.astrid.service.AstridDependencyInjector;
import com.todoroo.astrid.service.StatisticsService; import com.todoroo.astrid.service.StatisticsService;
import com.todoroo.astrid.sync.SyncBackgroundService;
import com.todoroo.astrid.sync.SyncContainer; import com.todoroo.astrid.sync.SyncContainer;
import com.todoroo.astrid.sync.SyncProvider; import com.todoroo.astrid.sync.SyncProvider;
import com.todoroo.astrid.utility.Constants; import com.todoroo.astrid.utility.Constants;
@ -55,17 +54,17 @@ import com.todoroo.astrid.utility.Flags;
import com.todoroo.gtasks.GoogleConnectionManager; import com.todoroo.gtasks.GoogleConnectionManager;
import com.todoroo.gtasks.GoogleLoginException; import com.todoroo.gtasks.GoogleLoginException;
import com.todoroo.gtasks.GoogleTaskService; import com.todoroo.gtasks.GoogleTaskService;
import com.todoroo.gtasks.GoogleTaskService.ConvenientTaskCreator;
import com.todoroo.gtasks.GoogleTaskTask; import com.todoroo.gtasks.GoogleTaskTask;
import com.todoroo.gtasks.GoogleTaskView; import com.todoroo.gtasks.GoogleTaskView;
import com.todoroo.gtasks.GoogleTasksException; import com.todoroo.gtasks.GoogleTasksException;
import com.todoroo.gtasks.GoogleTaskService.ConvenientTaskCreator;
import com.todoroo.gtasks.actions.Actions; import com.todoroo.gtasks.actions.Actions;
import com.todoroo.gtasks.actions.GetTasksAction; import com.todoroo.gtasks.actions.GetTasksAction;
import com.todoroo.gtasks.actions.ListAction; import com.todoroo.gtasks.actions.ListAction;
import com.todoroo.gtasks.actions.ListActions; import com.todoroo.gtasks.actions.ListActions;
import com.todoroo.gtasks.actions.ListCreationAction;
import com.todoroo.gtasks.actions.ListActions.TaskBuilder; import com.todoroo.gtasks.actions.ListActions.TaskBuilder;
import com.todoroo.gtasks.actions.ListActions.TaskModifier; import com.todoroo.gtasks.actions.ListActions.TaskModifier;
import com.todoroo.gtasks.actions.ListCreationAction;
@SuppressWarnings("nls") @SuppressWarnings("nls")
public class GtasksSyncProvider extends SyncProvider<GtasksTaskContainer> { public class GtasksSyncProvider extends SyncProvider<GtasksTaskContainer> {
@ -190,7 +189,7 @@ public class GtasksSyncProvider extends SyncProvider<GtasksTaskContainer> {
Intent intent = new Intent(activity, GtasksLoginActivity.class); Intent intent = new Intent(activity, GtasksLoginActivity.class);
activity.startActivityForResult(intent, 0); activity.startActivityForResult(intent, 0);
} else { } else {
activity.startService(new Intent(SyncBackgroundService.SYNC_ACTION, null, activity.startService(new Intent(null, null,
activity, GtasksBackgroundService.class)); activity, GtasksBackgroundService.class));
activity.finish(); activity.finish();
} }

@ -222,7 +222,7 @@ public class ProducteevLoginActivity extends Activity {
* Perform synchronization * Perform synchronization
*/ */
protected void synchronize() { protected void synchronize() {
startService(new Intent(ProducteevBackgroundService.SYNC_ACTION, null, startService(new Intent(null, null,
this, ProducteevBackgroundService.class)); this, ProducteevBackgroundService.class));
finish(); finish();
} }

@ -26,7 +26,7 @@ public class ProducteevSyncActionExposer extends BroadcastReceiver {
if(!ProducteevUtilities.INSTANCE.isLoggedIn()) if(!ProducteevUtilities.INSTANCE.isLoggedIn())
return; return;
Intent syncIntent = new Intent(ProducteevBackgroundService.SYNC_ACTION, null, Intent syncIntent = new Intent(null, null,
context, ProducteevBackgroundService.class); context, ProducteevBackgroundService.class);
PendingIntent pendingIntent = PendingIntent.getService(context, 0, syncIntent, PendingIntent.FLAG_UPDATE_CURRENT); PendingIntent pendingIntent = PendingIntent.getService(context, 0, syncIntent, PendingIntent.FLAG_UPDATE_CURRENT);
SyncAction syncAction = new SyncAction(context.getString(R.string.producteev_PPr_header), SyncAction syncAction = new SyncAction(context.getString(R.string.producteev_PPr_header),

@ -192,7 +192,7 @@ public class ProducteevSyncProvider extends SyncProvider<ProducteevTaskContainer
Intent intent = new Intent(activity, ProducteevLoginActivity.class); Intent intent = new Intent(activity, ProducteevLoginActivity.class);
activity.startActivityForResult(intent, 0); activity.startActivityForResult(intent, 0);
} else { } else {
activity.startService(new Intent(ProducteevBackgroundService.SYNC_ACTION, null, activity.startService(new Intent(null, null,
activity, ProducteevBackgroundService.class)); activity, ProducteevBackgroundService.class));
} }
} }

Loading…
Cancel
Save