From: jabarros Date: Tue, 20 Jan 2015 11:42:27 +0000 (+0100) Subject: Merge branch 'download_folder__refactoring_observance_of_downloads_in_progress' into... X-Git-Tag: oc-android-1.7.0_signed~23^2~8^2~1 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/d8ac7b2241bc99df58b5f4be4c3c4d83fc9efaf6?hp=05c236ba628b92972ccf7cc0f3c765d04f577b28 Merge branch 'download_folder__refactoring_observance_of_downloads_in_progress' into download_folder_update_database --- diff --git a/src/com/owncloud/android/datamodel/OCFile.java b/src/com/owncloud/android/datamodel/OCFile.java index bda6166d..e6fd4141 100644 --- a/src/com/owncloud/android/datamodel/OCFile.java +++ b/src/com/owncloud/android/datamodel/OCFile.java @@ -575,4 +575,8 @@ public class OCFile implements Parcelable, Comparable { this.mIsDownloading = isDownloading; } + public boolean isSynchronizing() { + // 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..f2a0baf7 100644 --- a/src/com/owncloud/android/files/FileMenuFilter.java +++ b/src/com/owncloud/android/files/FileMenuFilter.java @@ -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 diff --git a/src/com/owncloud/android/files/FileOperationsHelper.java b/src/com/owncloud/android/files/FileOperationsHelper.java index 4f7ccea1..c8cb2756 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()); diff --git a/src/com/owncloud/android/files/services/FileDownloader.java b/src/com/owncloud/android/files/services/FileDownloader.java index 59982771..741e30a8 100644 --- a/src/com/owncloud/android/files/services/FileDownloader.java +++ b/src/com/owncloud/android/files/services/FileDownloader.java @@ -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 } } } + */ /** diff --git a/src/com/owncloud/android/files/services/FileUploader.java b/src/com/owncloud/android/files/services/FileUploader.java index 04804402..386f1857 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) }; @@ -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; 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..bfec11cc 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,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)) { diff --git a/src/com/owncloud/android/ui/fragment/FileDetailFragment.java b/src/com/owncloud/android/ui/fragment/FileDetailFragment.java index 1e0e7ee3..dc607b51 100644 --- a/src/com/owncloud/android/ui/fragment/FileDetailFragment.java +++ b/src/com/owncloud/android/ui/fragment/FileDetailFragment.java @@ -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); diff --git a/src/com/owncloud/android/ui/fragment/OCFileListFragment.java b/src/com/owncloud/android/ui/fragment/OCFileListFragment.java index 9c85dd98..b70262ff 100644 --- a/src/com/owncloud/android/ui/fragment/OCFileListFragment.java +++ b/src/com/owncloud/android/ui/fragment/OCFileListFragment.java @@ -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); 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);