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 scripts/analysis/lint-results.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
DO NOT TOUCH; GENERATED BY DRONE
<span class="mdl-layout-title">Lint Report: 96 warnings</span>
<span class="mdl-layout-title">Lint Report: 95 warnings</span>
Original file line number Diff line number Diff line change
Expand Up @@ -993,6 +993,7 @@ public boolean saveShare(OCShare share) {
cv.put(ProviderTableMeta.OCSHARES_ACCOUNT_OWNER, account.name);
cv.put(ProviderTableMeta.OCSHARES_IS_PASSWORD_PROTECTED, share.isPasswordProtected() ? 1 : 0);
cv.put(ProviderTableMeta.OCSHARES_NOTE, share.getNote());
cv.put(ProviderTableMeta.OCSHARES_HIDE_DOWNLOAD, share.isHideFileDownload());

if (shareExistsForRemoteId(share.getRemoteId())) {// for renamed files; no more delete and create
overriden = true;
Expand Down Expand Up @@ -1199,6 +1200,7 @@ private OCShare createShareInstance(Cursor c) {
share.setIdRemoteShared(c.getLong(c.getColumnIndex(ProviderTableMeta.OCSHARES_ID_REMOTE_SHARED)));
share.setIsPasswordProtected(c.getInt(c.getColumnIndex(ProviderTableMeta.OCSHARES_IS_PASSWORD_PROTECTED)) == 1);
share.setNote(c.getString(c.getColumnIndex(ProviderTableMeta.OCSHARES_NOTE)));
share.setHideFileDownload(c.getInt(c.getColumnIndex(ProviderTableMeta.OCSHARES_HIDE_DOWNLOAD)) == 1);
}
return share;
}
Expand Down Expand Up @@ -1304,6 +1306,7 @@ public void saveShares(Collection<OCShare> shares) {
cv.put(ProviderTableMeta.OCSHARES_ACCOUNT_OWNER, account.name);
cv.put(ProviderTableMeta.OCSHARES_IS_PASSWORD_PROTECTED, share.isPasswordProtected() ? 1 : 0);
cv.put(ProviderTableMeta.OCSHARES_NOTE, share.getNote());
cv.put(ProviderTableMeta.OCSHARES_HIDE_DOWNLOAD, share.isHideFileDownload());

if (shareExistsForRemoteId(share.getRemoteId())) {
// updating an existing file
Expand Down Expand Up @@ -1584,6 +1587,7 @@ private ArrayList<ContentProviderOperation> prepareInsertShares(
cv.put(ProviderTableMeta.OCSHARES_ACCOUNT_OWNER, account.name);
cv.put(ProviderTableMeta.OCSHARES_IS_PASSWORD_PROTECTED, share.isPasswordProtected() ? 1 : 0);
cv.put(ProviderTableMeta.OCSHARES_NOTE, share.getNote());
cv.put(ProviderTableMeta.OCSHARES_HIDE_DOWNLOAD, share.isHideFileDownload());

// adding a new share resource
operations.add(ContentProviderOperation.newInsert(
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/owncloud/android/db/ProviderMeta.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
public class ProviderMeta {

public static final String DB_NAME = "filelist";
public static final int DB_VERSION = 36;
public static final int DB_VERSION = 37;

private ProviderMeta() {
}
Expand Down Expand Up @@ -132,6 +132,7 @@ static public class ProviderTableMeta implements BaseColumns {
public static final String OCSHARES_ACCOUNT_OWNER = "owner_share";
public static final String OCSHARES_IS_PASSWORD_PROTECTED = "is_password_protected";
public static final String OCSHARES_NOTE = "note";
public static final String OCSHARES_HIDE_DOWNLOAD = "hide_download";

public static final String OCSHARES_DEFAULT_SORT_ORDER = OCSHARES_FILE_SOURCE
+ " collate nocase asc";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/*
* ownCloud Android client application
*
* @author David A. Velasco
Expand Down Expand Up @@ -37,19 +37,20 @@
*/
public class UpdateShareViaLinkOperation extends SyncOperation {

private String mPath;
private String mPassword;
private Boolean mPublicUpload;
private long mExpirationDateInMillis;
private String path;
private String password;
private Boolean publicUpload;
private Boolean hideFileDownload;
private long expirationDateInMillis;

/**
* Constructor
*
* @param path Full path of the file/folder being shared. Mandatory argument
*/
public UpdateShareViaLinkOperation(String path) {
mPath = path;
mExpirationDateInMillis = 0;
this.path = path;
expirationDateInMillis = 0;
}

/**
Expand All @@ -60,7 +61,7 @@ public UpdateShareViaLinkOperation(String path) {
* Null results in no update applied to the password.
*/
public void setPassword(String password) {
mPassword = password;
this.password = password;
}

/**
Expand All @@ -72,7 +73,11 @@ public void setPassword(String password) {
* the expiration date.
*/
public void setExpirationDate(long expirationDateInMillis) {
mExpirationDateInMillis = expirationDateInMillis;
this.expirationDateInMillis = expirationDateInMillis;
}

public void setHideFileDownload(boolean hideFileDownload) {
this.hideFileDownload = hideFileDownload;
}

/**
Expand All @@ -82,32 +87,23 @@ public void setExpirationDate(long expirationDateInMillis) {
* Null results in no update applied to the upload permission.
*/
public void setPublicUpload(Boolean publicUpload) {
mPublicUpload = publicUpload;
this.publicUpload = publicUpload;
}

@Override
protected RemoteOperationResult run(OwnCloudClient client) {

OCShare publicShare = getStorageManager().getFirstShareByPathAndType(
mPath,
ShareType.PUBLIC_LINK,
""
);
OCShare publicShare = getStorageManager().getFirstShareByPathAndType(path, ShareType.PUBLIC_LINK, "");

if (publicShare == null) {
// TODO try to get remote share before failing?
return new RemoteOperationResult(
RemoteOperationResult.ResultCode.SHARE_NOT_FOUND
);
return new RemoteOperationResult(RemoteOperationResult.ResultCode.SHARE_NOT_FOUND);
}

// Update remote share with password
UpdateRemoteShareOperation updateOp = new UpdateRemoteShareOperation(
publicShare.getRemoteId()
);
updateOp.setPassword(mPassword);
updateOp.setExpirationDate(mExpirationDateInMillis);
updateOp.setPublicUpload(mPublicUpload);
UpdateRemoteShareOperation updateOp = new UpdateRemoteShareOperation(publicShare.getRemoteId());
updateOp.setPassword(password);
updateOp.setExpirationDate(expirationDateInMillis);
updateOp.setPublicUpload(publicUpload);
updateOp.setHideFileDownload(hideFileDownload);
RemoteOperationResult result = updateOp.execute(client);

if (result.isSuccess()) {
Expand All @@ -124,17 +120,17 @@ protected RemoteOperationResult run(OwnCloudClient client) {
}

public String getPath() {
return mPath;
return path;
}

public String getPassword() {
return mPassword;
return password;
}

private void updateData(OCShare share) {
// Update DB with the response
share.setPath(mPath);
if (mPath.endsWith(FileUtils.PATH_SEPARATOR)) {
share.setPath(path);
if (path.endsWith(FileUtils.PATH_SEPARATOR)) {
share.setIsFolder(true);
} else {
share.setIsFolder(false);
Expand All @@ -144,12 +140,11 @@ private void updateData(OCShare share) {

// Update OCFile with data from share: ShareByLink and publicLink
// TODO check & remove if not needed
OCFile file = getStorageManager().getFileByPath(mPath);
OCFile file = getStorageManager().getFileByPath(path);
if (file != null) {
file.setPublicLink(share.getShareLink());
file.setSharedViaLink(true);
getStorageManager().saveFile(file);
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,8 @@ private void createOCSharesTable(SQLiteDatabase db) {
+ ProviderTableMeta.OCSHARES_ID_REMOTE_SHARED + INTEGER
+ ProviderTableMeta.OCSHARES_ACCOUNT_OWNER + TEXT
+ ProviderTableMeta.OCSHARES_IS_PASSWORD_PROTECTED + INTEGER
+ ProviderTableMeta.OCSHARES_NOTE + " TEXT );");
+ ProviderTableMeta.OCSHARES_NOTE + TEXT
+ ProviderTableMeta.OCSHARES_HIDE_DOWNLOAD + " INTEGER );");
}

private void createCapabilitiesTable(SQLiteDatabase db) {
Expand Down Expand Up @@ -1783,6 +1784,24 @@ public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
if (!upgraded) {
Log_OC.i(SQL, String.format(Locale.ENGLISH, UPGRADE_VERSION_MSG, oldVersion, newVersion));
}

if (oldVersion < 37 && newVersion >= 37) {
Log_OC.i(SQL, "Entering in the #37 add hide-download to share table");
db.beginTransaction();
try {
db.execSQL(ALTER_TABLE + ProviderTableMeta.OCSHARES_TABLE_NAME +
ADD_COLUMN + ProviderTableMeta.OCSHARES_HIDE_DOWNLOAD + " INTEGER ");

upgraded = true;
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
}

if (!upgraded) {
Log_OC.i(SQL, String.format(Locale.ENGLISH, UPGRADE_VERSION_MSG, oldVersion, newVersion));
}
}

@Override
Expand Down
Loading