Revert changes for files uploading

This commit is contained in:
David A. Velasco 2015-01-20 11:28:36 +01:00
parent 49849786e5
commit d2883905c6
9 changed files with 29 additions and 18 deletions

View file

@ -572,8 +572,4 @@ public class OCFile implements Parcelable, Comparable<OCFile> {
return false;
}
public boolean isUploading() {
// TODO real implementation
return false;
}
}

View file

@ -43,6 +43,7 @@ import com.owncloud.android.ui.activity.ComponentsGetter;
public class FileMenuFilter {
private OCFile mFile;
private ComponentsGetter mComponentsGetter;
private Account mAccount;
private Context mContext;
@ -51,11 +52,14 @@ 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 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;
}
@ -135,9 +139,10 @@ public class FileMenuFilter {
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

View file

@ -297,7 +297,7 @@ public class FileOperationsHelper {
downloaderBinder.cancel(account, file);
} else if (uploaderBinder != null && file.isUploading()) {
} else if (uploaderBinder != null && uploaderBinder.isUploading(account, file)) {
uploaderBinder.cancel(account, file);
}
} else {

View file

@ -372,10 +372,9 @@ 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)
return false;
@ -394,7 +393,6 @@ public class FileUploader extends Service implements OnDatatransferProgressListe
}
}
}
*/
/**

View file

@ -41,6 +41,8 @@ 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.FileUploader.FileUploaderBinder;
import com.owncloud.android.ui.activity.ComponentsGetter;
import com.owncloud.android.utils.DisplayUtils;
import com.owncloud.android.utils.FileStorageUtils;
@ -63,18 +65,22 @@ 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
) {
mJustFolders = justFolders;
mContext = context;
mAccount = AccountUtils.getCurrentOwnCloudAccount(mContext);
mTransferServiceGetter = transferServiceGetter;
mAppPreferences = PreferenceManager
.getDefaultSharedPreferences(mContext);
@ -145,10 +151,11 @@ public class FileListListAdapter extends BaseAdapter implements ListAdapter {
ImageView localStateView = (ImageView) view.findViewById(R.id.imageView2);
localStateView.bringToFront();
FileUploaderBinder uploaderBinder = mTransferServiceGetter.getFileUploaderBinder();
if (file.isSynchronizing() || file.isDownloading()) {
localStateView.setImageResource(R.drawable.downloading_file_indicator);
localStateView.setVisibility(View.VISIBLE);
} else if (file.isUploading()) {
} else if (uploaderBinder != null && uploaderBinder.isUploading(mAccount, file)) {
localStateView.setImageResource(R.drawable.uploading_file_indicator);
localStateView.setVisibility(View.VISIBLE);
} else if (file.isDown()) {

View file

@ -179,6 +179,7 @@ public class FileDetailFragment extends FileFragment implements OnClickListener
FileMenuFilter mf = new FileMenuFilter(
getFile(),
mContainerActivity.getStorageManager().getAccount(),
mContainerActivity,
getSherlockActivity()
);
mf.filter(menu);
@ -345,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 || file.isDownloading() || file.isUploading()) {
if (transferring || file.isDownloading() || uploaderBinder.isUploading(mAccount, file)) {
setButtonsForTransferring();
} else if (file.isDown()) {
@ -446,9 +446,10 @@ 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);
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);
}
}

View file

@ -131,7 +131,8 @@ 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);
@ -252,6 +253,7 @@ public class OCFileListFragment extends ExtendedListFragment {
FileMenuFilter mf = new FileMenuFilter(
targetFile,
mContainerActivity.getStorageManager().getAccount(),
mContainerActivity,
getSherlockActivity()
);
mf.filter(menu);

View file

@ -232,6 +232,7 @@ public class PreviewImageFragment extends FileFragment {
FileMenuFilter mf = new FileMenuFilter(
getFile(),
mContainerActivity.getStorageManager().getAccount(),
mContainerActivity,
getSherlockActivity()
);
mf.filter(menu);

View file

@ -277,6 +277,7 @@ public class PreviewMediaFragment extends FileFragment implements
FileMenuFilter mf = new FileMenuFilter(
getFile(),
mContainerActivity.getStorageManager().getAccount(),
mContainerActivity,
getSherlockActivity()
);
mf.filter(menu);