Skip to content

Commit 6936da1

Browse files
committed
Revert "Merge pull request #1799 from wordpress-mobile/feature/1795-reader-render-attachments"
This reverts commit 0c5bd2d, reversing changes made to 083a272.
1 parent 0c5bd2d commit 6936da1

File tree

17 files changed

+315
-676
lines changed

17 files changed

+315
-676
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../res/drawable-xhdpi/ic_reader_video_overlay.png

WordPress/src/main/java/org/wordpress/android/datasets/ReaderDatabase.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
*/
2020
public class ReaderDatabase extends SQLiteOpenHelper {
2121
protected static final String DB_NAME = "wpreader.db";
22-
private static final int DB_VERSION = 85;
22+
private static final int DB_VERSION = 83;
2323

2424
/*
2525
* version history
@@ -40,8 +40,6 @@ public class ReaderDatabase extends SQLiteOpenHelper {
4040
* 81 - added image_url to tbl_blog_info
4141
* 82 - added idx_posts_timestamp to tbl_posts
4242
* 83 - removed tag_list from tbl_posts
43-
* 84 - added tbl_attachments
44-
* 85 - removed tbl_attachments, added attachments_json to tbl_posts
4543
*/
4644

4745
/*

WordPress/src/main/java/org/wordpress/android/datasets/ReaderPostTable.java

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ public class ReaderPostTable {
4747
+ "primary_tag," // 26
4848
+ "secondary_tag," // 27
4949
+ "is_likes_enabled," // 28
50-
+ "is_sharing_enabled," // 29
51-
+ "attachments_json"; // 30
50+
+ "is_sharing_enabled"; // 29
5251

5352

5453
protected static void createTables(SQLiteDatabase db) {
@@ -82,7 +81,6 @@ protected static void createTables(SQLiteDatabase db) {
8281
+ " secondary_tag TEXT,"
8382
+ " is_likes_enabled INTEGER DEFAULT 0,"
8483
+ " is_sharing_enabled INTEGER DEFAULT 0,"
85-
+ " attachments_json TEXT,"
8684
+ " PRIMARY KEY (post_id, blog_id)"
8785
+ ")");
8886
db.execSQL("CREATE INDEX idx_posts_timestamp ON tbl_posts(timestamp)");
@@ -375,7 +373,7 @@ public static void addOrUpdatePosts(final ReaderTag tag, ReaderPostList posts) {
375373
SQLiteStatement stmtPosts = db.compileStatement(
376374
"INSERT OR REPLACE INTO tbl_posts ("
377375
+ COLUMN_NAMES
378-
+ ") 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)");
376+
+ ") 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)");
379377
SQLiteStatement stmtTags = db.compileStatement(
380378
"INSERT OR REPLACE INTO tbl_post_tags (post_id, blog_id, pseudo_id, tag_name, tag_type) VALUES (?1,?2,?3,?4,?5)");
381379

@@ -412,7 +410,6 @@ public static void addOrUpdatePosts(final ReaderTag tag, ReaderPostList posts) {
412410
stmtPosts.bindString(27, post.getSecondaryTag());
413411
stmtPosts.bindLong (28, SqlUtils.boolToSql(post.isLikesEnabled));
414412
stmtPosts.bindLong (29, SqlUtils.boolToSql(post.isSharingEnabled));
415-
stmtPosts.bindString(30, post.getAttachmentsJson());
416413
stmtPosts.execute();
417414
}
418415

@@ -563,8 +560,6 @@ private static class PostColumnIndexes {
563560
private final int idx_is_likes_enabled;
564561
private final int idx_is_sharing_enabled;
565562

566-
private final int idx_attachments_json;
567-
568563
private PostColumnIndexes(Cursor c) {
569564
if (c == null)
570565
throw new IllegalArgumentException("PostColumnIndexes > null cursor");
@@ -605,8 +600,6 @@ private PostColumnIndexes(Cursor c) {
605600

606601
idx_is_likes_enabled = c.getColumnIndex("is_likes_enabled");
607602
idx_is_sharing_enabled = c.getColumnIndex("is_sharing_enabled");
608-
609-
idx_attachments_json = c.getColumnIndex("attachments_json");
610603
}
611604
}
612605

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

662-
post.setAttachmentsJson(c.getString(cols.idx_attachments_json));
663-
664655
return post;
665656
}
666657
}

WordPress/src/main/java/org/wordpress/android/models/ReaderPost.java

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@ public class ReaderPost {
5252
public boolean isLikesEnabled;
5353
public boolean isSharingEnabled; // currently unused
5454

55-
private String attachmentsJson;
56-
5755
public static ReaderPost fromJson(JSONObject json) {
5856
if (json == null) {
5957
throw new IllegalArgumentException("null json post");
@@ -157,12 +155,6 @@ public static ReaderPost fromJson(JSONObject json) {
157155
// parse the tags section
158156
assignTagsFromJson(post, json.optJSONObject("tags"));
159157

160-
// parse the attachments
161-
JSONObject jsonAttachments = json.optJSONObject("attachments");
162-
if (jsonAttachments != null) {
163-
post.attachmentsJson = jsonAttachments.toString();
164-
}
165-
166158
// the single-post sites/$site/posts/$post endpoint returns all site metadata
167159
// under meta/data/site (assuming ?meta=site was added to the request)
168160
JSONObject jsonSite = JSONUtil.getJSONChild(json, "meta/data/site");
@@ -351,6 +343,8 @@ public void setPublished(String published) {
351343
this.published = StringUtils.notNullStr(published);
352344
}
353345

346+
// --------------------------------------------------------------------------------------------
347+
354348
public String getPrimaryTag() {
355349
return StringUtils.notNullStr(primaryTag);
356350
}
@@ -374,17 +368,7 @@ public void setSecondaryTag(String tagName) {
374368
}
375369
}
376370

377-
/*
378-
* attachments are stored as the actual JSON to avoid having a separate table for
379-
* them, may need to revisit this if/when attachments become more important
380-
*/
381-
public String getAttachmentsJson() {
382-
return StringUtils.notNullStr(attachmentsJson);
383-
}
384-
public void setAttachmentsJson(String json) {
385-
attachmentsJson = StringUtils.notNullStr(json);
386-
}
387-
371+
// --------------------------------------------------------------------------------------------
388372

389373
public boolean hasText() {
390374
return !TextUtils.isEmpty(text);
@@ -450,8 +434,12 @@ public String getFeaturedImageForDisplay(int width, int height) {
450434
if (featuredImageForDisplay == null) {
451435
if (!hasFeaturedImage()) {
452436
featuredImageForDisplay = "";
437+
} else if (isPrivate) {
438+
// images in private posts can't use photon, so handle separately
439+
featuredImageForDisplay = ReaderUtils.getPrivateImageForDisplay(featuredImage, width, height);
453440
} else {
454-
featuredImageForDisplay = ReaderUtils.getResizedImageUrl(featuredImage, width, height, isPrivate);
441+
// not private, so set to correctly sized photon url
442+
featuredImageForDisplay = PhotonUtils.getPhotonImageUrl(featuredImage, width, height);
455443
}
456444
}
457445
return featuredImageForDisplay;

WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPhotoView.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import org.wordpress.android.ui.reader.utils.ReaderUtils;
2222
import org.wordpress.android.util.AppLog;
2323
import org.wordpress.android.util.DisplayUtils;
24+
import org.wordpress.android.util.PhotonUtils;
2425

2526
import uk.co.senab.photoview.PhotoViewAttacher;
2627

@@ -76,8 +77,13 @@ public void setImageUrl(String imageUrl,
7677
boolean isPrivate,
7778
PhotoViewListener listener) {
7879
int loResWidth = (int) (hiResWidth * 0.10f);
79-
mLoResImageUrl = ReaderUtils.getResizedImageUrl(imageUrl, loResWidth, 0, isPrivate);
80-
mHiResImageUrl = ReaderUtils.getResizedImageUrl(imageUrl, hiResWidth, 0, isPrivate);
80+
if (isPrivate) {
81+
mLoResImageUrl = ReaderUtils.getPrivateImageForDisplay(imageUrl, loResWidth, 0);
82+
mHiResImageUrl = ReaderUtils.getPrivateImageForDisplay(imageUrl, hiResWidth, 0);
83+
} else {
84+
mLoResImageUrl = PhotonUtils.getPhotonImageUrl(imageUrl, loResWidth, 0);
85+
mHiResImageUrl = PhotonUtils.getPhotonImageUrl(imageUrl, hiResWidth, 0);
86+
}
8187

8288
mPhotoViewListener = listener;
8389
loadLoResImage();

WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPhotoViewerActivity.java

Lines changed: 19 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
import org.wordpress.android.ui.reader.ReaderViewPagerTransformer.TransformType;
1717
import org.wordpress.android.ui.reader.models.ReaderImageList;
1818
import org.wordpress.android.ui.reader.utils.ReaderImageScanner;
19-
import org.wordpress.android.util.AppLog;
2019

2120
import javax.annotation.Nonnull;
2221

@@ -69,35 +68,26 @@ public void onPageSelected(int position) {
6968
}
7069

7170
private void loadImageList() {
72-
// content will be empty unless this was called by ReaderPostDetailFragment to show
73-
// a list of images in a post (in which case, it's the content of the post)
74-
if (TextUtils.isEmpty(mContent)) {
75-
final ReaderImageList imageList = new ReaderImageList(mIsPrivate);
76-
if (!TextUtils.isEmpty(mInitialImageUrl)) {
77-
imageList.add(mInitialImageUrl);
78-
}
79-
setImageList(imageList, mInitialImageUrl);
80-
} else {
81-
// parse images from content and make sure the list includes the passed url
82-
new Thread() {
83-
@Override
84-
public void run() {
85-
final ReaderImageList imageList = new ReaderImageScanner(mContent, mIsPrivate).getImageList();
86-
if (!TextUtils.isEmpty(mInitialImageUrl) && !imageList.hasImageUrl(mInitialImageUrl)) {
87-
AppLog.w(AppLog.T.READER, "reader photo viewer > initial image not in list");
88-
imageList.addImageUrl(0, mInitialImageUrl);
89-
}
90-
runOnUiThread(new Runnable() {
91-
@Override
92-
public void run() {
93-
if (!isFinishing()) {
94-
setImageList(imageList, mInitialImageUrl);
95-
}
96-
}
97-
});
71+
new Thread() {
72+
@Override
73+
public void run() {
74+
// parse list of images from content that was (optionally) passed to
75+
// this activity, and make sure the list includes the passed url
76+
ReaderImageScanner scanner = new ReaderImageScanner(mContent, mIsPrivate);
77+
final ReaderImageList imageList = scanner.getImageList();
78+
if (!TextUtils.isEmpty(mInitialImageUrl) && !imageList.hasImageUrl(mInitialImageUrl)) {
79+
imageList.addImageUrl(0, mInitialImageUrl);
9880
}
99-
}.start();
100-
}
81+
runOnUiThread(new Runnable() {
82+
@Override
83+
public void run() {
84+
if (!isFinishing()) {
85+
setImageList(imageList, mInitialImageUrl);
86+
}
87+
}
88+
});
89+
}
90+
}.start();
10191
}
10292

10393
private void setImageList(ReaderImageList imageList, String initialImageUrl) {

0 commit comments

Comments
 (0)