Show current account in uploads only

Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
Mario Danic 2017-07-07 21:09:58 +02:00 committed by AndyScherzinger
parent a380b3bbcf
commit f8929a3193
No known key found for this signature in database
GPG key ID: 6CADC7E3523C308B
2 changed files with 40 additions and 3 deletions

View file

@ -30,6 +30,7 @@ import android.net.Uri;
import com.evernote.android.job.JobManager; import com.evernote.android.job.JobManager;
import com.evernote.android.job.JobRequest; import com.evernote.android.job.JobRequest;
import com.evernote.android.job.util.support.PersistableBundleCompat; 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.OCUpload;
import com.owncloud.android.db.ProviderMeta.ProviderTableMeta; import com.owncloud.android.db.ProviderMeta.ProviderTableMeta;
import com.owncloud.android.db.UploadResult; import com.owncloud.android.db.UploadResult;
@ -374,6 +375,24 @@ public class UploadsStorageManager extends Observable {
return upload; 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. * 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); 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. * 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); 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 * 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. * @return Array of failed uploads, except for those that were not performed due to lack of Wifi connection.

View file

@ -149,7 +149,7 @@ public class ExpandableUploadListAdapter extends BaseExpandableListAdapter imple
mUploadGroups[0] = new UploadGroup(mParentActivity.getString(R.string.uploads_view_group_current_uploads)) { mUploadGroups[0] = new UploadGroup(mParentActivity.getString(R.string.uploads_view_group_current_uploads)) {
@Override @Override
public void refresh() { public void refresh() {
items = mUploadsStorageManager.getCurrentAndPendingUploads(); items = mUploadsStorageManager.getCurrentAndPendingUploadsForCurrentAccount();
Arrays.sort(items, comparator); 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)) { mUploadGroups[1] = new UploadGroup(mParentActivity.getString(R.string.uploads_view_group_failed_uploads)) {
@Override @Override
public void refresh() { public void refresh() {
items = mUploadsStorageManager.getFailedButNotDelayedUploads(); items = mUploadsStorageManager.getFailedButNotDelayedUploadsForCurrentAccount();
Arrays.sort(items, comparator); 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)) { mUploadGroups[2] = new UploadGroup(mParentActivity.getString(R.string.uploads_view_group_finished_uploads)) {
@Override @Override
public void refresh() { public void refresh() {
items = mUploadsStorageManager.getFinishedUploads(); items = mUploadsStorageManager.getFinishedUploadsForCurrentAccount();
Arrays.sort(items, comparator); Arrays.sort(items, comparator);
} }