Merge branch 'download_folder__refactoring_observance_of_downloads_in_progress' into download_folder_update_database

This commit is contained in:
jabarros 2015-01-20 12:42:27 +01:00
commit d8ac7b2241
12 changed files with 33 additions and 41 deletions

View file

@ -575,4 +575,8 @@ public class OCFile implements Parcelable, Comparable<OCFile> {
this.mIsDownloading = isDownloading;
}
public boolean isSynchronizing() {
// TODO real implementation
return false;
}
}

View file

@ -52,8 +52,8 @@ 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 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, ComponentsGetter cg, Context context) {
@ -140,14 +140,9 @@ public class FileMenuFilter {
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())
);
downloading = mFile.isDownloading() || mFile.isSynchronizing();
FileUploaderBinder uploaderBinder = mComponentsGetter.getFileUploaderBinder();
uploading = uploaderBinder != null && uploaderBinder.isUploading(mAccount, mFile);
uploading = (uploaderBinder != null && uploaderBinder.isUploading(mAccount, mFile));
}
/// decision is taken for each possible action on a file in the menu

View file

@ -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());

View file

@ -259,6 +259,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);
@ -276,6 +277,7 @@ public class FileDownloader extends Service implements OnDatatransferProgressLis
}
}
}
*/
/**

View file

@ -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) };
@ -372,8 +372,8 @@ 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.
*
* @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)
@ -400,7 +400,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 +415,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;

View 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
*/
/*
public boolean isSynchronizing(Account account, String remotePath) {
return mSyncFolderHandler.isSynchronizing(account, remotePath);
}
*/
}

View file

@ -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);
}

View file

@ -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,9 +41,7 @@ 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;
@ -71,12 +66,12 @@ 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,
Context context,
ComponentsGetter transferServiceGetter
) {
@ -85,7 +80,7 @@ public class FileListListAdapter extends BaseAdapter implements ListAdapter {
mAccount = AccountUtils.getCurrentOwnCloudAccount(mContext);
mTransferServiceGetter = transferServiceGetter;
mAppPreferences = PreferenceManager
.getDefaultSharedPreferences(mContext);
@ -156,12 +151,8 @@ 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)) {

View file

@ -346,9 +346,8 @@ public class FileDetailFragment extends FileFragment implements OnClickListener
cb.setChecked(file.keepInSync());
// 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() || uploaderBinder.isUploading(mAccount, file)) {
setButtonsForTransferring();
} else if (file.isDown()) {
@ -447,9 +446,8 @@ 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())) {
progressText.setText(R.string.uploader_upload_in_progress_ticker);

View file

@ -131,7 +131,7 @@ public class OCFileListFragment extends ExtendedListFragment {
boolean justFolders = (args == null) ? false : args.getBoolean(ARG_JUST_FOLDERS, false);
mAdapter = new FileListListAdapter(
justFolders,
getSherlockActivity(),
getSherlockActivity(),
mContainerActivity
);
setListAdapter(mAdapter);

View 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.
*/
/*
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

View file

@ -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);