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;
+ }
}
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 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;
}
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
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());
downloaderBinder.cancel(account, file);
- } else if (uploaderBinder != null && uploaderBinder.isUploading(account, file)) {
+ } else if (uploaderBinder != null && file.isUploading()) {
uploaderBinder.cancel(account, file);
}
} else {
* @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);
}
}
}
+ */
/**
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) };
* @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;
}
}
}
+ */
/**
*
* @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;
*
* @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;
* @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);
}
+ */
}
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);
}
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);
}
\r
\r
import java.io.File;\r
-import java.util.Collections;\r
-import java.util.Comparator;\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 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
\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
- Context context, \r
- ComponentsGetter transferServiceGetter\r
+ Context context\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
- 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
- } 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
FileMenuFilter mf = new FileMenuFilter(
getFile(),
mContainerActivity.getStorageManager().getAccount(),
- mContainerActivity,
getSherlockActivity()
);
mf.filter(menu);
// 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()) {
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);
}
}
boolean justFolders = (args == null) ? false : args.getBoolean(ARG_JUST_FOLDERS, false);
mAdapter = new FileListListAdapter(
justFolders,
- getSherlockActivity(),
- mContainerActivity
+ getSherlockActivity()
);
setListAdapter(mAdapter);
FileMenuFilter mf = new FileMenuFilter(
targetFile,
mContainerActivity.getStorageManager().getAccount(),
- mContainerActivity,
getSherlockActivity()
);
mf.filter(menu);
* @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()) {
getView().invalidate();
}
-
+ */
/**
* Enables or disables buttons for a file being downloaded
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);
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);