Browse Source

New stuff

Signed-off-by: Mario Danic <mario@lovelyhq.com>
Mario Danic 7 years ago
parent
commit
7266b533c5

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

@@ -744,6 +744,7 @@ public class FileUploader extends Service
                 upload.cancel();
                 upload.cancel();
                 // need to update now table in mUploadsStorageManager,
                 // need to update now table in mUploadsStorageManager,
                 // since the operation will not get to be run by FileUploader#uploadFile
                 // since the operation will not get to be run by FileUploader#uploadFile
+                mUploadsStorageManager.updateDatabaseUploadResult(Re, upload);
                 mUploadsStorageManager.removeUpload(accountName, remotePath);
                 mUploadsStorageManager.removeUpload(accountName, remotePath);
             } else {
             } else {
                 // try to cancel job in jobScheduler
                 // try to cancel job in jobScheduler
@@ -894,6 +895,13 @@ public class FileUploader extends Service
             if (boundListener != null) {
             if (boundListener != null) {
                 boundListener.onTransferProgress(progressRate, totalTransferredSoFar,
                 boundListener.onTransferProgress(progressRate, totalTransferredSoFar,
                         totalToTransfer, fileName);
                         totalToTransfer, fileName);
+
+                if (MainApp.getAppContext() != null &&
+                        (mCurrentUpload.getIsWifiRequired() && !Device.getNetworkType(MainApp.getAppContext()).
+                        equals(JobRequest.NetworkType.UNMETERED)) || (mCurrentUpload.getIsChargingRequired() &&
+                        !Device.isCharging(MainApp.getAppContext()))) {
+                    // pause
+                }
             }
             }
         }
         }
 
 

+ 6 - 0
src/main/java/com/owncloud/android/operations/UploadFileOperation.java

@@ -188,6 +188,12 @@ public class UploadFileOperation extends SyncOperation {
         mRemoteFolderToBeCreated = upload.isCreateRemoteFolder();
         mRemoteFolderToBeCreated = upload.isCreateRemoteFolder();
     }
     }
 
 
+    public boolean getIsWifiRequired() {
+        return mOnWifiOnly;
+    }
+
+    public boolean getIsChargingRequired() {return mWhileChargingOnly;}
+
     public Account getAccount() {
     public Account getAccount() {
         return mAccount;
         return mAccount;
     }
     }