From: purigarcia Date: Wed, 22 Jul 2015 16:13:45 +0000 (+0200) Subject: change the name of the method from keepInSync to favorite. Other changes commented... X-Git-Tag: oc-android-1.8~60^2 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/61e6191342ec1ae8324ea8ec163a5f31d49f6a07?ds=inline;hp=--cc change the name of the method from keepInSync to favorite. Other changes commented in the review --- 61e6191342ec1ae8324ea8ec163a5f31d49f6a07 diff --git a/res/layout/file_details_fragment.xml b/res/layout/file_details_fragment.xml index 93983c2f..f5faa47b 100644 --- a/res/layout/file_details_fragment.xml +++ b/res/layout/file_details_fragment.xml @@ -160,16 +160,16 @@ > + android:text="@string/favorite" /> - + diff --git a/res/values/strings.xml b/res/values/strings.xml index 21b840c2..22cf669d 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -200,7 +200,7 @@ Cannot authenticate against this server Account does not exist in the device yet - Favorite + Favorite Unfavorite Rename Remove diff --git a/src/com/owncloud/android/datamodel/FileDataStorageManager.java b/src/com/owncloud/android/datamodel/FileDataStorageManager.java index 7db0a637..c5fc94d1 100644 --- a/src/com/owncloud/android/datamodel/FileDataStorageManager.java +++ b/src/com/owncloud/android/datamodel/FileDataStorageManager.java @@ -190,7 +190,7 @@ public class FileDataStorageManager { cv.put(ProviderTableMeta.FILE_ACCOUNT_OWNER, mAccount.name); cv.put(ProviderTableMeta.FILE_LAST_SYNC_DATE, file.getLastSyncDateForProperties()); cv.put(ProviderTableMeta.FILE_LAST_SYNC_DATE_FOR_DATA, file.getLastSyncDateForData()); - cv.put(ProviderTableMeta.FILE_KEEP_IN_SYNC, file.keepInSync() ? 1 : 0); + cv.put(ProviderTableMeta.FILE_KEEP_IN_SYNC, file.isFavorite() ? 1 : 0); cv.put(ProviderTableMeta.FILE_ETAG, file.getEtag()); cv.put(ProviderTableMeta.FILE_SHARE_BY_LINK, file.isShareByLink() ? 1 : 0); cv.put(ProviderTableMeta.FILE_PUBLIC_LINK, file.getPublicLink()); @@ -300,7 +300,7 @@ public class FileDataStorageManager { cv.put(ProviderTableMeta.FILE_ACCOUNT_OWNER, mAccount.name); cv.put(ProviderTableMeta.FILE_LAST_SYNC_DATE, file.getLastSyncDateForProperties()); cv.put(ProviderTableMeta.FILE_LAST_SYNC_DATE_FOR_DATA, file.getLastSyncDateForData()); - cv.put(ProviderTableMeta.FILE_KEEP_IN_SYNC, file.keepInSync() ? 1 : 0); + cv.put(ProviderTableMeta.FILE_KEEP_IN_SYNC, file.isFavorite() ? 1 : 0); cv.put(ProviderTableMeta.FILE_ETAG, file.getEtag()); cv.put(ProviderTableMeta.FILE_SHARE_BY_LINK, file.isShareByLink() ? 1 : 0); cv.put(ProviderTableMeta.FILE_PUBLIC_LINK, file.getPublicLink()); @@ -377,7 +377,7 @@ public class FileDataStorageManager { cv.put(ProviderTableMeta.FILE_ACCOUNT_OWNER, mAccount.name); cv.put(ProviderTableMeta.FILE_LAST_SYNC_DATE, folder.getLastSyncDateForProperties()); cv.put(ProviderTableMeta.FILE_LAST_SYNC_DATE_FOR_DATA, folder.getLastSyncDateForData()); - cv.put(ProviderTableMeta.FILE_KEEP_IN_SYNC, folder.keepInSync() ? 1 : 0); + cv.put(ProviderTableMeta.FILE_KEEP_IN_SYNC, folder.isFavorite() ? 1 : 0); cv.put(ProviderTableMeta.FILE_ETAG, folder.getEtag()); cv.put(ProviderTableMeta.FILE_SHARE_BY_LINK, folder.isShareByLink() ? 1 : 0); cv.put(ProviderTableMeta.FILE_PUBLIC_LINK, folder.getPublicLink()); @@ -877,7 +877,7 @@ public class FileDataStorageManager { .getColumnIndex(ProviderTableMeta.FILE_LAST_SYNC_DATE))); file.setLastSyncDateForData(c.getLong(c. getColumnIndex(ProviderTableMeta.FILE_LAST_SYNC_DATE_FOR_DATA))); - file.setKeepInSync(c.getInt( + file.setFavorite(c.getInt( c.getColumnIndex(ProviderTableMeta.FILE_KEEP_IN_SYNC)) == 1 ? true : false); file.setEtag(c.getString(c.getColumnIndex(ProviderTableMeta.FILE_ETAG))); file.setShareByLink(c.getInt( @@ -1261,7 +1261,7 @@ public class FileDataStorageManager { ProviderTableMeta.FILE_LAST_SYNC_DATE_FOR_DATA, file.getLastSyncDateForData() ); - cv.put(ProviderTableMeta.FILE_KEEP_IN_SYNC, file.keepInSync() ? 1 : 0); + cv.put(ProviderTableMeta.FILE_KEEP_IN_SYNC, file.isFavorite() ? 1 : 0); cv.put(ProviderTableMeta.FILE_ETAG, file.getEtag()); cv.put(ProviderTableMeta.FILE_SHARE_BY_LINK, file.isShareByLink() ? 1 : 0); cv.put(ProviderTableMeta.FILE_PUBLIC_LINK, file.getPublicLink()); diff --git a/src/com/owncloud/android/datamodel/OCFile.java b/src/com/owncloud/android/datamodel/OCFile.java index 2c9c53be..d1821b44 100644 --- a/src/com/owncloud/android/datamodel/OCFile.java +++ b/src/com/owncloud/android/datamodel/OCFile.java @@ -60,7 +60,7 @@ public class OCFile implements Parcelable, Comparable { private boolean mNeedsUpdating; private long mLastSyncDateForProperties; private long mLastSyncDateForData; - private boolean mKeepInSync; + private boolean mFavorite; private String mEtag; @@ -107,7 +107,7 @@ public class OCFile implements Parcelable, Comparable { mLocalPath = source.readString(); mMimeType = source.readString(); mNeedsUpdating = source.readInt() == 0; - mKeepInSync = source.readInt() == 1; + mFavorite = source.readInt() == 1; mLastSyncDateForProperties = source.readLong(); mLastSyncDateForData = source.readLong(); mEtag = source.readString(); @@ -132,7 +132,7 @@ public class OCFile implements Parcelable, Comparable { dest.writeString(mLocalPath); dest.writeString(mMimeType); dest.writeInt(mNeedsUpdating ? 1 : 0); - dest.writeInt(mKeepInSync ? 1 : 0); + dest.writeInt(mFavorite ? 1 : 0); dest.writeLong(mLastSyncDateForProperties); dest.writeLong(mLastSyncDateForData); dest.writeString(mEtag); @@ -346,7 +346,7 @@ public class OCFile implements Parcelable, Comparable { mModifiedTimestampAtLastSyncForData = 0; mLastSyncDateForProperties = 0; mLastSyncDateForData = 0; - mKeepInSync = false; + mFavorite = false; mNeedsUpdating = false; mEtag = null; mShareByLink = false; @@ -444,12 +444,12 @@ public class OCFile implements Parcelable, Comparable { mLastSyncDateForData = lastSyncDate; } - public void setKeepInSync(boolean keepInSync) { - mKeepInSync = keepInSync; + public void setFavorite(boolean favorite) { + mFavorite = favorite; } - public boolean keepInSync() { - return mKeepInSync; + public boolean isFavorite() { + return mFavorite; } @Override @@ -483,8 +483,8 @@ public class OCFile implements Parcelable, Comparable { @Override public String toString() { - String asString = "[id=%s, name=%s, mime=%s, downloaded=%s, local=%s, remote=%s, parentId=%s, keepInSync=%s etag=%s]"; - asString = String.format(asString, Long.valueOf(mId), getFileName(), mMimeType, isDown(), mLocalPath, mRemotePath, Long.valueOf(mParentId), Boolean.valueOf(mKeepInSync), mEtag); + String asString = "[id=%s, name=%s, mime=%s, downloaded=%s, local=%s, remote=%s, parentId=%s, favorite=%s etag=%s]"; + asString = String.format(asString, Long.valueOf(mId), getFileName(), mMimeType, isDown(), mLocalPath, mRemotePath, Long.valueOf(mParentId), Boolean.valueOf(mFavorite), mEtag); return asString; } diff --git a/src/com/owncloud/android/files/FileMenuFilter.java b/src/com/owncloud/android/files/FileMenuFilter.java index 45aef48c..2c2754cc 100644 --- a/src/com/owncloud/android/files/FileMenuFilter.java +++ b/src/com/owncloud/android/files/FileMenuFilter.java @@ -216,14 +216,14 @@ public class FileMenuFilter { } // FAVORITES - if (mFile == null || downloading || uploading || mFile.isFolder() || mFile.keepInSync()) { + if (mFile == null || downloading || uploading || mFile.isFolder() || mFile.isFavorite()) { toHide.add(R.id.action_favorite_file); } else { toShow.add(R.id.action_favorite_file); } // UNFAVORITES - if (mFile == null || downloading || uploading || mFile.isFolder() || !mFile.keepInSync()) { + if (mFile == null || downloading || uploading || mFile.isFolder() || !mFile.isFavorite()) { toHide.add(R.id.action_unfavorite_file); } else { toShow.add(R.id.action_unfavorite_file); diff --git a/src/com/owncloud/android/files/FileOperationsHelper.java b/src/com/owncloud/android/files/FileOperationsHelper.java index fbc039b1..2f2907da 100644 --- a/src/com/owncloud/android/files/FileOperationsHelper.java +++ b/src/com/owncloud/android/files/FileOperationsHelper.java @@ -225,8 +225,8 @@ public class FileOperationsHelper { } } - public void toggleKeepInSync(OCFile file, boolean isFavorite) { - file.setKeepInSync(isFavorite); + public void toggleFavorite(OCFile file, boolean isFavorite) { + file.setFavorite(isFavorite); mFileActivity.getStorageManager().saveFile(file); /// register the OCFile instance in the observer service to monitor local updates @@ -238,7 +238,7 @@ public class FileOperationsHelper { mFileActivity.startService(observedFileIntent); /// immediate content synchronization - if (file.keepInSync()) { + if (file.isFavorite()) { syncFile(file); } } @@ -301,8 +301,8 @@ public class FileOperationsHelper { downloaderBinder.cancel(account, file); // TODO - review why is this here, and solve in a better way - // Remove etag for parent, if file is a keep_in_sync - if (file.keepInSync()) { + // Remove etag for parent, if file is a favorite + if (file.isFavorite()) { OCFile parent = mFileActivity.getStorageManager().getFileById(file.getParentId()); parent.setEtag(""); mFileActivity.getStorageManager().saveFile(parent); diff --git a/src/com/owncloud/android/operations/RefreshFolderOperation.java b/src/com/owncloud/android/operations/RefreshFolderOperation.java index 2e3c4692..ddbffb8c 100644 --- a/src/com/owncloud/android/operations/RefreshFolderOperation.java +++ b/src/com/owncloud/android/operations/RefreshFolderOperation.java @@ -365,7 +365,7 @@ public class RefreshFolderOperation extends RemoteOperation { if (localFile != null) { // some properties of local state are kept unmodified remoteFile.setFileId(localFile.getFileId()); - remoteFile.setKeepInSync(localFile.keepInSync()); + remoteFile.setFavorite(localFile.isFavorite()); remoteFile.setLastSyncDateForData(localFile.getLastSyncDateForData()); remoteFile.setModificationTimestampAtLastSyncForData( localFile.getModificationTimestampAtLastSyncForData() @@ -397,7 +397,7 @@ public class RefreshFolderOperation extends RemoteOperation { searchForLocalFileInDefaultPath(remoteFile); // legacy /// prepare content synchronization for kept-in-sync files - if (remoteFile.keepInSync()) { + if (remoteFile.isFavorite()) { SynchronizeFileOperation operation = new SynchronizeFileOperation( localFile, remoteFile, mAccount, diff --git a/src/com/owncloud/android/operations/SynchronizeFileOperation.java b/src/com/owncloud/android/operations/SynchronizeFileOperation.java index 27b0b5ad..f94adb15 100644 --- a/src/com/owncloud/android/operations/SynchronizeFileOperation.java +++ b/src/com/owncloud/android/operations/SynchronizeFileOperation.java @@ -245,12 +245,12 @@ public class SynchronizeFileOperation extends SyncOperation { if (mSyncFileContents) { requestForDownload(mLocalFile); // local, not server; we won't to keep - // the value of keepInSync! + // the value of favorite! // the update of local data will be done later by the FileUploader // service when the upload finishes } else { // TODO CHECK: is this really useful in some point in the code? - mServerFile.setKeepInSync(mLocalFile.keepInSync()); + mServerFile.setFavorite(mLocalFile.isFavorite()); mServerFile.setLastSyncDateForData(mLocalFile.getLastSyncDateForData()); mServerFile.setStoragePath(mLocalFile.getStoragePath()); mServerFile.setParentId(mLocalFile.getParentId()); @@ -285,7 +285,7 @@ public class SynchronizeFileOperation extends SyncOperation { i.putExtra(FileUploader.KEY_ACCOUNT, mAccount); i.putExtra(FileUploader.KEY_FILE, file); /*i.putExtra(FileUploader.KEY_REMOTE_FILE, mRemotePath); - // doing this we would lose the value of keepInSync in the road, and maybe + // doing this we would lose the value of isFavorite in the road, and maybe // it's not updated in the database when the FileUploader service gets it! i.putExtra(FileUploader.KEY_LOCAL_FILE, localFile.getStoragePath());*/ i.putExtra(FileUploader.KEY_UPLOAD_TYPE, FileUploader.UPLOAD_SINGLE_FILE); diff --git a/src/com/owncloud/android/operations/SynchronizeFolderOperation.java b/src/com/owncloud/android/operations/SynchronizeFolderOperation.java index 6bf1ef82..78b6a7ba 100644 --- a/src/com/owncloud/android/operations/SynchronizeFolderOperation.java +++ b/src/com/owncloud/android/operations/SynchronizeFolderOperation.java @@ -321,7 +321,7 @@ public class SynchronizeFolderOperation extends SyncOperation { if (localFile != null) { // some properties of local state are kept unmodified remoteFile.setFileId(localFile.getFileId()); - remoteFile.setKeepInSync(localFile.keepInSync()); + remoteFile.setFavorite(localFile.isFavorite()); remoteFile.setLastSyncDateForData(localFile.getLastSyncDateForData()); remoteFile.setModificationTimestampAtLastSyncForData( localFile.getModificationTimestampAtLastSyncForData() @@ -360,7 +360,7 @@ public class SynchronizeFolderOperation extends SyncOperation { startSyncFolderOperation(remoteFile.getRemotePath()); } - } else if (remoteFile.keepInSync()) { + } else if (remoteFile.isFavorite()) { /// prepare content synchronization for kept-in-sync files SynchronizeFileOperation operation = new SynchronizeFileOperation( localFile, diff --git a/src/com/owncloud/android/operations/UploadFileOperation.java b/src/com/owncloud/android/operations/UploadFileOperation.java index b114195b..12cf1ac7 100644 --- a/src/com/owncloud/android/operations/UploadFileOperation.java +++ b/src/com/owncloud/android/operations/UploadFileOperation.java @@ -407,7 +407,7 @@ public class UploadFileOperation extends RemoteOperation { newFile.setModificationTimestampAtLastSyncForData( mFile.getModificationTimestampAtLastSyncForData()); // newFile.setEtag(mFile.getEtag()) - newFile.setKeepInSync(mFile.keepInSync()); + newFile.setFavorite(mFile.isFavorite()); newFile.setLastSyncDateForProperties(mFile.getLastSyncDateForProperties()); newFile.setLastSyncDateForData(mFile.getLastSyncDateForData()); newFile.setStoragePath(mFile.getStoragePath()); diff --git a/src/com/owncloud/android/ui/activity/FileActivity.java b/src/com/owncloud/android/ui/activity/FileActivity.java index 87976487..b38e77b8 100644 --- a/src/com/owncloud/android/ui/activity/FileActivity.java +++ b/src/com/owncloud/android/ui/activity/FileActivity.java @@ -96,49 +96,49 @@ public class FileActivity extends ActionBarActivity "com.owncloud.android.ui.activity.WAITING_TO_PREVIEW"; public static final String EXTRA_FROM_NOTIFICATION = "com.owncloud.android.ui.activity.FROM_NOTIFICATION"; - + public static final String TAG = FileActivity.class.getSimpleName(); - + private static final String DIALOG_WAIT_TAG = "DIALOG_WAIT"; private static final String KEY_WAITING_FOR_OP_ID = "WAITING_FOR_OP_ID"; private static final String DIALOG_SHARE_PASSWORD = "DIALOG_SHARE_PASSWORD"; private static final String KEY_TRY_SHARE_AGAIN = "TRY_SHARE_AGAIN"; private static final String KEY_ACTION_BAR_TITLE = "ACTION_BAR_TITLE"; - + protected static final long DELAY_TO_REQUEST_OPERATION_ON_ACTIVITY_RESULTS = 200; - - + + /** OwnCloud {@link Account} where the main {@link OCFile} handled by the activity is located.*/ private Account mAccount; - + /** Main {@link OCFile} handled by the activity.*/ private OCFile mFile; - + /** Flag to signal that the activity will is finishing to enforce the creation of an ownCloud * {@link Account} */ private boolean mRedirectingToSetupAccount = false; - - /** Flag to signal when the value of mAccount was set */ + + /** Flag to signal when the value of mAccount was set */ protected boolean mAccountWasSet; - - /** Flag to signal when the value of mAccount was restored from a saved state */ + + /** Flag to signal when the value of mAccount was restored from a saved state */ protected boolean mAccountWasRestored; - + /** Flag to signal if the activity is launched by a notification */ private boolean mFromNotification; - + /** Messages handler associated to the main thread and the life cycle of the activity */ private Handler mHandler; - + /** Access point to the cached database for the current ownCloud {@link Account} */ private FileDataStorageManager mStorageManager = null; - + private FileOperationsHelper mFileOperationsHelper; - + private ServiceConnection mOperationsServiceConnection = null; - + private OperationsServiceBinder mOperationsServiceBinder = null; - + protected FileDownloaderBinder mDownloaderBinder = null; protected FileUploaderBinder mUploaderBinder = null; private ServiceConnection mDownloadServiceConnection, mUploadServiceConnection = null; @@ -161,12 +161,12 @@ public class FileActivity extends ActionBarActivity // TODO re-enable when "Accounts" is available in Navigation Drawer // protected boolean mShowAccounts = false; - + /** - * Loads the ownCloud {@link Account} and main {@link OCFile} to be handled by the instance of + * Loads the ownCloud {@link Account} and main {@link OCFile} to be handled by the instance of * the {@link FileActivity}. - * - * Grants that a valid ownCloud {@link Account} is associated to the instance, or that the user + * + * Grants that a valid ownCloud {@link Account} is associated to the instance, or that the user * is requested to create a new one. */ @Override @@ -194,11 +194,11 @@ public class FileActivity extends ActionBarActivity // or database setAccount(account, savedInstanceState != null); - + mOperationsServiceConnection = new OperationsServiceConnection(); bindService(new Intent(this, OperationsService.class), mOperationsServiceConnection, Context.BIND_AUTO_CREATE); - + mDownloadServiceConnection = newTransferenceServiceConnection(); if (mDownloadServiceConnection != null) { bindService(new Intent(this, FileDownloader.class), mDownloadServiceConnection, @@ -223,8 +223,8 @@ public class FileActivity extends ActionBarActivity } /** - * Since ownCloud {@link Account}s can be managed from the system setting menu, - * the existence of the {@link Account} associated to the instance must be checked + * Since ownCloud {@link Account}s can be managed from the system setting menu, + * the existence of the {@link Account} associated to the instance must be checked * every time it is restarted. */ @Override @@ -238,8 +238,8 @@ public class FileActivity extends ActionBarActivity Log_OC.v(TAG, "onRestart() end"); } - - @Override + + @Override protected void onStart() { super.onStart(); @@ -247,26 +247,26 @@ public class FileActivity extends ActionBarActivity onAccountSet(mAccountWasRestored); } } - + @Override protected void onResume() { super.onResume(); - + if (mOperationsServiceBinder != null) { doOnResumeAndBound(); } } - + @Override protected void onPause() { if (mOperationsServiceBinder != null) { mOperationsServiceBinder.removeOperationListener(this); } - + super.onPause(); } - - + + @Override protected void onDestroy() { if (mOperationsServiceConnection != null) { @@ -438,12 +438,12 @@ public class FileActivity extends ActionBarActivity /** - * Sets and validates the ownCloud {@link Account} associated to the Activity. - * + * Sets and validates the ownCloud {@link Account} associated to the Activity. + * * If not valid, tries to swap it for other valid and existing ownCloud {@link Account}. - * - * POSTCONDITION: updates {@link #mAccountWasSet} and {@link #mAccountWasRestored}. - * + * + * POSTCONDITION: updates {@link #mAccountWasSet} and {@link #mAccountWasRestored}. + * * @param account New {@link Account} to set. * @param savedAccount When 'true', account was retrieved from a saved instance state. */ @@ -456,19 +456,19 @@ public class FileActivity extends ActionBarActivity mAccount = account; mAccountWasSet = true; mAccountWasRestored = (savedAccount || mAccount.equals(oldAccount)); - + } else { swapToDefaultAccount(); } } - + /** - * Tries to swap the current ownCloud {@link Account} for other valid and existing. - * - * If no valid ownCloud {@link Account} exists, the the user is requested + * Tries to swap the current ownCloud {@link Account} for other valid and existing. + * + * If no valid ownCloud {@link Account} exists, the the user is requested * to create a new ownCloud {@link Account}. - * + * * POSTCONDITION: updates {@link #mAccountWasSet} and {@link #mAccountWasRestored}. */ private void swapToDefaultAccount() { @@ -480,7 +480,7 @@ public class FileActivity extends ActionBarActivity mRedirectingToSetupAccount = true; mAccountWasSet = false; mAccountWasRestored = false; - + } else { mAccountWasSet = true; mAccountWasRestored = (newAccount.equals(mAccount)); @@ -503,7 +503,7 @@ public class FileActivity extends ActionBarActivity null); } - + /** * {@inheritDoc} */ @@ -516,32 +516,32 @@ public class FileActivity extends ActionBarActivity outState.putBoolean(KEY_TRY_SHARE_AGAIN, mTryShareAgain); outState.putString(KEY_ACTION_BAR_TITLE, getSupportActionBar().getTitle().toString()); } - - + + /** * Getter for the main {@link OCFile} handled by the activity. - * + * * @return Main {@link OCFile} handled by the activity. */ public OCFile getFile() { return mFile; } - + /** * Setter for the main {@link OCFile} handled by the activity. - * + * * @param file Main {@link OCFile} to be handled by the activity. */ public void setFile(OCFile file) { mFile = file; } - + /** * Getter for the ownCloud {@link Account} where the main {@link OCFile} handled by the activity * is located. - * + * * @return OwnCloud {@link Account} where the main {@link OCFile} handled by the activity * is located. */ @@ -559,7 +559,7 @@ public class FileActivity extends ActionBarActivity public boolean fromNotification() { return mFromNotification; } - + /** * @return 'True' when the Activity is finishing to enforce the setup of a new account. */ @@ -574,11 +574,11 @@ public class FileActivity extends ActionBarActivity public void setTryShareAgain(boolean tryShareAgain) { mTryShareAgain = tryShareAgain; } - + public OperationsServiceBinder getOperationsServiceBinder() { return mOperationsServiceBinder; } - + protected ServiceConnection newTransferenceServiceConnection() { return null; } @@ -586,7 +586,7 @@ public class FileActivity extends ActionBarActivity /** * Helper class handling a callback from the {@link AccountManager} after the creation of * a new ownCloud {@link Account} finished, successfully or not. - * + * * At this moment, only called after the creation of the first account. */ public class AccountCreationCallback implements AccountManagerCallback { @@ -607,11 +607,11 @@ public class FileActivity extends ActionBarActivity } } catch (OperationCanceledException e) { Log_OC.d(TAG, "Account creation canceled"); - + } catch (Exception e) { Log_OC.e(TAG, "Account creation finished in exception: ", e); } - + } else { Log_OC.e(TAG, "Account creation callback with null bundle"); } @@ -619,19 +619,19 @@ public class FileActivity extends ActionBarActivity moveTaskToBack(true); } } - + } - - + + /** * Called when the ownCloud {@link Account} associated to the Activity was just updated. - * + * * Child classes must grant that state depending on the {@link Account} is updated. */ protected void onAccountSet(boolean stateWasRecovered) { if (getAccount() != null) { mStorageManager = new FileDataStorageManager(getAccount(), getContentResolver()); - + } else { Log_OC.wtf(TAG, "onAccountChanged was called with NULL account associated!"); } @@ -651,13 +651,13 @@ public class FileActivity extends ActionBarActivity public Handler getHandler() { return mHandler; } - + public FileOperationsHelper getFileOperationsHelper() { return mFileOperationsHelper; } - + /** - * + * * @param operation Removal operation performed. * @param result Result of the removal. */ @@ -665,17 +665,17 @@ public class FileActivity extends ActionBarActivity public void onRemoteOperationFinish(RemoteOperation operation, RemoteOperationResult result) { Log_OC.d(TAG, "Received result of operation in FileActivity - common behaviour for all the " + "FileActivities "); - + mFileOperationsHelper.setOpIdWaitingFor(Long.MAX_VALUE); - + if (!result.isSuccess() && ( - result.getCode() == ResultCode.UNAUTHORIZED || + result.getCode() == ResultCode.UNAUTHORIZED || result.isIdPRedirection() || (result.isException() && result.getException() instanceof AuthenticatorException) )) { - + requestCredentialsUpdate(); - + if (result.getCode() == ResultCode.UNAUTHORIZED) { dismissLoadingDialog(); Toast t = Toast.makeText(this, ErrorMessageAdapter.getErrorCauseMessage(result, @@ -687,10 +687,10 @@ public class FileActivity extends ActionBarActivity } else if (operation instanceof CreateShareOperation) { onCreateShareOperationFinish((CreateShareOperation) operation, result); - + } else if (operation instanceof UnshareLinkOperation) { onUnshareLinkOperationFinish((UnshareLinkOperation)operation, result); - + } else if (operation instanceof SynchronizeFolderOperation) { onSynchronizeFolderOperationFinish((SynchronizeFolderOperation)operation, result); @@ -704,12 +704,12 @@ public class FileActivity extends ActionBarActivity Intent updateAccountCredentials = new Intent(this, AuthenticatorActivity.class); updateAccountCredentials.putExtra(AuthenticatorActivity.EXTRA_ACCOUNT, getAccount()); updateAccountCredentials.putExtra( - AuthenticatorActivity.EXTRA_ACTION, + AuthenticatorActivity.EXTRA_ACTION, AuthenticatorActivity.ACTION_UPDATE_EXPIRED_TOKEN); updateAccountCredentials.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); startActivity(updateAccountCredentials); } - + private void onCreateShareOperationFinish(CreateShareOperation operation, RemoteOperationResult result) { @@ -717,7 +717,7 @@ public class FileActivity extends ActionBarActivity if (result.isSuccess()) { mTryShareAgain = false; updateFileFromDB(); - + Intent sendIntent = operation.getSendIntent(); startActivity(sendIntent); } else { @@ -741,22 +741,22 @@ public class FileActivity extends ActionBarActivity Toast.LENGTH_LONG); t.show(); } - } + } } - - + + private void onUnshareLinkOperationFinish(UnshareLinkOperation operation, RemoteOperationResult result) { dismissLoadingDialog(); - + if (result.isSuccess()){ updateFileFromDB(); - + } else { Toast t = Toast.makeText(this, ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources()), Toast.LENGTH_LONG); t.show(); - } + } } private void onSynchronizeFolderOperationFinish( @@ -781,18 +781,15 @@ public class FileActivity extends ActionBarActivity startActivity(i); } - } else { - if (operation.transferWasRequested()) { - - } else { + if (!operation.transferWasRequested()) { Toast msg = Toast.makeText(this, ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources()), Toast.LENGTH_LONG); msg.show(); } } } - + protected void updateFileFromDB(){ OCFile file = getFile(); if (file != null) { @@ -801,9 +798,9 @@ public class FileActivity extends ActionBarActivity } } - + /** - * Show loading dialog + * Show loading dialog */ public void showLoadingDialog() { // Construct dialog @@ -811,10 +808,10 @@ public class FileActivity extends ActionBarActivity FragmentManager fm = getSupportFragmentManager(); FragmentTransaction ft = fm.beginTransaction(); loading.show(ft, DIALOG_WAIT_TAG); - + } - + /** * Dismiss loading dialog */ @@ -826,7 +823,7 @@ public class FileActivity extends ActionBarActivity } } - + private void doOnResumeAndBound() { mOperationsServiceBinder.addOperationListener(FileActivity.this, mHandler); long waitingForOpId = mFileOperationsHelper.getOpIdWaitingFor(); @@ -840,8 +837,8 @@ public class FileActivity extends ActionBarActivity } - /** - * Implements callback methods for service binding. Passed as a parameter to { + /** + * Implements callback methods for service binding. Passed as a parameter to { */ private class OperationsServiceConnection implements ServiceConnection { @@ -859,7 +856,7 @@ public class FileActivity extends ActionBarActivity return; } } - + @Override public void onServiceDisconnected(ComponentName component) { diff --git a/src/com/owncloud/android/ui/adapter/FileListListAdapter.java b/src/com/owncloud/android/ui/adapter/FileListListAdapter.java index c6ea0344..8e8048ff 100644 --- a/src/com/owncloud/android/ui/adapter/FileListListAdapter.java +++ b/src/com/owncloud/android/ui/adapter/FileListListAdapter.java @@ -286,7 +286,7 @@ public class FileListListAdapter extends BaseAdapter implements ListAdapter { // this if-else is needed even though favorite icon is visible by default // because android reuses views in listview - if (!file.keepInSync()) { + if (!file.isFavorite()) { view.findViewById(R.id.favoriteIcon).setVisibility(View.GONE); } else { view.findViewById(R.id.favoriteIcon).setVisibility(View.VISIBLE); diff --git a/src/com/owncloud/android/ui/dialog/RemoveFileDialogFragment.java b/src/com/owncloud/android/ui/dialog/RemoveFileDialogFragment.java index 3045b278..72f40f97 100644 --- a/src/com/owncloud/android/ui/dialog/RemoveFileDialogFragment.java +++ b/src/com/owncloud/android/ui/dialog/RemoveFileDialogFragment.java @@ -110,21 +110,21 @@ implements ConfirmationDialogFragmentListener { FileDataStorageManager storageManager = cg.getStorageManager(); - boolean containsKeepInSync = false; + boolean containsFavorite = false; if (mTargetFile.isFolder()) { // TODO Enable when "On Device" is recovered ? Vector files = storageManager.getFolderContent(mTargetFile/*, false*/); for(OCFile file: files) { - containsKeepInSync = file.keepInSync() || containsKeepInSync; + containsFavorite = file.isFavorite() || containsFavorite; - if (containsKeepInSync) + if (containsFavorite) break; } } - // Remove etag for parent, if file is a keep_in_sync - // or is a folder and contains keep_in_sync - if (mTargetFile.keepInSync() || containsKeepInSync) { + // Remove etag for parent, if file is a favorite + // or is a folder and contains favorite + if (mTargetFile.isFavorite() || containsFavorite) { OCFile folder = null; if (mTargetFile.isFolder()) { folder = mTargetFile; diff --git a/src/com/owncloud/android/ui/fragment/FileDetailFragment.java b/src/com/owncloud/android/ui/fragment/FileDetailFragment.java index 94723721..9916a3d0 100644 --- a/src/com/owncloud/android/ui/fragment/FileDetailFragment.java +++ b/src/com/owncloud/android/ui/fragment/FileDetailFragment.java @@ -131,7 +131,7 @@ public class FileDetailFragment extends FileFragment implements OnClickListener mView = inflater.inflate(mLayout, null); if (mLayout == R.layout.file_details_fragment) { - mView.findViewById(R.id.fdKeepInSync).setOnClickListener(this); + mView.findViewById(R.id.fdFavorite).setOnClickListener(this); ProgressBar progressBar = (ProgressBar)mView.findViewById(R.id.fdProgressBar); mProgressListener = new ProgressListener(progressBar); mView.findViewById(R.id.fdCancelBtn).setOnClickListener(this); @@ -260,11 +260,11 @@ public class FileDetailFragment extends FileFragment implements OnClickListener return true; } case R.id.action_favorite_file:{ - mContainerActivity.getFileOperationsHelper().toggleKeepInSync(getFile(), true); + mContainerActivity.getFileOperationsHelper().toggleFavorite(getFile(), true); return true; } case R.id.action_unfavorite_file:{ - mContainerActivity.getFileOperationsHelper().toggleKeepInSync(getFile(), false); + mContainerActivity.getFileOperationsHelper().toggleFavorite(getFile(), false); return true; } default: @@ -275,9 +275,9 @@ public class FileDetailFragment extends FileFragment implements OnClickListener @Override public void onClick(View v) { switch (v.getId()) { - case R.id.fdKeepInSync: { - CheckBox cb = (CheckBox) getView().findViewById(R.id.fdKeepInSync); - mContainerActivity.getFileOperationsHelper().toggleKeepInSync(getFile(),cb.isChecked()); + case R.id.fdFavorite: { + CheckBox cb = (CheckBox) getView().findViewById(R.id.fdFavorite); + mContainerActivity.getFileOperationsHelper().toggleFavorite(getFile(),cb.isChecked()); break; } case R.id.fdCancelBtn: { @@ -337,8 +337,8 @@ public class FileDetailFragment extends FileFragment implements OnClickListener setTimeModified(file.getModificationTimestamp()); - CheckBox cb = (CheckBox)getView().findViewById(R.id.fdKeepInSync); - cb.setChecked(file.keepInSync()); + CheckBox cb = (CheckBox)getView().findViewById(R.id.fdFavorite); + cb.setChecked(file.isFavorite()); // configure UI for depending upon local state of the file FileDownloaderBinder downloaderBinder = mContainerActivity.getFileDownloaderBinder(); @@ -426,7 +426,7 @@ public class FileDetailFragment extends FileFragment implements OnClickListener private void setButtonsForTransferring() { if (!isEmpty()) { // let's protect the user from himself ;) - getView().findViewById(R.id.fdKeepInSync).setEnabled(false); + getView().findViewById(R.id.fdFavorite).setEnabled(false); // show the progress bar for the transfer getView().findViewById(R.id.fdProgressBlock).setVisibility(View.VISIBLE); @@ -448,7 +448,7 @@ public class FileDetailFragment extends FileFragment implements OnClickListener */ private void setButtonsForDown() { if (!isEmpty()) { - getView().findViewById(R.id.fdKeepInSync).setEnabled(true); + getView().findViewById(R.id.fdFavorite).setEnabled(true); // hides the progress bar getView().findViewById(R.id.fdProgressBlock).setVisibility(View.GONE); @@ -462,7 +462,7 @@ public class FileDetailFragment extends FileFragment implements OnClickListener */ private void setButtonsForRemote() { if (!isEmpty()) { - getView().findViewById(R.id.fdKeepInSync).setEnabled(true); + getView().findViewById(R.id.fdFavorite).setEnabled(true); // hides the progress bar getView().findViewById(R.id.fdProgressBlock).setVisibility(View.GONE); diff --git a/src/com/owncloud/android/ui/fragment/OCFileListFragment.java b/src/com/owncloud/android/ui/fragment/OCFileListFragment.java index 7160973c..47d99925 100644 --- a/src/com/owncloud/android/ui/fragment/OCFileListFragment.java +++ b/src/com/owncloud/android/ui/fragment/OCFileListFragment.java @@ -342,11 +342,11 @@ public class OCFileListFragment extends ExtendedListFragment { return true; } case R.id.action_favorite_file:{ - mContainerActivity.getFileOperationsHelper().toggleKeepInSync(mTargetFile, true); + mContainerActivity.getFileOperationsHelper().toggleFavorite(mTargetFile, true); return true; } case R.id.action_unfavorite_file:{ - mContainerActivity.getFileOperationsHelper().toggleKeepInSync(mTargetFile, false); + mContainerActivity.getFileOperationsHelper().toggleFavorite(mTargetFile, false); return true; } default: diff --git a/src/com/owncloud/android/ui/preview/PreviewImageFragment.java b/src/com/owncloud/android/ui/preview/PreviewImageFragment.java index b625ac22..7ca1cfbb 100644 --- a/src/com/owncloud/android/ui/preview/PreviewImageFragment.java +++ b/src/com/owncloud/android/ui/preview/PreviewImageFragment.java @@ -307,11 +307,11 @@ public class PreviewImageFragment extends FileFragment { return true; } case R.id.action_favorite_file:{ - mContainerActivity.getFileOperationsHelper().toggleKeepInSync(getFile(), true); + mContainerActivity.getFileOperationsHelper().toggleFavorite(getFile(), true); return true; } case R.id.action_unfavorite_file:{ - mContainerActivity.getFileOperationsHelper().toggleKeepInSync(getFile(), false); + mContainerActivity.getFileOperationsHelper().toggleFavorite(getFile(), false); return true; } default: diff --git a/src/com/owncloud/android/ui/preview/PreviewMediaFragment.java b/src/com/owncloud/android/ui/preview/PreviewMediaFragment.java index 53659438..d87b82cb 100644 --- a/src/com/owncloud/android/ui/preview/PreviewMediaFragment.java +++ b/src/com/owncloud/android/ui/preview/PreviewMediaFragment.java @@ -342,11 +342,11 @@ public class PreviewMediaFragment extends FileFragment implements return true; } case R.id.action_favorite_file:{ - mContainerActivity.getFileOperationsHelper().toggleKeepInSync(getFile(), true); + mContainerActivity.getFileOperationsHelper().toggleFavorite(getFile(), true); return true; } case R.id.action_unfavorite_file:{ - mContainerActivity.getFileOperationsHelper().toggleKeepInSync(getFile(), false); + mContainerActivity.getFileOperationsHelper().toggleFavorite(getFile(), false); return true; } default: