|
|
|
@ -9,6 +9,7 @@ import android.content.Intent;
|
|
|
|
import android.support.v4.view.Menu;
|
|
|
|
import android.support.v4.view.Menu;
|
|
|
|
import android.text.TextUtils;
|
|
|
|
import android.text.TextUtils;
|
|
|
|
import android.view.View;
|
|
|
|
import android.view.View;
|
|
|
|
|
|
|
|
import android.view.ViewGroup;
|
|
|
|
import android.widget.TextView;
|
|
|
|
import android.widget.TextView;
|
|
|
|
|
|
|
|
|
|
|
|
import com.timsu.astrid.R;
|
|
|
|
import com.timsu.astrid.R;
|
|
|
|
@ -17,10 +18,12 @@ import com.todoroo.andlib.service.ContextManager;
|
|
|
|
import com.todoroo.andlib.utility.DateUtilities;
|
|
|
|
import com.todoroo.andlib.utility.DateUtilities;
|
|
|
|
import com.todoroo.andlib.utility.Preferences;
|
|
|
|
import com.todoroo.andlib.utility.Preferences;
|
|
|
|
import com.todoroo.astrid.actfm.sync.ActFmPreferenceService;
|
|
|
|
import com.todoroo.astrid.actfm.sync.ActFmPreferenceService;
|
|
|
|
|
|
|
|
import com.todoroo.astrid.actfm.sync.ActFmSyncService;
|
|
|
|
import com.todoroo.astrid.activity.TaskListFragment;
|
|
|
|
import com.todoroo.astrid.activity.TaskListFragment;
|
|
|
|
import com.todoroo.astrid.api.AstridApiConstants;
|
|
|
|
import com.todoroo.astrid.api.AstridApiConstants;
|
|
|
|
import com.todoroo.astrid.dao.UserDao;
|
|
|
|
import com.todoroo.astrid.dao.UserDao;
|
|
|
|
import com.todoroo.astrid.data.User;
|
|
|
|
import com.todoroo.astrid.data.User;
|
|
|
|
|
|
|
|
import com.todoroo.astrid.helper.AsyncImageView;
|
|
|
|
import com.todoroo.astrid.helper.ProgressBarSyncResultCallback;
|
|
|
|
import com.todoroo.astrid.helper.ProgressBarSyncResultCallback;
|
|
|
|
import com.todoroo.astrid.service.SyncV2Service;
|
|
|
|
import com.todoroo.astrid.service.SyncV2Service;
|
|
|
|
import com.todoroo.astrid.service.ThemeService;
|
|
|
|
import com.todoroo.astrid.service.ThemeService;
|
|
|
|
@ -41,6 +44,12 @@ public class PersonViewFragment extends TaskListFragment {
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired ActFmPreferenceService actFmPreferenceService;
|
|
|
|
@Autowired ActFmPreferenceService actFmPreferenceService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired ActFmSyncService actFmSyncService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private AsyncImageView userImage;
|
|
|
|
|
|
|
|
private TextView userSubtitle;
|
|
|
|
|
|
|
|
private TextView userStatusButton;
|
|
|
|
|
|
|
|
|
|
|
|
private User user;
|
|
|
|
private User user;
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
@ -50,6 +59,19 @@ public class PersonViewFragment extends TaskListFragment {
|
|
|
|
user = userDao.fetch(extras.getLong(EXTRA_USER_ID_LOCAL), User.PROPERTIES);
|
|
|
|
user = userDao.fetch(extras.getLong(EXTRA_USER_ID_LOCAL), User.PROPERTIES);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
((TextView) getView().findViewById(android.R.id.empty)).setText(getEmptyDisplayString());
|
|
|
|
((TextView) getView().findViewById(android.R.id.empty)).setText(getEmptyDisplayString());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setupUserHeader();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void setupUserHeader() {
|
|
|
|
|
|
|
|
if (user != null) {
|
|
|
|
|
|
|
|
userImage.setDefaultImageResource(R.drawable.icn_default_person_image);
|
|
|
|
|
|
|
|
userImage.setUrl(user.getValue(User.PICTURE));
|
|
|
|
|
|
|
|
userSubtitle.setText(getUserSubtitleText());
|
|
|
|
|
|
|
|
setupUserStatusButton();
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
getView().findViewById(R.id.user_header).setVisibility(View.GONE);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
@ -67,6 +89,65 @@ public class PersonViewFragment extends TaskListFragment {
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private String getUserSubtitleText() {
|
|
|
|
|
|
|
|
String status = user.getValue(User.STATUS);
|
|
|
|
|
|
|
|
String userName = user.getDisplayName();
|
|
|
|
|
|
|
|
if (User.STATUS_PENDING.equals(status))
|
|
|
|
|
|
|
|
return getString(R.string.actfm_friendship_pending, userName);
|
|
|
|
|
|
|
|
else if (User.STATUS_BLOCKED.equals(status))
|
|
|
|
|
|
|
|
return getString(R.string.actfm_friendship_blocked, userName);
|
|
|
|
|
|
|
|
else if (User.STATUS_FRIENDS.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 return getString(R.string.actfm_friendship_no_status, userName);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void setupUserStatusButton() {
|
|
|
|
|
|
|
|
String status = user.getValue(User.STATUS);
|
|
|
|
|
|
|
|
userStatusButton.setVisibility(View.VISIBLE);
|
|
|
|
|
|
|
|
if (TextUtils.isEmpty(status))
|
|
|
|
|
|
|
|
userStatusButton.setText(getString(R.string.actfm_friendship_connect));
|
|
|
|
|
|
|
|
else if (User.STATUS_OTHER_PENDING.equals(status))
|
|
|
|
|
|
|
|
userStatusButton.setText(getString(R.string.actfm_friendship_accept));
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
userStatusButton.setVisibility(View.GONE);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
protected void setUpUiComponents() {
|
|
|
|
|
|
|
|
super.setUpUiComponents();
|
|
|
|
|
|
|
|
userImage = (AsyncImageView) getView().findViewById(R.id.user_image);
|
|
|
|
|
|
|
|
userSubtitle = (TextView) getView().findViewById(R.id.user_subtitle);
|
|
|
|
|
|
|
|
userStatusButton = (TextView) getActivity().findViewById(R.id.person_image);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
protected View getListBody(ViewGroup root) {
|
|
|
|
|
|
|
|
ViewGroup parent = (ViewGroup) getActivity().getLayoutInflater().inflate(R.layout.task_list_body_user, root, false);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
View taskListView = super.getListBody(parent);
|
|
|
|
|
|
|
|
parent.addView(taskListView);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return parent;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void handleStatusButtonClicked() {
|
|
|
|
|
|
|
|
String status = user.getValue(User.STATUS);
|
|
|
|
|
|
|
|
if (TextUtils.isEmpty(status)) { // Add friend case
|
|
|
|
|
|
|
|
user.setValue(User.PENDING_STATUS, User.PENDING_REQUEST);
|
|
|
|
|
|
|
|
} else if (User.STATUS_OTHER_PENDING.equals(status)) { // Accept friend case
|
|
|
|
|
|
|
|
user.setValue(User.PENDING_STATUS, User.PENDING_APPROVE);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (user.getSetValues().containsKey(User.PENDING_STATUS.name)) {
|
|
|
|
|
|
|
|
userDao.saveExisting(user);
|
|
|
|
|
|
|
|
userStatusButton.setVisibility(View.GONE);
|
|
|
|
|
|
|
|
refreshData(false);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
protected void addSyncRefreshMenuItem(Menu menu, int themeFlags) {
|
|
|
|
protected void addSyncRefreshMenuItem(Menu menu, int themeFlags) {
|
|
|
|
if(actFmPreferenceService.isLoggedIn()) {
|
|
|
|
if(actFmPreferenceService.isLoggedIn()) {
|
|
|
|
@ -98,21 +179,35 @@ public class PersonViewFragment extends TaskListFragment {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
protected void refresh() {
|
|
|
|
|
|
|
|
super.refresh();
|
|
|
|
|
|
|
|
setupUserHeader();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void refreshData(final boolean manual) {
|
|
|
|
private void refreshData(final boolean manual) {
|
|
|
|
if (user != null) {
|
|
|
|
if (user != null) {
|
|
|
|
((TextView) getView().findViewById(android.R.id.empty)).setText(R.string.DLG_loading);
|
|
|
|
((TextView) getView().findViewById(android.R.id.empty)).setText(R.string.DLG_loading);
|
|
|
|
|
|
|
|
new Thread() {
|
|
|
|
syncService.synchronizeList(user, manual, new ProgressBarSyncResultCallback(getActivity(), this,
|
|
|
|
|
|
|
|
R.id.progressBar, new Runnable() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
public void run() {
|
|
|
|
if (manual)
|
|
|
|
if (!TextUtils.isEmpty(user.getValue(User.PENDING_STATUS))) {
|
|
|
|
ContextManager.getContext().sendBroadcast(new Intent(AstridApiConstants.BROADCAST_EVENT_REFRESH));
|
|
|
|
actFmSyncService.pushUser(user);
|
|
|
|
else
|
|
|
|
user = userDao.fetch(user.getId(), User.PROPERTIES);
|
|
|
|
refresh();
|
|
|
|
}
|
|
|
|
((TextView) getView().findViewById(android.R.id.empty)).setText(getEmptyDisplayString());
|
|
|
|
syncService.synchronizeList(user, manual, new ProgressBarSyncResultCallback(getActivity(), PersonViewFragment.this,
|
|
|
|
|
|
|
|
R.id.progressBar, new Runnable() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void run() {
|
|
|
|
|
|
|
|
if (manual)
|
|
|
|
|
|
|
|
ContextManager.getContext().sendBroadcast(new Intent(AstridApiConstants.BROADCAST_EVENT_REFRESH));
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
refresh();
|
|
|
|
|
|
|
|
((TextView) getView().findViewById(android.R.id.empty)).setText(getEmptyDisplayString());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}));
|
|
|
|
}.start();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|