Skip to content

Commit 93fb670

Browse files
authored
CMM-761: add filesize to the media screen (wp.com sites) (#22220)
* Creating the field in MediaModel * Filling the field in rs requests * Adding the field to the db * Adding field to the UI * Minor refactor * Adding new field for formatted tests * Showing the new field * Skipping the parameter for other instances * Chanigng the model creation approach * Field fix * typo
1 parent 3e7e021 commit 93fb670

File tree

5 files changed

+21
-2
lines changed

5 files changed

+21
-2
lines changed

WordPress/src/main/java/org/wordpress/android/ui/media/MediaSettingsActivity.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -660,6 +660,10 @@ private void showMetaData() {
660660
mFileSizeView.setText(formattedSize);
661661
findViewById(R.id.layout_file_size).setVisibility(View.VISIBLE);
662662
findViewById(R.id.divider_file_size).setVisibility(View.VISIBLE);
663+
} else if (mMedia.getFileSizeFormatted() != null) {
664+
mFileSizeView.setText(mMedia.getFileSizeFormatted());
665+
findViewById(R.id.layout_file_size).setVisibility(View.VISIBLE);
666+
findViewById(R.id.divider_file_size).setVisibility(View.VISIBLE);
663667
} else {
664668
findViewById(R.id.layout_file_size).setVisibility(View.GONE);
665669
findViewById(R.id.divider_file_size).setVisibility(View.GONE);

libs/fluxc/src/main/java/org/wordpress/android/fluxc/model/MediaModel.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ public static MediaUploadState fromString(@Nullable String stringState) {
5959
@Nullable @Column private String mFileExtension;
6060
@Nullable @Column private String mMimeType;
6161
@Column private long mFileSize;
62+
@Nullable @Column private String mFileSizeFormatted;
6263

6364
// Descriptive strings
6465
@Nullable @Column private String mTitle;
@@ -143,6 +144,7 @@ public MediaModel() {
143144
this.mFileExtension = null;
144145
this.mMimeType = null;
145146
this.mFileSize = 0;
147+
this.mFileSizeFormatted = null;
146148
this.mTitle = null;
147149
this.mCaption = "";
148150
this.mDescription = "";
@@ -489,6 +491,15 @@ public long getFileSize() {
489491
return mFileSize;
490492
}
491493

494+
public void setFileSizeFormatted(@Nullable String fileSizeFormatted) {
495+
mFileSizeFormatted = fileSizeFormatted;
496+
}
497+
498+
@Nullable
499+
public String getFileSizeFormatted() {
500+
return mFileSizeFormatted;
501+
}
502+
492503
public void setTitle(@Nullable String title) {
493504
mTitle = title;
494505
}

libs/fluxc/src/main/java/org/wordpress/android/fluxc/network/rest/wpcom/media/MediaResponseUtils.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ class MediaResponseUtils
5959
from.thumbnails?.let { if (!TextUtils.isEmpty(it.medium)) it.medium else null },
6060
null,
6161
from.thumbnails?.let { if (!TextUtils.isEmpty(it.large)) it.large else null },
62-
MediaWPComRestResponse.DELETED_STATUS == from.status
63-
)
62+
MediaWPComRestResponse.DELETED_STATUS == from.status,
63+
).apply {
64+
fileSizeFormatted = from.size
65+
}
6466
}

libs/fluxc/src/main/java/org/wordpress/android/fluxc/network/rest/wpcom/media/MediaWPComRestResponse.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,5 @@ public static class Thumbnails {
4747
@Nullable public String videopress_guid;
4848
public boolean videopress_processing_done;
4949
@Nullable public String status;
50+
@Nullable public String size;
5051
}

libs/fluxc/src/main/java/org/wordpress/android/fluxc/persistence/WellSqlConfig.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2083,6 +2083,7 @@ open class WellSqlConfig : DefaultWellConfig {
20832083

20842084
209 -> {
20852085
db.execSQL("ALTER TABLE MediaModel ADD FILE_SIZE INTEGER")
2086+
db.execSQL("ALTER TABLE MediaModel ADD FILE_SIZE_FORMATTED TEXT")
20862087
}
20872088
}
20882089
}

0 commit comments

Comments
 (0)