Fixed bugs with adding members after the tag is created but before sync has finished

pull/14/head
Sam Bosley 12 years ago
parent 5155e6357e
commit 5a59088a46

@ -70,6 +70,8 @@ public class TagSettingsActivity extends FragmentActivity {
public static final int REQUEST_ACTFM_LOGIN = 3; public static final int REQUEST_ACTFM_LOGIN = 3;
public static final String TOKEN_AUTOPOPULATE_MEMBERS = "autopopulateMembers"; //$NON-NLS-1$ public static final String TOKEN_AUTOPOPULATE_MEMBERS = "autopopulateMembers"; //$NON-NLS-1$
public static final String TOKEN_AUTOPOPULATE_NAME = "autopopulateName"; //$NON-NLS-1$
private static final String MEMBERS_IN_PROGRESS = "members"; //$NON-NLS-1$ private static final String MEMBERS_IN_PROGRESS = "members"; //$NON-NLS-1$
@ -230,6 +232,12 @@ public class TagSettingsActivity extends FragmentActivity {
updateMembers(autopopulateMembers); updateMembers(autopopulateMembers);
getIntent().removeExtra(TOKEN_AUTOPOPULATE_MEMBERS); getIntent().removeExtra(TOKEN_AUTOPOPULATE_MEMBERS);
} }
String autopopulateName = getIntent().getStringExtra(TOKEN_AUTOPOPULATE_NAME);
if (!TextUtils.isEmpty(autopopulateName)) {
tagName.setText(autopopulateName);
getIntent().removeExtra(TOKEN_AUTOPOPULATE_NAME);
}
} }
@SuppressWarnings("nls") @SuppressWarnings("nls")

@ -139,13 +139,16 @@ public class TagViewFragment extends TaskListFragment {
Activity activity = getActivity(); Activity activity = getActivity();
Class<?> settingsClass = AstridPreferences.useTabletLayout(activity) ? TagSettingsActivityTablet.class : TagSettingsActivity.class; Class<?> settingsClass = AstridPreferences.useTabletLayout(activity) ? TagSettingsActivityTablet.class : TagSettingsActivity.class;
Intent intent = new Intent(getActivity(), settingsClass); Intent intent = new Intent(getActivity(), settingsClass);
intent.putExtra(EXTRA_TAG_DATA, tagData); if (extras.containsKey(TOKEN_MEMBERS)) { // This indicates that the fragment was launched from the calendar list creator--use special logic
if (extras.containsKey(TOKEN_MEMBERS)) { intent.putExtra(TagSettingsActivity.TOKEN_AUTOPOPULATE_MEMBERS, extras.getString(TOKEN_MEMBERS));
intent.putExtra(TagSettingsActivity.TOKEN_AUTOPOPULATE_MEMBERS, extras.getStringArrayList(TOKEN_MEMBERS)); intent.putExtra(TagSettingsActivity.TOKEN_AUTOPOPULATE_NAME, extras.getString(EXTRA_TAG_NAME));
extras.remove(TOKEN_MEMBERS); extras.remove(TOKEN_MEMBERS);
getActivity().startActivityForResult(intent, FilterListFragment.REQUEST_NEW_LIST);
} else {
intent.putExtra(EXTRA_TAG_DATA, tagData);
startActivityForResult(intent, REQUEST_CODE_SETTINGS);
} }
startActivityForResult(intent, REQUEST_CODE_SETTINGS);
if (!AstridPreferences.useTabletLayout(activity)) { if (!AstridPreferences.useTabletLayout(activity)) {
AndroidUtilities.callOverridePendingTransition(activity, R.anim.slide_left_in, R.anim.slide_left_out); AndroidUtilities.callOverridePendingTransition(activity, R.anim.slide_left_in, R.anim.slide_left_out);
} }
@ -208,6 +211,12 @@ public class TagViewFragment extends TaskListFragment {
if(tag == null && remoteId == 0) if(tag == null && remoteId == 0)
return; return;
if (extras.getBoolean(TOKEN_START_SETTINGS, false)) {
extras.remove(TOKEN_START_SETTINGS);
settingsListener.onClick(null);
return;
}
TodorooCursor<TagData> cursor = tagDataService.query(Query.select(TagData.PROPERTIES).where(Criterion.or(TagData.NAME.eqCaseInsensitive(tag), TodorooCursor<TagData> cursor = tagDataService.query(Query.select(TagData.PROPERTIES).where(Criterion.or(TagData.NAME.eqCaseInsensitive(tag),
Criterion.and(TagData.REMOTE_ID.gt(0), TagData.REMOTE_ID.eq(remoteId))))); Criterion.and(TagData.REMOTE_ID.gt(0), TagData.REMOTE_ID.eq(remoteId)))));
try { try {
@ -232,9 +241,6 @@ public class TagViewFragment extends TaskListFragment {
if (extras.getBoolean(TOKEN_START_ACTIVITY, false)) { if (extras.getBoolean(TOKEN_START_ACTIVITY, false)) {
extras.remove(TOKEN_START_ACTIVITY); extras.remove(TOKEN_START_ACTIVITY);
activity.showComments(); activity.showComments();
} else if (extras.getBoolean(TOKEN_START_SETTINGS, false)) {
extras.remove(TOKEN_START_SETTINGS);
settingsListener.onClick(null);
} }
} }
@ -319,6 +325,8 @@ public class TagViewFragment extends TaskListFragment {
} }
protected void setUpMembersGallery() { protected void setUpMembersGallery() {
if (tagData == null)
return;
LinearLayout membersView = (LinearLayout)getView().findViewById(R.id.shared_with); LinearLayout membersView = (LinearLayout)getView().findViewById(R.id.shared_with);
membersView.setOnClickListener(settingsListener); membersView.setOnClickListener(settingsListener);
try { try {

@ -35,7 +35,7 @@ import com.todoroo.astrid.tags.TagFilterExposer;
public class CalendarAlarmListCreator extends Activity { public class CalendarAlarmListCreator extends Activity {
public static final String TOKEN_LIST_ID = "listId"; //$NON-NLS-1$ public static final String TOKEN_LIST_NAME = "listName"; //$NON-NLS-1$
@Autowired @Autowired
private UserDao userDao; private UserDao userDao;
@ -50,7 +50,8 @@ public class CalendarAlarmListCreator extends Activity {
private ArrayList<String> emails; private ArrayList<String> emails;
private HashMap<String, User> emailsToUsers; private HashMap<String, User> emailsToUsers;
private TagData tagData; // private TagData tagData;
private String tagName;
private TextView inviteAll; private TextView inviteAll;
private TextView moreOptions; private TextView moreOptions;
private TextView ignoreButton; private TextView ignoreButton;
@ -73,7 +74,8 @@ public class CalendarAlarmListCreator extends Activity {
Intent intent = getIntent(); Intent intent = getIntent();
tagData = tagDataService.fetchById(intent.getLongExtra(TOKEN_LIST_ID, -1), TagData.PROPERTIES); // tagData = tagDataService.fetchById(intent.getLongExtra(TOKEN_LIST_ID, -1), TagData.PROPERTIES);
tagName = intent.getStringExtra(TOKEN_LIST_NAME);
inviteAll = (TextView) findViewById(R.id.invite_all); inviteAll = (TextView) findViewById(R.id.invite_all);
moreOptions = (TextView) findViewById(R.id.list_settings); moreOptions = (TextView) findViewById(R.id.list_settings);
ignoreButton = (TextView) findViewById(R.id.ignore); ignoreButton = (TextView) findViewById(R.id.ignore);
@ -111,7 +113,7 @@ public class CalendarAlarmListCreator extends Activity {
private void setupUi() { private void setupUi() {
TextView dialogView = (TextView) findViewById(R.id.reminder_message); TextView dialogView = (TextView) findViewById(R.id.reminder_message);
StringBuilder builder = new StringBuilder(getString(R.string.CRA_created_list_dialog, tagData.getValue(TagData.NAME))); StringBuilder builder = new StringBuilder(getString(R.string.CRA_created_list_dialog, tagName));
String attendeesString = buildAttendeesString(); String attendeesString = buildAttendeesString();
int color = ThemeService.getThemeColor(); int color = ThemeService.getThemeColor();
@ -159,6 +161,8 @@ public class CalendarAlarmListCreator extends Activity {
return; return;
} else { } else {
JSONArray membersArray = buildMembersArray(); JSONArray membersArray = buildMembersArray();
TagData tagData = new TagData();
tagData.setValue(TagData.NAME, tagName);
tagData.setValue(TagData.MEMBERS, membersArray.toString()); tagData.setValue(TagData.MEMBERS, membersArray.toString());
tagData.setValue(TagData.MEMBER_COUNT, membersArray.length()); tagData.setValue(TagData.MEMBER_COUNT, membersArray.length());
tagDataService.save(tagData); tagDataService.save(tagData);
@ -171,7 +175,8 @@ public class CalendarAlarmListCreator extends Activity {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
Intent intent = new Intent(CalendarAlarmListCreator.this, TaskListActivity.class); Intent intent = new Intent(CalendarAlarmListCreator.this, TaskListActivity.class);
intent.putExtra(TaskListFragment.TOKEN_FILTER, TagFilterExposer.filterFromTagData(CalendarAlarmListCreator.this, tagData)); intent.putExtra(TaskListFragment.TOKEN_FILTER, TagFilterExposer.filterFromTagData(CalendarAlarmListCreator.this, new TagData()));
intent.putExtra(TagViewFragment.EXTRA_TAG_NAME, tagName);
intent.putExtra(TagViewFragment.TOKEN_MEMBERS, buildMembersArray().toString()); intent.putExtra(TagViewFragment.TOKEN_MEMBERS, buildMembersArray().toString());
intent.putExtra(TagViewFragment.TOKEN_START_SETTINGS, true); intent.putExtra(TagViewFragment.TOKEN_START_SETTINGS, true);
startActivity(intent); startActivity(intent);

@ -215,14 +215,10 @@ public class CalendarReminderActivity extends Activity {
} }
private void createNewList(String name) { private void createNewList(String name) {
TagData newTagData = new TagData();
newTagData.setValue(TagData.NAME, name);
tagDataService.save(newTagData);
Intent newListIntent = new Intent(this, CalendarAlarmListCreator.class); Intent newListIntent = new Intent(this, CalendarAlarmListCreator.class);
newListIntent.putStringArrayListExtra(TOKEN_NAMES, getIntent().getStringArrayListExtra(TOKEN_NAMES)); newListIntent.putStringArrayListExtra(TOKEN_NAMES, getIntent().getStringArrayListExtra(TOKEN_NAMES));
newListIntent.putStringArrayListExtra(TOKEN_EMAILS, getIntent().getStringArrayListExtra(TOKEN_EMAILS)); newListIntent.putStringArrayListExtra(TOKEN_EMAILS, getIntent().getStringArrayListExtra(TOKEN_EMAILS));
newListIntent.putExtra(CalendarAlarmListCreator.TOKEN_LIST_ID, newTagData.getId()); newListIntent.putExtra(CalendarAlarmListCreator.TOKEN_LIST_NAME, name);
startActivity(newListIntent); startActivity(newListIntent);
dismissButton.performClick(); // finish with animation dismissButton.performClick(); // finish with animation

Loading…
Cancel
Save