Updated several references to picture properties to read from picture jsons

pull/14/head
Sam Bosley 12 years ago
parent c88d8f455b
commit 360f75df7d

@ -5,6 +5,9 @@
*/
package com.todoroo.astrid.data;
import org.json.JSONException;
import org.json.JSONObject;
import android.text.TextUtils;
import com.todoroo.andlib.data.AbstractModel;
@ -71,4 +74,18 @@ abstract public class RemoteModel extends AbstractModel {
public static boolean isUuidEmpty(String uuid) {
return NO_UUID.equals(uuid) || TextUtils.isEmpty(uuid);
}
public static final String PICTURE_THUMB = "thumb"; //$NON-NLS-1$
public static final String PICTURE_MEDIUM = "medium"; //$NON-NLS-1$
public static final String PICTURE_LARGE = "large"; //$NON-NLS-1$
public String getPictureUrl(StringProperty pictureProperty, String size) {
String value = getValue(pictureProperty);
try {
JSONObject pictureJson = new JSONObject(value);
return pictureJson.optString(size);
} catch (JSONException e) {
return value;
}
}
}

@ -20,6 +20,7 @@ import com.todoroo.andlib.utility.DateUtilities;
import com.todoroo.andlib.utility.Preferences;
import com.todoroo.astrid.activity.TaskListActivity;
import com.todoroo.astrid.adapter.UpdateAdapter;
import com.todoroo.astrid.data.RemoteModel;
import com.todoroo.astrid.data.TagData;
import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.data.Update;
@ -104,7 +105,7 @@ public class TagCommentsFragment extends CommentsFragment {
AsyncImageView imageView = (AsyncImageView) header.findViewById(R.id.tag_picture);
imageView.setDefaultImageResource(TagService.getDefaultImageIDForTag(tagName));
imageView.setUrl(tagData.getValue(TagData.PICTURE));
imageView.setUrl(tagData.getPictureUrl(TagData.PICTURE, RemoteModel.PICTURE_MEDIUM));
}
@Override

@ -417,7 +417,7 @@ public class TagSettingsActivity extends FragmentActivity {
setTitle(getString(R.string.tag_settings_title));
}
}
picture.setUrl(tagData.getValue(TagData.PICTURE));
picture.setUrl(tagData.getPictureUrl(TagData.PICTURE, RemoteModel.PICTURE_MEDIUM));
if (!isNewTag) {
ImageView shortcut = (ImageView) findViewById(R.id.create_shortcut);
shortcut.setImageBitmap(FilterListFragment.superImposeListIcon(this, picture.getImageBitmap(), tagData.getValue(TagData.NAME)));
@ -452,7 +452,7 @@ public class TagSettingsActivity extends FragmentActivity {
try {
String url = actFmSyncService.setTagPicture(tagData.getValue(TagData.UUID), bitmap);
if (TextUtils.isEmpty(url)) return;
if (imageCache.contains(tagData.getValue(TagData.PICTURE))) {
if (imageCache.contains(tagData.getPictureUrl(TagData.PICTURE, RemoteModel.PICTURE_MEDIUM))) {
imageCache.move(tagData.getValue(TagData.PICTURE), url);
}
tagData.setValue(TagData.PICTURE, url);

@ -1694,19 +1694,11 @@ public final class ActFmSyncService {
return item.optLong(key, 0) * 1000L;
}
public static void userFromJson(JSONObject json, User model) throws JSONException {
model.setValue(User.REMOTE_ID, json.getLong("id"));
model.setValue(User.NAME, json.optString("name"));
model.setValue(User.EMAIL, json.optString("email"));
model.setValue(User.PICTURE, json.optString("picture"));
model.setValue(User.STATUS, json.optString("status"));
}
public static void jsonFromUser(JSONObject json, User model) throws JSONException {
json.put("id", model.getValue(User.UUID));
json.put("name", model.getDisplayName());
json.put("email", model.getValue(User.EMAIL));
json.put("picture", model.getValue(User.PICTURE));
json.put("picture", model.getPictureUrl(User.PICTURE, RemoteModel.PICTURE_MEDIUM));
}
public static void updateFromJson(JSONObject json, Update model) throws JSONException {

@ -522,7 +522,7 @@ public class EditNoteActivity extends LinearLayout implements TimerActionListene
public static NoteOrUpdate fromUpdate(Update u, String linkColor) {
JSONObject user = ActFmPreferenceService.userFromModel(u);
String commentPicture = u.getValue(Update.PICTURE);
String commentPicture = u.getPictureUrl(Update.PICTURE, RemoteModel.PICTURE_MEDIUM);
Spanned title = UpdateAdapter.getUpdateComment(null, u, user, linkColor, UpdateAdapter.FROM_TASK_VIEW);
return new NoteOrUpdate(user.optString("picture"),

@ -35,6 +35,7 @@ import com.todoroo.astrid.api.FilterWithUpdate;
import com.todoroo.astrid.core.PluginServices;
import com.todoroo.astrid.dao.TaskDao.TaskCriteria;
import com.todoroo.astrid.data.Metadata;
import com.todoroo.astrid.data.RemoteModel;
import com.todoroo.astrid.data.TagData;
import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.data.User;
@ -102,7 +103,7 @@ public class PeopleFilterExposer extends BroadcastReceiver {
values.put(Task.USER_ID.name, user.getValue(User.UUID));
filter.valuesForNewTasks = values;
String imageUrl = user.getValue(User.PICTURE);
String imageUrl = user.getPictureUrl(User.PICTURE, RemoteModel.PICTURE_THUMB); //user.getValue(User.PICTURE);
filter.imageUrl = imageUrl;
Bundle extras = new Bundle();

@ -23,6 +23,7 @@ import com.todoroo.astrid.actfm.sync.ActFmSyncThread;
import com.todoroo.astrid.actfm.sync.messages.BriefMe;
import com.todoroo.astrid.activity.TaskListFragment;
import com.todoroo.astrid.dao.UserDao;
import com.todoroo.astrid.data.RemoteModel;
import com.todoroo.astrid.data.User;
import com.todoroo.astrid.helper.AsyncImageView;
import com.todoroo.astrid.service.SyncV2Service;
@ -68,7 +69,7 @@ public class PersonViewFragment extends TaskListFragment {
private void setupUserHeader() {
if (user != null) {
userImage.setDefaultImageResource(R.drawable.icn_default_person_image);
userImage.setUrl(user.getValue(User.PICTURE));
userImage.setUrl(user.getPictureUrl(User.PICTURE, RemoteModel.PICTURE_MEDIUM));
userSubtitle.setText(getUserSubtitleText());
setupUserStatusButton();
} else {

@ -134,7 +134,7 @@ public final class TagService {
count = tagData.getValue(TagData.TASK_COUNT);
remoteId = tagData.getValue(TagData.REMOTE_ID);
uuid = tagData.getValue(TagData.UUID);
image = tagData.getValue(TagData.PICTURE);
image = tagData.getPictureUrl(TagData.PICTURE, RemoteModel.PICTURE_THUMB);
userId = tagData.getValue(TagData.USER_ID);
memberCount = tagData.getValue(TagData.MEMBER_COUNT);
}

@ -23,6 +23,7 @@ import com.todoroo.astrid.activity.TaskListActivity;
import com.todoroo.astrid.adapter.TaskAdapter;
import com.todoroo.astrid.api.Filter;
import com.todoroo.astrid.dao.TaskDao.TaskCriteria;
import com.todoroo.astrid.data.RemoteModel;
import com.todoroo.astrid.data.TagData;
import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.helper.AsyncImageView;
@ -89,7 +90,7 @@ public class FeaturedTaskListFragment extends TagViewFragment {
protected void setUpMembersGallery() {
// Repurposed this method to set up the description view
AsyncImageView imageView = (AsyncImageView) getView().findViewById(R.id.url_image);
String imageUrl = tagData.getValue(TagData.PICTURE);
String imageUrl = tagData.getPictureUrl(TagData.PICTURE, RemoteModel.PICTURE_MEDIUM);
if (!TextUtils.isEmpty(imageUrl)) {
imageView.setVisibility(View.VISIBLE);
imageView.setDefaultImageResource(R.drawable.default_list_0);

@ -43,6 +43,7 @@ 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.Update;
import com.todoroo.astrid.helper.AsyncImageView;
@ -160,7 +161,7 @@ public class UpdateAdapter extends CursorAdapter {
}
final AsyncImageView commentPictureView = (AsyncImageView)view.findViewById(R.id.comment_picture); {
final String updatePicture = update.getValue(Update.PICTURE);
final String updatePicture = update.getPictureUrl(Update.PICTURE, RemoteModel.PICTURE_THUMB);
setupImagePopupForCommentView(view, commentPictureView, updatePicture,
update.getValue(Update.MESSAGE), fragment, imageCache);
}

Loading…
Cancel
Save