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

@ -71,6 +71,8 @@ public class TagSettingsActivity extends FragmentActivity {
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 TagData tagData;
@ -230,6 +232,12 @@ public class TagSettingsActivity extends FragmentActivity {
updateMembers(autopopulateMembers);
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")

@ -139,13 +139,16 @@ public class TagViewFragment extends TaskListFragment {
Activity activity = getActivity();
Class<?> settingsClass = AstridPreferences.useTabletLayout(activity) ? TagSettingsActivityTablet.class : TagSettingsActivity.class;
Intent intent = new Intent(getActivity(), settingsClass);
intent.putExtra(EXTRA_TAG_DATA, tagData);
if (extras.containsKey(TOKEN_MEMBERS)) {
intent.putExtra(TagSettingsActivity.TOKEN_AUTOPOPULATE_MEMBERS, extras.getStringArrayList(TOKEN_MEMBERS));
if (extras.containsKey(TOKEN_MEMBERS)) { // This indicates that the fragment was launched from the calendar list creator--use special logic
intent.putExtra(TagSettingsActivity.TOKEN_AUTOPOPULATE_MEMBERS, extras.getString(TOKEN_MEMBERS));
intent.putExtra(TagSettingsActivity.TOKEN_AUTOPOPULATE_NAME, extras.getString(EXTRA_TAG_NAME));
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)) {
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)
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),
Criterion.and(TagData.REMOTE_ID.gt(0), TagData.REMOTE_ID.eq(remoteId)))));
try {
@ -232,9 +241,6 @@ public class TagViewFragment extends TaskListFragment {
if (extras.getBoolean(TOKEN_START_ACTIVITY, false)) {
extras.remove(TOKEN_START_ACTIVITY);
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() {
if (tagData == null)
return;
LinearLayout membersView = (LinearLayout)getView().findViewById(R.id.shared_with);
membersView.setOnClickListener(settingsListener);
try {

@ -35,7 +35,7 @@ import com.todoroo.astrid.tags.TagFilterExposer;
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
private UserDao userDao;
@ -50,7 +50,8 @@ public class CalendarAlarmListCreator extends Activity {
private ArrayList<String> emails;
private HashMap<String, User> emailsToUsers;
private TagData tagData;
// private TagData tagData;
private String tagName;
private TextView inviteAll;
private TextView moreOptions;
private TextView ignoreButton;
@ -73,7 +74,8 @@ public class CalendarAlarmListCreator extends Activity {
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);
moreOptions = (TextView) findViewById(R.id.list_settings);
ignoreButton = (TextView) findViewById(R.id.ignore);
@ -111,7 +113,7 @@ public class CalendarAlarmListCreator extends Activity {
private void setupUi() {
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();
int color = ThemeService.getThemeColor();
@ -159,6 +161,8 @@ public class CalendarAlarmListCreator extends Activity {
return;
} else {
JSONArray membersArray = buildMembersArray();
TagData tagData = new TagData();
tagData.setValue(TagData.NAME, tagName);
tagData.setValue(TagData.MEMBERS, membersArray.toString());
tagData.setValue(TagData.MEMBER_COUNT, membersArray.length());
tagDataService.save(tagData);
@ -171,7 +175,8 @@ public class CalendarAlarmListCreator extends Activity {
@Override
public void onClick(View v) {
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_START_SETTINGS, true);
startActivity(intent);

@ -215,14 +215,10 @@ public class CalendarReminderActivity extends Activity {
}
private void createNewList(String name) {
TagData newTagData = new TagData();
newTagData.setValue(TagData.NAME, name);
tagDataService.save(newTagData);
Intent newListIntent = new Intent(this, CalendarAlarmListCreator.class);
newListIntent.putStringArrayListExtra(TOKEN_NAMES, getIntent().getStringArrayListExtra(TOKEN_NAMES));
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);
dismissButton.performClick(); // finish with animation

Loading…
Cancel
Save