Browse Source

BUG fixed: store file size with upload info to show correctly

David A. Velasco 9 years ago
parent
commit
d9bb808308

+ 2 - 0
src/com/owncloud/android/datamodel/UploadsStorageManager.java

@@ -106,6 +106,7 @@ public class UploadsStorageManager extends Observable {
         cv.put(ProviderTableMeta.UPLOADS_LOCAL_PATH, ocUpload.getLocalPath());
         cv.put(ProviderTableMeta.UPLOADS_REMOTE_PATH, ocUpload.getRemotePath());
         cv.put(ProviderTableMeta.UPLOADS_ACCOUNT_NAME, ocUpload.getAccountName());
+        cv.put(ProviderTableMeta.UPLOADS_FILE_SIZE, ocUpload.getFileSize());
         cv.put(ProviderTableMeta.UPLOADS_STATUS, ocUpload.getUploadStatus().value);
         cv.put(ProviderTableMeta.UPLOADS_LOCAL_BEHAVIOUR, ocUpload.getLocalAction());
         cv.put(ProviderTableMeta.UPLOADS_FORCE_OVERWRITE, ocUpload.isForceOverwrite() ? 1 : 0);
@@ -391,6 +392,7 @@ public class UploadsStorageManager extends Observable {
             String accountName = c.getString(c.getColumnIndex(ProviderTableMeta.UPLOADS_ACCOUNT_NAME));
             upload = new OCUpload(localPath, remotePath, accountName);
 
+            upload.setFileSize(c.getLong(c.getColumnIndex(ProviderTableMeta.UPLOADS_FILE_SIZE)));
             upload.setUploadId(c.getLong(c.getColumnIndex(ProviderTableMeta._ID)));
             upload.setUploadStatus(
                     UploadStatus.fromValue(c.getInt(c.getColumnIndex(ProviderTableMeta.UPLOADS_STATUS)))

+ 19 - 0
src/com/owncloud/android/db/OCUpload.java

@@ -66,6 +66,11 @@ public class OCUpload implements Parcelable {
      */
     private String mAccountName;
 
+    /**
+     * File size
+     */
+    private long mFileSize;
+
     /**
      * Local action for upload. (0 - COPY, 1 - MOVE, 2 - FORGET)
      */
@@ -149,6 +154,7 @@ public class OCUpload implements Parcelable {
         mRemotePath = "";
         mLocalPath = "";
         mAccountName = "";
+        mFileSize = -1;
         mId = -1;
         mLocalAction = FileUploader.LOCAL_BEHAVIOUR_COPY;
         mForceOverwrite = false;
@@ -224,6 +230,19 @@ public class OCUpload implements Parcelable {
         mRemotePath = remotePath;
     }
 
+
+    /**
+     * @return  File size
+     */
+    public long getFileSize() {
+        return mFileSize;
+    }
+
+    public void setFileSize(long fileSize) {
+        mFileSize = fileSize;
+    }
+
+
     /**
      * @return the mimeType
      */

+ 1 - 0
src/com/owncloud/android/db/ProviderMeta.java

@@ -139,6 +139,7 @@ public class ProviderMeta {
         public static final String UPLOADS_LOCAL_PATH = "local_path";
         public static final String UPLOADS_REMOTE_PATH = "remote_path";
         public static final String UPLOADS_ACCOUNT_NAME = "account_name";
+        public static final String UPLOADS_FILE_SIZE = "file_size";
         public static final String UPLOADS_STATUS = "status";
         public static final String UPLOADS_LOCAL_BEHAVIOUR = "local_behaviour";
         public static final String UPLOADS_UPLOAD_TIME = "upload_time";

+ 1 - 0
src/com/owncloud/android/files/services/FileUploader.java

@@ -453,6 +453,7 @@ public class FileUploader extends Service
 
                     // Save upload in database
                     OCUpload ocUpload = new OCUpload(files[i], account);
+                    ocUpload.setFileSize(files[i].getFileLength());
                     ocUpload.setForceOverwrite(forceOverwrite);
                     ocUpload.setCreateRemoteFolder(isCreateRemoteFolder);
                     ocUpload.setCreatedBy(createdBy);

+ 1 - 0
src/com/owncloud/android/providers/FileContentProvider.java

@@ -847,6 +847,7 @@ public class FileContentProvider extends ContentProvider {
                 + ProviderTableMeta.UPLOADS_LOCAL_PATH + " TEXT, "
                 + ProviderTableMeta.UPLOADS_REMOTE_PATH + " TEXT, "
                 + ProviderTableMeta.UPLOADS_ACCOUNT_NAME + " TEXT, "
+                + ProviderTableMeta.UPLOADS_FILE_SIZE + " LONG, "
                 + ProviderTableMeta.UPLOADS_STATUS + " INTEGER, "               // UploadStatus
                 + ProviderTableMeta.UPLOADS_LOCAL_BEHAVIOUR + " INTEGER, "      // Upload LocalBehaviour
                 + ProviderTableMeta.UPLOADS_UPLOAD_TIME + " INTEGER, "

+ 1 - 1
src/com/owncloud/android/ui/adapter/ExpandableUploadListAdapter.java

@@ -229,7 +229,7 @@ public class ExpandableUploadListAdapter extends BaseExpandableListAdapter imple
 
             // file size
             TextView fileSizeTextView = (TextView) view.findViewById(R.id.upload_file_size);
-            fileSizeTextView.setText(DisplayUtils.bytesToHumanReadable(remoteFile.length()) + ", ");
+            fileSizeTextView.setText(DisplayUtils.bytesToHumanReadable(upload.getFileSize()) + ", ");
 
             //* upload date
             TextView uploadDateTextView = (TextView) view.findViewById(R.id.upload_date);