Removed several more references to Update model

pull/14/head
Sam Bosley 13 years ago
parent bf6af525a6
commit cc0fcf95ef

@ -5,6 +5,17 @@
*/ */
package com.todoroo.astrid.data; package com.todoroo.astrid.data;
import android.content.ContentValues;
import android.net.Uri;
import com.todoroo.andlib.data.AbstractModel;
import com.todoroo.andlib.data.Property;
import com.todoroo.andlib.data.Property.LongProperty;
import com.todoroo.andlib.data.Property.StringProperty;
import com.todoroo.andlib.data.Table;
import com.todoroo.andlib.data.TodorooCursor;
import com.todoroo.astrid.api.AstridApiConstants;
/** /**
@ -13,162 +24,162 @@ package com.todoroo.astrid.data;
* @author Tim Su <tim@todoroo.com> * @author Tim Su <tim@todoroo.com>
* *
*/ */
//@SuppressWarnings("nls") @SuppressWarnings("nls")
//@Deprecated @Deprecated
//public class Update extends RemoteModel { public class Update extends RemoteModel {
//
// // --- table // --- table
//
// /** table for this model */ /** table for this model */
// public static final Table TABLE = new Table("updates", Update.class); public static final Table TABLE = new Table("updates", Update.class);
//
// /** content uri for this model */ /** content uri for this model */
// public static final Uri CONTENT_URI = Uri.parse("content://" + AstridApiConstants.API_PACKAGE + "/" + public static final Uri CONTENT_URI = Uri.parse("content://" + AstridApiConstants.API_PACKAGE + "/" +
// TABLE.name); TABLE.name);
//
// // --- properties // --- properties
//
// /** ID */ /** ID */
// public static final LongProperty ID = new LongProperty( public static final LongProperty ID = new LongProperty(
// TABLE, ID_PROPERTY_NAME); TABLE, ID_PROPERTY_NAME);
//
// /** Remote ID */ /** Remote ID */
// public static final StringProperty UUID = new StringProperty( public static final StringProperty UUID = new StringProperty(
// TABLE, UUID_PROPERTY_NAME); TABLE, UUID_PROPERTY_NAME);
//
// /** Associated Task remote-id (if any) */ /** Associated Task remote-id (if any) */
// @Deprecated // We changed uuids to strings @Deprecated // We changed uuids to strings
// public static final LongProperty TASK = new LongProperty( public static final LongProperty TASK = new LongProperty(
// TABLE, "task"); TABLE, "task");
//
// /** Associated Task uuidid (if any) */ /** Associated Task uuidid (if any) */
// public static final StringProperty TASK_UUID = new StringProperty( public static final StringProperty TASK_UUID = new StringProperty(
// TABLE, "taskUuid"); TABLE, "taskUuid");
//
// /** Associated Task local-id (if any) */ /** Associated Task local-id (if any) */
// public static final LongProperty TASK_LOCAL = new LongProperty( public static final LongProperty TASK_LOCAL = new LongProperty(
// TABLE, "taskLocal"); TABLE, "taskLocal");
//
// /** Associated Tag remote-ids (comma separated list with leading and trailing commas) */ /** Associated Tag remote-ids (comma separated list with leading and trailing commas) */
// public static final StringProperty TAGS = new StringProperty( public static final StringProperty TAGS = new StringProperty(
// TABLE, "tag"); TABLE, "tag");
//
// /** Associated Tag local-ids (comma separated list with leading and trailing commas) */ /** Associated Tag local-ids (comma separated list with leading and trailing commas) */
// public static final StringProperty TAGS_LOCAL = new StringProperty( public static final StringProperty TAGS_LOCAL = new StringProperty(
// TABLE, "tagsLocal"); TABLE, "tagsLocal");
//
// /** From user id */ /** From user id */
// public static final StringProperty USER_ID = new StringProperty( public static final StringProperty USER_ID = new StringProperty(
// TABLE, USER_ID_PROPERTY_NAME); TABLE, USER_ID_PROPERTY_NAME);
//
// /** From User Object (JSON) */ /** From User Object (JSON) */
// @Deprecated public static final StringProperty USER = new StringProperty( @Deprecated public static final StringProperty USER = new StringProperty(
// TABLE, USER_JSON_PROPERTY_NAME); TABLE, USER_JSON_PROPERTY_NAME);
//
// /** Other user id */ /** Other user id */
// public static final StringProperty OTHER_USER_ID = new StringProperty( public static final StringProperty OTHER_USER_ID = new StringProperty(
// TABLE, "other_user_id"); TABLE, "other_user_id");
//
// /** Other User Object (JSON) */ /** Other User Object (JSON) */
// public static final StringProperty OTHER_USER = new StringProperty( public static final StringProperty OTHER_USER = new StringProperty(
// TABLE, "other_user"); TABLE, "other_user");
//
// /** Action text */ /** Action text */
// public static final StringProperty ACTION = new StringProperty( public static final StringProperty ACTION = new StringProperty(
// TABLE, "action"); TABLE, "action");
//
// /** Action code */ /** Action code */
// public static final StringProperty ACTION_CODE = new StringProperty( public static final StringProperty ACTION_CODE = new StringProperty(
// TABLE, "actionCode"); TABLE, "actionCode");
//
// /** Message */ /** Message */
// public static final StringProperty MESSAGE = new StringProperty( public static final StringProperty MESSAGE = new StringProperty(
// TABLE, "message"); TABLE, "message");
//
// /** Target Object Name */ /** Target Object Name */
// public static final StringProperty TARGET_NAME = new StringProperty( public static final StringProperty TARGET_NAME = new StringProperty(
// TABLE, "targetName"); TABLE, "targetName");
//
// /** From User Object (JSON) */ /** From User Object (JSON) */
// public static final StringProperty PICTURE = new StringProperty( public static final StringProperty PICTURE = new StringProperty(
// TABLE, "picture"); TABLE, "picture");
//
// /** Unixtime Metadata was created */ /** Unixtime Metadata was created */
// public static final LongProperty CREATION_DATE = new LongProperty( public static final LongProperty CREATION_DATE = new LongProperty(
// TABLE, "created"); TABLE, "created");
//
// /** Pushed at date */ /** Pushed at date */
// public static final LongProperty PUSHED_AT = new LongProperty( public static final LongProperty PUSHED_AT = new LongProperty(
// TABLE, PUSHED_AT_PROPERTY_NAME); TABLE, PUSHED_AT_PROPERTY_NAME);
//
// /** List of all properties for this model */ /** List of all properties for this model */
// public static final Property<?>[] PROPERTIES = generateProperties(Update.class); public static final Property<?>[] PROPERTIES = generateProperties(Update.class);
//
// // --- constants // --- constants
//
// public static final String PICTURE_LOADING = "<loading>"; public static final String PICTURE_LOADING = "<loading>";
//
// // --- defaults // --- defaults
//
// /** Default values container */ /** Default values container */
// private static final ContentValues defaultValues = new ContentValues(); private static final ContentValues defaultValues = new ContentValues();
//
// @Override @Override
// public ContentValues getDefaultValues() { public ContentValues getDefaultValues() {
// return defaultValues; return defaultValues;
// } }
//
// static { static {
// defaultValues.put(UUID.name, NO_UUID); defaultValues.put(UUID.name, NO_UUID);
// defaultValues.put(TASK.name, 0); defaultValues.put(TASK.name, 0);
// defaultValues.put(TASK_UUID.name, NO_UUID); defaultValues.put(TASK_UUID.name, NO_UUID);
// defaultValues.put(TASK_LOCAL.name, 0); defaultValues.put(TASK_LOCAL.name, 0);
// defaultValues.put(TAGS.name, ""); defaultValues.put(TAGS.name, "");
// defaultValues.put(TAGS_LOCAL.name, 0); defaultValues.put(TAGS_LOCAL.name, 0);
// defaultValues.put(USER_ID.name, "0"); defaultValues.put(USER_ID.name, "0");
// defaultValues.put(USER.name, ""); defaultValues.put(USER.name, "");
// defaultValues.put(OTHER_USER_ID.name, "0"); defaultValues.put(OTHER_USER_ID.name, "0");
// defaultValues.put(OTHER_USER.name, ""); defaultValues.put(OTHER_USER.name, "");
// defaultValues.put(ACTION.name, ""); defaultValues.put(ACTION.name, "");
// defaultValues.put(ACTION_CODE.name, ""); defaultValues.put(ACTION_CODE.name, "");
// defaultValues.put(MESSAGE.name, ""); defaultValues.put(MESSAGE.name, "");
// defaultValues.put(TARGET_NAME.name, ""); defaultValues.put(TARGET_NAME.name, "");
// defaultValues.put(PICTURE.name, ""); defaultValues.put(PICTURE.name, "");
// defaultValues.put(PUSHED_AT.name, 0L); defaultValues.put(PUSHED_AT.name, 0L);
// } }
//
// // --- data access boilerplate // --- data access boilerplate
//
// public Update() { public Update() {
// super(); super();
// } }
//
// public Update(TodorooCursor<Update> cursor) { public Update(TodorooCursor<Update> cursor) {
// this(); this();
// readPropertiesFromCursor(cursor); readPropertiesFromCursor(cursor);
// } }
//
// public void readFromCursor(TodorooCursor<Update> cursor) { public void readFromCursor(TodorooCursor<Update> cursor) {
// super.readPropertiesFromCursor(cursor); super.readPropertiesFromCursor(cursor);
// } }
//
// @Override @Override
// public long getId() { public long getId() {
// return getIdHelper(ID); return getIdHelper(ID);
// } }
//
// @Override @Override
// public String getUuid() { public String getUuid() {
// return getUuidHelper(UUID); return getUuidHelper(UUID);
// } }
//
// // --- parcelable helpers // --- parcelable helpers
//
// private static final Creator<Update> CREATOR = new ModelCreator<Update>(Update.class); private static final Creator<Update> CREATOR = new ModelCreator<Update>(Update.class);
//
// @Override @Override
// protected Creator<? extends AbstractModel> getCreator() { protected Creator<? extends AbstractModel> getCreator() {
// return CREATOR; return CREATOR;
// } }
//} }

@ -36,7 +36,6 @@ import com.todoroo.astrid.activity.TaskListFragment;
import com.todoroo.astrid.api.AstridApiConstants; import com.todoroo.astrid.api.AstridApiConstants;
import com.todoroo.astrid.api.Filter; import com.todoroo.astrid.api.Filter;
import com.todoroo.astrid.api.FilterWithCustomIntent; import com.todoroo.astrid.api.FilterWithCustomIntent;
import com.todoroo.astrid.dao.UpdateDao;
import com.todoroo.astrid.data.SyncFlags; import com.todoroo.astrid.data.SyncFlags;
import com.todoroo.astrid.data.TagData; import com.todoroo.astrid.data.TagData;
import com.todoroo.astrid.data.Task; import com.todoroo.astrid.data.Task;
@ -93,9 +92,6 @@ public class GCMIntentService extends GCMBaseIntentService {
@Autowired @Autowired
private TagDataService tagDataService; private TagDataService tagDataService;
@Autowired
private UpdateDao updateDao;
public GCMIntentService() { public GCMIntentService() {
super(); super();
DependencyInjectionService.getInstance().inject(this); DependencyInjectionService.getInstance().inject(this);

@ -53,7 +53,6 @@ import com.todoroo.astrid.dao.MetadataDao;
import com.todoroo.astrid.dao.TagDataDao; import com.todoroo.astrid.dao.TagDataDao;
import com.todoroo.astrid.dao.TaskDao; import com.todoroo.astrid.dao.TaskDao;
import com.todoroo.astrid.dao.TaskDao.TaskCriteria; import com.todoroo.astrid.dao.TaskDao.TaskCriteria;
import com.todoroo.astrid.dao.UpdateDao;
import com.todoroo.astrid.dao.UserDao; import com.todoroo.astrid.dao.UserDao;
import com.todoroo.astrid.data.Metadata; import com.todoroo.astrid.data.Metadata;
import com.todoroo.astrid.data.MetadataApiDao.MetadataCriteria; import com.todoroo.astrid.data.MetadataApiDao.MetadataCriteria;
@ -94,7 +93,6 @@ public final class ActFmSyncService {
@Autowired ActFmDataService actFmDataService; @Autowired ActFmDataService actFmDataService;
@Autowired TaskDao taskDao; @Autowired TaskDao taskDao;
@Autowired TagDataDao tagDataDao; @Autowired TagDataDao tagDataDao;
@Autowired UpdateDao updateDao;
@Autowired UserDao userDao; @Autowired UserDao userDao;
@Autowired MetadataDao metadataDao; @Autowired MetadataDao metadataDao;
@Autowired ABTestEventReportingService abTestEventReportingService; @Autowired ABTestEventReportingService abTestEventReportingService;

@ -380,7 +380,7 @@ public class EditNoteActivity extends LinearLayout implements TimerActionListene
// picture // picture
final AsyncImageView commentPictureView = (AsyncImageView)view.findViewById(R.id.comment_picture); { final AsyncImageView commentPictureView = (AsyncImageView)view.findViewById(R.id.comment_picture); {
UpdateAdapter.setupImagePopupForCommentView(view, commentPictureView, item.commentPicture, item.title.toString(), fragment, imageCache); // UpdateAdapter.setupImagePopupForCommentView(view, commentPictureView, item.commentPicture, item.title.toString(), fragment, imageCache);
} }
} }
@ -517,7 +517,7 @@ public class EditNoteActivity extends LinearLayout implements TimerActionListene
String commentPicture = u.getPictureUrl(UserActivity.PICTURE, RemoteModel.PICTURE_MEDIUM); String commentPicture = u.getPictureUrl(UserActivity.PICTURE, RemoteModel.PICTURE_MEDIUM);
Spanned title = UpdateAdapter.getUpdateComment(null, u, user, linkColor, UpdateAdapter.FROM_TASK_VIEW); Spanned title = null; //UpdateAdapter.getUpdateComment(null, u, user, linkColor, UpdateAdapter.FROM_TASK_VIEW);
return new NoteOrUpdate(user.optString("picture"), return new NoteOrUpdate(user.optString("picture"),
title, title,
commentPicture, commentPicture,

@ -5,48 +5,21 @@
*/ */
package com.todoroo.astrid.adapter; package com.todoroo.astrid.adapter;
import java.io.IOException;
import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import org.json.JSONException;
import org.json.JSONObject;
import android.app.AlertDialog;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface;
import android.database.Cursor; import android.database.Cursor;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.text.Html;
import android.text.SpannableString;
import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.text.TextPaint;
import android.text.TextUtils;
import android.text.format.DateUtils;
import android.text.method.LinkMovementMethod;
import android.text.style.ClickableSpan;
import android.util.TypedValue; import android.util.TypedValue;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.CursorAdapter; import android.widget.CursorAdapter;
import android.widget.TextView;
import com.timsu.astrid.R; import com.timsu.astrid.R;
import com.todoroo.andlib.data.TodorooCursor; import com.todoroo.andlib.data.TodorooCursor;
import com.todoroo.andlib.service.ContextManager;
import com.todoroo.andlib.service.DependencyInjectionService; import com.todoroo.andlib.service.DependencyInjectionService;
import com.todoroo.andlib.utility.DateUtilities;
import com.todoroo.astrid.actfm.sync.ActFmPreferenceService;
import com.todoroo.astrid.activity.AstridActivity;
import com.todoroo.astrid.core.PluginServices;
import com.todoroo.astrid.data.RemoteModel;
import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.data.UserActivity; import com.todoroo.astrid.data.UserActivity;
import com.todoroo.astrid.helper.AsyncImageView;
import com.todoroo.astrid.helper.ImageDiskCache; import com.todoroo.astrid.helper.ImageDiskCache;
/** /**
@ -150,36 +123,35 @@ public class UpdateAdapter extends CursorAdapter {
} }
/** Helper method to set the contents and visibility of each field */ /** Helper method to set the contents and visibility of each field */
@SuppressWarnings("nls")
public synchronized void setFieldContentsAndVisibility(View view, UserActivity update) { public synchronized void setFieldContentsAndVisibility(View view, UserActivity update) {
JSONObject user = ActFmPreferenceService.userFromModel(update); // JSONObject user = ActFmPreferenceService.userFromModel(update);
//
// picture // // picture
final AsyncImageView pictureView = (AsyncImageView)view.findViewById(R.id.picture); { // final AsyncImageView pictureView = (AsyncImageView)view.findViewById(R.id.picture); {
String pictureUrl = user.optString("picture"); // String pictureUrl = user.optString("picture");
pictureView.setUrl(pictureUrl); // pictureView.setUrl(pictureUrl);
} // }
//
final AsyncImageView commentPictureView = (AsyncImageView)view.findViewById(R.id.comment_picture); { // final AsyncImageView commentPictureView = (AsyncImageView)view.findViewById(R.id.comment_picture); {
final String updatePicture = update.getPictureUrl(UserActivity.PICTURE, RemoteModel.PICTURE_THUMB); // final String updatePicture = update.getPictureUrl(UserActivity.PICTURE, RemoteModel.PICTURE_THUMB);
setupImagePopupForCommentView(view, commentPictureView, updatePicture, // setupImagePopupForCommentView(view, commentPictureView, updatePicture,
update.getValue(UserActivity.MESSAGE), fragment, imageCache); // update.getValue(UserActivity.MESSAGE), fragment, imageCache);
} // }
//
// name // // name
final TextView nameView = (TextView)view.findViewById(R.id.title); { // final TextView nameView = (TextView)view.findViewById(R.id.title); {
nameView.setText(getUpdateComment((AstridActivity)fragment.getActivity(), update, user, linkColor, fromView)); // nameView.setText(getUpdateComment((AstridActivity)fragment.getActivity(), update, user, linkColor, fromView));
nameView.setMovementMethod(new LinkMovementMethod()); // nameView.setMovementMethod(new LinkMovementMethod());
} // }
//
//
// date // // date
final TextView date = (TextView)view.findViewById(R.id.date); { // final TextView date = (TextView)view.findViewById(R.id.date); {
CharSequence dateString = DateUtils.getRelativeTimeSpanString(update.getValue(UserActivity.CREATED_AT), // CharSequence dateString = DateUtils.getRelativeTimeSpanString(update.getValue(UserActivity.CREATED_AT),
DateUtilities.now(), DateUtils.MINUTE_IN_MILLIS, // DateUtilities.now(), DateUtils.MINUTE_IN_MILLIS,
DateUtils.FORMAT_ABBREV_RELATIVE); // DateUtils.FORMAT_ABBREV_RELATIVE);
date.setText(dateString); // date.setText(dateString);
} // }
} }
@ -188,207 +160,207 @@ public class UpdateAdapter extends CursorAdapter {
return false; return false;
} }
public static void setupImagePopupForCommentView(View view, AsyncImageView commentPictureView, final String updatePicture, // public static void setupImagePopupForCommentView(View view, AsyncImageView commentPictureView, final String updatePicture,
final String message, final Fragment fragment, ImageDiskCache imageCache) { // final String message, final Fragment fragment, ImageDiskCache imageCache) {
if (!TextUtils.isEmpty(updatePicture) && !"null".equals(updatePicture)) { //$NON-NLS-1$ // if (!TextUtils.isEmpty(updatePicture) && !"null".equals(updatePicture)) { //$NON-NLS-1$
commentPictureView.setVisibility(View.VISIBLE); // commentPictureView.setVisibility(View.VISIBLE);
commentPictureView.setUrl(updatePicture); // commentPictureView.setUrl(updatePicture);
//
if(imageCache.contains(updatePicture)) { // if(imageCache.contains(updatePicture)) {
try { // try {
commentPictureView.setDefaultImageBitmap(imageCache.get(updatePicture)); // commentPictureView.setDefaultImageBitmap(imageCache.get(updatePicture));
} catch (IOException e) { // } catch (IOException e) {
e.printStackTrace(); // e.printStackTrace();
} // }
} // }
else { // else {
commentPictureView.setUrl(updatePicture); // commentPictureView.setUrl(updatePicture);
} // }
//
view.setOnClickListener(new OnClickListener() { // view.setOnClickListener(new OnClickListener() {
@Override // @Override
public void onClick(View v) { // public void onClick(View v) {
AlertDialog image = new AlertDialog.Builder(fragment.getActivity()).create(); // AlertDialog image = new AlertDialog.Builder(fragment.getActivity()).create();
AsyncImageView imageView = new AsyncImageView(fragment.getActivity()); // AsyncImageView imageView = new AsyncImageView(fragment.getActivity());
imageView.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); // imageView.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
imageView.setDefaultImageResource(android.R.drawable.ic_menu_gallery); // imageView.setDefaultImageResource(android.R.drawable.ic_menu_gallery);
imageView.setUrl(updatePicture); // imageView.setUrl(updatePicture);
image.setView(imageView); // image.setView(imageView);
//
image.setMessage(message); // image.setMessage(message);
image.setButton(fragment.getString(R.string.DLG_close), new DialogInterface.OnClickListener() { // image.setButton(fragment.getString(R.string.DLG_close), new DialogInterface.OnClickListener() {
@Override // @Override
public void onClick(DialogInterface dialog, int which) { // public void onClick(DialogInterface dialog, int which) {
return; // return;
} // }
}); // });
image.show(); // image.show();
} // }
}); // });
} else { // } else {
commentPictureView.setVisibility(View.GONE); // commentPictureView.setVisibility(View.GONE);
} // }
} // }
//
public static String linkify (String string, String linkColor) { // public static String linkify (String string, String linkColor) {
return String.format("<font color=%s>%s</font>", linkColor, string); //$NON-NLS-1$ // return String.format("<font color=%s>%s</font>", linkColor, string); //$NON-NLS-1$
} // }
//
@SuppressWarnings("nls") // @SuppressWarnings("nls")
public static Spanned getUpdateComment (final AstridActivity activity, UserActivity update, JSONObject user, String linkColor, String fromView) { // public static Spanned getUpdateComment (final AstridActivity activity, UserActivity update, JSONObject user, String linkColor, String fromView) {
if (user == null) // if (user == null)
user = ActFmPreferenceService.userFromModel(update); // user = ActFmPreferenceService.userFromModel(update);
//
JSONObject otherUser = null; // JSONObject otherUser = null;
try { // try {
otherUser = new JSONObject(update.getValue(UserActivity.OTHER_USER)); // otherUser = new JSONObject(update.getValue(UserActivity.OTHER_USER));
} catch (JSONException e) { // } catch (JSONException e) {
otherUser = new JSONObject(); // otherUser = new JSONObject();
} // }
//
return getUpdateComment(activity, update, update.getValue(UserActivity.ACTION), // return getUpdateComment(activity, update, update.getValue(UserActivity.ACTION),
user.optString("name"), update.getValue(UserActivity.TARGET_NAME), // user.optString("name"), update.getValue(UserActivity.TARGET_NAME),
update.getValue(UserActivity.MESSAGE), otherUser.optString("name"), // update.getValue(UserActivity.MESSAGE), otherUser.optString("name"),
linkColor, fromView); // linkColor, fromView);
} // }
//
public static Spanned getUpdateComment (final AstridActivity activity, UserActivity update, String actionCode, String user, String targetName, // public static Spanned getUpdateComment (final AstridActivity activity, UserActivity update, String actionCode, String user, String targetName,
String message, String otherUser, String linkColor, String fromView) { // String message, String otherUser, String linkColor, String fromView) {
if (TextUtils.isEmpty(user)) { // if (TextUtils.isEmpty(user)) {
user = ContextManager.getString(R.string.ENA_no_user); // user = ContextManager.getString(R.string.ENA_no_user);
} // }
//
String userLink = user; //linkify(user, linkColor); // String userLink = user; //linkify(user, linkColor);
String targetNameLink = targetName; //linkify(targetName, linkColor); // String targetNameLink = targetName; //linkify(targetName, linkColor);
String otherUserLink = otherUser; //linkify(otherUser, linkColor); // String otherUserLink = otherUser; //linkify(otherUser, linkColor);
//
int commentResource = 0; // int commentResource = 0;
if (actionCode.equals(UPDATE_FRIENDS)) { // if (actionCode.equals(UPDATE_FRIENDS)) {
commentResource = R.string.update_string_friends; // commentResource = R.string.update_string_friends;
} // }
else if (actionCode.equals(UPDATE_REQUEST_FRIENDSHIP)) { // else if (actionCode.equals(UPDATE_REQUEST_FRIENDSHIP)) {
commentResource = R.string.update_string_request_friendship; // commentResource = R.string.update_string_request_friendship;
} // }
else if (actionCode.equals(UPDATE_CONFIRMED_FRIENDSHIP)) { // else if (actionCode.equals(UPDATE_CONFIRMED_FRIENDSHIP)) {
commentResource = R.string.update_string_confirmed_friendship; // commentResource = R.string.update_string_confirmed_friendship;
} // }
else if (actionCode.equals(UPDATE_TASK_CREATED)) { // else if (actionCode.equals(UPDATE_TASK_CREATED)) {
if (fromView.equals(FROM_TAG_VIEW)) // if (fromView.equals(FROM_TAG_VIEW))
commentResource = R.string.update_string_task_created_on_list; // commentResource = R.string.update_string_task_created_on_list;
else if (fromView.equals(FROM_RECENT_ACTIVITY_VIEW)) // else if (fromView.equals(FROM_RECENT_ACTIVITY_VIEW))
commentResource = R.string.update_string_task_created_global; // commentResource = R.string.update_string_task_created_global;
else // else
commentResource = R.string.update_string_task_created; // commentResource = R.string.update_string_task_created;
} // }
else if (actionCode.equals(UPDATE_TASK_COMPLETED)) { // else if (actionCode.equals(UPDATE_TASK_COMPLETED)) {
commentResource = R.string.update_string_task_completed; // commentResource = R.string.update_string_task_completed;
} // }
else if (actionCode.equals(UPDATE_TASK_UNCOMPLETED)) { // else if (actionCode.equals(UPDATE_TASK_UNCOMPLETED)) {
commentResource = R.string.update_string_task_uncompleted; // commentResource = R.string.update_string_task_uncompleted;
} // }
else if (actionCode.equals(UPDATE_TASK_TAGGED) && !TextUtils.isEmpty(otherUser)) { // else if (actionCode.equals(UPDATE_TASK_TAGGED) && !TextUtils.isEmpty(otherUser)) {
if (fromView.equals(FROM_TAG_VIEW)) // if (fromView.equals(FROM_TAG_VIEW))
commentResource = R.string.update_string_task_tagged_list; // commentResource = R.string.update_string_task_tagged_list;
else // else
commentResource = R.string.update_string_task_tagged; // commentResource = R.string.update_string_task_tagged;
} // }
else if (actionCode.equals(UPDATE_TASK_ASSIGNED) && !TextUtils.isEmpty(otherUser)) { // else if (actionCode.equals(UPDATE_TASK_ASSIGNED) && !TextUtils.isEmpty(otherUser)) {
commentResource = R.string.update_string_task_assigned; // commentResource = R.string.update_string_task_assigned;
} // }
else if (actionCode.equals(UPDATE_TASK_COMMENT)) { // else if (actionCode.equals(UPDATE_TASK_COMMENT)) {
if (fromView.equals(FROM_TASK_VIEW) || TextUtils.isEmpty(targetName)) // if (fromView.equals(FROM_TASK_VIEW) || TextUtils.isEmpty(targetName))
commentResource = R.string.update_string_default_comment; // commentResource = R.string.update_string_default_comment;
else // else
commentResource = R.string.update_string_task_comment; // commentResource = R.string.update_string_task_comment;
} // }
else if (actionCode.equals(UPDATE_TAG_COMMENT)) { // else if (actionCode.equals(UPDATE_TAG_COMMENT)) {
if (fromView.equals(FROM_TAG_VIEW) || TextUtils.isEmpty(targetName)) // if (fromView.equals(FROM_TAG_VIEW) || TextUtils.isEmpty(targetName))
commentResource = R.string.update_string_default_comment; // commentResource = R.string.update_string_default_comment;
else // else
commentResource = R.string.update_string_tag_comment; // commentResource = R.string.update_string_tag_comment;
//
} // }
else if (actionCode.equals(UPDATE_TAG_CREATED)) { // else if (actionCode.equals(UPDATE_TAG_CREATED)) {
if (fromView.equals(FROM_RECENT_ACTIVITY_VIEW)) // if (fromView.equals(FROM_RECENT_ACTIVITY_VIEW))
commentResource = R.string.update_string_tag_created_global; // commentResource = R.string.update_string_tag_created_global;
else // else
commentResource = R.string.update_string_tag_created; // commentResource = R.string.update_string_tag_created;
} // }
//
if (commentResource == 0) { // if (commentResource == 0) {
return Html.fromHtml(String.format("%s %s", userLink, action)); //$NON-NLS-1$ // return Html.fromHtml(String.format("%s %s", userLink, action)); //$NON-NLS-1$
} // }
//
String original = ContextManager.getString(commentResource, userLink, targetNameLink, message, otherUserLink); // String original = ContextManager.getString(commentResource, userLink, targetNameLink, message, otherUserLink);
int taskLinkIndex = original.indexOf(TARGET_LINK_PREFIX); // int taskLinkIndex = original.indexOf(TARGET_LINK_PREFIX);
//
if (taskLinkIndex < 0) // if (taskLinkIndex < 0)
return Html.fromHtml(original); // return Html.fromHtml(original);
//
String[] components = original.split(" "); //$NON-NLS-1$ // String[] components = original.split(" "); //$NON-NLS-1$
SpannableStringBuilder builder = new SpannableStringBuilder(); // SpannableStringBuilder builder = new SpannableStringBuilder();
StringBuilder htmlStringBuilder = new StringBuilder(); // StringBuilder htmlStringBuilder = new StringBuilder();
//
for (String comp : components) { // for (String comp : components) {
Matcher m = TARGET_LINK_PATTERN.matcher(comp); // Matcher m = TARGET_LINK_PATTERN.matcher(comp);
if (m.find()) { // if (m.find()) {
builder.append(Html.fromHtml(htmlStringBuilder.toString())); // builder.append(Html.fromHtml(htmlStringBuilder.toString()));
htmlStringBuilder.setLength(0); // htmlStringBuilder.setLength(0);
//
String linkType = m.group(1); // String linkType = m.group(1);
CharSequence link = getLinkSpan(activity, update, actionCode, user, // CharSequence link = getLinkSpan(activity, update, actionCode, user,
targetName, message, otherUser, linkColor, linkType); // targetName, message, otherUser, linkColor, linkType);
if (link != null) { // if (link != null) {
builder.append(link); // builder.append(link);
if (!m.hitEnd()) { // if (!m.hitEnd()) {
builder.append(comp.substring(m.end())); // builder.append(comp.substring(m.end()));
} // }
builder.append(' '); // builder.append(' ');
} // }
} else { // } else {
htmlStringBuilder.append(comp); // htmlStringBuilder.append(comp);
htmlStringBuilder.append(' '); // htmlStringBuilder.append(' ');
} // }
} // }
//
if (htmlStringBuilder.length() > 0) // if (htmlStringBuilder.length() > 0)
builder.append(Html.fromHtml(htmlStringBuilder.toString())); // builder.append(Html.fromHtml(htmlStringBuilder.toString()));
//
return builder; // return builder;
} // }
//
private static CharSequence getLinkSpan(final AstridActivity activity, UserActivity update, String actionCode, String user, String targetName, // private static CharSequence getLinkSpan(final AstridActivity activity, UserActivity update, String actionCode, String user, String targetName,
String message, String otherUser, String linkColor, String linkType) { // String message, String otherUser, String linkColor, String linkType) {
if (TASK_LINK_TYPE.equals(linkType)) { // if (TASK_LINK_TYPE.equals(linkType)) {
long taskId = update.getValue(UserActivity.TASK_LOCAL); // long taskId = update.getValue(UserActivity.TASK_LOCAL);
if (taskId <= 0) { // if (taskId <= 0) {
Task local = PluginServices.getTaskService().fetchByUUID(update.getValue(UserActivity.TASK_UUID), Task.ID); // Task local = PluginServices.getTaskService().fetchByUUID(update.getValue(UserActivity.TASK_UUID), Task.ID);
if (local != null) // if (local != null)
taskId = local.getId(); // taskId = local.getId();
} // }
//
final long taskIdToUse = taskId; // final long taskIdToUse = taskId;
//
if (taskId > 0) { // if (taskId > 0) {
SpannableString taskSpan = new SpannableString(targetName); // SpannableString taskSpan = new SpannableString(targetName);
taskSpan.setSpan(new ClickableSpan() { // taskSpan.setSpan(new ClickableSpan() {
@Override // @Override
public void onClick(View widget) { // public void onClick(View widget) {
if (activity != null) // TODO: This shouldn't happen, but sometimes does // if (activity != null) // TODO: This shouldn't happen, but sometimes does
activity.onTaskListItemClicked(taskIdToUse); // activity.onTaskListItemClicked(taskIdToUse);
} // }
//
@Override // @Override
public void updateDrawState(TextPaint ds) { // public void updateDrawState(TextPaint ds) {
super.updateDrawState(ds); // super.updateDrawState(ds);
ds.setUnderlineText(false); // ds.setUnderlineText(false);
} // }
}, 0, targetName.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE); // }, 0, targetName.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
return taskSpan; // return taskSpan;
} else { // } else {
return Html.fromHtml(linkify(targetName, linkColor)); // return Html.fromHtml(linkify(targetName, linkColor));
} // }
} // }
return null; // return null;
} // }
} }

@ -22,6 +22,7 @@ import com.todoroo.astrid.data.TagMetadata;
import com.todoroo.astrid.data.TagOutstanding; import com.todoroo.astrid.data.TagOutstanding;
import com.todoroo.astrid.data.Task; import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.data.TaskOutstanding; import com.todoroo.astrid.data.TaskOutstanding;
import com.todoroo.astrid.data.Update;
import com.todoroo.astrid.data.User; import com.todoroo.astrid.data.User;
import com.todoroo.astrid.data.UserActivity; import com.todoroo.astrid.data.UserActivity;
import com.todoroo.astrid.data.UserActivityOutstanding; import com.todoroo.astrid.data.UserActivityOutstanding;

@ -9,12 +9,14 @@ import com.todoroo.andlib.service.Autowired;
import com.todoroo.andlib.service.DependencyInjectionService; import com.todoroo.andlib.service.DependencyInjectionService;
import com.todoroo.astrid.data.Update; import com.todoroo.astrid.data.Update;
/** /**
* Data Access layer for {@link Update}-related operations. * Data Access layer for {@link Update}-related operations.
* *
* @author Tim Su <tim@todoroo.com> * @author Tim Su <tim@todoroo.com>
* *
*/ */
@Deprecated
public class UpdateDao extends RemoteModelDao<Update> { public class UpdateDao extends RemoteModelDao<Update> {
@Autowired Database database; @Autowired Database database;

@ -14,12 +14,15 @@ import com.todoroo.andlib.sql.Functions;
import com.todoroo.andlib.sql.Order; import com.todoroo.andlib.sql.Order;
import com.todoroo.andlib.sql.Query; import com.todoroo.andlib.sql.Query;
import com.todoroo.astrid.api.PermaSql; import com.todoroo.astrid.api.PermaSql;
import com.todoroo.astrid.dao.MetadataDao.MetadataCriteria;
import com.todoroo.astrid.dao.TagDataDao; import com.todoroo.astrid.dao.TagDataDao;
import com.todoroo.astrid.dao.TaskDao; import com.todoroo.astrid.dao.TaskDao;
import com.todoroo.astrid.dao.UserActivityDao; import com.todoroo.astrid.dao.UserActivityDao;
import com.todoroo.astrid.data.Metadata;
import com.todoroo.astrid.data.RemoteModel; import com.todoroo.astrid.data.RemoteModel;
import com.todoroo.astrid.data.TagData; import com.todoroo.astrid.data.TagData;
import com.todoroo.astrid.data.UserActivity; import com.todoroo.astrid.data.UserActivity;
import com.todoroo.astrid.tags.TaskToTagMetadata;
/** /**
* Service layer for {@link TagData}-centered activities. * Service layer for {@link TagData}-centered activities.
@ -140,20 +143,21 @@ public class TagDataService {
return getUpdatesWithExtraCriteria(tagData, Criterion.all); return getUpdatesWithExtraCriteria(tagData, Criterion.all);
} }
@SuppressWarnings("nls") private static Query queryForTagData(TagData tagData) {
return Query.select(UserActivity.PROPERTIES).where(Criterion.or(
Criterion.and(UserActivity.ACTION.eq(UserActivity.ACTION_TAG_COMMENT), UserActivity.TARGET_ID.eq(tagData.getUuid())),
Criterion.and(UserActivity.ACTION.eq(UserActivity.ACTION_TASK_COMMENT),
UserActivity.TARGET_ID.in(Query.select(TaskToTagMetadata.TASK_UUID)
.from(Metadata.TABLE).where(Criterion.and(MetadataCriteria.withKey(TaskToTagMetadata.KEY), TaskToTagMetadata.TAG_UUID.eq(tagData.getUuid())))))));
}
public TodorooCursor<UserActivity> getUpdatesWithExtraCriteria(TagData tagData, Criterion criterion) { public TodorooCursor<UserActivity> getUpdatesWithExtraCriteria(TagData tagData, Criterion criterion) {
if (tagData == null) if (tagData == null)
return updateDao.query(Query.select(UserActivity.PROPERTIES).where( return userActivityDao.query(Query.select(UserActivity.PROPERTIES).where(
criterion). criterion).
orderBy(Order.desc(UserActivity.CREATED_AT))); orderBy(Order.desc(UserActivity.CREATED_AT)));
if(RemoteModel.NO_UUID.equals(tagData.getValue(TagData.UUID))) return userActivityDao.query(queryForTagData(tagData).orderBy(Order.desc(UserActivity.CREATED_AT)));
return updateDao.query(Query.select(UserActivity.PROPERTIES).where(Update.TAGS_LOCAL.like("%," + tagData.getId() + ",%")).orderBy(Order.desc(Update.CREATION_DATE)));
return updateDao.query(Query.select(UserActivity.PROPERTIES).where(Criterion.and(criterion,
Criterion.or(Update.TAGS.like("%," + tagData.getValue(TagData.UUID) + ",%"),
Update.TAGS_LOCAL.like("%," + tagData.getId() + ",%")))).
orderBy(Order.desc(UserActivity.CREATED_AT)));
} }
/** /**
@ -165,10 +169,7 @@ public class TagDataService {
if(RemoteModel.NO_UUID.equals(tagData.getValue(TagData.UUID))) if(RemoteModel.NO_UUID.equals(tagData.getValue(TagData.UUID)))
return null; return null;
@SuppressWarnings("nls") TodorooCursor<UserActivity> updates = userActivityDao.query(queryForTagData(tagData).orderBy(Order.desc(UserActivity.CREATED_AT)).limit(1));
TodorooCursor<UserActivity> updates = updateDao.query(Query.select(Update.PROPERTIES).where(
UserActivity.TAGS.like("%," + tagData.getValue(TagData.UUID) + ",%")).
orderBy(Order.desc(Update.CREATION_DATE)).limit(1));
try { try {
if(updates.getCount() == 0) if(updates.getCount() == 0)
return null; return null;

Loading…
Cancel
Save