From: David A. Velasco Date: Mon, 19 Jan 2015 12:39:32 +0000 (+0100) Subject: Removed call to methods to check transfer state of files through binders and replaced... X-Git-Tag: oc-android-1.7.0_signed~23^2~10 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/49849786e5164692481917bcc91e81264c7ac01d?ds=inline;hp=-c Removed call to methods to check transfer state of files through binders and replaced with methods on OCFile --- 49849786e5164692481917bcc91e81264c7ac01d diff --git a/src/com/owncloud/android/datamodel/OCFile.java b/src/com/owncloud/android/datamodel/OCFile.java index cf25d278..e543b443 100644 --- a/src/com/owncloud/android/datamodel/OCFile.java +++ b/src/com/owncloud/android/datamodel/OCFile.java @@ -562,4 +562,18 @@ public class OCFile implements Parcelable, Comparable { 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; + } } diff --git a/src/com/owncloud/android/files/FileMenuFilter.java b/src/com/owncloud/android/files/FileMenuFilter.java index 0c3f18a1..0d138c81 100644 --- a/src/com/owncloud/android/files/FileMenuFilter.java +++ b/src/com/owncloud/android/files/FileMenuFilter.java @@ -43,7 +43,6 @@ import com.owncloud.android.ui.activity.ComponentsGetter; public class FileMenuFilter { private OCFile mFile; - private ComponentsGetter mComponentsGetter; 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 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. */ - public FileMenuFilter(OCFile targetFile, Account account, ComponentsGetter cg, Context context) { + public FileMenuFilter(OCFile targetFile, Account account, Context context) { mFile = targetFile; mAccount = account; - mComponentsGetter = cg; mContext = context; } @@ -139,15 +135,9 @@ public class FileMenuFilter { private void filter(List toShow, List 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 diff --git a/src/com/owncloud/android/files/FileOperationsHelper.java b/src/com/owncloud/android/files/FileOperationsHelper.java index 4f7ccea1..48c45b93 100644 --- a/src/com/owncloud/android/files/FileOperationsHelper.java +++ b/src/com/owncloud/android/files/FileOperationsHelper.java @@ -287,7 +287,7 @@ public class FileOperationsHelper { 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()); @@ -297,7 +297,7 @@ public class FileOperationsHelper { downloaderBinder.cancel(account, file); - } else if (uploaderBinder != null && uploaderBinder.isUploading(account, file)) { + } else if (uploaderBinder != null && file.isUploading()) { uploaderBinder.cancel(account, file); } } else { diff --git a/src/com/owncloud/android/files/services/FileDownloader.java b/src/com/owncloud/android/files/services/FileDownloader.java index eb870e1d..ab9e3327 100644 --- a/src/com/owncloud/android/files/services/FileDownloader.java +++ b/src/com/owncloud/android/files/services/FileDownloader.java @@ -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. */ + /* 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 } } } + */ /** diff --git a/src/com/owncloud/android/files/services/FileUploader.java b/src/com/owncloud/android/files/services/FileUploader.java index 04804402..acbc405d 100644 --- a/src/com/owncloud/android/files/services/FileUploader.java +++ b/src/com/owncloud/android/files/services/FileUploader.java @@ -199,7 +199,7 @@ public class FileUploader extends Service implements OnDatatransferProgressListe 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) }; @@ -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 */ + /* 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 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; @@ -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 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; diff --git a/src/com/owncloud/android/services/OperationsService.java b/src/com/owncloud/android/services/OperationsService.java index 71ccf441..779e5b6a 100644 --- a/src/com/owncloud/android/services/OperationsService.java +++ b/src/com/owncloud/android/services/OperationsService.java @@ -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 */ + /* public boolean isSynchronizing(Account account, String remotePath) { return mSyncFolderHandler.isSynchronizing(account, remotePath); } + */ } diff --git a/src/com/owncloud/android/ui/activity/FileDisplayActivity.java b/src/com/owncloud/android/ui/activity/FileDisplayActivity.java index 398a833d..fbd35edc 100644 --- a/src/com/owncloud/android/ui/activity/FileDisplayActivity.java +++ b/src/com/owncloud/android/ui/activity/FileDisplayActivity.java @@ -1725,7 +1725,7 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener { 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); @@ -1781,10 +1781,9 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener { } private void requestForDownload(OCFile file) { - Account account = getAccount(); - if (!mDownloaderBinder.isDownloading(account, file)) { + if (file.isDownloading()) { 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); } diff --git a/src/com/owncloud/android/ui/adapter/FileListListAdapter.java b/src/com/owncloud/android/ui/adapter/FileListListAdapter.java index 0e3e0377..4803e01d 100644 --- a/src/com/owncloud/android/ui/adapter/FileListListAdapter.java +++ b/src/com/owncloud/android/ui/adapter/FileListListAdapter.java @@ -19,11 +19,8 @@ package com.owncloud.android.ui.adapter; import java.io.File; -import java.util.Collections; -import java.util.Comparator; import java.util.Vector; -import third_parties.daveKoeller.AlphanumComparator; import android.accounts.Account; import android.content.Context; import android.content.SharedPreferences; @@ -44,10 +41,6 @@ import com.owncloud.android.authentication.AccountUtils; import com.owncloud.android.datamodel.FileDataStorageManager; import com.owncloud.android.datamodel.OCFile; import com.owncloud.android.datamodel.ThumbnailsCacheManager; -import com.owncloud.android.files.services.FileDownloader.FileDownloaderBinder; -import com.owncloud.android.files.services.FileUploader.FileUploaderBinder; -import com.owncloud.android.services.OperationsService.OperationsServiceBinder; -import com.owncloud.android.ui.activity.ComponentsGetter; import com.owncloud.android.utils.DisplayUtils; import com.owncloud.android.utils.FileStorageUtils; @@ -70,22 +63,18 @@ public class FileListListAdapter extends BaseAdapter implements ListAdapter { private FileDataStorageManager mStorageManager; private Account mAccount; - private ComponentsGetter mTransferServiceGetter; - + private SharedPreferences mAppPreferences; public FileListListAdapter( boolean justFolders, - Context context, - ComponentsGetter transferServiceGetter + Context context ) { mJustFolders = justFolders; mContext = context; mAccount = AccountUtils.getCurrentOwnCloudAccount(mContext); - mTransferServiceGetter = transferServiceGetter; - mAppPreferences = PreferenceManager .getDefaultSharedPreferences(mContext); @@ -156,15 +145,10 @@ public class FileListListAdapter extends BaseAdapter implements ListAdapter { ImageView localStateView = (ImageView) view.findViewById(R.id.imageView2); localStateView.bringToFront(); - FileDownloaderBinder downloaderBinder = - mTransferServiceGetter.getFileDownloaderBinder(); - FileUploaderBinder uploaderBinder = mTransferServiceGetter.getFileUploaderBinder(); - OperationsServiceBinder opsBinder = mTransferServiceGetter.getOperationsServiceBinder(); - if ((downloaderBinder != null && downloaderBinder.isDownloading(mAccount, file)) || - (file.isFolder() && opsBinder != null && opsBinder.isSynchronizing(mAccount, file.getRemotePath()))) { + if (file.isSynchronizing() || file.isDownloading()) { localStateView.setImageResource(R.drawable.downloading_file_indicator); localStateView.setVisibility(View.VISIBLE); - } else if (uploaderBinder != null && uploaderBinder.isUploading(mAccount, file)) { + } else if (file.isUploading()) { localStateView.setImageResource(R.drawable.uploading_file_indicator); localStateView.setVisibility(View.VISIBLE); } else if (file.isDown()) { diff --git a/src/com/owncloud/android/ui/fragment/FileDetailFragment.java b/src/com/owncloud/android/ui/fragment/FileDetailFragment.java index 1e0e7ee3..e1571ffb 100644 --- a/src/com/owncloud/android/ui/fragment/FileDetailFragment.java +++ b/src/com/owncloud/android/ui/fragment/FileDetailFragment.java @@ -179,7 +179,6 @@ public class FileDetailFragment extends FileFragment implements OnClickListener FileMenuFilter mf = new FileMenuFilter( getFile(), mContainerActivity.getStorageManager().getAccount(), - mContainerActivity, 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(); - 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()) { @@ -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); - 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); - } else if (uploaderBinder != null && uploaderBinder.isUploading(mAccount, getFile())) { + } else if (getFile().isUploading()) { progressText.setText(R.string.uploader_upload_in_progress_ticker); } } diff --git a/src/com/owncloud/android/ui/fragment/OCFileListFragment.java b/src/com/owncloud/android/ui/fragment/OCFileListFragment.java index 9c85dd98..5820119d 100644 --- a/src/com/owncloud/android/ui/fragment/OCFileListFragment.java +++ b/src/com/owncloud/android/ui/fragment/OCFileListFragment.java @@ -131,8 +131,7 @@ public class OCFileListFragment extends ExtendedListFragment { boolean justFolders = (args == null) ? false : args.getBoolean(ARG_JUST_FOLDERS, false); mAdapter = new FileListListAdapter( justFolders, - getSherlockActivity(), - mContainerActivity + getSherlockActivity() ); setListAdapter(mAdapter); @@ -253,7 +252,6 @@ public class OCFileListFragment extends ExtendedListFragment { FileMenuFilter mf = new FileMenuFilter( targetFile, mContainerActivity.getStorageManager().getAccount(), - mContainerActivity, getSherlockActivity() ); mf.filter(menu); diff --git a/src/com/owncloud/android/ui/preview/FileDownloadFragment.java b/src/com/owncloud/android/ui/preview/FileDownloadFragment.java index 98bbda38..7af29c64 100644 --- a/src/com/owncloud/android/ui/preview/FileDownloadFragment.java +++ b/src/com/owncloud/android/ui/preview/FileDownloadFragment.java @@ -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. */ + /* 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()) { @@ -227,7 +228,7 @@ public class FileDownloadFragment extends FileFragment implements OnClickListene getView().invalidate(); } - + */ /** * Enables or disables buttons for a file being downloaded diff --git a/src/com/owncloud/android/ui/preview/PreviewImageActivity.java b/src/com/owncloud/android/ui/preview/PreviewImageActivity.java index 1cee30e8..13d6adcf 100644 --- a/src/com/owncloud/android/ui/preview/PreviewImageActivity.java +++ b/src/com/owncloud/android/ui/preview/PreviewImageActivity.java @@ -365,7 +365,7 @@ ViewPager.OnPageChangeListener, OnRemoteOperationListener { 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); diff --git a/src/com/owncloud/android/ui/preview/PreviewImageFragment.java b/src/com/owncloud/android/ui/preview/PreviewImageFragment.java index 0995793d..48a45be7 100644 --- a/src/com/owncloud/android/ui/preview/PreviewImageFragment.java +++ b/src/com/owncloud/android/ui/preview/PreviewImageFragment.java @@ -232,7 +232,6 @@ public class PreviewImageFragment extends FileFragment { FileMenuFilter mf = new FileMenuFilter( getFile(), mContainerActivity.getStorageManager().getAccount(), - mContainerActivity, getSherlockActivity() ); mf.filter(menu); diff --git a/src/com/owncloud/android/ui/preview/PreviewMediaFragment.java b/src/com/owncloud/android/ui/preview/PreviewMediaFragment.java index 7d6489b2..fe488d43 100644 --- a/src/com/owncloud/android/ui/preview/PreviewMediaFragment.java +++ b/src/com/owncloud/android/ui/preview/PreviewMediaFragment.java @@ -277,7 +277,6 @@ public class PreviewMediaFragment extends FileFragment implements FileMenuFilter mf = new FileMenuFilter( getFile(), mContainerActivity.getStorageManager().getAccount(), - mContainerActivity, getSherlockActivity() ); mf.filter(menu);