Remove getPictureUrl

pull/189/head
Alex Baker 10 years ago
parent 6e00422d81
commit 1e47a6dfa5

@ -26,8 +26,6 @@ import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import static org.tasks.date.DateTimeUtils.currentTimeMillis;
/**
* A model that is synchronized to a remote server and has a remote id
*
@ -92,14 +90,6 @@ abstract public class RemoteModel extends AbstractModel {
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 String getPictureUrl(StringProperty pictureProperty, String size) {
String value = getValue(pictureProperty);
return PictureHelper.getPictureUrl(value, size);
}
public Bitmap getPictureBitmap(StringProperty pictureProperty) {
String value = getValue(pictureProperty);
return PictureHelper.getPictureBitmap(value);
@ -109,17 +99,6 @@ abstract public class RemoteModel extends AbstractModel {
public static final String PICTURES_DIRECTORY = "pictures"; //$NON-NLS-1$
public static String getPictureHash(TagData tagData) {
long tag_date = 0;
if (tagData.containsValue(TagData.CREATION_DATE)) {
tag_date = tagData.getCreationDate();
}
if (tag_date == 0) {
tag_date = currentTimeMillis();
}
return String.format("cached::%s%s", tagData.getName(), tag_date);
}
@TargetApi(Build.VERSION_CODES.FROYO)
public static JSONObject savePictureJson(Context context, Bitmap bitmap) {
try {
@ -154,23 +133,6 @@ abstract public class RemoteModel extends AbstractModel {
return null;
}
public static String getPictureUrl(String value, String size) {
try {
if (value == null) {
return null;
}
JSONObject pictureJson = new JSONObject(value);
if (pictureJson.has("path")) // Unpushed encoded bitmap //$NON-NLS-1$
{
return null;
}
return pictureJson.optString(size);
} catch (JSONException e) {
log.error(e.getMessage(), e);
return value;
}
}
public static Bitmap getPictureBitmap(String value) {
try {
if (value == null) {

@ -50,10 +50,6 @@ public final class TagData extends RemoteModel {
public static final StringProperty NAME = new StringProperty(
TABLE, "name");
/** Project picture */
public static final StringProperty PICTURE = new StringProperty(
TABLE, "picture", Property.PROP_FLAG_JSON | Property.PROP_FLAG_PICTURE);
/** Tag team array (JSON) */
@Deprecated public static final StringProperty MEMBERS = new StringProperty(
TABLE, "members");
@ -144,7 +140,6 @@ public final class TagData extends RemoteModel {
defaultValues.put(USER.name, "");
defaultValues.put(UUID.name, NO_UUID);
defaultValues.put(NAME.name, "");
defaultValues.put(PICTURE.name, "");
defaultValues.put(IS_TEAM.name, 1);
defaultValues.put(MEMBERS.name, "");
defaultValues.put(MEMBER_COUNT.name, 0);
@ -266,8 +261,4 @@ public final class TagData extends RemoteModel {
public void setMemberCount(Integer memberCount) {
setValue(MEMBER_COUNT, memberCount);
}
public void setPicture(String picture) {
setValue(PICTURE, picture);
}
}

@ -69,7 +69,6 @@ public class TagSettingsActivity extends InjectingActionBarActivity {
@Inject ResourceResolver resourceResolver;
private EditText tagName;
private Bitmap setBitmap;
private boolean isNewTag = false;
private boolean isDialog;
@ -177,13 +176,6 @@ public class TagSettingsActivity extends InjectingActionBarActivity {
}
}
if (setBitmap != null) {
JSONObject pictureJson = RemoteModel.PictureHelper.savePictureJson(this, setBitmap);
if (pictureJson != null) {
tagData.setPicture(pictureJson.toString());
}
}
JSONArray members = new JSONArray();
tagData.setMemberCount(members.length());
@ -205,19 +197,6 @@ public class TagSettingsActivity extends InjectingActionBarActivity {
finish();
}
private void saveTagPictureLocally(Bitmap bitmap) {
if (bitmap == null) {
return;
}
try {
String tagPicture = RemoteModel.PictureHelper.getPictureHash(tagData);
tagData.setPicture(tagPicture);
}
catch (Exception e) {
log.error(e.getMessage(), e);
}
}
@Override
public void finish() {
finishWithAnimation(!isDialog);
@ -253,8 +232,7 @@ public class TagSettingsActivity extends InjectingActionBarActivity {
CameraResultCallback callback = new CameraResultCallback() {
@Override
public void handleCameraResult(Bitmap bitmap) {
setBitmap = bitmap;
saveTagPictureLocally(bitmap);
log.error("Not expecting this");
}
};
if (!ActFmCameraModule.activityResult(this, requestCode, resultCode, data, callback)) {

@ -100,7 +100,6 @@ public class NameMaps {
putTagPropertyToServerName(TagData.UUID, "uuid", false);
putTagPropertyToServerName(TagData.TASK_COUNT, "task_count", false);
putTagPropertyToServerName(TagData.TAG_DESCRIPTION, "description", true);
putTagPropertyToServerName(TagData.PICTURE, "picture", true);
putTagPropertyToServerName(TagData.IS_FOLDER, "is_folder", false);
}

@ -13,7 +13,6 @@ import android.graphics.Bitmap;
import android.support.v4.app.Fragment;
import android.text.Html;
import android.text.Spanned;
import android.text.TextUtils;
import android.text.format.DateUtils;
import android.text.method.LinkMovementMethod;
import android.util.TypedValue;
@ -31,7 +30,6 @@ import com.todoroo.andlib.data.Property.StringProperty;
import com.todoroo.andlib.data.TodorooCursor;
import com.todoroo.andlib.utility.DateUtilities;
import com.todoroo.astrid.actfm.sync.messages.NameMaps;
import com.todoroo.astrid.data.RemoteModel;
import com.todoroo.astrid.data.UserActivity;
import org.tasks.R;
@ -152,13 +150,8 @@ public class UpdateAdapter extends CursorAdapter {
private void setupUserActivityRow(View view, UserActivity activity) {
final ImageView commentPictureView = (ImageView)view.findViewById(R.id.comment_picture); {
String pictureThumb = activity.getPictureUrl(UserActivity.PICTURE, RemoteModel.PICTURE_MEDIUM);
Bitmap updateBitmap = null;
if (TextUtils.isEmpty(pictureThumb)) {
updateBitmap = activity.getPictureBitmap(UserActivity.PICTURE);
}
setupImagePopupForCommentView(view, commentPictureView, pictureThumb, updateBitmap,
activity.getMessage(), fragment);
Bitmap updateBitmap = activity.getPictureBitmap(UserActivity.PICTURE);
setupImagePopupForCommentView(view, commentPictureView, updateBitmap, activity.getMessage(), fragment);
}
// name
@ -168,7 +161,6 @@ public class UpdateAdapter extends CursorAdapter {
nameView.setTextColor(color);
}
// date
final TextView date = (TextView)view.findViewById(R.id.date); {
CharSequence dateString = DateUtils.getRelativeTimeSpanString(activity.getCreatedAt(),
@ -183,13 +175,11 @@ public class UpdateAdapter extends CursorAdapter {
return false;
}
public static void setupImagePopupForCommentView(View view, ImageView commentPictureView, final String pictureThumb, final Bitmap updateBitmap,
public static void setupImagePopupForCommentView(View view, ImageView commentPictureView, final Bitmap updateBitmap,
final String message, final Fragment fragment) {
if ((!TextUtils.isEmpty(pictureThumb) && !"null".equals(pictureThumb)) || updateBitmap != null) { //$NON-NLS-1$
if (updateBitmap != null) { //$NON-NLS-1$
commentPictureView.setVisibility(View.VISIBLE);
if (updateBitmap != null) {
commentPictureView.setImageBitmap(updateBitmap);
}
commentPictureView.setImageBitmap(updateBitmap);
view.setOnClickListener(new OnClickListener() {
@Override
@ -198,9 +188,7 @@ public class UpdateAdapter extends CursorAdapter {
ImageView imageView = new ImageView(fragment.getActivity());
imageView.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
imageView.setImageResource(android.R.drawable.ic_menu_gallery);
if (updateBitmap != null) {
imageView.setImageBitmap(updateBitmap);
}
imageView.setImageBitmap(updateBitmap);
image.setView(imageView);
image.setMessage(message);

@ -358,7 +358,7 @@ public class EditNoteActivity extends LinearLayout implements TimerActionListene
// picture
final ImageView commentPictureView = (ImageView)view.findViewById(R.id.comment_picture);
UpdateAdapter.setupImagePopupForCommentView(view, commentPictureView, item.pictureThumb, item.commentBitmap, item.title.toString(), fragment);
UpdateAdapter.setupImagePopupForCommentView(view, commentPictureView, item.commentBitmap, item.title.toString(), fragment);
}
private void addComment() {
@ -407,14 +407,12 @@ public class EditNoteActivity extends LinearLayout implements TimerActionListene
private static class NoteOrUpdate {
private final Spanned title;
private final String pictureThumb;
private final Bitmap commentBitmap;
private final long createdAt;
public NoteOrUpdate(Spanned title, String pictureThumb, Bitmap commentBitmap, long createdAt) {
public NoteOrUpdate(Spanned title, Bitmap commentBitmap, long createdAt) {
super();
this.title = title;
this.pictureThumb = pictureThumb;
this.commentBitmap = commentBitmap;
this.createdAt = createdAt;
}
@ -428,31 +426,21 @@ public class EditNoteActivity extends LinearLayout implements TimerActionListene
}
Spanned title = Html.fromHtml(String.format("%s\n%s", m.getValue(NoteMetadata.TITLE), m.getValue(NoteMetadata.BODY))); //$NON-NLS-1$
return new NoteOrUpdate(title,
m.getValue(NoteMetadata.COMMENT_PICTURE),
null,
m.getCreationDate());
}
public static NoteOrUpdate fromUpdate(UserActivity u) {
String pictureThumb;
Spanned title;
Bitmap commentBitmap = null;
long createdAt;
if(u == null) {
throw new RuntimeException("UserActivity should never be null");
}
pictureThumb = u.getPictureUrl(UserActivity.PICTURE, RemoteModel.PICTURE_MEDIUM);
if (TextUtils.isEmpty(pictureThumb)) {
commentBitmap = u.getPictureBitmap(UserActivity.PICTURE);
}
title = UpdateAdapter.getUpdateComment(u);
createdAt = u.getCreatedAt();
Bitmap commentBitmap = u.getPictureBitmap(UserActivity.PICTURE);
Spanned title = UpdateAdapter.getUpdateComment(u);
long createdAt = u.getCreatedAt();
return new NoteOrUpdate(
title,
pictureThumb,
commentBitmap,
createdAt);
}

@ -11,7 +11,6 @@ import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.graphics.drawable.BitmapDrawable;
import android.os.Bundle;
import android.text.TextUtils;
@ -86,9 +85,6 @@ public class TagFilterExposer extends InjectingBroadcastReceiver implements Astr
};
filter.customTaskList = new ComponentName(context, TagViewFragment.class);
if(tag.image != null) {
filter.imageUrl = tag.image;
}
Bundle extras = new Bundle();
extras.putString(TagViewFragment.EXTRA_TAG_NAME, tag.tag);
extras.putString(TagViewFragment.EXTRA_TAG_UUID, tag.uuid);

@ -83,13 +83,11 @@ public final class TagService {
public String tag;
public int count;
public String uuid;
public String image;
public Tag(TagData tagData) {
tag = tagData.getName();
count = tagData.getTaskCount();
uuid = tagData.getUUID();
image = tagData.getPictureUrl(TagData.PICTURE, RemoteModel.PICTURE_THUMB);
}
@Override

@ -211,7 +211,7 @@ public class WidgetHelper {
long id = preferences.getLong(WidgetConfigActivity.PREF_TAG_ID + widgetId, 0);
TagData tagData;
if (id > 0) {
tagData = tagDataService.fetchById(id, TagData.ID, TagData.NAME, TagData.TASK_COUNT, TagData.UUID, TagData.PICTURE, TagData.USER_ID, TagData.MEMBER_COUNT);
tagData = tagDataService.fetchById(id, TagData.ID, TagData.NAME, TagData.TASK_COUNT, TagData.UUID, TagData.USER_ID, TagData.MEMBER_COUNT);
if (tagData != null && !tagData.getName().equals(filter.title)) { // Tag has been renamed; rebuild filter
filter = TagFilterExposer.filterFromTagData(context, tagData);
preferences.setString(WidgetConfigActivity.PREF_SQL + widgetId, filter.getSqlQuery());

Loading…
Cancel
Save