Revert changes for files uploading
authorDavid A. Velasco <dvelasco@solidgear.es>
Tue, 20 Jan 2015 10:28:36 +0000 (11:28 +0100)
committerDavid A. Velasco <dvelasco@solidgear.es>
Tue, 20 Jan 2015 10:28:36 +0000 (11:28 +0100)
src/com/owncloud/android/datamodel/OCFile.java
src/com/owncloud/android/files/FileMenuFilter.java
src/com/owncloud/android/files/FileOperationsHelper.java
src/com/owncloud/android/files/services/FileUploader.java
src/com/owncloud/android/ui/adapter/FileListListAdapter.java
src/com/owncloud/android/ui/fragment/FileDetailFragment.java
src/com/owncloud/android/ui/fragment/OCFileListFragment.java
src/com/owncloud/android/ui/preview/PreviewImageFragment.java
src/com/owncloud/android/ui/preview/PreviewMediaFragment.java

index e543b44..2ba0415 100644 (file)
@@ -572,8 +572,4 @@ public class OCFile implements Parcelable, Comparable<OCFile> {
         return false;
     }
 
         return false;
     }
 
-    public boolean isUploading() {
-        // TODO real implementation
-        return false;
-    }
 }
 }
index 0d138c8..f2a0baf 100644 (file)
@@ -43,6 +43,7 @@ import com.owncloud.android.ui.activity.ComponentsGetter;
 public class FileMenuFilter {
 
     private OCFile mFile;
 public class FileMenuFilter {
 
     private OCFile mFile;
+    private ComponentsGetter mComponentsGetter;
     private Account mAccount;
     private Context mContext;
     
     private Account mAccount;
     private Context mContext;
     
@@ -51,11 +52,14 @@ public class FileMenuFilter {
      * 
      * @param targetFile        {@link OCFile} target of the action to filter in the {@link Menu}.
      * @param account           ownCloud {@link Account} holding targetFile.
      * 
      * @param targetFile        {@link OCFile} target of the action to filter in the {@link Menu}.
      * @param account           ownCloud {@link Account} holding targetFile.
+     * @param cg                Accessor to app components, needed to access the
+     *                          {@link FileUploader} and {@link FileDownloader} services
      * @param context           Android {@link Context}, needed to access build setup resources.
      */
      * @param context           Android {@link Context}, needed to access build setup resources.
      */
-    public FileMenuFilter(OCFile targetFile, Account account, Context context) {
+    public FileMenuFilter(OCFile targetFile, Account account, ComponentsGetter cg, Context context) {
         mFile = targetFile;
         mAccount = account;
         mFile = targetFile;
         mAccount = account;
+        mComponentsGetter = cg;
         mContext = context;
     }
     
         mContext = context;
     }
     
@@ -135,9 +139,10 @@ public class FileMenuFilter {
     private void filter(List<Integer> toShow, List <Integer> toHide) {
         boolean downloading = false;
         boolean uploading = false;
     private void filter(List<Integer> toShow, List <Integer> toHide) {
         boolean downloading = false;
         boolean uploading = false;
-        if (mFile != null && mAccount != null) {
+        if (mComponentsGetter != null && mFile != null && mAccount != null) {
             downloading = mFile.isDownloading() || mFile.isSynchronizing();
             downloading = mFile.isDownloading() || mFile.isSynchronizing();
-            uploading = mFile.isUploading();
+            FileUploaderBinder uploaderBinder = mComponentsGetter.getFileUploaderBinder();
+            uploading = (uploaderBinder != null && uploaderBinder.isUploading(mAccount, mFile));
         }
         
         /// decision is taken for each possible action on a file in the menu
         }
         
         /// decision is taken for each possible action on a file in the menu
index 48c45b9..c8cb275 100644 (file)
@@ -297,7 +297,7 @@ public class FileOperationsHelper {
 
                 downloaderBinder.cancel(account, file);
 
 
                 downloaderBinder.cancel(account, file);
 
-            } else if (uploaderBinder != null && file.isUploading()) {
+            } else if (uploaderBinder != null && uploaderBinder.isUploading(account, file)) {
                 uploaderBinder.cancel(account, file);
             }
         } else {
                 uploaderBinder.cancel(account, file);
             }
         } else {
index acbc405..386f185 100644 (file)
@@ -372,10 +372,9 @@ public class FileUploader extends Service implements OnDatatransferProgressListe
          * 
          * If 'file' is a directory, returns 'true' if some of its descendant files is uploading or waiting to upload. 
          * 
          * 
          * If 'file' is a directory, returns 'true' if some of its descendant files is uploading or waiting to upload. 
          * 
-         * @param account Owncloud account where the remote file will be stored.
-         * @param file A file that could be in the queue of pending uploads
+         * @param account   ownCloud account where the remote file will be stored.
+         * @param file      A file that could be in the queue of pending uploads
          */
          */
-        /*
         public boolean isUploading(Account account, OCFile file) {
             if (account == null || file == null)
                 return false;
         public boolean isUploading(Account account, OCFile file) {
             if (account == null || file == null)
                 return false;
@@ -394,7 +393,6 @@ public class FileUploader extends Service implements OnDatatransferProgressListe
                 }
             }
         }
                 }
             }
         }
-        */
 
 
         /**
 
 
         /**
index 4803e01..bfec11c 100644 (file)
@@ -41,6 +41,8 @@ import com.owncloud.android.authentication.AccountUtils;
 import com.owncloud.android.datamodel.FileDataStorageManager;\r
 import com.owncloud.android.datamodel.OCFile;\r
 import com.owncloud.android.datamodel.ThumbnailsCacheManager;\r
 import com.owncloud.android.datamodel.FileDataStorageManager;\r
 import com.owncloud.android.datamodel.OCFile;\r
 import com.owncloud.android.datamodel.ThumbnailsCacheManager;\r
+import com.owncloud.android.files.services.FileUploader.FileUploaderBinder;\r
+import com.owncloud.android.ui.activity.ComponentsGetter;\r
 import com.owncloud.android.utils.DisplayUtils;\r
 import com.owncloud.android.utils.FileStorageUtils;\r
 \r
 import com.owncloud.android.utils.DisplayUtils;\r
 import com.owncloud.android.utils.FileStorageUtils;\r
 \r
@@ -63,18 +65,22 @@ public class FileListListAdapter extends BaseAdapter implements ListAdapter {
 \r
     private FileDataStorageManager mStorageManager;\r
     private Account mAccount;\r
 \r
     private FileDataStorageManager mStorageManager;\r
     private Account mAccount;\r
+    private ComponentsGetter mTransferServiceGetter;\r
 \r
     private SharedPreferences mAppPreferences;\r
     \r
     public FileListListAdapter(\r
             boolean justFolders, \r
 \r
     private SharedPreferences mAppPreferences;\r
     \r
     public FileListListAdapter(\r
             boolean justFolders, \r
-            Context context\r
+            Context context,\r
+            ComponentsGetter transferServiceGetter\r
             ) {\r
 \r
         mJustFolders = justFolders;\r
         mContext = context;\r
         mAccount = AccountUtils.getCurrentOwnCloudAccount(mContext);\r
 \r
             ) {\r
 \r
         mJustFolders = justFolders;\r
         mContext = context;\r
         mAccount = AccountUtils.getCurrentOwnCloudAccount(mContext);\r
 \r
+        mTransferServiceGetter = transferServiceGetter;\r
+\r
         mAppPreferences = PreferenceManager\r
                 .getDefaultSharedPreferences(mContext);\r
         \r
         mAppPreferences = PreferenceManager\r
                 .getDefaultSharedPreferences(mContext);\r
         \r
@@ -145,10 +151,11 @@ public class FileListListAdapter extends BaseAdapter implements ListAdapter {
 \r
             ImageView localStateView = (ImageView) view.findViewById(R.id.imageView2);\r
             localStateView.bringToFront();\r
 \r
             ImageView localStateView = (ImageView) view.findViewById(R.id.imageView2);\r
             localStateView.bringToFront();\r
+            FileUploaderBinder uploaderBinder = mTransferServiceGetter.getFileUploaderBinder();\r
             if (file.isSynchronizing() || file.isDownloading()) {\r
                 localStateView.setImageResource(R.drawable.downloading_file_indicator);\r
                 localStateView.setVisibility(View.VISIBLE);\r
             if (file.isSynchronizing() || file.isDownloading()) {\r
                 localStateView.setImageResource(R.drawable.downloading_file_indicator);\r
                 localStateView.setVisibility(View.VISIBLE);\r
-            } else if (file.isUploading()) {\r
+            } else if (uploaderBinder != null && uploaderBinder.isUploading(mAccount, file)) {\r
                 localStateView.setImageResource(R.drawable.uploading_file_indicator);\r
                 localStateView.setVisibility(View.VISIBLE);\r
             } else if (file.isDown()) {\r
                 localStateView.setImageResource(R.drawable.uploading_file_indicator);\r
                 localStateView.setVisibility(View.VISIBLE);\r
             } else if (file.isDown()) {\r
index e1571ff..dc607b5 100644 (file)
@@ -179,6 +179,7 @@ public class FileDetailFragment extends FileFragment implements OnClickListener
             FileMenuFilter mf = new FileMenuFilter(
                 getFile(),
                 mContainerActivity.getStorageManager().getAccount(),
             FileMenuFilter mf = new FileMenuFilter(
                 getFile(),
                 mContainerActivity.getStorageManager().getAccount(),
+                mContainerActivity,
                 getSherlockActivity()
             );
             mf.filter(menu);
                 getSherlockActivity()
             );
             mf.filter(menu);
@@ -345,9 +346,8 @@ public class FileDetailFragment extends FileFragment implements OnClickListener
             cb.setChecked(file.keepInSync());
 
             // configure UI for depending upon local state of the file
             cb.setChecked(file.keepInSync());
 
             // configure UI for depending upon local state of the file
-            FileDownloaderBinder downloaderBinder = mContainerActivity.getFileDownloaderBinder();
             FileUploaderBinder uploaderBinder = mContainerActivity.getFileUploaderBinder();
             FileUploaderBinder uploaderBinder = mContainerActivity.getFileUploaderBinder();
-            if (transferring || file.isDownloading() || file.isUploading()) {
+            if (transferring || file.isDownloading() || uploaderBinder.isUploading(mAccount, file)) {
                 setButtonsForTransferring();
                 
             } else if (file.isDown()) {
                 setButtonsForTransferring();
                 
             } else if (file.isDown()) {
@@ -446,9 +446,10 @@ public class FileDetailFragment extends FileFragment implements OnClickListener
             getView().findViewById(R.id.fdProgressBlock).setVisibility(View.VISIBLE);
             TextView progressText = (TextView)getView().findViewById(R.id.fdProgressText);
             progressText.setVisibility(View.VISIBLE);
             getView().findViewById(R.id.fdProgressBlock).setVisibility(View.VISIBLE);
             TextView progressText = (TextView)getView().findViewById(R.id.fdProgressText);
             progressText.setVisibility(View.VISIBLE);
+            FileUploaderBinder uploaderBinder = mContainerActivity.getFileUploaderBinder();
             if (getFile().isDownloading()) {
                 progressText.setText(R.string.downloader_download_in_progress_ticker);
             if (getFile().isDownloading()) {
                 progressText.setText(R.string.downloader_download_in_progress_ticker);
-            } else if (getFile().isUploading()) {
+            } else if (uploaderBinder != null && uploaderBinder.isUploading(mAccount, getFile())) {
                 progressText.setText(R.string.uploader_upload_in_progress_ticker);
             }
         }
                 progressText.setText(R.string.uploader_upload_in_progress_ticker);
             }
         }
index 5820119..b70262f 100644 (file)
@@ -131,7 +131,8 @@ public class OCFileListFragment extends ExtendedListFragment {
         boolean justFolders = (args == null) ? false : args.getBoolean(ARG_JUST_FOLDERS, false); 
         mAdapter = new FileListListAdapter(
                 justFolders,
         boolean justFolders = (args == null) ? false : args.getBoolean(ARG_JUST_FOLDERS, false); 
         mAdapter = new FileListListAdapter(
                 justFolders,
-                getSherlockActivity()
+                getSherlockActivity(),
+                mContainerActivity
                 );
         setListAdapter(mAdapter);
 
                 );
         setListAdapter(mAdapter);
 
@@ -252,6 +253,7 @@ public class OCFileListFragment extends ExtendedListFragment {
                 FileMenuFilter mf = new FileMenuFilter(
                     targetFile,
                     mContainerActivity.getStorageManager().getAccount(),
                 FileMenuFilter mf = new FileMenuFilter(
                     targetFile,
                     mContainerActivity.getStorageManager().getAccount(),
+                    mContainerActivity,
                     getSherlockActivity()
                 );
                 mf.filter(menu);
                     getSherlockActivity()
                 );
                 mf.filter(menu);
index 48a45be..0995793 100644 (file)
@@ -232,6 +232,7 @@ public class PreviewImageFragment extends FileFragment {
             FileMenuFilter mf = new FileMenuFilter(
                 getFile(),
                 mContainerActivity.getStorageManager().getAccount(),
             FileMenuFilter mf = new FileMenuFilter(
                 getFile(),
                 mContainerActivity.getStorageManager().getAccount(),
+                mContainerActivity,
                 getSherlockActivity()
             );
             mf.filter(menu);
                 getSherlockActivity()
             );
             mf.filter(menu);
index fe488d4..7d6489b 100644 (file)
@@ -277,6 +277,7 @@ public class PreviewMediaFragment extends FileFragment implements
             FileMenuFilter mf = new FileMenuFilter(
                 getFile(),
                 mContainerActivity.getStorageManager().getAccount(),
             FileMenuFilter mf = new FileMenuFilter(
                 getFile(),
                 mContainerActivity.getStorageManager().getAccount(),
+                mContainerActivity,
                 getSherlockActivity()
             );
             mf.filter(menu);
                 getSherlockActivity()
             );
             mf.filter(menu);