'Wifi-only' condition for instant uploads fixed - uploads are not done if connection is not through Wifi

This commit is contained in:
David A. Velasco 2016-02-23 09:09:04 +01:00
parent 366a1f7c51
commit 245e8fe5c7
11 changed files with 274 additions and 124 deletions

View file

@ -33,6 +33,7 @@ import com.owncloud.android.lib.common.utils.Log_OC;
import com.owncloud.android.operations.UploadFileOperation;
import java.io.File;
import java.security.Provider;
import java.util.Observable;
/**
@ -135,6 +136,7 @@ public class UploadsStorageManager extends Observable {
cv.put(ProviderTableMeta.UPLOADS_IS_WHILE_CHARGING_ONLY, ocUpload.isWhileChargingOnly() ? 1 : 0);
cv.put(ProviderTableMeta.UPLOADS_IS_WIFI_ONLY, ocUpload.isUseWifiOnly() ? 1 : 0);
cv.put(ProviderTableMeta.UPLOADS_LAST_RESULT, ocUpload.getLastResult().getValue());
cv.put(ProviderTableMeta.UPLOADS_CREATED_BY, ocUpload.getCreadtedBy());
Uri result = getDB().insert(ProviderTableMeta.CONTENT_URI_UPLOADS, cv);
@ -459,6 +461,7 @@ public class UploadsStorageManager extends Observable {
c.getColumnIndex(ProviderTableMeta.UPLOADS_IS_WIFI_ONLY)) == 1);
upload.setLastResult(UploadResult.fromValue(
c.getInt(c.getColumnIndex(ProviderTableMeta.UPLOADS_LAST_RESULT))));
upload.setCreatedBy(c.getInt(c.getColumnIndex(ProviderTableMeta.UPLOADS_CREATED_BY)));
}
return upload;
}

View file

@ -34,6 +34,7 @@ import com.owncloud.android.datamodel.UploadsStorageManager;
import com.owncloud.android.datamodel.UploadsStorageManager.UploadStatus;
import com.owncloud.android.files.services.FileUploader;
import com.owncloud.android.lib.common.utils.Log_OC;
import com.owncloud.android.operations.UploadFileOperation;
import com.owncloud.android.utils.MimetypeIconUtil;
import com.owncloud.android.utils.UploadUtils;
@ -100,6 +101,11 @@ public class OCUpload implements Parcelable {
*/
private UploadResult mLastResult;
/**
* Defines the origin of the upload; see constants CREATED_ in {@link UploadFileOperation}
*/
private int mCreatedBy;
/**
* Main constructor
@ -151,6 +157,7 @@ public class OCUpload implements Parcelable {
mIsWhileChargingOnly = false;
mUploadStatus = UploadStatus.UPLOAD_LATER;
mLastResult = UploadResult.UNKNOWN;
mCreatedBy = UploadFileOperation.CREATED_BY_USER;
}
// Getters & Setters
@ -295,6 +302,16 @@ public class OCUpload implements Parcelable {
return mIsWhileChargingOnly;
}
public void setCreatedBy(int createdBy) {
mCreatedBy = createdBy;
}
public int getCreadtedBy() {
return mCreatedBy;
}
/**
* For debugging purposes only.
*/
@ -395,6 +412,7 @@ public class OCUpload implements Parcelable {
} catch (IllegalArgumentException x) {
mLastResult = UploadResult.UNKNOWN;
}
mCreatedBy = source.readInt();
}
@ -416,6 +434,7 @@ public class OCUpload implements Parcelable {
dest.writeInt(mIsWhileChargingOnly ? 1 : 0);
dest.writeString(mUploadStatus.name());
dest.writeString(((mLastResult == null) ? "" : mLastResult.name()));
dest.writeInt(mCreatedBy);
}

View file

@ -0,0 +1,59 @@
/**
* ownCloud Android client application
*
* @author David A. Velasco
* Copyright (C) 2016 ownCloud Inc.
* <p/>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2,
* as published by the Free Software Foundation.
* <p/>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p/>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.owncloud.android.db;
import android.content.Context;
import android.preference.PreferenceManager;
/**
* Helper to simplify reading of Preferences all around the app
*/
public class PreferenceReader {
public static boolean instantPictureUploadEnabled(Context context) {
return PreferenceManager.getDefaultSharedPreferences(context).getBoolean(
"instant_uploading",
false
);
}
public static boolean instantVideoUploadEnabled(Context context) {
return PreferenceManager.getDefaultSharedPreferences(context).getBoolean(
"instant_video_uploading",
false
);
}
public static boolean instantPictureUploadViaWiFiOnly(Context context) {
return PreferenceManager.getDefaultSharedPreferences(context).getBoolean(
"instant_upload_on_wifi",
false
);
}
public static boolean instantVideoUploadViaWiFiOnly(Context context) {
return PreferenceManager.getDefaultSharedPreferences(context).getBoolean(
"instant_video_upload_on_wifi",
false
);
}
}

View file

@ -147,8 +147,10 @@ public class ProviderMeta {
public static final String UPLOADS_IS_WIFI_ONLY = "is_wifi_only";
public static final String UPLOADS_UPLOAD_TIMESTAMP = "upload_timestamp";
public static final String UPLOADS_LAST_RESULT = "last_result";
public static final String UPLOADS_CREATED_BY = "created_by";
//public static final String UPLOADS_DEFAULT_SORT_ORDER = UPLOADS_FILE_ID + " collate nocase asc";
public static final String UPLOADS_DEFAULT_SORT_ORDER = ProviderTableMeta._ID + " collate nocase desc";
}
}

View file

@ -1,8 +1,10 @@
/**
* ownCloud Android client application
* <p/>
* @author Bartek Przybylski
* @author David A. Velasco
* Copyright (C) 2012 Bartek Przybylski
* Copyright (C) 2015 ownCloud Inc.
* Copyright (C) 2016 ownCloud Inc.
* <p/>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2,
@ -32,8 +34,10 @@ import android.provider.MediaStore.Video;
import android.support.v4.content.ContextCompat;
import com.owncloud.android.authentication.AccountUtils;
import com.owncloud.android.db.PreferenceReader;
import com.owncloud.android.files.services.FileUploader;
import com.owncloud.android.lib.common.utils.Log_OC;
import com.owncloud.android.operations.UploadFileOperation;
import com.owncloud.android.utils.FileStorageUtils;
@ -81,9 +85,9 @@ public class InstantUploadBroadcastReceiver extends BroadcastReceiver {
String file_name = null;
String mime_type = null;
Log_OC.w(TAG, "New photo received");
Log_OC.i(TAG, "New photo received");
if (!instantPictureUploadEnabled(context)) {
if (!PreferenceReader.instantPictureUploadEnabled(context)) {
Log_OC.d(TAG, "Instant picture upload disabled, ignoring new picture");
return;
}
@ -124,8 +128,16 @@ public class InstantUploadBroadcastReceiver extends BroadcastReceiver {
Log_OC.d(TAG, "Path: " + file_path + "");
int behaviour = getUploadBehaviour(context);
FileUploader.uploadNewFile(context, account, file_path, FileStorageUtils.getInstantUploadFilePath(context,
file_name), behaviour, mime_type, true, instantPictureUploadViaWiFiOnly(context));
FileUploader.uploadNewFile(
context,
account,
file_path,
FileStorageUtils.getInstantUploadFilePath(context, file_name),
behaviour,
mime_type,
true, // create parent folder if not existent
UploadFileOperation.CREATED_AS_INSTANT_PICTURE
);
}
private Integer getUploadBehaviour(Context context) {
@ -148,9 +160,9 @@ public class InstantUploadBroadcastReceiver extends BroadcastReceiver {
String file_name = null;
String mime_type = null;
Log_OC.w(TAG, "New video received");
Log_OC.i(TAG, "New video received");
if (!instantVideoUploadEnabled(context)) {
if (!PreferenceReader.instantVideoUploadEnabled(context)) {
Log_OC.d(TAG, "Instant video upload disabled, ignoring new video");
return;
}
@ -182,24 +194,9 @@ public class InstantUploadBroadcastReceiver extends BroadcastReceiver {
FileStorageUtils.getInstantVideoUploadFilePath(context, file_name),
behaviour,
mime_type,
true,
instantVideoUploadViaWiFiOnly(context)
true, // create parent folder if not existent
UploadFileOperation.CREATED_AS_INSTANT_VIDEO
);
}
public static boolean instantPictureUploadEnabled(Context context) {
return PreferenceManager.getDefaultSharedPreferences(context).getBoolean("instant_uploading", false);
}
public static boolean instantVideoUploadEnabled(Context context) {
return PreferenceManager.getDefaultSharedPreferences(context).getBoolean("instant_video_uploading", false);
}
public static boolean instantPictureUploadViaWiFiOnly(Context context) {
return PreferenceManager.getDefaultSharedPreferences(context).getBoolean("instant_upload_on_wifi", false);
}
public static boolean instantVideoUploadViaWiFiOnly(Context context) {
return PreferenceManager.getDefaultSharedPreferences(context).getBoolean("instant_video_upload_on_wifi", false);
}
}

View file

@ -34,6 +34,7 @@ import android.os.Bundle;
import android.preference.PreferenceManager;
import com.owncloud.android.authentication.AccountUtils;
import com.owncloud.android.db.PreferenceReader;
import com.owncloud.android.lib.common.utils.Log_OC;
import com.owncloud.android.utils.FileStorageUtils;
@ -98,8 +99,8 @@ public class ConnectivityActionReceiver extends BroadcastReceiver {
}
private void wifiDisconnected(Context context) {
boolean instantPictureWiFiOnly = instantPictureUploadViaWiFiOnly(context);
boolean instantVideoWiFiOnly = instantVideoUploadViaWiFiOnly(context);
boolean instantPictureWiFiOnly = PreferenceReader.instantPictureUploadViaWiFiOnly(context);
boolean instantVideoWiFiOnly = PreferenceReader.instantVideoUploadViaWiFiOnly(context);
if (instantPictureWiFiOnly || instantVideoWiFiOnly) {
Account account = AccountUtils.getCurrentOwnCloudAccount(context);
if (account == null) {
@ -131,18 +132,4 @@ public class ConnectivityActionReceiver extends BroadcastReceiver {
}
private static boolean instantPictureUploadViaWiFiOnly(Context context) {
return PreferenceManager.getDefaultSharedPreferences(context).getBoolean(
"instant_upload_on_wifi",
false
);
}
private static boolean instantVideoUploadViaWiFiOnly(Context context) {
return PreferenceManager.getDefaultSharedPreferences(context).getBoolean(
"instant_video_upload_on_wifi",
false
);
}
}

View file

@ -2,7 +2,7 @@
* ownCloud Android client application
*
* @author Bartek Przybylski
* @authro masensio
* @author masensio
* @author LukeOwnCloud
* @author David A. Velasco
* Copyright (C) 2012 Bartek Przybylski
@ -50,6 +50,7 @@ import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.datamodel.UploadsStorageManager;
import com.owncloud.android.datamodel.UploadsStorageManager.UploadStatus;
import com.owncloud.android.db.OCUpload;
import com.owncloud.android.db.PreferenceReader;
import com.owncloud.android.db.UploadResult;
import com.owncloud.android.lib.common.OwnCloudAccount;
import com.owncloud.android.lib.common.OwnCloudClient;
@ -136,9 +137,9 @@ public class FileUploader extends Service
*/
public static final String KEY_CREATE_REMOTE_FOLDER = "CREATE_REMOTE_FOLDER";
/**
* Set to true if upload is to performed only when connected via wifi.
* Key to signal what is the origin of the upload request
*/
public static final String KEY_WIFI_ONLY = "WIFI_ONLY";
public static final String KEY_CREATED_BY = "CREATED_BY";
/**
* Set to true if upload is to performed only when phone is being charged.
*/
@ -260,7 +261,7 @@ public class FileUploader extends Service
* Call to upload several new files
*/
public static void uploadNewFile(Context context, Account account, String[] localPaths, String[] remotePaths,
Integer behaviour, String mimeType, Boolean createRemoteFolder, Boolean wifiOnly) {
Integer behaviour, String mimeType, Boolean createRemoteFolder, int createdBy) {
Log_OC.d(TAG, "FileUploader.uploadNewFile()");
Intent intent = new Intent(context, FileUploader.class);
@ -270,7 +271,7 @@ public class FileUploader extends Service
intent.putExtra(FileUploader.KEY_LOCAL_BEHAVIOUR, behaviour);
intent.putExtra(FileUploader.KEY_MIME_TYPE, mimeType);
intent.putExtra(FileUploader.KEY_CREATE_REMOTE_FOLDER, createRemoteFolder);
intent.putExtra(FileUploader.KEY_WIFI_ONLY, wifiOnly);
intent.putExtra(FileUploader.KEY_CREATED_BY, createdBy);
context.startService(intent);
}
@ -279,10 +280,10 @@ public class FileUploader extends Service
* Call to upload a new single file
*/
public static void uploadNewFile(Context context, Account account, String localPath, String remotePath, int
behaviour, String mimeType, boolean createRemoteFile, boolean wifiOnly) {
behaviour, String mimeType, boolean createRemoteFile, int createdBy) {
uploadNewFile(context, account, new String[]{localPath}, new String[]{remotePath}, behaviour, mimeType,
createRemoteFile, wifiOnly);
createRemoteFile, createdBy);
}
/**
@ -440,7 +441,7 @@ public class FileUploader extends Service
int localAction = intent.getIntExtra(KEY_LOCAL_BEHAVIOUR, LOCAL_BEHAVIOUR_FORGET);
boolean isCreateRemoteFolder = intent.getBooleanExtra(KEY_CREATE_REMOTE_FOLDER, false);
boolean isUseWifiOnly = intent.getBooleanExtra(KEY_WIFI_ONLY, true);
int createdBy = intent.getIntExtra(KEY_CREATED_BY, UploadFileOperation.CREATED_BY_USER);
boolean isWhileChargingOnly = intent.getBooleanExtra(KEY_WHILE_CHARGING_ONLY, false);
//long uploadTimestamp = intent.getLongExtra(KEY_UPLOAD_TIMESTAMP, -1);
@ -492,6 +493,7 @@ public class FileUploader extends Service
localAction,
this
);
newUpload.setCreatedBy(createdBy);
if (isCreateRemoteFolder) {
newUpload.setRemoteFolderToBeCreated();
}
@ -502,9 +504,10 @@ public class FileUploader extends Service
OCUpload ocUpload = new OCUpload(files[i], account);
ocUpload.setForceOverwrite(forceOverwrite);
ocUpload.setCreateRemoteFolder(isCreateRemoteFolder);
ocUpload.setCreatedBy(createdBy);
ocUpload.setLocalAction(localAction);
ocUpload.setUseWifiOnly(isUseWifiOnly);
ocUpload.setWhileChargingOnly(isWhileChargingOnly);
/*ocUpload.setUseWifiOnly(isUseWifiOnly);
ocUpload.setWhileChargingOnly(isWhileChargingOnly);*/
ocUpload.setUploadStatus(UploadStatus.UPLOAD_LATER);
// storagePath inside upload is the temporary path. file
@ -551,16 +554,13 @@ public class FileUploader extends Service
account,
upload,
chunked,
upload.isForceOverwrite(),
upload.getLocalAction(),
upload.isForceOverwrite(), // TODO should be read from DB?
upload.getLocalAction(), // TODO should be read from DB?
this
);
if (upload.isCreateRemoteFolder()) {
newUpload.setRemoteFolderToBeCreated();
}
newUpload.addDatatransferProgressListener(this);
newUpload.addDatatransferProgressListener((FileUploaderBinder) mBinder);
newUpload.setOCUploadId(upload.getUploadId());
Pair<String, String> putResult = mPendingUploads.putIfAbsent(
account.name,
@ -920,70 +920,86 @@ public class FileUploader extends Service
mCurrentUpload = mPendingUploads.get(uploadKey);
if (mCurrentUpload != null) {
// Detect if the account exists
if (AccountUtils.exists(mCurrentUpload.getAccount(), getApplicationContext())) {
Log_OC.d(TAG, "Account " + mCurrentUpload.getAccount().name + " exists");
mUploadsStorageManager.updateDatabaseUploadStart(mCurrentUpload);
/// Check account existence
if (!AccountUtils.exists(mCurrentUpload.getAccount(), this)) {
Log_OC.w(TAG, "Account " + mCurrentUpload.getAccount().name +
" does not exist anymore -> cancelling all its uploads");
cancelUploadsForAccount(mCurrentUpload.getAccount());
return;
}
notifyUploadStart(mCurrentUpload);
/// Check that connectivity conditions are met
if (mCurrentUpload.isInstantPicture() &&
PreferenceReader.instantPictureUploadViaWiFiOnly(this)) {
RemoteOperationResult uploadResult = null;
Log_OC.d(TAG, "Upload delayed until WiFi is available: " + mCurrentUpload.getRemotePath());
// TODO - update mUploadsStorageManager
return;
}
if (mCurrentUpload.isInstantVideo() &&
PreferenceReader.instantVideoUploadViaWiFiOnly(this)) {
try {
/// prepare client object to send the request to the ownCloud server
if (mCurrentAccount == null || !mCurrentAccount.equals(mCurrentUpload.getAccount())) {
mCurrentAccount = mCurrentUpload.getAccount();
mStorageManager = new FileDataStorageManager(
mCurrentAccount,
getContentResolver()
);
} // else, reuse storage manager from previous operation
Log_OC.d(TAG, "Upload delayed until WiFi is available: " + mCurrentUpload.getRemotePath());
// TODO - update mUploadsStorageManager
return;
}
// always get client from client manager, to get fresh credentials in case of update
OwnCloudAccount ocAccount = new OwnCloudAccount(mCurrentAccount, this);
mUploadClient = OwnCloudClientManagerFactory.getDefaultSingleton().
getClientFor(ocAccount, this);
/// OK, let's upload
mUploadsStorageManager.updateDatabaseUploadStart(mCurrentUpload);
/// perform the upload
uploadResult = mCurrentUpload.execute(mUploadClient, mStorageManager);
notifyUploadStart(mCurrentUpload);
RemoteOperationResult uploadResult = null;
try {
/// prepare client object to send the request to the ownCloud server
if (mCurrentAccount == null || !mCurrentAccount.equals(mCurrentUpload.getAccount())) {
mCurrentAccount = mCurrentUpload.getAccount();
mStorageManager = new FileDataStorageManager(
mCurrentAccount,
getContentResolver()
);
} // else, reuse storage manager from previous operation
// always get client from client manager, to get fresh credentials in case of update
OwnCloudAccount ocAccount = new OwnCloudAccount(mCurrentAccount, this);
mUploadClient = OwnCloudClientManagerFactory.getDefaultSingleton().
getClientFor(ocAccount, this);
/// perform the upload
uploadResult = mCurrentUpload.execute(mUploadClient, mStorageManager);
} catch (Exception e) {
Log_OC.e(TAG, "Error uploading", e);
uploadResult = new RemoteOperationResult(e);
} catch (Exception e) {
Log_OC.e(TAG, "Error uploading", e);
uploadResult = new RemoteOperationResult(e);
} finally {
Pair<UploadFileOperation, String> removeResult;
if (mCurrentUpload.wasRenamed()) {
removeResult = mPendingUploads.removePayload(
mCurrentAccount.name,
mCurrentUpload.getOldFile().getRemotePath()
);
/** TODO: grant that name is also updated for mCurrentUpload.getOCUploadId */
} finally {
Pair<UploadFileOperation, String> removeResult;
if (mCurrentUpload.wasRenamed()) {
removeResult = mPendingUploads.removePayload(
mCurrentAccount.name,
mCurrentUpload.getOldFile().getRemotePath()
);
/** TODO: grant that name is also updated for mCurrentUpload.getOCUploadId */
} else {
removeResult = mPendingUploads.removePayload(
mCurrentAccount.name,
mCurrentUpload.getRemotePath()
);
}
mUploadsStorageManager.updateDatabaseUploadResult(uploadResult, mCurrentUpload);
/// notify result
notifyUploadResult(mCurrentUpload, uploadResult);
sendBroadcastUploadFinished(mCurrentUpload, uploadResult, removeResult.second);
} else {
removeResult = mPendingUploads.removePayload(
mCurrentAccount.name,
mCurrentUpload.getRemotePath()
);
}
} else {
// Cancel the transfer
Log_OC.d(TAG, "Account " + mCurrentUpload.getAccount().toString() +
" doesn't exist");
cancelUploadsForAccount(mCurrentUpload.getAccount());
mUploadsStorageManager.updateDatabaseUploadResult(uploadResult, mCurrentUpload);
/// notify result
notifyUploadResult(mCurrentUpload, uploadResult);
sendBroadcastUploadFinished(mCurrentUpload, uploadResult, removeResult.second);
}
}
}

View file

@ -2,7 +2,7 @@
* ownCloud Android client application
*
* @author David A. Velasco
* Copyright (C) 2015 ownCloud Inc.
* Copyright (C) 2016 ownCloud Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2,
@ -72,6 +72,11 @@ public class UploadFileOperation extends SyncOperation {
private static final String MIME_TYPE_PDF = "application/pdf";
private static final String FILE_EXTENSION_PDF = ".pdf";
public static final int CREATED_BY_USER = 0;
public static final int CREATED_AS_INSTANT_PICTURE = 1;
public static final int CREATED_AS_INSTANT_VIDEO = 2;
/**
* Checks if content provider, using the content:// scheme, returns a file with mime-type
* 'application/pdf' but file has not extension
@ -138,6 +143,8 @@ public class UploadFileOperation extends SyncOperation {
private boolean mRemoteFolderToBeCreated = false;
private boolean mForceOverwrite = false;
private int mLocalBehaviour = FileUploader.LOCAL_BEHAVIOUR_COPY;
private int mCreatedBy = CREATED_BY_USER;
private boolean mWasRenamed = false;
private String mOriginalFileName = null;
private long mOCUploadId = -1;
@ -157,11 +164,12 @@ public class UploadFileOperation extends SyncOperation {
protected RequestEntity mEntity = null;
public UploadFileOperation(Account account,
OCFile file,
boolean chunked,
boolean forceOverwrite,
int localBehaviour,
Context context) {
OCFile file,
boolean chunked,
boolean forceOverwrite,
int localBehaviour,
Context context
) {
if (account == null)
throw new IllegalArgumentException("Illegal NULL account in UploadFileOperation " +
"creation");
@ -185,11 +193,11 @@ public class UploadFileOperation extends SyncOperation {
}
public UploadFileOperation(Account account,
OCUpload upload,
boolean chunked,
boolean forceOverwrite,
int localBehaviour,
Context context
OCUpload upload,
boolean chunked,
boolean forceOverwrite,
int localBehaviour,
Context context
) {
if (account == null)
throw new IllegalArgumentException("Illegal NULL account in UploadFileOperation " +
@ -215,6 +223,9 @@ public class UploadFileOperation extends SyncOperation {
mOriginalStoragePath = mFile.getStoragePath();
mOriginalFileName = mFile.getFileName();
mContext = context;
mOCUploadId = upload.getUploadId();
mCreatedBy = upload.getCreadtedBy();
mRemoteFolderToBeCreated = upload.isCreateRemoteFolder();
}
public Account getAccount() {
@ -261,6 +272,25 @@ public class UploadFileOperation extends SyncOperation {
return mWasRenamed;
}
public void setCreatedBy(int createdBy) {
mCreatedBy = createdBy;
if (createdBy < CREATED_BY_USER || CREATED_AS_INSTANT_VIDEO < createdBy) {
mCreatedBy = CREATED_BY_USER;
}
}
public int getCreatedBy () {
return mCreatedBy;
}
public boolean isInstantPicture() {
return mCreatedBy == CREATED_AS_INSTANT_PICTURE;
}
public boolean isInstantVideo() {
return mCreatedBy == CREATED_AS_INSTANT_VIDEO;
}
public void setOCUploadId(long id){
mOCUploadId = id;
}

View file

@ -858,7 +858,9 @@ public class FileContentProvider extends ContentProvider {
+ ProviderTableMeta.UPLOADS_IS_WHILE_CHARGING_ONLY + " INTEGER, " // boolean
+ ProviderTableMeta.UPLOADS_IS_WIFI_ONLY + " INTEGER, " // boolean
+ ProviderTableMeta.UPLOADS_UPLOAD_TIMESTAMP + " INTEGER, "
+ ProviderTableMeta.UPLOADS_LAST_RESULT + " INTEGER );" ); // Upload LastResult
+ ProviderTableMeta.UPLOADS_LAST_RESULT + " INTEGER, " // Upload LastResult
+ ProviderTableMeta.UPLOADS_CREATED_BY + " INTEGER );" // Upload createdBy
);
/* before:

View file

@ -81,6 +81,7 @@ import com.owncloud.android.operations.RefreshFolderOperation;
import com.owncloud.android.operations.RemoveFileOperation;
import com.owncloud.android.operations.RenameFileOperation;
import com.owncloud.android.operations.SynchronizeFileOperation;
import com.owncloud.android.operations.UploadFileOperation;
import com.owncloud.android.services.observer.FileObserverService;
import com.owncloud.android.syncadapter.FileSyncAdapter;
import com.owncloud.android.ui.dialog.ConfirmationDialogFragment;
@ -735,7 +736,16 @@ public class FileDisplayActivity extends HookActivity implements
int behaviour = (resultCode == UploadFilesActivity.RESULT_OK_AND_MOVE) ? FileUploader
.LOCAL_BEHAVIOUR_MOVE : FileUploader.LOCAL_BEHAVIOUR_COPY;
FileUploader.uploadNewFile(this, getAccount(), filePaths, remotePaths, behaviour, null, false, false);
FileUploader.uploadNewFile(
this,
getAccount(),
filePaths,
remotePaths,
behaviour,
null, // MIME type will be detected from file name
false, // do not create parent folder if not existent
UploadFileOperation.CREATED_BY_USER
);
} else {
Log_OC.d(TAG, "User clicked on 'Update' with no selection");
@ -810,7 +820,16 @@ public class FileDisplayActivity extends HookActivity implements
int behaviour = (resultCode == UploadFilesActivity.RESULT_OK_AND_MOVE) ? FileUploader.LOCAL_BEHAVIOUR_MOVE :
FileUploader.LOCAL_BEHAVIOUR_COPY;
FileUploader.uploadNewFile(this, getAccount(), filePath, remotePath, behaviour, mimeType, false, false);
FileUploader.uploadNewFile(
this,
getAccount(),
filePath,
remotePath,
behaviour,
mimeType,
false, // do not create parent folder if not existent
UploadFileOperation.CREATED_BY_USER
);
}

View file

@ -73,6 +73,7 @@ import com.owncloud.android.lib.common.operations.RemoteOperation;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.lib.common.utils.Log_OC;
import com.owncloud.android.operations.CreateFolderOperation;
import com.owncloud.android.operations.UploadFileOperation;
import com.owncloud.android.ui.dialog.CreateFolderDialogFragment;
import com.owncloud.android.ui.dialog.LoadingDialog;
import com.owncloud.android.utils.CopyTmpFileAsyncTask;
@ -563,8 +564,16 @@ public class Uploader extends FileActivity
throw new SecurityException();
}
FileUploader.uploadNewFile(this, getAccount(), local.toArray(new String[local.size()]), remote
.toArray(new String[remote.size()]), FileUploader.LOCAL_BEHAVIOUR_FORGET, null, false, false);
FileUploader.uploadNewFile(
this,
getAccount(),
local.toArray(new String[local.size()]),
remote.toArray(new String[remote.size()]),
FileUploader.LOCAL_BEHAVIOUR_FORGET,
null, // MIME type will be detected from file name
false, // do not create parent folder if not existent
UploadFileOperation.CREATED_BY_USER
);
//Save the path to shared preferences
SharedPreferences.Editor appPrefs = PreferenceManager
@ -693,8 +702,15 @@ public class Uploader extends FileActivity
dismissWaitingCopyDialog();
}
if (result != null) {
FileUploader.uploadNewFile(this, getAccount(), result, mRemoteCacheData.get(index), FileUploader
.LOCAL_BEHAVIOUR_FORGET, null, false, false);
FileUploader.uploadNewFile(
this, getAccount(),
result,
mRemoteCacheData.get(index),
FileUploader.LOCAL_BEHAVIOUR_FORGET,
null, // MIME type will be detected from file name
false, // do not create parent folder if not existent
UploadFileOperation.CREATED_BY_USER
);
} else {
String message = String.format(getString(R.string.uploader_error_forbidden_content),