return false;
}
- public boolean isUploading() {
- // TODO real implementation
- return false;
- }
}
public class FileMenuFilter {
private OCFile mFile;
+ private ComponentsGetter mComponentsGetter;
private Account mAccount;
private Context mContext;
*
* @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.
*/
- public FileMenuFilter(OCFile targetFile, Account account, Context context) {
+ public FileMenuFilter(OCFile targetFile, Account account, ComponentsGetter cg, Context context) {
mFile = targetFile;
mAccount = account;
+ mComponentsGetter = cg;
mContext = context;
}
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();
- 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
downloaderBinder.cancel(account, file);
- } else if (uploaderBinder != null && file.isUploading()) {
+ } else if (uploaderBinder != null && uploaderBinder.isUploading(account, file)) {
uploaderBinder.cancel(account, file);
}
} else {
*
* 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;
}
}
}
- */
/**
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
\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
- Context context\r
+ Context context,\r
+ ComponentsGetter transferServiceGetter\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
\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
- } 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
FileMenuFilter mf = new FileMenuFilter(
getFile(),
mContainerActivity.getStorageManager().getAccount(),
+ mContainerActivity,
getSherlockActivity()
);
mf.filter(menu);
cb.setChecked(file.keepInSync());
// configure UI for depending upon local state of the file
- FileDownloaderBinder downloaderBinder = mContainerActivity.getFileDownloaderBinder();
FileUploaderBinder uploaderBinder = mContainerActivity.getFileUploaderBinder();
- if (transferring || file.isDownloading() || file.isUploading()) {
+ if (transferring || file.isDownloading() || uploaderBinder.isUploading(mAccount, file)) {
setButtonsForTransferring();
} else if (file.isDown()) {
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);
- } else if (getFile().isUploading()) {
+ } else if (uploaderBinder != null && uploaderBinder.isUploading(mAccount, getFile())) {
progressText.setText(R.string.uploader_upload_in_progress_ticker);
}
}
boolean justFolders = (args == null) ? false : args.getBoolean(ARG_JUST_FOLDERS, false);
mAdapter = new FileListListAdapter(
justFolders,
- getSherlockActivity()
+ getSherlockActivity(),
+ mContainerActivity
);
setListAdapter(mAdapter);
FileMenuFilter mf = new FileMenuFilter(
targetFile,
mContainerActivity.getStorageManager().getAccount(),
+ mContainerActivity,
getSherlockActivity()
);
mf.filter(menu);
FileMenuFilter mf = new FileMenuFilter(
getFile(),
mContainerActivity.getStorageManager().getAccount(),
+ mContainerActivity,
getSherlockActivity()
);
mf.filter(menu);
FileMenuFilter mf = new FileMenuFilter(
getFile(),
mContainerActivity.getStorageManager().getAccount(),
+ mContainerActivity,
getSherlockActivity()
);
mf.filter(menu);