diff --git a/WordPress/src/main/java/org/wordpress/android/ui/media/MediaSettingsActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/media/MediaSettingsActivity.java
index 41281ae6a94b..f028df1f8d15 100644
--- a/WordPress/src/main/java/org/wordpress/android/ui/media/MediaSettingsActivity.java
+++ b/WordPress/src/main/java/org/wordpress/android/ui/media/MediaSettingsActivity.java
@@ -95,6 +95,7 @@
import org.wordpress.android.util.ToastUtils;
import org.wordpress.android.util.WPMediaUtils;
import org.wordpress.android.util.WPPermissionUtils;
+import org.wordpress.android.util.FormatUtils;
import org.wordpress.android.util.extensions.CompatExtensionsKt;
import org.wordpress.android.util.extensions.ContextExtensionsKt;
import org.wordpress.android.util.extensions.ViewExtensionsKt;
@@ -144,6 +145,8 @@ public class MediaSettingsActivity extends BaseAppCompatActivity
private SeekBar mImageSizeSeekBarView;
private Spinner mAlignmentSpinnerView;
private FloatingActionButton mFabView;
+ private TextView mFileSizeView;
+ private TextView mFileSizeLabelView;
private AlertDialog mDeleteMediaConfirmationDialog;
@@ -256,6 +259,8 @@ public void handleOnBackPressed() {
mImageSizeSeekBarView = findViewById(R.id.image_size_seekbar);
mAlignmentSpinnerView = findViewById(org.wordpress.android.editor.R.id.alignment_spinner);
mFabView = findViewById(R.id.fab_button);
+ mFileSizeView = findViewById(R.id.text_file_size);
+ mFileSizeLabelView = findViewById(R.id.text_file_size_label);
int mediaId;
if (savedInstanceState != null) {
@@ -642,6 +647,24 @@ private void showMetaData() {
TextView txtFileType = findViewById(R.id.text_filetype);
txtFileType.setText(StringUtils.notNullStr(mMedia.getFileExtension()).toUpperCase(Locale.ROOT));
+ // Display file size if available
+ if (mMedia.getFileSize() > 0) {
+ final String[] units = new String[] {
+ getString(R.string.file_size_in_bytes),
+ getString(R.string.file_size_in_kilobytes),
+ getString(R.string.file_size_in_megabytes),
+ getString(R.string.file_size_in_gigabytes),
+ getString(R.string.file_size_in_terabytes)
+ };
+ String formattedSize = FormatUtils.formatFileSize(mMedia.getFileSize(), units);
+ mFileSizeView.setText(formattedSize);
+ findViewById(R.id.layout_file_size).setVisibility(View.VISIBLE);
+ findViewById(R.id.divider_file_size).setVisibility(View.VISIBLE);
+ } else {
+ findViewById(R.id.layout_file_size).setVisibility(View.GONE);
+ findViewById(R.id.divider_file_size).setVisibility(View.GONE);
+ }
+
showImageDimensions(mMedia.getWidth(), mMedia.getHeight());
String uploadDate = null;
diff --git a/WordPress/src/main/res/layout/media_settings_activity.xml b/WordPress/src/main/res/layout/media_settings_activity.xml
index 1c5662959a26..895b73008396 100644
--- a/WordPress/src/main/res/layout/media_settings_activity.xml
+++ b/WordPress/src/main/res/layout/media_settings_activity.xml
@@ -413,6 +413,36 @@
android:layout_width="match_parent"
android:layout_height="1dp" />
+
+
+
+
+
+
+
+
+
+
URL
File Name
File Type
+ File Size
Image Dimensions
Video Dimensions
Duration
@@ -728,7 +729,7 @@
%s B
- %s kB
+ %s KB
%s MB
%s GB
%s TB
diff --git a/libs/fluxc/src/main/java/org/wordpress/android/fluxc/model/MediaModel.java b/libs/fluxc/src/main/java/org/wordpress/android/fluxc/model/MediaModel.java
index 53ae7e3092d0..e7e2e33a62c3 100644
--- a/libs/fluxc/src/main/java/org/wordpress/android/fluxc/model/MediaModel.java
+++ b/libs/fluxc/src/main/java/org/wordpress/android/fluxc/model/MediaModel.java
@@ -58,6 +58,7 @@ public static MediaUploadState fromString(@Nullable String stringState) {
@Nullable @Column private String mFilePath;
@Nullable @Column private String mFileExtension;
@Nullable @Column private String mMimeType;
+ @Column private long mFileSize;
// Descriptive strings
@Nullable @Column private String mTitle;
@@ -141,6 +142,7 @@ public MediaModel() {
this.mFilePath = null;
this.mFileExtension = null;
this.mMimeType = null;
+ this.mFileSize = 0;
this.mTitle = null;
this.mCaption = "";
this.mDescription = "";
@@ -331,6 +333,7 @@ && getLocalSiteId() == otherMedia.getLocalSiteId() && getLocalPostId() == otherM
&& getMediaId() == otherMedia.getMediaId() && getPostId() == otherMedia.getPostId()
&& getAuthorId() == otherMedia.getAuthorId() && getWidth() == otherMedia.getWidth()
&& getHeight() == otherMedia.getHeight() && getLength() == otherMedia.getLength()
+ && getFileSize() == otherMedia.getFileSize()
&& getHorizontalAlignment() == otherMedia.getHorizontalAlignment()
&& getVerticalAlignment() == otherMedia.getVerticalAlignment()
&& getVideoPressProcessingDone() == otherMedia.getVideoPressProcessingDone()
@@ -478,6 +481,14 @@ public String getMimeType() {
return mMimeType;
}
+ public void setFileSize(long fileSize) {
+ mFileSize = fileSize;
+ }
+
+ public long getFileSize() {
+ return mFileSize;
+ }
+
public void setTitle(@Nullable String title) {
mTitle = title;
}
diff --git a/libs/fluxc/src/main/java/org/wordpress/android/fluxc/network/rest/wpapi/media/MediaRSApiRestClient.kt b/libs/fluxc/src/main/java/org/wordpress/android/fluxc/network/rest/wpapi/media/MediaRSApiRestClient.kt
index d09322287c6f..568679c0c3e5 100644
--- a/libs/fluxc/src/main/java/org/wordpress/android/fluxc/network/rest/wpapi/media/MediaRSApiRestClient.kt
+++ b/libs/fluxc/src/main/java/org/wordpress/android/fluxc/network/rest/wpapi/media/MediaRSApiRestClient.kt
@@ -417,7 +417,10 @@ class MediaRSApiRestClient @Inject constructor(
// Parse the media details
when (val parsedType = this@toMediaModel.mediaDetails.parseAsMimeType(this@toMediaModel.mimeType)) {
- is MediaDetailsPayload.Audio -> length = parsedType.v1.length.toInt()
+ is MediaDetailsPayload.Audio -> {
+ length = parsedType.v1.length.toInt()
+ fileSize = parsedType.v1.fileSize.toLong()
+ }
is MediaDetailsPayload.Image -> {
fileName = parseFileNameFromPath(parsedType.v1.file)
width = parsedType.v1.width.toInt()
@@ -425,13 +428,15 @@ class MediaRSApiRestClient @Inject constructor(
thumbnailUrl = parsedType.v1.sizes?.get("thumbnail")?.sourceUrl
fileUrlMediumSize = parsedType.v1.sizes?.get("medium")?.sourceUrl
fileUrlLargeSize = parsedType.v1.sizes?.get("large")?.sourceUrl
+ fileSize = parsedType.v1.fileSize.toLong()
}
is MediaDetailsPayload.Video -> {
width = parsedType.v1.width.toInt()
height = parsedType.v1.height.toInt()
length = parsedType.v1.length.toInt()
+ fileSize = parsedType.v1.fileSize.toLong()
}
- is MediaDetailsPayload.Document,
+ is MediaDetailsPayload.Document -> fileSize = parsedType.v1.fileSize.toLong()
null -> {}
}
diff --git a/libs/fluxc/src/main/java/org/wordpress/android/fluxc/persistence/WellSqlConfig.kt b/libs/fluxc/src/main/java/org/wordpress/android/fluxc/persistence/WellSqlConfig.kt
index b996138fb687..476f6882e38f 100644
--- a/libs/fluxc/src/main/java/org/wordpress/android/fluxc/persistence/WellSqlConfig.kt
+++ b/libs/fluxc/src/main/java/org/wordpress/android/fluxc/persistence/WellSqlConfig.kt
@@ -41,7 +41,7 @@ open class WellSqlConfig : DefaultWellConfig {
annotation class AddOn
override fun getDbVersion(): Int {
- return 209
+ return 210
}
override fun getDbName(): String {
@@ -2080,6 +2080,10 @@ open class WellSqlConfig : DefaultWellConfig {
208 -> {
db.execSQL("DROP TABLE IF EXISTS EncryptedLogModel")
}
+
+ 209 -> {
+ db.execSQL("ALTER TABLE MediaModel ADD FILE_SIZE INTEGER")
+ }
}
}
db.setTransactionSuccessful()