diff --git a/astrid/AndroidManifest.xml b/astrid/AndroidManifest.xml index b53fad1e9..6737fe6d3 100644 --- a/astrid/AndroidManifest.xml +++ b/astrid/AndroidManifest.xml @@ -230,6 +230,27 @@ + + + + + + + + + + + + + + + + + + + diff --git a/astrid/astrid.launch b/astrid/astrid.launch index cb6cda0f4..e1e654a56 100644 --- a/astrid/astrid.launch +++ b/astrid/astrid.launch @@ -4,7 +4,7 @@ - + diff --git a/astrid/common-src/com/todoroo/andlib/sql/Criterion.java b/astrid/common-src/com/todoroo/andlib/sql/Criterion.java index 9de7d828b..76c46d580 100644 --- a/astrid/common-src/com/todoroo/andlib/sql/Criterion.java +++ b/astrid/common-src/com/todoroo/andlib/sql/Criterion.java @@ -18,7 +18,7 @@ public abstract class Criterion { public static Criterion all = new Criterion(Operator.exists) { @Override protected void populate(StringBuilder sb) { - sb.append(true); + sb.append(1); } }; diff --git a/astrid/plugin-src/com/todoroo/astrid/rmilk/MilkPreferences.java b/astrid/plugin-src/com/todoroo/astrid/rmilk/MilkPreferences.java index e21bd3e8e..84f705ba8 100644 --- a/astrid/plugin-src/com/todoroo/astrid/rmilk/MilkPreferences.java +++ b/astrid/plugin-src/com/todoroo/astrid/rmilk/MilkPreferences.java @@ -38,6 +38,7 @@ public class MilkPreferences extends PreferenceActivity { initializePreference(screen); // status + boolean loggedIn = Utilities.isLoggedIn(); final String status = "Please Log In To RTM!"; //$NON-NLS-1$ final int statusColor = Color.RED; @@ -65,8 +66,12 @@ public class MilkPreferences extends PreferenceActivity { return true; } }); - /*Preference clearDataPreference = screen.getPreferenceManager().findPreference( - getString(R.string.rmilk_MPr_forget_key));*/ + Preference clearDataPreference = screen.getPreferenceManager().findPreference( + getString(R.string.rmilk_MPr_forget_key)); + if(!loggedIn) { + syncAction.setTitle(R.string.rmilk_MPr_sync_log_in); + clearDataPreference.setEnabled(false); + } } private void initializePreference(Preference preference) { diff --git a/astrid/plugin-src/com/todoroo/astrid/rmilk/data/MilkDatabase.java b/astrid/plugin-src/com/todoroo/astrid/rmilk/data/MilkDatabase.java index 179f7990a..12f134e53 100644 --- a/astrid/plugin-src/com/todoroo/astrid/rmilk/data/MilkDatabase.java +++ b/astrid/plugin-src/com/todoroo/astrid/rmilk/data/MilkDatabase.java @@ -36,7 +36,8 @@ public class MilkDatabase extends AbstractDatabase { * also make sure that our SQLite helper does the right thing. */ public static final Table[] TABLES = new Table[] { - MilkList.TABLE + MilkList.TABLE, + MilkTask.TABLE }; // --- implementation 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 84b6c1680..6d3ef24a6 100644 --- a/astrid/plugin-src/com/todoroo/astrid/rmilk/sync/RTMSyncProvider.java +++ b/astrid/plugin-src/com/todoroo/astrid/rmilk/sync/RTMSyncProvider.java @@ -7,6 +7,8 @@ import java.io.IOException; import java.util.ArrayList; import java.util.Date; +import android.app.Activity; +import android.app.ProgressDialog; import android.content.Context; import android.content.Intent; import android.content.res.Resources; @@ -24,6 +26,7 @@ import com.todoroo.andlib.service.DependencyInjectionService; import com.todoroo.andlib.service.ExceptionService; import com.todoroo.andlib.utility.AndroidUtilities; import com.todoroo.andlib.utility.DateUtilities; +import com.todoroo.andlib.utility.DialogUtilities; import com.todoroo.astrid.api.SynchronizationProvider; import com.todoroo.astrid.model.Task; import com.todoroo.astrid.rmilk.MilkLoginActivity; @@ -46,9 +49,10 @@ import com.todoroo.astrid.service.AstridDependencyInjector; public class RTMSyncProvider extends SynchronizationProvider { - protected ServiceImpl rtmService = null; - protected String timeline = null; - protected MilkDataService dataService = null; + private ServiceImpl rtmService = null; + private String timeline = null; + private MilkDataService dataService = null; + private ProgressDialog progressDialog = null; static { AstridDependencyInjector.initialize(); @@ -57,6 +61,9 @@ public class RTMSyncProvider extends SynchronizationProvider { @Autowired protected ExceptionService exceptionService; + @Autowired + protected DialogUtilities dialogUtilities; + public RTMSyncProvider() { super(); DependencyInjectionService.getInstance().inject(this); @@ -71,6 +78,12 @@ public class RTMSyncProvider extends SynchronizationProvider { Context context = ContextManager.getContext(); dataService = new MilkDataService(context); + if(context instanceof Activity) { + progressDialog = dialogUtilities.progressDialog(context, + context.getString(R.string.DLG_communicating_text)); + progressDialog.show(); + } + // authenticate the user. this will automatically call the next step authenticate(context); } @@ -125,9 +138,19 @@ public class RTMSyncProvider extends SynchronizationProvider { } } - /** Perform authentication with RTM. Will open the SyncBrowser if necessary */ - @SuppressWarnings("nls") private void authenticate(final Context context) { + new Thread(new Runnable() { + public void run() { + authenticateInNewThread(context); + } + }).start(); + } + + /** + * Perform authentication with RTM. Will open the SyncBrowser if necessary + */ + @SuppressWarnings("nls") + private void authenticateInNewThread(final Context context) { final Resources r = context.getResources(); FlurryAgent.onEvent("rtm-started"); @@ -174,6 +197,7 @@ public class RTMSyncProvider extends SynchronizationProvider { try { String token = rtmService.completeAuthorization(); Utilities.setToken(token); + // TODO proceed with sync return null; } catch (Exception e) { // didn't work @@ -202,15 +226,7 @@ public class RTMSyncProvider extends SynchronizationProvider { // ----------------------------------------------------- synchronization! // ---------------------------------------------------------------------- - private void performSync(final Context context) { - new Thread(new Runnable() { - public void run() { - performSyncInNewThread(context); - } - }).start(); - } - - protected void performSyncInNewThread(final Context context) { + protected void performSync(final Context context) { try { // get RTM timeline timeline = rtmService.timelines_create(); diff --git a/astrid/res/values/rmilk_strings.xml b/astrid/res/values/strings-rmilk.xml similarity index 96% rename from astrid/res/values/rmilk_strings.xml rename to astrid/res/values/strings-rmilk.xml index 5075212e9..5e4e61b2f 100644 --- a/astrid/res/values/rmilk_strings.xml +++ b/astrid/res/values/strings-rmilk.xml @@ -87,13 +87,15 @@ Synchronize Now! + + Log In & Synchronize! rmilk_sync - Clear Personal Data + Log Out - Log out of Remember the Milk + Clears all RTM synchronization data rmilk_forget