From: Javier Gonzalez Date: Wed, 1 Oct 2014 09:35:50 +0000 (+0200) Subject: Merge pull request #641 from owncloud/thumbnails_for_downloaded_images X-Git-Tag: oc-android-1.7.0_signed~163 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/d456e2fb6c2e1f0669187d8b8fe48f36f4f6cef5?ds=inline;hp=-c Merge pull request #641 from owncloud/thumbnails_for_downloaded_images Thumbnails for downloaded images --- d456e2fb6c2e1f0669187d8b8fe48f36f4f6cef5 diff --combined src/com/owncloud/android/datamodel/FileDataStorageManager.java index 4848246f,a65eef8d..795004a1 --- a/src/com/owncloud/android/datamodel/FileDataStorageManager.java +++ b/src/com/owncloud/android/datamodel/FileDataStorageManager.java @@@ -27,11 -27,11 +27,11 @@@ import java.util.Vector import com.owncloud.android.MainApp; import com.owncloud.android.db.ProviderMeta.ProviderTableMeta; +import com.owncloud.android.lib.common.utils.Log_OC; import com.owncloud.android.lib.resources.shares.OCShare; import com.owncloud.android.lib.resources.shares.ShareType; import com.owncloud.android.lib.resources.files.FileUtils; import com.owncloud.android.utils.FileStorageUtils; -import com.owncloud.android.utils.Log_OC; import android.accounts.Account; @@@ -188,6 -188,7 +188,7 @@@ public class FileDataStorageManager cv.put(ProviderTableMeta.FILE_PUBLIC_LINK, file.getPublicLink()); cv.put(ProviderTableMeta.FILE_PERMISSIONS, file.getPermissions()); cv.put(ProviderTableMeta.FILE_REMOTE_ID, file.getRemoteId()); + cv.put(ProviderTableMeta.FILE_UPDATE_THUMBNAIL, file.needsUpdateThumbnail()); boolean sameRemotePath = fileExists(file.getRemotePath()); if (sameRemotePath || @@@ -878,6 -879,8 +879,8 @@@ file.setPublicLink(c.getString(c.getColumnIndex(ProviderTableMeta.FILE_PUBLIC_LINK))); file.setPermissions(c.getString(c.getColumnIndex(ProviderTableMeta.FILE_PERMISSIONS))); file.setRemoteId(c.getString(c.getColumnIndex(ProviderTableMeta.FILE_REMOTE_ID))); + file.setNeedsUpdateThumbnail(c.getInt( + c.getColumnIndex(ProviderTableMeta.FILE_UPDATE_THUMBNAIL)) == 1 ? true : false); } return file; @@@ -1222,6 -1225,7 +1225,7 @@@ cv.put(ProviderTableMeta.FILE_PUBLIC_LINK, file.getPublicLink()); cv.put(ProviderTableMeta.FILE_PERMISSIONS, file.getPermissions()); cv.put(ProviderTableMeta.FILE_REMOTE_ID, file.getRemoteId()); + cv.put(ProviderTableMeta.FILE_UPDATE_THUMBNAIL, file.needsUpdateThumbnail() ? 1 : 0); boolean existsByPath = fileExists(file.getRemotePath()); if (existsByPath || fileExists(file.getFileId())) { diff --combined src/com/owncloud/android/datamodel/OCFile.java index 58851063,5f45cc42..c3284fc0 --- a/src/com/owncloud/android/datamodel/OCFile.java +++ b/src/com/owncloud/android/datamodel/OCFile.java @@@ -20,7 -20,7 +20,7 @@@ package com.owncloud.android.datamodel import java.io.File; -import com.owncloud.android.utils.Log_OC; +import com.owncloud.android.lib.common.utils.Log_OC; import android.os.Parcel; @@@ -68,6 -68,8 +68,8 @@@ public class OCFile implements Parcelab private String mPermissions; private String mRemoteId; + private boolean mNeedsUpdateThumbnail; + /** * Create new {@link OCFile} with given path. @@@ -109,6 -111,8 +111,8 @@@ mPublicLink = source.readString(); mPermissions = source.readString(); mRemoteId = source.readString(); + mNeedsUpdateThumbnail = source.readInt() == 0; + } @Override @@@ -131,6 -135,7 +135,7 @@@ dest.writeString(mPublicLink); dest.writeString(mPermissions); dest.writeString(mRemoteId); + dest.writeInt(mNeedsUpdateThumbnail ? 1 : 0); } /** @@@ -343,6 -348,7 +348,7 @@@ mPublicLink = null; mPermissions = null; mRemoteId = null; + mNeedsUpdateThumbnail = false; } /** @@@ -408,6 -414,14 +414,14 @@@ return mNeedsUpdating; } + public boolean needsUpdateThumbnail() { + return mNeedsUpdateThumbnail; + } + + public void setNeedsUpdateThumbnail(boolean needsUpdateThumbnail) { + this.mNeedsUpdateThumbnail = needsUpdateThumbnail; + } + public long getLastSyncDateForProperties() { return mLastSyncDateForProperties; } diff --combined src/com/owncloud/android/files/services/FileDownloader.java index 2e423beb,7799ca1f..cb0f12ce --- a/src/com/owncloud/android/files/services/FileDownloader.java +++ b/src/com/owncloud/android/files/services/FileDownloader.java @@@ -41,7 -41,6 +41,7 @@@ import com.owncloud.android.notificatio import com.owncloud.android.notifications.NotificationDelayer; import com.owncloud.android.lib.common.operations.RemoteOperationResult; import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode; +import com.owncloud.android.lib.common.utils.Log_OC; import com.owncloud.android.lib.resources.files.FileUtils; import com.owncloud.android.operations.DownloadFileOperation; import com.owncloud.android.ui.activity.FileActivity; @@@ -49,6 -48,7 +49,6 @@@ import com.owncloud.android.ui.activity import com.owncloud.android.ui.preview.PreviewImageActivity; import com.owncloud.android.ui.preview.PreviewImageFragment; import com.owncloud.android.utils.ErrorMessageAdapter; -import com.owncloud.android.utils.Log_OC; import android.accounts.Account; import android.accounts.AccountsException; @@@ -391,6 -391,7 +391,7 @@@ public class FileDownloader extends Ser long syncDate = System.currentTimeMillis(); file.setLastSyncDateForProperties(syncDate); file.setLastSyncDateForData(syncDate); + file.setNeedsUpdateThumbnail(true); file.setModificationTimestamp(mCurrentDownload.getModificationTimestamp()); file.setModificationTimestampAtLastSyncForData(mCurrentDownload.getModificationTimestamp()); // file.setEtag(mCurrentDownload.getEtag()); // TODO Etag, where available diff --combined src/com/owncloud/android/providers/FileContentProvider.java index 8113e046,3a93c167..9792f3e9 --- a/src/com/owncloud/android/providers/FileContentProvider.java +++ b/src/com/owncloud/android/providers/FileContentProvider.java @@@ -24,8 -24,8 +24,8 @@@ import java.util.HashMap import com.owncloud.android.R; import com.owncloud.android.db.ProviderMeta; import com.owncloud.android.db.ProviderMeta.ProviderTableMeta; +import com.owncloud.android.lib.common.utils.Log_OC; import com.owncloud.android.lib.resources.shares.ShareType; -import com.owncloud.android.utils.Log_OC; @@@ -97,6 -97,8 +97,8 @@@ public class FileContentProvider extend ProviderTableMeta.FILE_PERMISSIONS); mFileProjectionMap.put(ProviderTableMeta.FILE_REMOTE_ID, ProviderTableMeta.FILE_REMOTE_ID); + mFileProjectionMap.put(ProviderTableMeta.FILE_UPDATE_THUMBNAIL, + ProviderTableMeta.FILE_UPDATE_THUMBNAIL); } private static final int SINGLE_FILE = 1; @@@ -559,7 -561,8 +561,8 @@@ + ProviderTableMeta.FILE_SHARE_BY_LINK + " INTEGER, " + ProviderTableMeta.FILE_PUBLIC_LINK + " TEXT, " + ProviderTableMeta.FILE_PERMISSIONS + " TEXT null," - + ProviderTableMeta.FILE_REMOTE_ID + " TEXT null);" + + ProviderTableMeta.FILE_REMOTE_ID + " TEXT null," + + ProviderTableMeta.FILE_UPDATE_THUMBNAIL + " INTEGER);" //boolean ); // Create table ocshares @@@ -708,6 -711,23 +711,23 @@@ } if (!upgraded) Log_OC.i("SQL", "OUT of the ADD in onUpgrade; oldVersion == " + oldVersion + ", newVersion == " + newVersion); + + if (oldVersion < 8 && newVersion >= 8) { + Log_OC.i("SQL", "Entering in the #8 ADD in onUpgrade"); + db.beginTransaction(); + try { + db .execSQL("ALTER TABLE " + ProviderTableMeta.FILE_TABLE_NAME + + " ADD COLUMN " + ProviderTableMeta.FILE_UPDATE_THUMBNAIL + " INTEGER " + + " DEFAULT 0"); + + upgraded = true; + db.setTransactionSuccessful(); + } finally { + db.endTransaction(); + } + } + if (!upgraded) + Log_OC.i("SQL", "OUT of the ADD in onUpgrade; oldVersion == " + oldVersion + ", newVersion == " + newVersion); } }