mirror of
https://github.com/nextcloud/android.git
synced 2024-11-27 09:39:25 +03:00
add folder type to persistent entity
This commit is contained in:
parent
2bd7611a31
commit
8e3edb5a19
7 changed files with 47 additions and 28 deletions
|
@ -27,11 +27,10 @@ import java.util.List;
|
|||
* Business object representing a media folder with all information that are gathered via media queries.
|
||||
*/
|
||||
public class MediaFolder {
|
||||
public static final int AUDIO = 3;
|
||||
public static final int VIDEO = 1;
|
||||
public static final int IMAGE = 2;
|
||||
public static final int IMAGE_VIDEO = 3;
|
||||
public static final int CUSTOM = 4;
|
||||
public static final Integer IMAGE = 0;
|
||||
public static final Integer VIDEO = 1;
|
||||
public static final Integer IMAGE_VIDEO = 2;
|
||||
public static final Integer CUSTOM = 3;
|
||||
|
||||
/** name of the folder. */
|
||||
public String folderName;
|
||||
|
|
|
@ -38,6 +38,7 @@ public class SyncedFolder implements Serializable {
|
|||
private String account;
|
||||
private Integer uploadAction;
|
||||
private boolean enabled;
|
||||
private Integer type;
|
||||
|
||||
/**
|
||||
* constructor for already persisted entity.
|
||||
|
@ -51,9 +52,10 @@ public class SyncedFolder implements Serializable {
|
|||
* @param account the account owning the synced folder
|
||||
* @param uploadAction the action to be done after the upload
|
||||
* @param enabled flag if synced folder config is active
|
||||
* @param type the type of the folder
|
||||
*/
|
||||
public SyncedFolder(long id, String localPath, String remotePath, Boolean wifiOnly, Boolean chargingOnly,
|
||||
Boolean subfolderByDate, String account, Integer uploadAction, Boolean enabled) {
|
||||
Boolean subfolderByDate, String account, Integer uploadAction, Boolean enabled, Integer type) {
|
||||
this.id = id;
|
||||
this.localPath = localPath;
|
||||
this.remotePath = remotePath;
|
||||
|
@ -63,6 +65,7 @@ public class SyncedFolder implements Serializable {
|
|||
this.account = account;
|
||||
this.uploadAction = uploadAction;
|
||||
this.enabled = enabled;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -76,9 +79,10 @@ public class SyncedFolder implements Serializable {
|
|||
* @param account the account owning the synced folder
|
||||
* @param uploadAction the action to be done after the upload
|
||||
* @param enabled flag if synced folder config is active
|
||||
* @param type the type of the folder
|
||||
*/
|
||||
public SyncedFolder(String localPath, String remotePath, Boolean wifiOnly, Boolean chargingOnly,
|
||||
Boolean subfolderByDate, String account, Integer uploadAction, Boolean enabled) {
|
||||
Boolean subfolderByDate, String account, Integer uploadAction, Boolean enabled, Integer type) {
|
||||
this.localPath = localPath;
|
||||
this.remotePath = remotePath;
|
||||
this.wifiOnly = wifiOnly;
|
||||
|
@ -87,6 +91,7 @@ public class SyncedFolder implements Serializable {
|
|||
this.account = account;
|
||||
this.uploadAction = uploadAction;
|
||||
this.enabled = enabled;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
|
@ -160,4 +165,12 @@ public class SyncedFolder implements Serializable {
|
|||
public void setEnabled(boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
}
|
|
@ -31,7 +31,6 @@ public class SyncedFolderDisplayItem extends SyncedFolder {
|
|||
private List<String> filePaths;
|
||||
private String folderName;
|
||||
private long numberOfFiles;
|
||||
private int type;
|
||||
|
||||
/**
|
||||
* constructor for the display item specialization for a synced folder object.
|
||||
|
@ -52,18 +51,17 @@ public class SyncedFolderDisplayItem extends SyncedFolder {
|
|||
*/
|
||||
public SyncedFolderDisplayItem(long id, String localPath, String remotePath, Boolean wifiOnly, Boolean chargingOnly,
|
||||
Boolean subfolderByDate, String account, Integer uploadAction, Boolean enabled,
|
||||
List<String> filePaths, String folderName, long numberOfFiles, int type) {
|
||||
super(id, localPath, remotePath, wifiOnly, chargingOnly, subfolderByDate, account, uploadAction, enabled);
|
||||
List<String> filePaths, String folderName, long numberOfFiles, Integer type) {
|
||||
super(id, localPath, remotePath, wifiOnly, chargingOnly, subfolderByDate, account, uploadAction, enabled, type);
|
||||
this.filePaths = filePaths;
|
||||
this.folderName = folderName;
|
||||
this.numberOfFiles = numberOfFiles;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public SyncedFolderDisplayItem(long id, String localPath, String remotePath, Boolean wifiOnly, Boolean chargingOnly,
|
||||
Boolean subfolderByDate, String account, Integer uploadAction, Boolean enabled,
|
||||
String folderName) {
|
||||
super(id, localPath, remotePath, wifiOnly, chargingOnly, subfolderByDate, account, uploadAction, enabled);
|
||||
String folderName, Integer type) {
|
||||
super(id, localPath, remotePath, wifiOnly, chargingOnly, subfolderByDate, account, uploadAction, enabled, type);
|
||||
this.folderName = folderName;
|
||||
}
|
||||
|
||||
|
@ -90,12 +88,4 @@ public class SyncedFolderDisplayItem extends SyncedFolder {
|
|||
public void setNumberOfFiles(long numberOfFiles) {
|
||||
this.numberOfFiles = numberOfFiles;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -187,7 +187,6 @@ public class SyncedFolderProvider extends Observable {
|
|||
}
|
||||
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -211,15 +210,12 @@ public class SyncedFolderProvider extends Observable {
|
|||
*
|
||||
* @param id for the synced folder.
|
||||
*/
|
||||
|
||||
private int deleteSyncFolderWithId(long id) {
|
||||
int result = mContentResolver.delete(
|
||||
return mContentResolver.delete(
|
||||
ProviderMeta.ProviderTableMeta.CONTENT_URI_SYNCED_FOLDERS,
|
||||
ProviderMeta.ProviderTableMeta._ID + " = ?",
|
||||
new String[]{String.valueOf(id)}
|
||||
);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
@ -325,9 +321,11 @@ public class SyncedFolderProvider extends Observable {
|
|||
ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_UPLOAD_ACTION));
|
||||
Boolean enabled = cursor.getInt(cursor.getColumnIndex(
|
||||
ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_ENABLED)) == 1;
|
||||
Integer type = cursor.getInt(cursor.getColumnIndex(
|
||||
ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_TYPE));
|
||||
|
||||
syncedFolder = new SyncedFolder(id, localPath, remotePath, wifiOnly, chargingOnly, subfolderByDate,
|
||||
accountName, uploadAction, enabled);
|
||||
accountName, uploadAction, enabled, type);
|
||||
}
|
||||
return syncedFolder;
|
||||
}
|
||||
|
@ -349,6 +347,8 @@ public class SyncedFolderProvider extends Observable {
|
|||
cv.put(ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_SUBFOLDER_BY_DATE, syncedFolder.getSubfolderByDate());
|
||||
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());
|
||||
|
||||
return cv;
|
||||
}
|
||||
|
||||
|
|
|
@ -176,6 +176,7 @@ public class ProviderMeta {
|
|||
public static final String SYNCED_FOLDER_WIFI_ONLY = "wifi_only";
|
||||
public static final String SYNCED_FOLDER_CHARGING_ONLY = "charging_only";
|
||||
public static final String SYNCED_FOLDER_ENABLED = "enabled";
|
||||
public static final String SYNCED_FOLDER_TYPE = "type";
|
||||
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";
|
||||
|
|
|
@ -937,7 +937,22 @@ public class FileContentProvider extends ContentProvider {
|
|||
} finally {
|
||||
db.endTransaction();
|
||||
}
|
||||
}
|
||||
|
||||
if (oldVersion < 18 && newVersion >= 18) {
|
||||
Log_OC.i(SQL, "Entering in the #18 ADD in onUpgrade");
|
||||
db.beginTransaction();
|
||||
try {
|
||||
// add type column default being IMAGE(0)
|
||||
db.execSQL(ALTER_TABLE + ProviderTableMeta.SYNCED_FOLDERS_TABLE_NAME +
|
||||
ADD_COLUMN + ProviderTableMeta.SYNCED_FOLDER_TYPE +
|
||||
" INTEGER " + " DEFAULT 0");
|
||||
|
||||
upgraded = true;
|
||||
db.setTransactionSuccessful();
|
||||
} finally {
|
||||
db.endTransaction();
|
||||
}
|
||||
}
|
||||
|
||||
if (!upgraded) {
|
||||
|
|
|
@ -294,7 +294,8 @@ public class FolderSyncActivity extends FileActivity implements FolderSyncAdapte
|
|||
syncedFolder.getAccount(),
|
||||
syncedFolder.getUploadAction(),
|
||||
syncedFolder.isEnabled(),
|
||||
new File(syncedFolder.getLocalPath()).getName());
|
||||
new File(syncedFolder.getLocalPath()).getName(),
|
||||
syncedFolder.getType());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue