diff --git a/api/src/com/todoroo/astrid/data/User.java b/api/src/com/todoroo/astrid/data/User.java index 43eb2b0c3..b84d32e85 100644 --- a/api/src/com/todoroo/astrid/data/User.java +++ b/api/src/com/todoroo/astrid/data/User.java @@ -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 diff --git a/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmSyncV2Provider.java b/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmSyncV2Provider.java index d93cd5277..dbe856b9f 100644 --- a/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmSyncV2Provider.java +++ b/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmSyncV2Provider.java @@ -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 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 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 diff --git a/astrid/plugin-src/com/todoroo/astrid/actfm/sync/messages/NameMaps.java b/astrid/plugin-src/com/todoroo/astrid/actfm/sync/messages/NameMaps.java index 9efd4b686..200d04ea4 100644 --- a/astrid/plugin-src/com/todoroo/astrid/actfm/sync/messages/NameMaps.java +++ b/astrid/plugin-src/com/todoroo/astrid/actfm/sync/messages/NameMaps.java @@ -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 diff --git a/astrid/plugin-src/com/todoroo/astrid/people/PeopleFilterExposer.java b/astrid/plugin-src/com/todoroo/astrid/people/PeopleFilterExposer.java index 4f6437691..2e2fc5cda 100644 --- a/astrid/plugin-src/com/todoroo/astrid/people/PeopleFilterExposer.java +++ b/astrid/plugin-src/com/todoroo/astrid/people/PeopleFilterExposer.java @@ -57,7 +57,7 @@ public class PeopleFilterExposer extends BroadcastReceiver { private FilterListItem[] prepareFilters(Context context) { TodorooCursor 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 items = new ArrayList(); diff --git a/astrid/plugin-src/com/todoroo/astrid/people/PersonViewFragment.java b/astrid/plugin-src/com/todoroo/astrid/people/PersonViewFragment.java index 3973cce82..c9f4710b4 100644 --- a/astrid/plugin-src/com/todoroo/astrid/people/PersonViewFragment.java +++ b/astrid/plugin-src/com/todoroo/astrid/people/PersonViewFragment.java @@ -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); } diff --git a/astrid/res/values/strings-actfm.xml b/astrid/res/values/strings-actfm.xml index 6e7d28bdc..f215301c5 100644 --- a/astrid/res/values/strings-actfm.xml +++ b/astrid/res/values/strings-actfm.xml @@ -57,6 +57,8 @@ You\'ve sent a friend request to %s! You\'ve blocked %s. + + You\'ve ignored %s. You\'re friends with %s! Add tasks for them below.