From: jabarros Date: Mon, 19 Jan 2015 13:41:34 +0000 (+0100) Subject: Increase db number and added getters and setter for new 'uploading' and 'downloading... X-Git-Tag: oc-android-1.7.0_signed~23^2~8^2~4 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/115268008e337fa9aa82a8b769ca0da4586412f8 Increase db number and added getters and setter for new 'uploading' and 'downloading' fields in OCFile --- diff --git a/src/com/owncloud/android/datamodel/FileDataStorageManager.java b/src/com/owncloud/android/datamodel/FileDataStorageManager.java index d8030642..c1bf61be 100644 --- a/src/com/owncloud/android/datamodel/FileDataStorageManager.java +++ b/src/com/owncloud/android/datamodel/FileDataStorageManager.java @@ -193,6 +193,8 @@ public class FileDataStorageManager { cv.put(ProviderTableMeta.FILE_PERMISSIONS, file.getPermissions()); cv.put(ProviderTableMeta.FILE_REMOTE_ID, file.getRemoteId()); cv.put(ProviderTableMeta.FILE_UPDATE_THUMBNAIL, file.needsUpdateThumbnail()); + cv.put(ProviderTableMeta.FILE_IS_DOWNLOADING, file.isDownloading()); + cv.put(ProviderTableMeta.FILE_IS_UPLOADING, file.isUploading()); boolean sameRemotePath = fileExists(file.getRemotePath()); if (sameRemotePath || @@ -302,6 +304,8 @@ public class FileDataStorageManager { cv.put(ProviderTableMeta.FILE_PERMISSIONS, file.getPermissions()); cv.put(ProviderTableMeta.FILE_REMOTE_ID, file.getRemoteId()); cv.put(ProviderTableMeta.FILE_UPDATE_THUMBNAIL, file.needsUpdateThumbnail()); + cv.put(ProviderTableMeta.FILE_IS_DOWNLOADING, file.isDownloading()); + cv.put(ProviderTableMeta.FILE_IS_UPLOADING, file.isUploading()); boolean existsByPath = fileExists(file.getRemotePath()); if (existsByPath || fileExists(file.getFileId())) { @@ -877,6 +881,10 @@ public class FileDataStorageManager { file.setRemoteId(c.getString(c.getColumnIndex(ProviderTableMeta.FILE_REMOTE_ID))); file.setNeedsUpdateThumbnail(c.getInt( c.getColumnIndex(ProviderTableMeta.FILE_UPDATE_THUMBNAIL)) == 1 ? true : false); + file.setDownloading(c.getInt( + c.getColumnIndex(ProviderTableMeta.FILE_IS_DOWNLOADING)) == 1 ? true : false); + file.setUploading(c.getInt( + c.getColumnIndex(ProviderTableMeta.FILE_IS_UPLOADING)) == 1 ? true : false); } return file; @@ -1259,6 +1267,14 @@ public class FileDataStorageManager { ProviderTableMeta.FILE_UPDATE_THUMBNAIL, file.needsUpdateThumbnail() ? 1 : 0 ); + cv.put( + ProviderTableMeta.FILE_IS_DOWNLOADING, + file.isDownloading() ? 1 : 0 + ); + cv.put( + ProviderTableMeta.FILE_IS_UPLOADING, + file.isUploading() ? 1 : 0 + ); boolean existsByPath = fileExists(file.getRemotePath()); if (existsByPath || fileExists(file.getFileId())) { diff --git a/src/com/owncloud/android/datamodel/OCFile.java b/src/com/owncloud/android/datamodel/OCFile.java index cf25d278..222746b5 100644 --- a/src/com/owncloud/android/datamodel/OCFile.java +++ b/src/com/owncloud/android/datamodel/OCFile.java @@ -70,6 +70,9 @@ public class OCFile implements Parcelable, Comparable { private boolean mNeedsUpdateThumbnail; + private boolean mIsDownloading; + private boolean mIsUploading; + /** * Create new {@link OCFile} with given path. @@ -112,6 +115,8 @@ public class OCFile implements Parcelable, Comparable { mPermissions = source.readString(); mRemoteId = source.readString(); mNeedsUpdateThumbnail = source.readInt() == 0; + mIsDownloading = source.readInt() == 0; + mIsUploading = source.readInt() == 0; } @@ -136,6 +141,8 @@ public class OCFile implements Parcelable, Comparable { dest.writeString(mPermissions); dest.writeString(mRemoteId); dest.writeInt(mNeedsUpdateThumbnail ? 1 : 0); + dest.writeInt(mIsDownloading ? 1 : 0); + dest.writeInt(mIsUploading ? 1 : 0); } /** @@ -348,6 +355,8 @@ public class OCFile implements Parcelable, Comparable { mPermissions = null; mRemoteId = null; mNeedsUpdateThumbnail = false; + mIsDownloading = false; + mIsUploading = false; } /** @@ -562,4 +571,20 @@ public class OCFile implements Parcelable, Comparable { this.mRemoteId = remoteId; } + public boolean isDownloading() { + return mIsDownloading; + } + + public boolean isUploading() { + return mIsUploading; + } + + public void setUploading(boolean isUploading) { + this.mIsUploading = isUploading; + } + + public void setDownloading(boolean isDownloading) { + this.mIsDownloading = isDownloading; + } + } diff --git a/src/com/owncloud/android/db/ProviderMeta.java b/src/com/owncloud/android/db/ProviderMeta.java index 2c74249a..06770b67 100644 --- a/src/com/owncloud/android/db/ProviderMeta.java +++ b/src/com/owncloud/android/db/ProviderMeta.java @@ -31,7 +31,7 @@ import com.owncloud.android.MainApp; public class ProviderMeta { public static final String DB_NAME = "filelist"; - public static final int DB_VERSION = 8; + public static final int DB_VERSION = 9; private ProviderMeta() { } diff --git a/src/com/owncloud/android/files/services/FileDownloader.java b/src/com/owncloud/android/files/services/FileDownloader.java index eb870e1d..7c8cad54 100644 --- a/src/com/owncloud/android/files/services/FileDownloader.java +++ b/src/com/owncloud/android/files/services/FileDownloader.java @@ -415,6 +415,8 @@ public class FileDownloader extends Service implements OnDatatransferProgressLis file.setStoragePath(mCurrentDownload.getSavePath()); file.setFileLength((new File(mCurrentDownload.getSavePath()).length())); file.setRemoteId(mCurrentDownload.getFile().getRemoteId()); + file.setDownloading(false); + file.setUploading(false); mStorageManager.saveFile(file); mStorageManager.triggerMediaScan(file.getStoragePath()); } diff --git a/src/com/owncloud/android/files/services/FileUploader.java b/src/com/owncloud/android/files/services/FileUploader.java index 04804402..d26fad51 100644 --- a/src/com/owncloud/android/files/services/FileUploader.java +++ b/src/com/owncloud/android/files/services/FileUploader.java @@ -635,6 +635,8 @@ public class FileUploader extends Service implements OnDatatransferProgressListe // in the instance returned by mCurrentUpload.getFile() } file.setNeedsUpdateThumbnail(true); + file.setDownloading(false); + file.setUploading(false); mStorageManager.saveFile(file); }