Skip to content

Commit

Permalink
Revert "Merge pull request #1799 from wordpress-mobile/feature/1795-r…
Browse files Browse the repository at this point in the history
…eader-render-attachments"

This reverts commit 0c5bd2d, reversing
changes made to 083a272.
  • Loading branch information
roundhill committed Sep 3, 2014
1 parent 0c5bd2d commit 6936da1
Show file tree
Hide file tree
Showing 17 changed files with 315 additions and 676 deletions.
1 change: 1 addition & 0 deletions WordPress/src/main/assets/ic_reader_video_overlay.png
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
*/
public class ReaderDatabase extends SQLiteOpenHelper {
protected static final String DB_NAME = "wpreader.db";
private static final int DB_VERSION = 85;
private static final int DB_VERSION = 83;

/*
* version history
Expand All @@ -40,8 +40,6 @@ public class ReaderDatabase extends SQLiteOpenHelper {
* 81 - added image_url to tbl_blog_info
* 82 - added idx_posts_timestamp to tbl_posts
* 83 - removed tag_list from tbl_posts
* 84 - added tbl_attachments
* 85 - removed tbl_attachments, added attachments_json to tbl_posts
*/

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ public class ReaderPostTable {
+ "primary_tag," // 26
+ "secondary_tag," // 27
+ "is_likes_enabled," // 28
+ "is_sharing_enabled," // 29
+ "attachments_json"; // 30
+ "is_sharing_enabled"; // 29


protected static void createTables(SQLiteDatabase db) {
Expand Down Expand Up @@ -82,7 +81,6 @@ protected static void createTables(SQLiteDatabase db) {
+ " secondary_tag TEXT,"
+ " is_likes_enabled INTEGER DEFAULT 0,"
+ " is_sharing_enabled INTEGER DEFAULT 0,"
+ " attachments_json TEXT,"
+ " PRIMARY KEY (post_id, blog_id)"
+ ")");
db.execSQL("CREATE INDEX idx_posts_timestamp ON tbl_posts(timestamp)");
Expand Down Expand Up @@ -375,7 +373,7 @@ public static void addOrUpdatePosts(final ReaderTag tag, ReaderPostList posts) {
SQLiteStatement stmtPosts = db.compileStatement(
"INSERT OR REPLACE INTO tbl_posts ("
+ COLUMN_NAMES
+ ") VALUES (?1,?2,?3,?4,?5,?6,?7,?8,?9,?10,?11,?12,?13,?14,?15,?16,?17,?18,?19,?20,?21,?22,?23,?24,?25,?26,?27,?28,?29,?30)");
+ ") VALUES (?1,?2,?3,?4,?5,?6,?7,?8,?9,?10,?11,?12,?13,?14,?15,?16,?17,?18,?19,?20,?21,?22,?23,?24,?25,?26,?27,?28,?29)");
SQLiteStatement stmtTags = db.compileStatement(
"INSERT OR REPLACE INTO tbl_post_tags (post_id, blog_id, pseudo_id, tag_name, tag_type) VALUES (?1,?2,?3,?4,?5)");

Expand Down Expand Up @@ -412,7 +410,6 @@ public static void addOrUpdatePosts(final ReaderTag tag, ReaderPostList posts) {
stmtPosts.bindString(27, post.getSecondaryTag());
stmtPosts.bindLong (28, SqlUtils.boolToSql(post.isLikesEnabled));
stmtPosts.bindLong (29, SqlUtils.boolToSql(post.isSharingEnabled));
stmtPosts.bindString(30, post.getAttachmentsJson());
stmtPosts.execute();
}

Expand Down Expand Up @@ -563,8 +560,6 @@ private static class PostColumnIndexes {
private final int idx_is_likes_enabled;
private final int idx_is_sharing_enabled;

private final int idx_attachments_json;

private PostColumnIndexes(Cursor c) {
if (c == null)
throw new IllegalArgumentException("PostColumnIndexes > null cursor");
Expand Down Expand Up @@ -605,8 +600,6 @@ private PostColumnIndexes(Cursor c) {

idx_is_likes_enabled = c.getColumnIndex("is_likes_enabled");
idx_is_sharing_enabled = c.getColumnIndex("is_sharing_enabled");

idx_attachments_json = c.getColumnIndex("attachments_json");
}
}

Expand Down Expand Up @@ -659,8 +652,6 @@ private static ReaderPost getPostFromCursor(Cursor c, PostColumnIndexes cols) {
post.isLikesEnabled = SqlUtils.sqlToBool(c.getInt(cols.idx_is_likes_enabled));
post.isSharingEnabled = SqlUtils.sqlToBool(c.getInt(cols.idx_is_sharing_enabled));

post.setAttachmentsJson(c.getString(cols.idx_attachments_json));

return post;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ public class ReaderPost {
public boolean isLikesEnabled;
public boolean isSharingEnabled; // currently unused

private String attachmentsJson;

public static ReaderPost fromJson(JSONObject json) {
if (json == null) {
throw new IllegalArgumentException("null json post");
Expand Down Expand Up @@ -157,12 +155,6 @@ public static ReaderPost fromJson(JSONObject json) {
// parse the tags section
assignTagsFromJson(post, json.optJSONObject("tags"));

// parse the attachments
JSONObject jsonAttachments = json.optJSONObject("attachments");
if (jsonAttachments != null) {
post.attachmentsJson = jsonAttachments.toString();
}

// the single-post sites/$site/posts/$post endpoint returns all site metadata
// under meta/data/site (assuming ?meta=site was added to the request)
JSONObject jsonSite = JSONUtil.getJSONChild(json, "meta/data/site");
Expand Down Expand Up @@ -351,6 +343,8 @@ public void setPublished(String published) {
this.published = StringUtils.notNullStr(published);
}

// --------------------------------------------------------------------------------------------

public String getPrimaryTag() {
return StringUtils.notNullStr(primaryTag);
}
Expand All @@ -374,17 +368,7 @@ public void setSecondaryTag(String tagName) {
}
}

/*
* attachments are stored as the actual JSON to avoid having a separate table for
* them, may need to revisit this if/when attachments become more important
*/
public String getAttachmentsJson() {
return StringUtils.notNullStr(attachmentsJson);
}
public void setAttachmentsJson(String json) {
attachmentsJson = StringUtils.notNullStr(json);
}

// --------------------------------------------------------------------------------------------

public boolean hasText() {
return !TextUtils.isEmpty(text);
Expand Down Expand Up @@ -450,8 +434,12 @@ public String getFeaturedImageForDisplay(int width, int height) {
if (featuredImageForDisplay == null) {
if (!hasFeaturedImage()) {
featuredImageForDisplay = "";
} else if (isPrivate) {
// images in private posts can't use photon, so handle separately
featuredImageForDisplay = ReaderUtils.getPrivateImageForDisplay(featuredImage, width, height);
} else {
featuredImageForDisplay = ReaderUtils.getResizedImageUrl(featuredImage, width, height, isPrivate);
// not private, so set to correctly sized photon url
featuredImageForDisplay = PhotonUtils.getPhotonImageUrl(featuredImage, width, height);
}
}
return featuredImageForDisplay;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.wordpress.android.ui.reader.utils.ReaderUtils;
import org.wordpress.android.util.AppLog;
import org.wordpress.android.util.DisplayUtils;
import org.wordpress.android.util.PhotonUtils;

import uk.co.senab.photoview.PhotoViewAttacher;

Expand Down Expand Up @@ -76,8 +77,13 @@ public void setImageUrl(String imageUrl,
boolean isPrivate,
PhotoViewListener listener) {
int loResWidth = (int) (hiResWidth * 0.10f);
mLoResImageUrl = ReaderUtils.getResizedImageUrl(imageUrl, loResWidth, 0, isPrivate);
mHiResImageUrl = ReaderUtils.getResizedImageUrl(imageUrl, hiResWidth, 0, isPrivate);
if (isPrivate) {
mLoResImageUrl = ReaderUtils.getPrivateImageForDisplay(imageUrl, loResWidth, 0);
mHiResImageUrl = ReaderUtils.getPrivateImageForDisplay(imageUrl, hiResWidth, 0);
} else {
mLoResImageUrl = PhotonUtils.getPhotonImageUrl(imageUrl, loResWidth, 0);
mHiResImageUrl = PhotonUtils.getPhotonImageUrl(imageUrl, hiResWidth, 0);
}

mPhotoViewListener = listener;
loadLoResImage();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import org.wordpress.android.ui.reader.ReaderViewPagerTransformer.TransformType;
import org.wordpress.android.ui.reader.models.ReaderImageList;
import org.wordpress.android.ui.reader.utils.ReaderImageScanner;
import org.wordpress.android.util.AppLog;

import javax.annotation.Nonnull;

Expand Down Expand Up @@ -69,35 +68,26 @@ public void onPageSelected(int position) {
}

private void loadImageList() {
// content will be empty unless this was called by ReaderPostDetailFragment to show
// a list of images in a post (in which case, it's the content of the post)
if (TextUtils.isEmpty(mContent)) {
final ReaderImageList imageList = new ReaderImageList(mIsPrivate);
if (!TextUtils.isEmpty(mInitialImageUrl)) {
imageList.add(mInitialImageUrl);
}
setImageList(imageList, mInitialImageUrl);
} else {
// parse images from content and make sure the list includes the passed url
new Thread() {
@Override
public void run() {
final ReaderImageList imageList = new ReaderImageScanner(mContent, mIsPrivate).getImageList();
if (!TextUtils.isEmpty(mInitialImageUrl) && !imageList.hasImageUrl(mInitialImageUrl)) {
AppLog.w(AppLog.T.READER, "reader photo viewer > initial image not in list");
imageList.addImageUrl(0, mInitialImageUrl);
}
runOnUiThread(new Runnable() {
@Override
public void run() {
if (!isFinishing()) {
setImageList(imageList, mInitialImageUrl);
}
}
});
new Thread() {
@Override
public void run() {
// parse list of images from content that was (optionally) passed to
// this activity, and make sure the list includes the passed url
ReaderImageScanner scanner = new ReaderImageScanner(mContent, mIsPrivate);
final ReaderImageList imageList = scanner.getImageList();
if (!TextUtils.isEmpty(mInitialImageUrl) && !imageList.hasImageUrl(mInitialImageUrl)) {
imageList.addImageUrl(0, mInitialImageUrl);
}
}.start();
}
runOnUiThread(new Runnable() {
@Override
public void run() {
if (!isFinishing()) {
setImageList(imageList, mInitialImageUrl);
}
}
});
}
}.start();
}

private void setImageList(ReaderImageList imageList, String initialImageUrl) {
Expand Down
Loading

0 comments on commit 6936da1

Please sign in to comment.