Browse Source

git added filesize
improving status messages

Luke Owncloud 10 years ago
parent
commit
0ff6921665

+ 0 - 1
res/layout/upload_list_group.xml

@@ -17,7 +17,6 @@
         android:id="@+id/uploadListGroupName"
         android:layout_width="fill_parent"
         android:layout_height="25dip"
-        android:gravity="center_vertical|end"
         android:paddingLeft="5dip"
         android:paddingRight="5dip"
         android:textColor="#ffffffff"

+ 30 - 1
res/layout/upload_list_item.xml

@@ -58,6 +58,35 @@
             android:textColor="#303030"
             android:textSize="16dip" />
 
+        
+        <LinearLayout
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_marginLeft="4dp"
+            android:layout_marginRight="4dp"
+            android:weightSum="1">
+
+            <TextView
+                android:id="@+id/upload_local_path"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:text="TextView"
+                android:layout_weight=".5"
+                android:textColor="@color/list_item_lastmod_and_filesize_text"
+                android:textSize="12dip"/>
+
+            <TextView
+                android:id="@+id/upload_file_size"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:gravity="right"
+                android:text="TextView"
+                android:textColor="@color/list_item_lastmod_and_filesize_text"
+                android:layout_weight=".5"
+                android:textSize="12dip"/>
+
+        </LinearLayout>
+        
         <LinearLayout
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
@@ -75,7 +104,7 @@
                 android:textSize="12dip"/>
 
             <TextView
-                android:id="@+id/file_size"
+                android:id="@+id/upload_date"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:gravity="right"

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

@@ -21,7 +21,6 @@ import android.widget.TextView;
 import com.owncloud.android.R;
 import com.owncloud.android.datamodel.ThumbnailsCacheManager;
 import com.owncloud.android.db.UploadDbHandler;
-import com.owncloud.android.db.UploadDbHandler.UploadStatus;
 import com.owncloud.android.db.UploadDbObject;
 import com.owncloud.android.files.services.FileUploadService;
 import com.owncloud.android.lib.common.network.OnDatatransferProgressListener;
@@ -137,15 +136,61 @@ public class ExpandableUploadListAdapter extends BaseExpandableListAdapter imple
             UploadDbObject uploadObject = uploadsItems[position];
 
             TextView fileName = (TextView) view.findViewById(R.id.upload_name);
-            fileName.setText(uploadObject.getLocalPath());
+            String file = uploadObject.getOCFile().getFileName();
+            fileName.setText(file);
+            
+            TextView localPath = (TextView) view.findViewById(R.id.upload_local_path);
+            String path = uploadObject.getOCFile().getStoragePath();
+            path = path.substring(0, path.length() - file.length() - 1);
+            localPath.setText(path);
+
+            TextView fileSize = (TextView) view.findViewById(R.id.upload_file_size);
+            fileSize.setText(DisplayUtils.bytesToHumanReadable(uploadObject.getOCFile().getFileLength()));
 
             TextView statusView = (TextView) view.findViewById(R.id.upload_status);
-            String status = uploadObject.getUploadStatus().toString();
-            if (uploadObject.getLastResult() != null && !uploadObject.getLastResult().isSuccess()) {
-                status += ": " + uploadObject.getLastResult().getLogMessage();
-            }
-            if (uploadObject.getUploadStatus() == UploadStatus.UPLOAD_LATER) {
-                status += ": " + FileUploadService.getUploadLaterReason(mActivity, uploadObject);
+            String status;
+            switch (uploadObject.getUploadStatus()) {
+            case UPLOAD_IN_PROGRESS:
+                status = mActivity.getResources().getString(R.string.uploader_upload_in_progress_ticker);
+                break;
+            case UPLOAD_FAILED_GIVE_UP:
+                if(uploadObject.getLastResult() != null) {
+                status = "Upload failed: " + uploadObject.getLastResult().getLogMessage();
+                 } else {
+                     status = "Upload failed.";
+                }
+                break;
+            case UPLOAD_FAILED_RETRY:
+                if(uploadObject.getLastResult() != null){
+                    status = "Last failure: "
+                        + uploadObject.getLastResult().getLogMessage();
+                } else {
+                    status = "Upload will be retried shortly.";
+                }
+                break;
+            case UPLOAD_LATER:
+                status = FileUploadService.getUploadLaterReason(mActivity, uploadObject);
+                break;
+            case UPLOAD_SUCCEEDED:
+                status = "";
+                break;
+            case UPLOAD_CANCELLED:
+                if(uploadObject.getLastResult() == null){
+                    status = "Upload cancelled.";
+                } else {
+                    status = uploadObject.getLastResult()
+                    .getLogMessage();
+                }
+                break;
+            case UPLOAD_PAUSED:
+                status = "Upload paused.";
+                break;
+            default:
+                status = uploadObject.getUploadStatus().toString();
+                if(uploadObject.getLastResult() != null){
+                    uploadObject.getLastResult().getLogMessage();
+                } 
+                break;
             }
             statusView.setText(status);
 
@@ -160,10 +205,10 @@ public class ExpandableUploadListAdapter extends BaseExpandableListAdapter imple
             } catch (NullPointerException e) {
             }            
 
-            TextView fileSizeV = (TextView) view.findViewById(R.id.file_size);
+            TextView uploadDateV = (TextView) view.findViewById(R.id.upload_date);
             CharSequence dateString = DisplayUtils.getRelativeDateTimeString(mActivity, uploadObject.getUploadTime()
                     .getTimeInMillis(), DateUtils.SECOND_IN_MILLIS, DateUtils.WEEK_IN_MILLIS, 0);
-            fileSizeV.setText(dateString);
+            uploadDateV.setText(dateString);
             ImageView checkBoxV = (ImageView) view.findViewById(R.id.custom_checkbox);
             // if (!file.isDirectory()) {
             // fileSizeV.setVisibility(View.VISIBLE);