From b3f3bd02ea1bb98a6843d6b61fb9c9f9a7a7fd20 Mon Sep 17 00:00:00 2001 From: Tim Su Date: Thu, 19 Jan 2012 00:55:46 -0800 Subject: [PATCH] If you haven't saved a tag, don't transmit picture until after you have. --- .../astrid/actfm/TagSettingsActivity.java | 56 +++++++++++++------ 1 file changed, 38 insertions(+), 18 deletions(-) diff --git a/astrid/plugin-src/com/todoroo/astrid/actfm/TagSettingsActivity.java b/astrid/plugin-src/com/todoroo/astrid/actfm/TagSettingsActivity.java index 9ee1f7979..0d8133e02 100644 --- a/astrid/plugin-src/com/todoroo/astrid/actfm/TagSettingsActivity.java +++ b/astrid/plugin-src/com/todoroo/astrid/actfm/TagSettingsActivity.java @@ -63,6 +63,7 @@ public class TagSettingsActivity extends Activity { private EditText tagName; private EditText tagDescription; private CheckBox isSilent; + private Bitmap setBitmap; boolean isNewTag = false; @@ -204,23 +205,44 @@ public class TagSettingsActivity extends Activity { else Toast.makeText(this, R.string.tag_list_saved, Toast.LENGTH_LONG).show(); - tagDataService.save(tagData); InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(tagName.getWindowToken(), 0); if (isNewTag) { - Intent intent = new Intent(this, TagViewActivity.class); - intent.putExtra(TagViewActivity.EXTRA_TAG_NAME, newName); - intent.putExtra(TagViewActivity.TOKEN_FILTER, TagFilterExposer.filterFromTagData(this, tagData)); - super.finish(); - startActivity(intent); - AndroidUtilities.callApiMethod(5, this, "overridePendingTransition", //$NON-NLS-1$ - new Class[] { Integer.TYPE, Integer.TYPE }, - R.anim.slide_left_in, R.anim.slide_left_out); - return; - } + Flags.set(Flags.ACTFM_SUPPRESS_SYNC); + tagDataService.save(tagData); + final String name = newName; + final Runnable loadTag = new Runnable() { + @Override + public void run() { + Intent intent = new Intent(TagSettingsActivity.this, TagViewActivity.class); + intent.putExtra(TagViewActivity.EXTRA_TAG_NAME, name); + intent.putExtra(TagViewActivity.TOKEN_FILTER, + TagFilterExposer.filterFromTagData(TagSettingsActivity.this, tagData)); + finish(); + startActivity(intent); + } + }; + + if(actFmPreferenceService.isLoggedIn()) { + new Thread(new Runnable() { + @Override + public void run() { + actFmSyncService.pushTagDataOnSave(tagData, tagData.getMergedValues()); + if(setBitmap != null && tagData.getValue(TagData.REMOTE_ID) > 0) + uploadTagPicture(setBitmap); + runOnUiThread(loadTag); + } + }).start(); + } else { + loadTag.run(); + } + return; + } else { + tagDataService.save(tagData); + } refreshSettingsPage(); finish(); @@ -234,13 +256,9 @@ public class TagSettingsActivity extends Activity { private void finishWithAnimation(boolean backAnimation) { super.finish(); if (backAnimation) { - AndroidUtilities.callApiMethod(5, this, "overridePendingTransition", //$NON-NLS-1$ - new Class[] { Integer.TYPE, Integer.TYPE }, - R.anim.slide_right_in, R.anim.slide_right_out); + overridePendingTransition(R.anim.slide_right_in, R.anim.slide_right_out); } else { - AndroidUtilities.callApiMethod(5, this, "overridePendingTransition", //$NON-NLS-1$ - new Class[] { Integer.TYPE, Integer.TYPE }, - R.anim.slide_left_in, R.anim.slide_left_out); + overridePendingTransition(R.anim.slide_left_in, R.anim.slide_left_out); } } @@ -323,7 +341,9 @@ public class TagSettingsActivity extends Activity { @Override public void handleCameraResult(Bitmap bitmap) { picture.setImageBitmap(bitmap); - uploadTagPicture(bitmap); + setBitmap = bitmap; + if(tagData.getValue(TagData.REMOTE_ID) > 0) + uploadTagPicture(bitmap); } }; if (ActFmCameraModule.activityResult(this, requestCode, resultCode, data, callback)) {