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/findbugs-results.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
418
407
9 changes: 7 additions & 2 deletions spotbugs-filter.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
<Match>
<Or>
<Class name="~.*\.Dagger.*" />
<Class name="~com.nextcloud.client.di\..*_.*" />
<Class name="~com\.nextcloud\.client\.di\..*_.*" />
<Class name="~dagger\.android\..*" />
</Or>
</Match>
<!-- Dagger generated code uses internal APIs -->
Expand All @@ -30,7 +31,7 @@
<Match>
<Or>
<Class name="~.*BindingImpl"/>
<Class name="~.*\.DataBinderMapperImpl"/>
<Class name="~.*\.DataBinderMapperImpl"/>
</Or>
</Match>

Expand All @@ -39,6 +40,10 @@
<Or>
<Package name="~io\.noties\..*" />
<Package name="~third_parties\.ezvcard_android\..*" />
<Package name="~com\.afollestad\.sectionedrecyclerview\..*" />
<Package name="~butterknife\..*" />
<Package name="~de\.cotech\..*" />
<Package name="~pl\.droidsonroids\..*" />
</Or>
</Match>
<Match>
Expand Down
44 changes: 31 additions & 13 deletions src/main/java/com/owncloud/android/datamodel/SyncedFolder.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,12 @@

import java.io.Serializable;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;

/**
* Synced folder entity containing all information per synced folder.
*/
@AllArgsConstructor
public class SyncedFolder implements Serializable, Cloneable {
public static final long UNPERSISTED_ID = Long.MIN_VALUE;
public static final long EMPTY_ENABLED_TIMESTAMP_MS = -1;
Expand All @@ -39,14 +37,15 @@ public class SyncedFolder implements Serializable, Cloneable {
@Getter @Setter private long id;
@Getter @Setter private String localPath;
@Getter @Setter private String remotePath;
@Getter @Setter private Boolean wifiOnly;
@Getter @Setter private Boolean chargingOnly;
@Getter @Setter private Boolean subfolderByDate;
@Getter @Setter private boolean wifiOnly;
@Getter @Setter private boolean chargingOnly;
@Getter @Setter private boolean subfolderByDate;
@Getter @Setter private String account;
@Getter @Setter private Integer uploadAction;
@Getter @Setter private int uploadAction;
@Getter private boolean enabled;
@Getter private long enabledTimestampMs;
@Getter @Setter private MediaFolderType type;
@Getter @Setter private boolean hidden;

/**
* constructor for new, to be persisted entity.
Expand All @@ -61,22 +60,40 @@ public class SyncedFolder implements Serializable, Cloneable {
* @param enabled flag if synced folder config is active
* @param timestampMs the current timestamp in milliseconds
* @param type the type of the folder
* @param hidden hide item flag
*/
public SyncedFolder(String localPath, String remotePath, Boolean wifiOnly, Boolean chargingOnly,
Boolean subfolderByDate, String account, Integer uploadAction, Boolean enabled,
long timestampMs, MediaFolderType type) {
public SyncedFolder(String localPath,
String remotePath,
boolean wifiOnly,
boolean chargingOnly,
boolean subfolderByDate,
String account,
int uploadAction,
boolean enabled,
long timestampMs,
MediaFolderType type,
boolean hidden) {
this(UNPERSISTED_ID, localPath, remotePath, wifiOnly, chargingOnly, subfolderByDate, account, uploadAction,
enabled, timestampMs, type);
enabled, timestampMs, type, hidden);
}

/**
* constructor for wrapping existing folders.
*
* @param id id
*/
protected SyncedFolder(long id, String localPath, String remotePath, Boolean wifiOnly, Boolean chargingOnly,
Boolean subfolderByDate, String account, Integer uploadAction, Boolean enabled,
long timestampMs, MediaFolderType type) {
protected SyncedFolder(long id,
String localPath,
String remotePath,
boolean wifiOnly,
boolean chargingOnly,
boolean subfolderByDate,
String account,
int uploadAction,
boolean enabled,
long timestampMs,
MediaFolderType type,
boolean hidden) {
this.id = id;
this.localPath = localPath;
this.remotePath = remotePath;
Expand All @@ -87,6 +104,7 @@ protected SyncedFolder(long id, String localPath, String remotePath, Boolean wif
this.uploadAction = uploadAction;
this.setEnabled(enabled, timestampMs);
this.type = type;
this.hidden = hidden;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,24 +53,43 @@ public class SyncedFolderDisplayItem extends SyncedFolder {
* @param folderName the UI info for the folder's name
* @param numberOfFiles the UI info for number of files within the folder
* @param type the type of the folder
* @param hidden hide item flag
*/
public SyncedFolderDisplayItem(long id, String localPath, String remotePath, Boolean wifiOnly, Boolean chargingOnly,
Boolean subfolderByDate, String account, Integer uploadAction, Boolean enabled,
long timestampMs, List<String> filePaths, String folderName, long numberOfFiles,
MediaFolderType type)
{
public SyncedFolderDisplayItem(long id,
String localPath,
String remotePath,
boolean wifiOnly,
boolean chargingOnly,
boolean subfolderByDate,
String account,
int uploadAction,
boolean enabled,
long timestampMs,
List<String> filePaths,
String folderName,
long numberOfFiles,
MediaFolderType type,
boolean hidden) {
super(id, localPath, remotePath, wifiOnly, chargingOnly, subfolderByDate, account, uploadAction, enabled,
timestampMs, type);
timestampMs, type, hidden);
this.filePaths = filePaths;
this.folderName = folderName;
this.numberOfFiles = numberOfFiles;
}

public SyncedFolderDisplayItem(long id, String localPath, String remotePath, Boolean wifiOnly, Boolean chargingOnly,
Boolean subfolderByDate, String account, Integer uploadAction, Boolean enabled,
long timestampMs, String folderName, MediaFolderType type) {
public SyncedFolderDisplayItem(long id,
String localPath,
String remotePath,
boolean wifiOnly,
boolean chargingOnly,
boolean subfolderByDate,
String account,
int uploadAction,
boolean enabled,
long timestampMs,
String folderName, MediaFolderType type, boolean hidden) {
super(id, localPath, remotePath, wifiOnly, chargingOnly, subfolderByDate, account, uploadAction, enabled,
timestampMs, type);
timestampMs, type, hidden);
this.folderName = folderName;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -338,25 +338,27 @@ private SyncedFolder createSyncedFolderFromCursor(Cursor cursor) {
ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_LOCAL_PATH));
String remotePath = cursor.getString(cursor.getColumnIndex(
ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_REMOTE_PATH));
Boolean wifiOnly = cursor.getInt(cursor.getColumnIndex(
boolean wifiOnly = cursor.getInt(cursor.getColumnIndex(
ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_WIFI_ONLY)) == 1;
Boolean chargingOnly = cursor.getInt(cursor.getColumnIndex(
boolean chargingOnly = cursor.getInt(cursor.getColumnIndex(
ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_CHARGING_ONLY)) == 1;
Boolean subfolderByDate = cursor.getInt(cursor.getColumnIndex(
boolean subfolderByDate = cursor.getInt(cursor.getColumnIndex(
ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_SUBFOLDER_BY_DATE)) == 1;
String accountName = cursor.getString(cursor.getColumnIndex(
ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_ACCOUNT));
Integer uploadAction = cursor.getInt(cursor.getColumnIndex(
int uploadAction = cursor.getInt(cursor.getColumnIndex(
ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_UPLOAD_ACTION));
Boolean enabled = cursor.getInt(cursor.getColumnIndex(
boolean enabled = cursor.getInt(cursor.getColumnIndex(
ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_ENABLED)) == 1;
long enabledTimestampMs = cursor.getLong(cursor.getColumnIndex(
ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_ENABLED_TIMESTAMP_MS));
MediaFolderType type = MediaFolderType.getById(cursor.getInt(cursor.getColumnIndex(
ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_TYPE)));
boolean hidden = cursor.getInt(cursor.getColumnIndex(
ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_HIDDEN)) == 1;

syncedFolder = new SyncedFolder(id, localPath, remotePath, wifiOnly, chargingOnly, subfolderByDate,
accountName, uploadAction, enabled, enabledTimestampMs, type);
accountName, uploadAction, enabled, enabledTimestampMs, type, hidden);
}
return syncedFolder;
}
Expand All @@ -372,14 +374,15 @@ private ContentValues createContentValuesFromSyncedFolder(SyncedFolder syncedFol
ContentValues cv = new ContentValues();
cv.put(ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_LOCAL_PATH, syncedFolder.getLocalPath());
cv.put(ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_REMOTE_PATH, syncedFolder.getRemotePath());
cv.put(ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_WIFI_ONLY, syncedFolder.getWifiOnly());
cv.put(ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_CHARGING_ONLY, syncedFolder.getChargingOnly());
cv.put(ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_WIFI_ONLY, syncedFolder.isWifiOnly());
cv.put(ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_CHARGING_ONLY, syncedFolder.isChargingOnly());
cv.put(ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_ENABLED, syncedFolder.isEnabled());
cv.put(ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_ENABLED_TIMESTAMP_MS, syncedFolder.getEnabledTimestampMs());
cv.put(ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_SUBFOLDER_BY_DATE, syncedFolder.getSubfolderByDate());
cv.put(ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_SUBFOLDER_BY_DATE, syncedFolder.isSubfolderByDate());
cv.put(ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_ACCOUNT, syncedFolder.getAccount());
cv.put(ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_UPLOAD_ACTION, syncedFolder.getUploadAction());
cv.put(ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_TYPE, syncedFolder.getType().getId());
cv.put(ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_HIDDEN, syncedFolder.isHidden());

return cv;
}
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 @@ -31,7 +31,7 @@
*/
public class ProviderMeta {
public static final String DB_NAME = "filelist";
public static final int DB_VERSION = 50;
public static final int DB_VERSION = 51;

private ProviderMeta() {
// No instance
Expand Down Expand Up @@ -225,6 +225,7 @@ static public class ProviderTableMeta implements BaseColumns {
public static final String SYNCED_FOLDER_SUBFOLDER_BY_DATE = "subfolder_by_date";
public static final String SYNCED_FOLDER_ACCOUNT = "account";
public static final String SYNCED_FOLDER_UPLOAD_ACTION = "upload_option";
public static final String SYNCED_FOLDER_HIDDEN = "hidden";

// Columns of external links table
public static final String EXTERNAL_LINKS_ICON_URL = "icon_url";
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/owncloud/android/jobs/FilesSyncJob.java
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,10 @@ private void syncFolder(Context context, Resources resources, boolean lightVersi

remotePath = resources.getString(R.string.syncedFolder_remote_folder);
} else {
needsCharging = syncedFolder.getChargingOnly();
needsWifi = syncedFolder.getWifiOnly();
needsCharging = syncedFolder.isChargingOnly();
needsWifi = syncedFolder.isWifiOnly();
uploadAction = syncedFolder.getUploadAction();
subfolderByDate = syncedFolder.getSubfolderByDate();
subfolderByDate = syncedFolder.isSubfolderByDate();
remotePath = syncedFolder.getRemotePath();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -833,7 +833,8 @@ private void createSyncedFoldersTable(SQLiteDatabase db) {
+ ProviderTableMeta.SYNCED_FOLDER_SUBFOLDER_BY_DATE + " INTEGER, " // subfolder by date
+ ProviderTableMeta.SYNCED_FOLDER_ACCOUNT + " TEXT, " // account
+ ProviderTableMeta.SYNCED_FOLDER_UPLOAD_ACTION + " INTEGER, " // upload action
+ ProviderTableMeta.SYNCED_FOLDER_TYPE + " INTEGER );" // type
+ ProviderTableMeta.SYNCED_FOLDER_TYPE + " INTEGER, " // type
+ ProviderTableMeta.SYNCED_FOLDER_HIDDEN + " INTEGER );" // hidden
);
}

Expand Down Expand Up @@ -2045,6 +2046,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 < 51 && newVersion >= 51) {
Log_OC.i(SQL, "Entering in the #51 add show/hide to folderSync table");
db.beginTransaction();
try {
db.execSQL(ALTER_TABLE + ProviderTableMeta.SYNCED_FOLDERS_TABLE_NAME +
ADD_COLUMN + ProviderTableMeta.SYNCED_FOLDER_HIDDEN + " 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