mirror of
https://github.com/nextcloud/android.git
synced 2024-11-23 13:45:35 +03:00
Show current account in uploads only
Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
parent
a380b3bbcf
commit
f8929a3193
2 changed files with 40 additions and 3 deletions
|
@ -30,6 +30,7 @@ import android.net.Uri;
|
|||
import com.evernote.android.job.JobManager;
|
||||
import com.evernote.android.job.JobRequest;
|
||||
import com.evernote.android.job.util.support.PersistableBundleCompat;
|
||||
import com.owncloud.android.authentication.AccountUtils;
|
||||
import com.owncloud.android.db.OCUpload;
|
||||
import com.owncloud.android.db.ProviderMeta.ProviderTableMeta;
|
||||
import com.owncloud.android.db.UploadResult;
|
||||
|
@ -374,6 +375,24 @@ public class UploadsStorageManager extends Observable {
|
|||
return upload;
|
||||
}
|
||||
|
||||
public OCUpload[] getCurrentAndPendingUploadsForCurrentAccount() {
|
||||
Account account = AccountUtils.getCurrentOwnCloudAccount(mContext);
|
||||
|
||||
OCUpload[] uploads = getUploads(
|
||||
ProviderTableMeta.UPLOADS_STATUS + "==" + UploadStatus.UPLOAD_IN_PROGRESS.value + " OR " +
|
||||
ProviderTableMeta.UPLOADS_LAST_RESULT + "==" + UploadResult.DELAYED_FOR_WIFI.getValue() + " OR " +
|
||||
ProviderTableMeta.UPLOADS_LAST_RESULT + "==" + UploadResult.DELAYED_FOR_CHARGING.getValue() + " AND " +
|
||||
ProviderTableMeta.UPLOADS_ACCOUNT_NAME + "==" + account.name,
|
||||
null
|
||||
);
|
||||
|
||||
//return uploads;
|
||||
|
||||
List<OCUpload> result = getPendingJobs();
|
||||
Collections.addAll(result, uploads);
|
||||
return result.toArray(uploads);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all uploads which are currently being uploaded or waiting in the queue to be uploaded.
|
||||
*/
|
||||
|
@ -443,6 +462,13 @@ public class UploadsStorageManager extends Observable {
|
|||
ProviderTableMeta.UPLOADS_STATUS + "==" + UploadStatus.UPLOAD_FAILED.value, null);
|
||||
}
|
||||
|
||||
public OCUpload[] getFinishedUploadsForCurrentAccount() {
|
||||
Account account = AccountUtils.getCurrentOwnCloudAccount(mContext);
|
||||
|
||||
return getUploads(ProviderTableMeta.UPLOADS_STATUS + "==" + UploadStatus.UPLOAD_SUCCEEDED.value + AND +
|
||||
ProviderTableMeta.UPLOADS_ACCOUNT_NAME + "==" + account.name, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all uploads which where successfully completed.
|
||||
*/
|
||||
|
@ -451,6 +477,17 @@ public class UploadsStorageManager extends Observable {
|
|||
return getUploads(ProviderTableMeta.UPLOADS_STATUS + "==" + UploadStatus.UPLOAD_SUCCEEDED.value, null);
|
||||
}
|
||||
|
||||
public OCUpload[] getFailedButNotDelayedUploadsForCurrentAccount() {
|
||||
Account account = AccountUtils.getCurrentOwnCloudAccount(mContext);
|
||||
|
||||
return getUploads(ProviderTableMeta.UPLOADS_STATUS + "==" + UploadStatus.UPLOAD_FAILED.value + AND +
|
||||
ProviderTableMeta.UPLOADS_LAST_RESULT + "<>" + UploadResult.DELAYED_FOR_WIFI.getValue() + AND +
|
||||
ProviderTableMeta.UPLOADS_LAST_RESULT + "<>" + UploadResult.DELAYED_FOR_CHARGING.getValue() + AND +
|
||||
ProviderTableMeta.UPLOADS_ACCOUNT_NAME + "==" + account.name,
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all failed uploads, except for those that were not performed due to lack of Wifi connection
|
||||
* @return Array of failed uploads, except for those that were not performed due to lack of Wifi connection.
|
||||
|
|
|
@ -149,7 +149,7 @@ public class ExpandableUploadListAdapter extends BaseExpandableListAdapter imple
|
|||
mUploadGroups[0] = new UploadGroup(mParentActivity.getString(R.string.uploads_view_group_current_uploads)) {
|
||||
@Override
|
||||
public void refresh() {
|
||||
items = mUploadsStorageManager.getCurrentAndPendingUploads();
|
||||
items = mUploadsStorageManager.getCurrentAndPendingUploadsForCurrentAccount();
|
||||
Arrays.sort(items, comparator);
|
||||
}
|
||||
|
||||
|
@ -161,7 +161,7 @@ public class ExpandableUploadListAdapter extends BaseExpandableListAdapter imple
|
|||
mUploadGroups[1] = new UploadGroup(mParentActivity.getString(R.string.uploads_view_group_failed_uploads)) {
|
||||
@Override
|
||||
public void refresh() {
|
||||
items = mUploadsStorageManager.getFailedButNotDelayedUploads();
|
||||
items = mUploadsStorageManager.getFailedButNotDelayedUploadsForCurrentAccount();
|
||||
Arrays.sort(items, comparator);
|
||||
}
|
||||
|
||||
|
@ -174,7 +174,7 @@ public class ExpandableUploadListAdapter extends BaseExpandableListAdapter imple
|
|||
mUploadGroups[2] = new UploadGroup(mParentActivity.getString(R.string.uploads_view_group_finished_uploads)) {
|
||||
@Override
|
||||
public void refresh() {
|
||||
items = mUploadsStorageManager.getFinishedUploads();
|
||||
items = mUploadsStorageManager.getFinishedUploadsForCurrentAccount();
|
||||
Arrays.sort(items, comparator);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue