Reimplemented friend connection tracking under new sync

pull/14/head
Sam Bosley 12 years ago
parent 45f697fd1b
commit 2e4a941530

@ -76,7 +76,7 @@ public final class User extends RemoteModel {
/** Friendship tatus that needs to be reported to the server.
* One of the PENDING constants below */
public static final StringProperty PENDING_STATUS = new StringProperty(
@Deprecated public static final StringProperty PENDING_STATUS = new StringProperty(
TABLE, "pendingStatus");
/** List of all properties for this model */
@ -94,7 +94,6 @@ public final class User extends RemoteModel {
defaultValues.put(PUSHED_AT.name, 0L);
defaultValues.put(UUID.name, NO_UUID);
defaultValues.put(STATUS.name, "");
defaultValues.put(PENDING_STATUS.name, "");
}
@Override
@ -108,10 +107,10 @@ public final class User extends RemoteModel {
public static final String STATUS_IGNORED = "ignored";
public static final String STATUS_BLOCKED = "blocked";
public static final String PENDING_REQUEST = "request";
public static final String PENDING_APPROVE = "approve";
public static final String PENDING_IGNORE = "ignore";
public static final String PENDING_UNFRIEND = "unfriend";
public static final String STATUS_REQUEST = "request";
public static final String STATUS_CONFIRM = "confirm";
public static final String STATUS_IGNORE = "ignore";
public static final String STATUS_RENOUNCE = "renounce";
// --- data access boilerplate

@ -23,7 +23,6 @@ import com.todoroo.andlib.data.TodorooCursor;
import com.todoroo.andlib.service.Autowired;
import com.todoroo.andlib.service.ContextManager;
import com.todoroo.andlib.sql.Criterion;
import com.todoroo.andlib.sql.Functions;
import com.todoroo.andlib.sql.Query;
import com.todoroo.andlib.utility.Preferences;
import com.todoroo.astrid.actfm.sync.messages.BriefMe;
@ -445,16 +444,16 @@ public class ActFmSyncV2Provider extends SyncV2Provider {
}
private void pushQueuedUsers(final SyncResultCallback callback,
final AtomicInteger finisher) {
TodorooCursor<User> users = userDao.query(Query.select(User.PROPERTIES).where(
Criterion.and(User.PENDING_STATUS.isNotNull(), Functions.length(User.PENDING_STATUS).gt(0))));
try {
pushQueued(callback, finisher, users, true, userPusher);
} finally {
users.close();
}
}
// private void pushQueuedUsers(final SyncResultCallback callback,
// final AtomicInteger finisher) {
// TodorooCursor<User> users = userDao.query(Query.select(User.PROPERTIES).where(
// Criterion.and(User.PENDING_STATUS.isNotNull(), Functions.length(User.PENDING_STATUS).gt(0))));
// try {
// pushQueued(callback, finisher, users, true, userPusher);
// } finally {
// users.close();
// }
// }
// --- synchronize list

@ -196,6 +196,7 @@ public class NameMaps {
putUserPropertyToServerName(User.PICTURE, "picture", false);
putUserPropertyToServerName(User.FIRST_NAME, "first_name", false);
putUserPropertyToServerName(User.LAST_NAME, "last_name", false);
putUserPropertyToServerName(User.STATUS, "connection", true);
// Reverse the mapping to construct the server to local map

@ -57,7 +57,7 @@ public class PeopleFilterExposer extends BroadcastReceiver {
private FilterListItem[] prepareFilters(Context context) {
TodorooCursor<User> users = PluginServices.getUserDao().query(Query.select(User.PROPERTIES)
.where(Criterion.not(Criterion.or(User.STATUS.eq(User.STATUS_BLOCKED),
User.STATUS.eq(User.STATUS_IGNORED))))
User.STATUS.eq(User.STATUS_IGNORED), User.STATUS.eq(User.STATUS_RENOUNCE), User.STATUS.eq(User.STATUS_IGNORE))))
.orderBy(Order.asc(User.FIRST_NAME), Order.asc(User.LAST_NAME), Order.asc(User.NAME)));
try {
List<FilterListItem> items = new ArrayList<FilterListItem>();

@ -36,8 +36,6 @@ public class PersonViewFragment extends TaskListFragment {
public static final String EXTRA_HIDE_QUICK_ADD = "hide_quickAdd"; //$NON-NLS-1$
private static final String LAST_FETCH_KEY = "actfm_last_user_"; //$NON-NLS-1$
protected static final int MENU_REFRESH_ID = MENU_SUPPORT_ID + 1;
@Autowired UserDao userDao;
@ -98,23 +96,24 @@ public class PersonViewFragment extends TaskListFragment {
private String getUserSubtitleText() {
String status = user.getValue(User.STATUS);
String userName = user.getDisplayName();
if (User.STATUS_PENDING.equals(status))
if (User.STATUS_PENDING.equals(status) || User.STATUS_REQUEST.equals(status))
return getString(R.string.actfm_friendship_pending, userName);
else if (User.STATUS_BLOCKED.equals(status))
else if (User.STATUS_BLOCKED.equals(status) || User.STATUS_RENOUNCE.equals(status))
return getString(R.string.actfm_friendship_blocked, userName);
else if (User.STATUS_FRIENDS.equals(status))
else if (User.STATUS_FRIENDS.equals(status) || User.STATUS_CONFIRM.equals(status))
return getString(R.string.actfm_friendship_friends, userName);
else if (User.STATUS_OTHER_PENDING.equals(status))
return getString(R.string.actfm_friendship_other_pending, userName);
else if (User.STATUS_IGNORED.equals(status) || User.STATUS_IGNORE.equals(status))
return getString(R.string.actfm_friendship_ignored, userName);
else return getString(R.string.actfm_friendship_no_status, userName);
}
private void setupUserStatusButton() {
String status = user.getValue(User.STATUS);
String pendingStatus = user.getValue(User.PENDING_STATUS);
userStatusButton.setVisibility(View.VISIBLE);
if (!TextUtils.isEmpty(pendingStatus))
if (User.STATUS_CONFIRM.equals(status) || User.STATUS_IGNORE.equals(status) || User.STATUS_RENOUNCE.equals(status) || User.STATUS_REQUEST.equals(user)) // All the pending status options
userStatusButton.setVisibility(View.GONE);
else if (TextUtils.isEmpty(status) || "null".equals(status)) //$NON-NLS-1$
userStatusButton.setText(getString(R.string.actfm_friendship_connect));
@ -146,13 +145,13 @@ public class PersonViewFragment extends TaskListFragment {
if (user != null) { // Just in case
String status = user.getValue(User.STATUS);
if (TextUtils.isEmpty(status) || "null".equals(status)) { // Add friend case //$NON-NLS-1$
user.setValue(User.PENDING_STATUS, User.PENDING_REQUEST);
user.setValue(User.STATUS, User.STATUS_REQUEST);
} else if (User.STATUS_OTHER_PENDING.equals(status)) { // Accept friend case
user.setValue(User.PENDING_STATUS, User.PENDING_APPROVE);
user.setValue(User.STATUS, User.STATUS_CONFIRM);
}
ContentValues setValues = user.getSetValues();
if (setValues != null && setValues.containsKey(User.PENDING_STATUS.name)) {
if (setValues != null && setValues.containsKey(User.STATUS.name)) {
userDao.saveExisting(user);
userStatusButton.setVisibility(View.GONE);
}

@ -57,6 +57,8 @@
<string name="actfm_friendship_pending">You\'ve sent a friend request to %s!</string>
<string name="actfm_friendship_blocked">You\'ve blocked %s.</string>
<string name="actfm_friendship_ignored">You\'ve ignored %s.</string>
<string name="actfm_friendship_friends">You\'re friends with %s! Add tasks for them below.</string>

Loading…
Cancel
Save