Removed call to methods to check transfer state of files through binders and replaced...
authorDavid A. Velasco <dvelasco@solidgear.es>
Mon, 19 Jan 2015 12:39:32 +0000 (13:39 +0100)
committerDavid A. Velasco <dvelasco@solidgear.es>
Tue, 20 Jan 2015 08:42:58 +0000 (09:42 +0100)
14 files changed:
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/FileDownloader.java
src/com/owncloud/android/files/services/FileUploader.java
src/com/owncloud/android/services/OperationsService.java
src/com/owncloud/android/ui/activity/FileDisplayActivity.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/FileDownloadFragment.java
src/com/owncloud/android/ui/preview/PreviewImageActivity.java
src/com/owncloud/android/ui/preview/PreviewImageFragment.java
src/com/owncloud/android/ui/preview/PreviewMediaFragment.java

index cf25d27..e543b44 100644 (file)
@@ -562,4 +562,18 @@ public class OCFile implements Parcelable, Comparable<OCFile> {
         this.mRemoteId = remoteId;
     }
 
         this.mRemoteId = remoteId;
     }
 
+    public boolean isSynchronizing() {
+        // TODO real implementation
+        return false;
+    }
+
+    public boolean isDownloading() {
+        // TODO real implementation
+        return false;
+    }
+
+    public boolean isUploading() {
+        // TODO real implementation
+        return false;
+    }
 }
 }
index 0c3f18a..0d138c8 100644 (file)
@@ -43,7 +43,6 @@ 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;
     
@@ -52,14 +51,11 @@ 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 get 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, ComponentsGetter cg, Context context) {
+    public FileMenuFilter(OCFile targetFile, Account account, Context context) {
         mFile = targetFile;
         mAccount = account;
         mFile = targetFile;
         mAccount = account;
-        mComponentsGetter = cg;
         mContext = context;
     }
     
         mContext = context;
     }
     
@@ -139,15 +135,9 @@ 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 (mComponentsGetter != null && mFile != null && mAccount != null) {
-            FileDownloaderBinder downloaderBinder = mComponentsGetter.getFileDownloaderBinder();
-            downloading = downloaderBinder != null && downloaderBinder.isDownloading(mAccount, mFile);
-            OperationsServiceBinder opsBinder = mComponentsGetter.getOperationsServiceBinder();
-            downloading |= (
-                    mFile.isFolder() && opsBinder != null && opsBinder.isSynchronizing(mAccount, mFile.getRemotePath())
-            );
-            FileUploaderBinder uploaderBinder = mComponentsGetter.getFileUploaderBinder();
-            uploading = uploaderBinder != null && uploaderBinder.isUploading(mAccount, mFile);
+        if (mFile != null && mAccount != null) {
+            downloading = mFile.isDownloading() || mFile.isSynchronizing();
+            uploading = mFile.isUploading();
         }
         
         /// 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 4f7ccea..48c45b9 100644 (file)
@@ -287,7 +287,7 @@ public class FileOperationsHelper {
         if (!file.isFolder()) {
             FileDownloaderBinder downloaderBinder = mFileActivity.getFileDownloaderBinder();
             FileUploaderBinder uploaderBinder = mFileActivity.getFileUploaderBinder();
         if (!file.isFolder()) {
             FileDownloaderBinder downloaderBinder = mFileActivity.getFileDownloaderBinder();
             FileUploaderBinder uploaderBinder = mFileActivity.getFileUploaderBinder();
-            if (downloaderBinder != null && downloaderBinder.isDownloading(account, file)) {
+            if (downloaderBinder != null && file.isDownloading()) {
                 // Remove etag for parent, if file is a keep_in_sync
                 if (file.keepInSync()) {
                     OCFile parent = mFileActivity.getStorageManager().getFileById(file.getParentId());
                 // Remove etag for parent, if file is a keep_in_sync
                 if (file.keepInSync()) {
                     OCFile parent = mFileActivity.getStorageManager().getFileById(file.getParentId());
@@ -297,7 +297,7 @@ public class FileOperationsHelper {
 
                 downloaderBinder.cancel(account, file);
 
 
                 downloaderBinder.cancel(account, file);
 
-            } else if (uploaderBinder != null && uploaderBinder.isUploading(account, file)) {
+            } else if (uploaderBinder != null && file.isUploading()) {
                 uploaderBinder.cancel(account, file);
             }
         } else {
                 uploaderBinder.cancel(account, file);
             }
         } else {
index eb870e1..ab9e332 100644 (file)
@@ -253,6 +253,7 @@ public class FileDownloader extends Service implements OnDatatransferProgressLis
          * @param account       Owncloud account where the remote file is stored.
          * @param file          A file that could be in the queue of downloads.
          */
          * @param account       Owncloud account where the remote file is stored.
          * @param file          A file that could be in the queue of downloads.
          */
+        /*
         public boolean isDownloading(Account account, OCFile file) {
             if (account == null || file == null) return false;
             String targetKey = buildRemoteName(account, file);
         public boolean isDownloading(Account account, OCFile file) {
             if (account == null || file == null) return false;
             String targetKey = buildRemoteName(account, file);
@@ -270,6 +271,7 @@ public class FileDownloader extends Service implements OnDatatransferProgressLis
                 }
             }
         }
                 }
             }
         }
+        */
 
         
         /**
 
         
         /**
index 0480440..acbc405 100644 (file)
@@ -199,7 +199,7 @@ public class FileUploader extends Service implements OnDatatransferProgressListe
         if (uploadType == UPLOAD_SINGLE_FILE) {
 
             if (intent.hasExtra(KEY_FILE)) {
         if (uploadType == UPLOAD_SINGLE_FILE) {
 
             if (intent.hasExtra(KEY_FILE)) {
-                files = new OCFile[] { intent.getParcelableExtra(KEY_FILE) };
+                files = new OCFile[] { (OCFile) intent.getParcelableExtra(KEY_FILE) };
 
             } else {
                 localPaths = new String[] { intent.getStringExtra(KEY_LOCAL_FILE) };
 
             } else {
                 localPaths = new String[] { intent.getStringExtra(KEY_LOCAL_FILE) };
@@ -375,6 +375,7 @@ public class FileUploader extends Service implements OnDatatransferProgressListe
          * @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;
@@ -393,6 +394,7 @@ public class FileUploader extends Service implements OnDatatransferProgressListe
                 }
             }
         }
                 }
             }
         }
+        */
 
 
         /**
 
 
         /**
@@ -400,7 +402,7 @@ public class FileUploader extends Service implements OnDatatransferProgressListe
          * 
          * @param listener      Object to notify about progress of transfer.    
          * @param account       ownCloud account holding the file of interest.
          * 
          * @param listener      Object to notify about progress of transfer.    
          * @param account       ownCloud account holding the file of interest.
-         * @param file          {@link OCfile} of interest for listener. 
+         * @param file          {@link OCFile} of interest for listener.
          */
         public void addDatatransferProgressListener (OnDatatransferProgressListener listener, Account account, OCFile file) {
             if (account == null || file == null || listener == null) return;
          */
         public void addDatatransferProgressListener (OnDatatransferProgressListener listener, Account account, OCFile file) {
             if (account == null || file == null || listener == null) return;
@@ -415,7 +417,7 @@ public class FileUploader extends Service implements OnDatatransferProgressListe
          * 
          * @param listener      Object to notify about progress of transfer.    
          * @param account       ownCloud account holding the file of interest.
          * 
          * @param listener      Object to notify about progress of transfer.    
          * @param account       ownCloud account holding the file of interest.
-         * @param file          {@link OCfile} of interest for listener. 
+         * @param file          {@link OCFile} of interest for listener.
          */
         public void removeDatatransferProgressListener (OnDatatransferProgressListener listener, Account account, OCFile file) {
             if (account == null || file == null || listener == null) return;
          */
         public void removeDatatransferProgressListener (OnDatatransferProgressListener listener, Account account, OCFile file) {
             if (account == null || file == null || listener == null) return;
index 71ccf44..779e5b6 100644 (file)
@@ -379,9 +379,11 @@ public class OperationsService extends Service {
          * @param account       ownCloud account where the remote file is stored.
          * @param file          A file that could be affected 
          */
          * @param account       ownCloud account where the remote file is stored.
          * @param file          A file that could be affected 
          */
+        /*
         public boolean isSynchronizing(Account account, String remotePath) {
             return mSyncFolderHandler.isSynchronizing(account, remotePath);
         }
         public boolean isSynchronizing(Account account, String remotePath) {
             return mSyncFolderHandler.isSynchronizing(account, remotePath);
         }
+        */
 
     }
 
 
     }
 
index 398a833..fbd35ed 100644 (file)
@@ -1725,7 +1725,7 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener {
 
     private void requestForDownload() {
         Account account = getAccount();
 
     private void requestForDownload() {
         Account account = getAccount();
-        if (!mDownloaderBinder.isDownloading(account, mWaitingToPreview)) {
+        if (mWaitingToPreview.isDownloading()) {
             Intent i = new Intent(this, FileDownloader.class);
             i.putExtra(FileDownloader.EXTRA_ACCOUNT, account);
             i.putExtra(FileDownloader.EXTRA_FILE, mWaitingToPreview);
             Intent i = new Intent(this, FileDownloader.class);
             i.putExtra(FileDownloader.EXTRA_ACCOUNT, account);
             i.putExtra(FileDownloader.EXTRA_FILE, mWaitingToPreview);
@@ -1781,10 +1781,9 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener {
     }
     
     private void requestForDownload(OCFile file) {
     }
     
     private void requestForDownload(OCFile file) {
-        Account account = getAccount();
-        if (!mDownloaderBinder.isDownloading(account, file)) {
+        if (file.isDownloading()) {
             Intent i = new Intent(this, FileDownloader.class);
             Intent i = new Intent(this, FileDownloader.class);
-            i.putExtra(FileDownloader.EXTRA_ACCOUNT, account);
+            i.putExtra(FileDownloader.EXTRA_ACCOUNT, getAccount());
             i.putExtra(FileDownloader.EXTRA_FILE, file);
             startService(i);
         }
             i.putExtra(FileDownloader.EXTRA_FILE, file);
             startService(i);
         }
index 0e3e037..4803e01 100644 (file)
@@ -19,11 +19,8 @@ package com.owncloud.android.ui.adapter;
 \r
 \r
 import java.io.File;\r
 \r
 \r
 import java.io.File;\r
-import java.util.Collections;\r
-import java.util.Comparator;\r
 import java.util.Vector;\r
 \r
 import java.util.Vector;\r
 \r
-import third_parties.daveKoeller.AlphanumComparator;\r
 import android.accounts.Account;\r
 import android.content.Context;\r
 import android.content.SharedPreferences;\r
 import android.accounts.Account;\r
 import android.content.Context;\r
 import android.content.SharedPreferences;\r
@@ -44,10 +41,6 @@ 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.FileDownloader.FileDownloaderBinder;\r
-import com.owncloud.android.files.services.FileUploader.FileUploaderBinder;\r
-import com.owncloud.android.services.OperationsService.OperationsServiceBinder;\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
@@ -70,22 +63,18 @@ 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
+\r
     private SharedPreferences mAppPreferences;\r
     \r
     public FileListListAdapter(\r
             boolean justFolders, \r
     private SharedPreferences mAppPreferences;\r
     \r
     public FileListListAdapter(\r
             boolean justFolders, \r
-            Context context, \r
-            ComponentsGetter transferServiceGetter\r
+            Context context\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
@@ -156,15 +145,10 @@ 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
-            FileDownloaderBinder downloaderBinder = \r
-                    mTransferServiceGetter.getFileDownloaderBinder();\r
-            FileUploaderBinder uploaderBinder = mTransferServiceGetter.getFileUploaderBinder();\r
-            OperationsServiceBinder opsBinder = mTransferServiceGetter.getOperationsServiceBinder();\r
-            if ((downloaderBinder != null && downloaderBinder.isDownloading(mAccount, file)) ||\r
-                 (file.isFolder() && opsBinder != null && opsBinder.isSynchronizing(mAccount, file.getRemotePath()))) {\r
+            if (file.isSynchronizing() || file.isDownloading()) {\r
                 localStateView.setImageResource(R.drawable.downloading_file_indicator);\r
                 localStateView.setVisibility(View.VISIBLE);\r
                 localStateView.setImageResource(R.drawable.downloading_file_indicator);\r
                 localStateView.setVisibility(View.VISIBLE);\r
-            } else if (uploaderBinder != null && uploaderBinder.isUploading(mAccount, file)) {\r
+            } else if (file.isUploading()) {\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 1e0e7ee..e1571ff 100644 (file)
@@ -179,7 +179,6 @@ 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);
@@ -348,7 +347,7 @@ public class FileDetailFragment extends FileFragment implements OnClickListener
             // configure UI for depending upon local state of the file
             FileDownloaderBinder downloaderBinder = mContainerActivity.getFileDownloaderBinder();
             FileUploaderBinder uploaderBinder = mContainerActivity.getFileUploaderBinder();
             // configure UI for depending upon local state of the file
             FileDownloaderBinder downloaderBinder = mContainerActivity.getFileDownloaderBinder();
             FileUploaderBinder uploaderBinder = mContainerActivity.getFileUploaderBinder();
-            if (transferring || (downloaderBinder != null && downloaderBinder.isDownloading(mAccount, file)) || (uploaderBinder != null && uploaderBinder.isUploading(mAccount, file))) {
+            if (transferring || file.isDownloading() || file.isUploading()) {
                 setButtonsForTransferring();
                 
             } else if (file.isDown()) {
                 setButtonsForTransferring();
                 
             } else if (file.isDown()) {
@@ -447,11 +446,9 @@ 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);
-            FileDownloaderBinder downloaderBinder = mContainerActivity.getFileDownloaderBinder();
-            FileUploaderBinder uploaderBinder = mContainerActivity.getFileUploaderBinder();
-            if (downloaderBinder != null && downloaderBinder.isDownloading(mAccount, getFile())) {
+            if (getFile().isDownloading()) {
                 progressText.setText(R.string.downloader_download_in_progress_ticker);
                 progressText.setText(R.string.downloader_download_in_progress_ticker);
-            } else if (uploaderBinder != null && uploaderBinder.isUploading(mAccount, getFile())) {
+            } else if (getFile().isUploading()) {
                 progressText.setText(R.string.uploader_upload_in_progress_ticker);
             }
         }
                 progressText.setText(R.string.uploader_upload_in_progress_ticker);
             }
         }
index 9c85dd9..5820119 100644 (file)
@@ -131,8 +131,7 @@ 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(), 
-                mContainerActivity
+                getSherlockActivity()
                 );
         setListAdapter(mAdapter);
 
                 );
         setListAdapter(mAdapter);
 
@@ -253,7 +252,6 @@ 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 98bbda3..7af29c6 100644 (file)
@@ -211,10 +211,11 @@ public class FileDownloadFragment extends FileFragment implements OnClickListene
      * @param   transferring    When true, the view must be updated assuming that the holded file is 
      *                          downloading, no matter what the downloaderBinder says.
      */
      * @param   transferring    When true, the view must be updated assuming that the holded file is 
      *                          downloading, no matter what the downloaderBinder says.
      */
+    /*
     public void updateView(boolean transferring) {
         // configure UI for depending upon local state of the file
     public void updateView(boolean transferring) {
         // configure UI for depending upon local state of the file
-        FileDownloaderBinder downloaderBinder = (mContainerActivity == null) ? null : mContainerActivity.getFileDownloaderBinder();
-        if (transferring || (downloaderBinder != null && downloaderBinder.isDownloading(mAccount, getFile()))) {
+        // TODO remove
+        if (transferring || getFile().isDownloading()) {
             setButtonsForTransferring();
             
         } else if (getFile().isDown()) {
             setButtonsForTransferring();
             
         } else if (getFile().isDown()) {
@@ -227,7 +228,7 @@ public class FileDownloadFragment extends FileFragment implements OnClickListene
         getView().invalidate();
         
     }
         getView().invalidate();
         
     }
-
+    */
 
     /**
      * Enables or disables buttons for a file being downloaded
 
     /**
      * Enables or disables buttons for a file being downloaded
index 1cee30e..13d6adc 100644 (file)
@@ -365,7 +365,7 @@ ViewPager.OnPageChangeListener, OnRemoteOperationListener {
         if (mDownloaderBinder == null) {
             Log_OC.d(TAG, "requestForDownload called without binder to download service");
             
         if (mDownloaderBinder == null) {
             Log_OC.d(TAG, "requestForDownload called without binder to download service");
             
-        } else if (!mDownloaderBinder.isDownloading(getAccount(), file)) {
+        } else if (!file.isDownloading()) {
             Intent i = new Intent(this, FileDownloader.class);
             i.putExtra(FileDownloader.EXTRA_ACCOUNT, getAccount());
             i.putExtra(FileDownloader.EXTRA_FILE, file);
             Intent i = new Intent(this, FileDownloader.class);
             i.putExtra(FileDownloader.EXTRA_ACCOUNT, getAccount());
             i.putExtra(FileDownloader.EXTRA_FILE, file);
index 0995793..48a45be 100644 (file)
@@ -232,7 +232,6 @@ 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 7d6489b..fe488d4 100644 (file)
@@ -277,7 +277,6 @@ 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);