Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ buildscript {
ext {
// SDK
sdkCompileVersion = 28
sdkMinVersion = 19
sdkMinVersion = 21
sdkTargetVersion = 28

// Android jetpack
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,20 +169,6 @@ private void wifiConnected(Context context) {
Log_OC.d(TAG, "Requesting retry of camera uploads (& friends)");
TransferRequester requester = new TransferRequester();

//Avoid duplicate uploads, because uploads retry is also managed in FileUploader
//by using jobs in versions 5 or higher
if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.LOLLIPOP) {
requester.retryFailedUploads(
MainApp.Companion.getAppContext(),
null,
// for the interrupted when Wifi fell, if any
// (side effect: any upload failed due to network error will be
// retried too, instant or not)
UploadResult.NETWORK_CONNECTION,
true
);
}

requester.retryFailedUploads(
MainApp.Companion.getAppContext(),
null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ public class AvailableOfflineHandler {
private String mAccountName;
private JobScheduler mJobScheduler;

@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public AvailableOfflineHandler(Context context, String accountName) {
mAccountName = accountName;
mJobScheduler = (JobScheduler) context.getSystemService(Context.JOB_SCHEDULER_SERVICE);
Expand All @@ -55,7 +54,6 @@ public AvailableOfflineHandler(Context context, String accountName) {
/**
* Schedule a periodic job to check whether recently updated available offline files need to be synchronized
*/
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public void scheduleAvailableOfflineJob(Context context) {
ComponentName serviceComponent = new ComponentName(context, AvailableOfflineSyncJobService.class);
JobInfo.Builder builder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
* This job should be executed every 15 minutes since a file is set as available offline for the first time and stopped
* when there's no available offline files
*/
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public class AvailableOfflineSyncJobService extends JobService {
private static final String TAG = "AvOfflineSyncJobService";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,64 +55,60 @@ public CameraUploadsHandler(CameraUploadsConfiguration cameraUploadsConfiguratio
* Schedule a periodic job to check pictures and videos to be uploaded
*/
public void scheduleCameraUploadsSyncJob(Context context) {
// DB Connection
CameraUploadsSyncStorageManager cameraUploadsSyncStorageManager = new
CameraUploadsSyncStorageManager(context.getContentResolver());

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {

// DB Connection
CameraUploadsSyncStorageManager cameraUploadsSyncStorageManager = new
CameraUploadsSyncStorageManager(context.getContentResolver());

OCCameraUploadSync ocCameraUploadSync = cameraUploadsSyncStorageManager.
getCameraUploadSync(null, null, null);
OCCameraUploadSync ocCameraUploadSync = cameraUploadsSyncStorageManager.
getCameraUploadSync(null, null, null);

// Initialize synchronization timestamps for pictures/videos, if needed
if (ocCameraUploadSync == null ||
ocCameraUploadSync.getPicturesLastSync() == 0 ||
ocCameraUploadSync.getVideosLastSync() == 0) {
// Initialize synchronization timestamps for pictures/videos, if needed
if (ocCameraUploadSync == null ||
ocCameraUploadSync.getPicturesLastSync() == 0 ||
ocCameraUploadSync.getVideosLastSync() == 0) {

initializeCameraUploadSync(cameraUploadsSyncStorageManager, ocCameraUploadSync);
}
initializeCameraUploadSync(cameraUploadsSyncStorageManager, ocCameraUploadSync);
}

ComponentName serviceComponent = new ComponentName(context, CameraUploadsSyncJobService.class);
JobInfo.Builder builder;
ComponentName serviceComponent = new ComponentName(context, CameraUploadsSyncJobService.class);
JobInfo.Builder builder;

builder = new JobInfo.Builder(JOB_ID_CAMERA_UPLOAD, serviceComponent);
builder = new JobInfo.Builder(JOB_ID_CAMERA_UPLOAD, serviceComponent);

builder.setPersisted(true);
builder.setPersisted(true);

// Execute job every 15 minutes
builder.setPeriodic(MILLISECONDS_INTERVAL_CAMERA_UPLOAD);
// Execute job every 15 minutes
builder.setPeriodic(MILLISECONDS_INTERVAL_CAMERA_UPLOAD);

// Extra data
PersistableBundle extras = new PersistableBundle();
// Extra data
PersistableBundle extras = new PersistableBundle();

extras.putInt(Extras.EXTRA_CAMERA_UPLOADS_SYNC_JOB_ID, JOB_ID_CAMERA_UPLOAD);
extras.putInt(Extras.EXTRA_CAMERA_UPLOADS_SYNC_JOB_ID, JOB_ID_CAMERA_UPLOAD);

extras.putString(Extras.EXTRA_ACCOUNT_NAME, mCameraUploadsConfig.getUploadAccountName());
extras.putString(Extras.EXTRA_ACCOUNT_NAME, mCameraUploadsConfig.getUploadAccountName());

if (mCameraUploadsConfig.isEnabledForPictures()) {
extras.putString(Extras.EXTRA_CAMERA_UPLOADS_PICTURES_PATH, mCameraUploadsConfig.
getUploadPathForPictures());
}
if (mCameraUploadsConfig.isEnabledForPictures()) {
extras.putString(Extras.EXTRA_CAMERA_UPLOADS_PICTURES_PATH, mCameraUploadsConfig.
getUploadPathForPictures());
}

if (mCameraUploadsConfig.isEnabledForVideos()) {
extras.putString(Extras.EXTRA_CAMERA_UPLOADS_VIDEOS_PATH, mCameraUploadsConfig.
getUploadPathForVideos());
}
if (mCameraUploadsConfig.isEnabledForVideos()) {
extras.putString(Extras.EXTRA_CAMERA_UPLOADS_VIDEOS_PATH, mCameraUploadsConfig.
getUploadPathForVideos());
}

extras.putString(Extras.EXTRA_CAMERA_UPLOADS_SOURCE_PATH, mCameraUploadsConfig.getSourcePath());
extras.putString(Extras.EXTRA_CAMERA_UPLOADS_SOURCE_PATH, mCameraUploadsConfig.getSourcePath());

extras.putInt(Extras.EXTRA_CAMERA_UPLOADS_BEHAVIOR_AFTER_UPLOAD, mCameraUploadsConfig.
getBehaviourAfterUpload());
extras.putInt(Extras.EXTRA_CAMERA_UPLOADS_BEHAVIOR_AFTER_UPLOAD, mCameraUploadsConfig.
getBehaviourAfterUpload());

builder.setExtras(extras);
builder.setExtras(extras);

Log_OC.d(TAG, "Scheduling a CameraUploadsSyncJobService");
Log_OC.d(TAG, "Scheduling a CameraUploadsSyncJobService");

JobScheduler jobScheduler = (JobScheduler) context.getSystemService(Context.JOB_SCHEDULER_SERVICE);
JobScheduler jobScheduler = (JobScheduler) context.getSystemService(Context.JOB_SCHEDULER_SERVICE);

jobScheduler.schedule(builder.build());
}
jobScheduler.schedule(builder.build());
}

/**
Expand Down Expand Up @@ -161,6 +157,7 @@ private void initializeCameraUploadSync(CameraUploadsSyncStorageManager cameraUp

/**
* Update timestamp (in milliseconds) from which to start checking pictures to upload
*
* @param lastSyncTimestamp
*/
public void updatePicturesLastSync(Context context, long lastSyncTimestamp) {
Expand All @@ -181,6 +178,7 @@ public void updatePicturesLastSync(Context context, long lastSyncTimestamp) {

/**
* Update timestamp (in milliseconds) from which to start checking videos to upload
*
* @param lastSyncTimestamp
*/
public void updateVideosLastSync(Context context, long lastSyncTimestamp) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
import java.util.Date;
import java.util.Locale;

@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public class CameraUploadsSyncJobService extends JobService {

private static final String TAG = CameraUploadsSyncJobService.class.getSimpleName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import com.owncloud.android.lib.common.utils.Log_OC;
import com.owncloud.android.utils.Extras;

@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public class RetryDownloadJobService extends JobService {

private static final String TAG = RetryDownloadJobService.class.getName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import com.owncloud.android.lib.common.utils.Log_OC;
import com.owncloud.android.utils.Extras;

@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public class RetryUploadJobService extends JobService {

private static final String TAG = RetryUploadJobService.class.getName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@
/**
* Facade class providing methods to ease requesting commands to transfer services {@link FileUploader} and
* {@link FileDownloader}.
*
* <p>
* Protects client objects from the verbosity of {@link android.content.Intent}s.
*
* <p>
* TODO add methods for {@link FileDownloader}, right now it's just about uploads
*/

Expand Down Expand Up @@ -171,13 +171,13 @@ public void retry(Context context, OCUpload upload, boolean requestedFromWifiBac
/**
* Retry a subset of all the stored failed uploads.
*
* @param context Caller {@link Context}
* @param account If not null, only failed uploads to this OC account will be retried; otherwise,
* uploads of all accounts will be retried.
* @param uploadResult If not null, only failed uploads with the result specified will be retried;
* otherwise, failed uploads due to any result will be retried.
* @param requestedFromWifiBackEvent true if the retry was requested because wifi connection was back,
* false otherwise
* @param context Caller {@link Context}
* @param account If not null, only failed uploads to this OC account will be retried; otherwise,
* uploads of all accounts will be retried.
* @param uploadResult If not null, only failed uploads with the result specified will be retried;
* otherwise, failed uploads due to any result will be retried.
* @param requestedFromWifiBackEvent true if the retry was requested because wifi connection was back,
* false otherwise
*/
public void retryFailedUploads(Context context, Account account, UploadResult uploadResult,
boolean requestedFromWifiBackEvent) {
Expand All @@ -201,9 +201,9 @@ public void retryFailedUploads(Context context, Account account, UploadResult up
/**
* Private implementation of retry.
*
* @param context Caller {@link Context}
* @param account OC account where the upload will be retried.
* @param upload Persisted upload to retry.
* @param context Caller {@link Context}
* @param account OC account where the upload will be retried.
* @param upload Persisted upload to retry.
* @param requestedFromWifiBackEvent true if the retry was requested because wifi connection was back,
* false otherwise
*/
Expand Down Expand Up @@ -235,8 +235,8 @@ private void retry(Context context, Account account, OCUpload upload, boolean re
/**
* Return 'true' when conditions for a scheduled retry are met.
*
* @param context Caller {@link Context}
* @return 'true' when conditions for a scheduled retry are met, 'false' otherwise.
* @param context Caller {@link Context}
* @return 'true' when conditions for a scheduled retry are met, 'false' otherwise.
*/
boolean shouldScheduleRetry(Context context, Exception exception) {
return (
Expand All @@ -251,10 +251,10 @@ boolean shouldScheduleRetry(Context context, Exception exception) {
* Schedule a future retry of an upload, to be done when a connection via an unmetered network (free Wifi)
* is available.
*
* @param context Caller {@link Context}.
* @param jobId Identifier to set to the retry job.
* @param accountName Local name of the OC account where the upload will be retried.
* @param remotePath Full path of the file to upload, relative to root of the OC account.
* @param context Caller {@link Context}.
* @param jobId Identifier to set to the retry job.
* @param accountName Local name of the OC account where the upload will be retried.
* @param remotePath Full path of the file to upload, relative to root of the OC account.
*/
void scheduleUpload(Context context, int jobId, String accountName, String remotePath) {
boolean scheduled = scheduleTransfer(
Expand All @@ -281,10 +281,10 @@ void scheduleUpload(Context context, int jobId, String accountName, String remot
* Schedule a future retry of a download, to be done when a connection via an unmetered network (free Wifi)
* is available.
*
* @param context Caller {@link Context}.
* @param jobId Identifier to set to the retry job.
* @param accountName Local name of the OC account where the download will be retried.
* @param remotePath Full path of the file to download, relative to root of the OC account.
* @param context Caller {@link Context}.
* @param jobId Identifier to set to the retry job.
* @param accountName Local name of the OC account where the download will be retried.
* @param remotePath Full path of the file to download, relative to root of the OC account.
*/
void scheduleDownload(Context context, int jobId, String accountName, String remotePath) {
boolean scheduled = scheduleTransfer(
Expand All @@ -311,12 +311,12 @@ void scheduleDownload(Context context, int jobId, String accountName, String rem
* Schedule a future transfer of an upload, to be done when a connection via an unmetered network (free Wifi)
* is available.
*
* @param context Caller {@link Context}.
* @param scheduledRetryService Class of the appropriate retry service, either to retry downloads
* or to retry uploads.
* @param jobId Identifier to set to the retry job.
* @param accountName Local name of the OC account where the upload will be retried.
* @param remotePath Full path of the file to upload, relative to root of the OC account.
* @param context Caller {@link Context}.
* @param scheduledRetryService Class of the appropriate retry service, either to retry downloads
* or to retry uploads.
* @param jobId Identifier to set to the retry job.
* @param accountName Local name of the OC account where the upload will be retried.
* @param remotePath Full path of the file to upload, relative to root of the OC account.
*/
private boolean scheduleTransfer(
Context context,
Expand All @@ -325,12 +325,6 @@ private boolean scheduleTransfer(
String accountName,
String remotePath
) {

// JobShceduler requires Android >= 5.0 ; do not remove this protection while minSdkVersion is lower
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
return false;
}

ComponentName serviceComponent = new ComponentName(
context,
scheduledRetryService
Expand Down Expand Up @@ -361,9 +355,10 @@ private boolean scheduleTransfer(

/**
* Retrieve the type of network connection required to schedule the last upload for an account
*
* @param context
* @param accountName
* @param remotePath to upload the file
* @param remotePath to upload the file
* @return 2 if only wifi is required, 1 if any internet connection is required (wifi or cellular)
*/
private int getRequiredNetworkType(Context context, String accountName, String remotePath) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,7 @@ private void initControllerView(View v) {
if (mProgress != null) {
if (mProgress instanceof SeekBar) {
SeekBar seeker = (SeekBar) mProgress;
DisplayUtils.colorPreLollipopHorizontalSeekBar(seeker);
seeker.setOnSeekBarChangeListener(this);
} else {
DisplayUtils.colorPreLollipopHorizontalProgressBar(mProgress);
}
mProgress.setMax(1000);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,7 @@ class FileCursor(projection: Array<String>?) : MatrixCursor(projection ?: DEFAUL
flags = flags or Document.FLAG_DIR_SUPPORTS_CREATE
}

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
flags = flags or Document.FLAG_SUPPORTS_RENAME
}
flags = flags or Document.FLAG_SUPPORTS_RENAME

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
flags = flags or Document.FLAG_SUPPORTS_COPY
Expand Down
Loading