diff --git a/src/main/java/com/owncloud/android/authentication/AuthenticatorActivity.java b/src/main/java/com/owncloud/android/authentication/AuthenticatorActivity.java index 2baa3425e8..2b1a2de97e 100644 --- a/src/main/java/com/owncloud/android/authentication/AuthenticatorActivity.java +++ b/src/main/java/com/owncloud/android/authentication/AuthenticatorActivity.java @@ -545,7 +545,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity mAuthTokenType = getIntent().getExtras().getString(AccountAuthenticator.KEY_AUTH_TOKEN_TYPE); if (mAuthTokenType == null) { if (mAccount != null) { - boolean oAuthRequired = (mAccountMgr.getUserData(mAccount, Constants.KEY_SUPPORTS_OAUTH2) != null); + boolean oAuthRequired = mAccountMgr.getUserData(mAccount, Constants.KEY_SUPPORTS_OAUTH2) != null; boolean samlWebSsoRequired = ( mAccountMgr.getUserData (mAccount, Constants.KEY_SUPPORTS_SAML_WEB_SSO) != null diff --git a/src/main/java/com/owncloud/android/authentication/AuthenticatorUrlUtils.java b/src/main/java/com/owncloud/android/authentication/AuthenticatorUrlUtils.java index 01133293ad..4c5d5869bc 100644 --- a/src/main/java/com/owncloud/android/authentication/AuthenticatorUrlUtils.java +++ b/src/main/java/com/owncloud/android/authentication/AuthenticatorUrlUtils.java @@ -91,7 +91,7 @@ public abstract class AuthenticatorUrlUtils { normalizedUrl = normalizeUrlSuffix(normalizedUrl); } - return (normalizedUrl != null ? normalizedUrl : ""); + return normalizedUrl != null ? normalizedUrl : ""; } public static String trimWebdavSuffix(String url) { diff --git a/src/main/java/com/owncloud/android/datamodel/FilesystemDataProvider.java b/src/main/java/com/owncloud/android/datamodel/FilesystemDataProvider.java index 29c176878c..ccd2d63b85 100644 --- a/src/main/java/com/owncloud/android/datamodel/FilesystemDataProvider.java +++ b/src/main/java/com/owncloud/android/datamodel/FilesystemDataProvider.java @@ -222,8 +222,6 @@ public class FilesystemDataProvider { return crc.getValue(); - } catch (FileNotFoundException e) { - return -1; } catch (IOException e) { return -1; } diff --git a/src/main/java/com/owncloud/android/db/OCUpload.java b/src/main/java/com/owncloud/android/db/OCUpload.java index a0a5fbabd2..aabeb0e9ae 100644 --- a/src/main/java/com/owncloud/android/db/OCUpload.java +++ b/src/main/java/com/owncloud/android/db/OCUpload.java @@ -1,4 +1,4 @@ -/** +/* * ownCloud Android client application * * @author LukeOwncloud @@ -401,8 +401,8 @@ public class OCUpload implements Parcelable { mRemotePath = source.readString(); mAccountName = source.readString(); mLocalAction = source.readInt(); - mForceOverwrite = (source.readInt() == 1); - mIsCreateRemoteFolder = (source.readInt() == 1); + mForceOverwrite = source.readInt() == 1; + mIsCreateRemoteFolder = source.readInt() == 1; try { mUploadStatus = UploadStatus.valueOf(source.readString()); } catch (IllegalArgumentException x) { @@ -415,8 +415,8 @@ public class OCUpload implements Parcelable { mLastResult = UploadResult.UNKNOWN; } mCreatedBy = source.readInt(); - mIsUseWifiOnly = (source.readInt() == 1); - mIsWhileChargingOnly = (source.readInt() == 1); + mIsUseWifiOnly = source.readInt() == 1; + mIsWhileChargingOnly = source.readInt() == 1; mFolderUnlockToken = source.readString(); } diff --git a/src/main/java/com/owncloud/android/files/services/FileDownloader.java b/src/main/java/com/owncloud/android/files/services/FileDownloader.java index 89a885e8b1..0031316d61 100644 --- a/src/main/java/com/owncloud/android/files/services/FileDownloader.java +++ b/src/main/java/com/owncloud/android/files/services/FileDownloader.java @@ -134,7 +134,7 @@ public class FileDownloader extends Service .setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.notification_icon)) .setColor(ThemeUtils.primaryColor(getApplicationContext(), true)); - if ((android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O)) { + if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) { builder.setChannelId(NotificationUtils.NOTIFICATION_CHANNEL_DOWNLOAD); } @@ -528,7 +528,7 @@ public class FileDownloader extends Service new File(download.getSavePath()).getName()) ); - if ((android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O)) { + if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) { mNotificationBuilder.setChannelId(NotificationUtils.NOTIFICATION_CHANNEL_DOWNLOAD); } diff --git a/src/main/java/com/owncloud/android/files/services/FileUploader.java b/src/main/java/com/owncloud/android/files/services/FileUploader.java index bcacb2cf1f..caa3b477d1 100644 --- a/src/main/java/com/owncloud/android/files/services/FileUploader.java +++ b/src/main/java/com/owncloud/android/files/services/FileUploader.java @@ -469,7 +469,7 @@ public class FileUploader extends Service .setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.notification_icon)) .setColor(ThemeUtils.primaryColor(getApplicationContext(), true)); - if ((android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O)) { + if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) { builder.setChannelId(NotificationUtils.NOTIFICATION_CHANNEL_UPLOAD); } @@ -601,7 +601,7 @@ public class FileUploader extends Service files[i] = UploadFileOperation.obtainNewOCFileToUpload( remotePaths[i], localPaths[i], - ((mimeTypes != null) ? mimeTypes[i] : null) + mimeTypes != null ? mimeTypes[i] : null ); if (files[i] == null) { Log_OC.e(TAG, "obtainNewOCFileToUpload() returned null for remotePaths[i]:" + remotePaths[i] @@ -612,13 +612,13 @@ public class FileUploader extends Service } // at this point variable "OCFile[] files" is loaded correctly. - String uploadKey = null; - UploadFileOperation newUpload = null; + String uploadKey; + UploadFileOperation newUpload; try { - for (int i = 0; i < files.length; i++) { + for (OCFile file : files) { - OCUpload ocUpload = new OCUpload(files[i], account); - ocUpload.setFileSize(files[i].getFileLength()); + OCUpload ocUpload = new OCUpload(file, account); + ocUpload.setFileSize(file.getFileLength()); ocUpload.setForceOverwrite(forceOverwrite); ocUpload.setCreateRemoteFolder(isCreateRemoteFolder); ocUpload.setCreatedBy(createdBy); @@ -630,7 +630,7 @@ public class FileUploader extends Service newUpload = new UploadFileOperation( account, - files[i], + file, ocUpload, forceOverwrite, localAction, @@ -649,7 +649,7 @@ public class FileUploader extends Service Pair putResult = mPendingUploads.putIfAbsent( account.name, - files[i].getRemotePath(), + file.getRemotePath(), newUpload ); if (putResult != null) { @@ -1153,7 +1153,7 @@ public class FileUploader extends Service String.format(getString(R.string.uploader_upload_in_progress_content), 0, upload.getFileName()) ); - if ((android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O)) { + if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) { mNotificationBuilder.setChannelId(NotificationUtils.NOTIFICATION_CHANNEL_UPLOAD); } @@ -1223,7 +1223,7 @@ public class FileUploader extends Service String content; // check credentials error - boolean needsToUpdateCredentials = (ResultCode.UNAUTHORIZED.equals(uploadResult.getCode())); + boolean needsToUpdateCredentials = ResultCode.UNAUTHORIZED.equals(uploadResult.getCode()); tickerId = (needsToUpdateCredentials) ? R.string.uploader_upload_failed_credentials_error : tickerId; diff --git a/src/main/java/com/owncloud/android/jobs/NotificationJob.java b/src/main/java/com/owncloud/android/jobs/NotificationJob.java index 2d02dc5342..6fb0a24184 100644 --- a/src/main/java/com/owncloud/android/jobs/NotificationJob.java +++ b/src/main/java/com/owncloud/android/jobs/NotificationJob.java @@ -60,7 +60,7 @@ public class NotificationJob extends Job { @NonNull @Override - protected Result onRunJob(Params params) { + protected Result onRunJob(@NonNull Params params) { Context context = getContext(); PersistableBundleCompat persistableBundleCompat = getParams().getExtras(); @@ -68,7 +68,6 @@ public class NotificationJob extends Job { String signature = persistableBundleCompat.getString(KEY_NOTIFICATION_SIGNATURE, ""); if (!TextUtils.isEmpty(subject) && !TextUtils.isEmpty(signature)) { - try { byte[] base64DecodedSubject = Base64.decode(subject, Base64.DEFAULT); byte[] base64DecodedSignature = Base64.decode(signature, Base64.DEFAULT); @@ -92,14 +91,10 @@ public class NotificationJob extends Job { if (!decryptedPushMessage.getApp().equals("spreed")) { sendNotification(decryptedPushMessage.getSubject(), signatureVerification.getAccount()); } - } - } catch (NoSuchAlgorithmException e1) { - Log.d(TAG, "No proper algorithm to decrypt the message " + e1.getLocalizedMessage()); - } catch (NoSuchPaddingException e1) { - Log.d(TAG, "No proper padding to decrypt the message " + e1.getLocalizedMessage()); - } catch (InvalidKeyException e1) { - Log.d(TAG, "Invalid private key " + e1.getLocalizedMessage()); + } catch (NoSuchAlgorithmException | NoSuchPaddingException | InvalidKeyException e1) { + Log.d(TAG, "Error decrypting message " + e1.getClass().getName() + + " " + e1.getLocalizedMessage()); } } catch (Exception exception) { Log.d(TAG, "Something went very wrong" + exception.getLocalizedMessage()); @@ -127,7 +122,7 @@ public class NotificationJob extends Job { .setAutoCancel(true) .setContentIntent(pendingIntent); - if ((android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O)) { + if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) { notificationBuilder.setChannelId(NotificationUtils.NOTIFICATION_CHANNEL_PUSH); } @@ -136,5 +131,4 @@ public class NotificationJob extends Job { notificationManager.notify(0, notificationBuilder.build()); } - } diff --git a/src/main/java/com/owncloud/android/media/MediaService.java b/src/main/java/com/owncloud/android/media/MediaService.java index 0ba7e202f1..1fdcee567c 100644 --- a/src/main/java/com/owncloud/android/media/MediaService.java +++ b/src/main/java/com/owncloud/android/media/MediaService.java @@ -470,27 +470,9 @@ public class MediaService extends Service implements OnCompletionListener, OnPre mWifiLock.release(); } - } catch (SecurityException e) { - Log_OC.e(TAG, "SecurityException playing " + mAccount.name + mFile.getRemotePath(), e); - Toast.makeText(this, String.format(getString(R.string.media_err_security_ex), mFile.getFileName()), - Toast.LENGTH_LONG).show(); - processStopRequest(true); - - } catch (IOException e) { - Log_OC.e(TAG, "IOException playing " + mAccount.name + mFile.getRemotePath(), e); - Toast.makeText(this, String.format(getString(R.string.media_err_io_ex), mFile.getFileName()), - Toast.LENGTH_LONG).show(); - processStopRequest(true); - - } catch (IllegalStateException e) { - Log_OC.e(TAG, "IllegalStateException " + mAccount.name + mFile.getRemotePath(), e); - Toast.makeText(this, String.format(getString(R.string.media_err_unexpected), mFile.getFileName()), - Toast.LENGTH_LONG).show(); - processStopRequest(true); - - } catch (IllegalArgumentException e) { - Log_OC.e(TAG, "IllegalArgumentException " + mAccount.name + mFile.getRemotePath(), e); - Toast.makeText(this, String.format(getString(R.string.media_err_unexpected), mFile.getFileName()), + } catch (SecurityException | IOException | IllegalStateException | IllegalArgumentException e) { + Log_OC.e(TAG, e.getClass().getSimpleName() + " playing " + mAccount.name + mFile.getRemotePath(), e); + Toast.makeText(this, String.format(getString(R.string.media_err_playing), mFile.getFileName()), Toast.LENGTH_LONG).show(); processStopRequest(true); } @@ -556,7 +538,7 @@ public class MediaService extends Service implements OnCompletionListener, OnPre mNotificationBuilder.setContentTitle(ticker); mNotificationBuilder.setContentText(content); - if ((android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O)) { + if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) { mNotificationBuilder.setChannelId(NotificationUtils.NOTIFICATION_CHANNEL_MEDIA); } @@ -593,7 +575,7 @@ public class MediaService extends Service implements OnCompletionListener, OnPre mNotificationBuilder.setContentTitle(ticker); mNotificationBuilder.setContentText(content); - if ((android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O)) { + if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) { mNotificationBuilder.setChannelId(NotificationUtils.NOTIFICATION_CHANNEL_MEDIA); } diff --git a/src/main/java/com/owncloud/android/media/MediaServiceBinder.java b/src/main/java/com/owncloud/android/media/MediaServiceBinder.java index 7dff43071f..1265f5b359 100644 --- a/src/main/java/com/owncloud/android/media/MediaServiceBinder.java +++ b/src/main/java/com/owncloud/android/media/MediaServiceBinder.java @@ -57,12 +57,10 @@ public class MediaServiceBinder extends Binder implements MediaController.MediaP mService = service; } - public boolean isPlaying(OCFile mFile) { - return (mFile != null && mFile.equals(mService.getCurrentFile())); + return mFile != null && mFile.equals(mService.getCurrentFile()); } - @Override public boolean canPause() { return true; diff --git a/src/main/java/com/owncloud/android/operations/RemoveRemoteEncryptedFileOperation.java b/src/main/java/com/owncloud/android/operations/RemoveRemoteEncryptedFileOperation.java index c64f6fa8b2..3ffefd6bfe 100644 --- a/src/main/java/com/owncloud/android/operations/RemoveRemoteEncryptedFileOperation.java +++ b/src/main/java/com/owncloud/android/operations/RemoveRemoteEncryptedFileOperation.java @@ -126,7 +126,7 @@ public class RemoveRemoteEncryptedFileOperation extends RemoteOperation { int status = client.executeMethod(delete, REMOVE_READ_TIMEOUT, REMOVE_CONNECTION_TIMEOUT); delete.getResponseBodyAsString(); // exhaust the response, although not interesting - result = new RemoteOperationResult((delete.succeeded() || status == HttpStatus.SC_NOT_FOUND), delete); + result = new RemoteOperationResult(delete.succeeded() || status == HttpStatus.SC_NOT_FOUND, delete); Log_OC.i(TAG, "Remove " + remotePath + ": " + result.getLogMessage()); // remove file from metadata diff --git a/src/main/java/com/owncloud/android/operations/RenameFileOperation.java b/src/main/java/com/owncloud/android/operations/RenameFileOperation.java index c82cc7da56..e721786d6a 100644 --- a/src/main/java/com/owncloud/android/operations/RenameFileOperation.java +++ b/src/main/java/com/owncloud/android/operations/RenameFileOperation.java @@ -46,8 +46,6 @@ public class RenameFileOperation extends SyncOperation { private String mRemotePath; private String mNewName; private String mNewRemotePath; - - /** * Constructor @@ -114,7 +112,7 @@ public class RenameFileOperation extends SyncOperation { } catch (IOException e) { Log_OC.e(TAG, "Rename " + mFile.getRemotePath() + " to " + ((mNewRemotePath==null) ? mNewName : mNewRemotePath) + ": " + - ((result!= null) ? result.getLogMessage() : ""), e); + (result!= null ? result.getLogMessage() : ""), e); } return result; @@ -184,7 +182,7 @@ public class RenameFileOperation extends SyncOperation { Log_OC.i(TAG, "Test for validity of name " + mNewName + " in the file system failed"); return false; } - boolean result = (testFile.exists() && testFile.isFile()); + boolean result = testFile.exists() && testFile.isFile(); // cleaning ; result is ignored, since there is not much we could do in case of failure, // but repeat and repeat... @@ -192,5 +190,4 @@ public class RenameFileOperation extends SyncOperation { return result; } - } diff --git a/src/main/java/com/owncloud/android/operations/SynchronizeFileOperation.java b/src/main/java/com/owncloud/android/operations/SynchronizeFileOperation.java index d09ed2f84c..5b1aa36b51 100644 --- a/src/main/java/com/owncloud/android/operations/SynchronizeFileOperation.java +++ b/src/main/java/com/owncloud/android/operations/SynchronizeFileOperation.java @@ -210,7 +210,7 @@ public class SynchronizeFileOperation extends SyncOperation { serverChanged = mServerFile.getModificationTimestamp() != mLocalFile.getModificationTimestampAtLastSyncForData(); } else { - serverChanged = (!mServerFile.getEtag().equals(mLocalFile.getEtag())); + serverChanged = !mServerFile.getEtag().equals(mLocalFile.getEtag()); } boolean localChanged = ( mLocalFile.getLocalModificationTimestamp() > mLocalFile.getLastSyncDateForData() diff --git a/src/main/java/com/owncloud/android/services/OperationsService.java b/src/main/java/com/owncloud/android/services/OperationsService.java index d3cdb908d7..1986ff5037 100644 --- a/src/main/java/com/owncloud/android/services/OperationsService.java +++ b/src/main/java/com/owncloud/android/services/OperationsService.java @@ -331,7 +331,7 @@ public class OperationsService extends Service { * in process. */ public boolean isPerformingBlockingOperation() { - return (!mServiceHandler.mPendingOperations.isEmpty()); + return !mServiceHandler.mPendingOperations.isEmpty(); } diff --git a/src/main/java/com/owncloud/android/services/SyncFolderHandler.java b/src/main/java/com/owncloud/android/services/SyncFolderHandler.java index 548938222e..f41ff3bea1 100644 --- a/src/main/java/com/owncloud/android/services/SyncFolderHandler.java +++ b/src/main/java/com/owncloud/android/services/SyncFolderHandler.java @@ -51,7 +51,6 @@ class SyncFolderHandler extends Handler { private static final String TAG = SyncFolderHandler.class.getSimpleName(); - private OperationsService mService; private IndexedForest mPendingOperations = new IndexedForest<>(); @@ -69,7 +68,6 @@ class SyncFolderHandler extends Handler { mService = service; } - /** * Returns True when the folder located in 'remotePath' in the ownCloud account 'account', or any of its * descendants, is being synchronized (or waiting for it). @@ -81,10 +79,9 @@ class SyncFolderHandler extends Handler { if (account == null || remotePath == null) { return false; } - return (mPendingOperations.contains(account.name, remotePath)); + return mPendingOperations.contains(account.name, remotePath); } - @Override public void handleMessage(Message msg) { Pair itemSyncKey = (Pair) msg.obj; diff --git a/src/main/java/com/owncloud/android/syncadapter/FileSyncAdapter.java b/src/main/java/com/owncloud/android/syncadapter/FileSyncAdapter.java index 9f3b724e5b..0d9d091210 100644 --- a/src/main/java/com/owncloud/android/syncadapter/FileSyncAdapter.java +++ b/src/main/java/com/owncloud/android/syncadapter/FileSyncAdapter.java @@ -525,7 +525,7 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter { NotificationManager notificationManager = ((NotificationManager) getContext(). getSystemService(Context.NOTIFICATION_SERVICE)); - if ((android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O)) { + if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) { builder.setChannelId(NotificationUtils.NOTIFICATION_CHANNEL_FILE_SYNC); } diff --git a/src/main/java/com/owncloud/android/ui/activity/BaseActivity.java b/src/main/java/com/owncloud/android/ui/activity/BaseActivity.java index d3352239f3..3e7041e1c2 100644 --- a/src/main/java/com/owncloud/android/ui/activity/BaseActivity.java +++ b/src/main/java/com/owncloud/android/ui/activity/BaseActivity.java @@ -71,7 +71,7 @@ public abstract class BaseActivity extends AppCompatActivity { protected void onRestart() { Log_OC.v(TAG, "onRestart() start"); super.onRestart(); - boolean validAccount = (mCurrentAccount != null && AccountUtils.exists(mCurrentAccount, this)); + boolean validAccount = mCurrentAccount != null && AccountUtils.exists(mCurrentAccount, this); if (!validAccount) { swapToDefaultAccount(); } diff --git a/src/main/java/com/owncloud/android/ui/activity/FileActivity.java b/src/main/java/com/owncloud/android/ui/activity/FileActivity.java index 9355be1841..3f99e05c82 100644 --- a/src/main/java/com/owncloud/android/ui/activity/FileActivity.java +++ b/src/main/java/com/owncloud/android/ui/activity/FileActivity.java @@ -384,7 +384,7 @@ public abstract class FileActivity extends DrawerActivity } OwnCloudClient client; OwnCloudAccount ocAccount = new OwnCloudAccount(account, context); - client = (OwnCloudClientManagerFactory.getDefaultSingleton().removeClientFor(ocAccount)); + client = OwnCloudClientManagerFactory.getDefaultSingleton().removeClientFor(ocAccount); if (client != null) { OwnCloudCredentials cred = client.getCredentials(); if (cred != null) { diff --git a/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java b/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java index 247645e575..2da4aafd15 100644 --- a/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java +++ b/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java @@ -1322,8 +1322,8 @@ public class FileDisplayActivity extends HookActivity setFile(currentFile); } - mSyncInProgress = (!FileSyncAdapter.EVENT_FULL_SYNC_END.equals(event) && - !RefreshFolderOperation.EVENT_SINGLE_FOLDER_SHARES_SYNCED.equals(event)); + mSyncInProgress = !FileSyncAdapter.EVENT_FULL_SYNC_END.equals(event) && + !RefreshFolderOperation.EVENT_SINGLE_FOLDER_SHARES_SYNCED.equals(event); if (RefreshFolderOperation.EVENT_SINGLE_FOLDER_CONTENTS_SYNCED.equals(event) && synchResult != null && !synchResult.isSuccess()) { @@ -1410,8 +1410,8 @@ public class FileDisplayActivity extends HookActivity String accountName = intent.getStringExtra(FileUploader.ACCOUNT_NAME); boolean sameAccount = getAccount() != null && accountName.equals(getAccount().name); OCFile currentDir = getCurrentDir(); - boolean isDescendant = (currentDir != null) && (uploadedRemotePath != null) && - (uploadedRemotePath.startsWith(currentDir.getRemotePath())); + boolean isDescendant = currentDir != null && uploadedRemotePath != null && + uploadedRemotePath.startsWith(currentDir.getRemotePath()); if (sameAccount && isDescendant) { String linkedToRemotePath = @@ -2266,7 +2266,7 @@ public class FileDisplayActivity extends HookActivity String activityName) { mWaitingToSend = file; requestForDownload(mWaitingToSend, downloadBehaviour, packageName, activityName); - boolean hasSecondFragment = (getSecondFragment() != null); + boolean hasSecondFragment = getSecondFragment() != null; updateFragmentsVisibility(hasSecondFragment); } diff --git a/src/main/java/com/owncloud/android/ui/activity/FolderPickerActivity.java b/src/main/java/com/owncloud/android/ui/activity/FolderPickerActivity.java index 3d737d3c48..7b8641af69 100644 --- a/src/main/java/com/owncloud/android/ui/activity/FolderPickerActivity.java +++ b/src/main/java/com/owncloud/android/ui/activity/FolderPickerActivity.java @@ -379,7 +379,7 @@ public class FolderPickerActivity extends FileActivity implements FileFragment.C ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { - boolean atRoot = (currentDir == null || currentDir.getParentId() == 0); + boolean atRoot = currentDir == null || currentDir.getParentId() == 0; actionBar.setDisplayHomeAsUpEnabled(!atRoot); actionBar.setHomeButtonEnabled(!atRoot); diff --git a/src/main/java/com/owncloud/android/ui/activity/NotificationsActivity.java b/src/main/java/com/owncloud/android/ui/activity/NotificationsActivity.java index d96a27c7ec..3278fc6982 100644 --- a/src/main/java/com/owncloud/android/ui/activity/NotificationsActivity.java +++ b/src/main/java/com/owncloud/android/ui/activity/NotificationsActivity.java @@ -295,19 +295,13 @@ public class NotificationsActivity extends FileActivity { // show error runOnUiThread(() -> setEmptyContent(noResultsHeadline, getString(R.string.account_not_found))); } - } catch (com.owncloud.android.lib.common.accounts.AccountUtils.AccountNotFoundException e) { - Log_OC.e(TAG, "Account not found", e); - } catch (IOException e) { - Log_OC.e(TAG, "IO error", e); - } catch (OperationCanceledException e) { - Log_OC.e(TAG, "Operation has been canceled", e); - } catch (AuthenticatorException e) { - Log_OC.e(TAG, "Authentication Exception", e); + } catch (com.owncloud.android.lib.common.accounts.AccountUtils.AccountNotFoundException | IOException | + OperationCanceledException | AuthenticatorException e) { + Log_OC.e(TAG, "Error fetching notification data", e); } }); t.start(); - } private void hideRefreshLayoutLoader() { diff --git a/src/main/java/com/owncloud/android/ui/activity/ToolbarActivity.java b/src/main/java/com/owncloud/android/ui/activity/ToolbarActivity.java index 894a9599f9..78fb80dcaa 100644 --- a/src/main/java/com/owncloud/android/ui/activity/ToolbarActivity.java +++ b/src/main/java/com/owncloud/android/ui/activity/ToolbarActivity.java @@ -99,10 +99,8 @@ public abstract class ToolbarActivity extends BaseActivity { boolean inRoot; // choose the appropriate title - inRoot = ( - chosenFile == null || - (chosenFile.isFolder() && chosenFile.getParentId() == FileDataStorageManager.ROOT_PARENT_ID) - ); + inRoot = chosenFile == null || + (chosenFile.isFolder() && chosenFile.getParentId() == FileDataStorageManager.ROOT_PARENT_ID); if (!inRoot) { title = chosenFile.getFileName(); } diff --git a/src/main/java/com/owncloud/android/ui/activity/UploadFilesActivity.java b/src/main/java/com/owncloud/android/ui/activity/UploadFilesActivity.java index d630ce8d46..80c5cf27ee 100644 --- a/src/main/java/com/owncloud/android/ui/activity/UploadFilesActivity.java +++ b/src/main/java/com/owncloud/android/ui/activity/UploadFilesActivity.java @@ -321,7 +321,7 @@ public class UploadFilesActivity extends FileActivity implements return false; } else { View mSearchEditFrame = mSearchView.findViewById(android.support.v7.appcompat.R.id.search_edit_frame); - return (mSearchEditFrame != null && mSearchEditFrame.getVisibility() == View.VISIBLE); + return mSearchEditFrame != null && mSearchEditFrame.getVisibility() == View.VISIBLE; } } diff --git a/src/main/java/com/owncloud/android/ui/adapter/ProgressListener.java b/src/main/java/com/owncloud/android/ui/adapter/ProgressListener.java index 175caf282b..8c6bcf86aa 100644 --- a/src/main/java/com/owncloud/android/ui/adapter/ProgressListener.java +++ b/src/main/java/com/owncloud/android/ui/adapter/ProgressListener.java @@ -61,10 +61,7 @@ public class ProgressListener implements OnDatatransferProgressListener { public boolean isWrapping(ProgressBar progressBar) { ProgressBar wrappedProgressBar = mProgressBar.get(); - return ( - wrappedProgressBar != null && - wrappedProgressBar == progressBar // on purpose; don't replace with equals - ); + return wrappedProgressBar != null && wrappedProgressBar == progressBar; // on purpose; don't replace with equals } public OCUpload getUpload() { diff --git a/src/main/java/com/owncloud/android/ui/adapter/SslCertificateViewAdapter.java b/src/main/java/com/owncloud/android/ui/adapter/SslCertificateViewAdapter.java index cc00c01746..88f6835392 100644 --- a/src/main/java/com/owncloud/android/ui/adapter/SslCertificateViewAdapter.java +++ b/src/main/java/com/owncloud/android/ui/adapter/SslCertificateViewAdapter.java @@ -38,12 +38,11 @@ public class SslCertificateViewAdapter implements SslUntrustedCertDialog.Certifi //private final static String TAG = SslCertificateViewAdapter.class.getSimpleName(); private SslCertificate mCertificate; - /** * Constructor * - * @param + * @param certificate the SSL certificate */ public SslCertificateViewAdapter(SslCertificate certificate) { mCertificate = certificate; @@ -51,7 +50,7 @@ public class SslCertificateViewAdapter implements SslUntrustedCertDialog.Certifi @Override public void updateCertificateView(View dialogView) { - TextView nullCerView = (TextView) dialogView.findViewById(R.id.null_cert); + TextView nullCerView = dialogView.findViewById(R.id.null_cert); if (mCertificate != null) { nullCerView.setVisibility(View.GONE); showSubject(mCertificate.getIssuedTo(), dialogView); @@ -65,8 +64,8 @@ public class SslCertificateViewAdapter implements SslUntrustedCertDialog.Certifi } private void showValidity(Date notBefore, Date notAfter, View dialogView) { - TextView fromView = ((TextView)dialogView.findViewById(R.id.value_validity_from)); - TextView toView = ((TextView)dialogView.findViewById(R.id.value_validity_to)); + TextView fromView = dialogView.findViewById(R.id.value_validity_from); + TextView toView = dialogView.findViewById(R.id.value_validity_to); DateFormat dateFormat = DateFormat.getDateInstance(); fromView.setText(dateFormat.format(notBefore)); toView.setText(dateFormat.format(notAfter)); @@ -74,55 +73,53 @@ public class SslCertificateViewAdapter implements SslUntrustedCertDialog.Certifi private void showSubject(SslCertificate.DName subject, View dialogView) { - TextView cnView = ((TextView)dialogView.findViewById(R.id.value_subject_CN)); + TextView cnView = dialogView.findViewById(R.id.value_subject_CN); cnView.setText(subject.getCName()); cnView.setVisibility(View.VISIBLE); - TextView oView = ((TextView)dialogView.findViewById(R.id.value_subject_O)); + TextView oView = dialogView.findViewById(R.id.value_subject_O); oView.setText(subject.getOName()); oView.setVisibility(View.VISIBLE); - TextView ouView = ((TextView)dialogView.findViewById(R.id.value_subject_OU)); + TextView ouView = dialogView.findViewById(R.id.value_subject_OU); ouView.setText(subject.getUName()); ouView.setVisibility(View.VISIBLE); // SslCertificates don't offer this information - ((TextView)dialogView.findViewById(R.id.value_subject_C)).setVisibility(View.GONE); - ((TextView)dialogView.findViewById(R.id.value_subject_ST)).setVisibility(View.GONE); - ((TextView)dialogView.findViewById(R.id.value_subject_L)).setVisibility(View.GONE); - ((TextView)dialogView.findViewById(R.id.label_subject_C)).setVisibility(View.GONE); - ((TextView)dialogView.findViewById(R.id.label_subject_ST)).setVisibility(View.GONE); - ((TextView)dialogView.findViewById(R.id.label_subject_L)).setVisibility(View.GONE); + dialogView.findViewById(R.id.value_subject_C).setVisibility(View.GONE); + dialogView.findViewById(R.id.value_subject_ST).setVisibility(View.GONE); + dialogView.findViewById(R.id.value_subject_L).setVisibility(View.GONE); + dialogView.findViewById(R.id.label_subject_C).setVisibility(View.GONE); + dialogView.findViewById(R.id.label_subject_ST).setVisibility(View.GONE); + dialogView.findViewById(R.id.label_subject_L).setVisibility(View.GONE); } - private void showIssuer(SslCertificate.DName issuer, View dialogView) { - TextView cnView = ((TextView)dialogView.findViewById(R.id.value_issuer_CN)); + TextView cnView = dialogView.findViewById(R.id.value_issuer_CN); cnView.setText(issuer.getCName()); cnView.setVisibility(View.VISIBLE); - TextView oView = ((TextView)dialogView.findViewById(R.id.value_issuer_O)); + TextView oView = dialogView.findViewById(R.id.value_issuer_O); oView.setText(issuer.getOName()); oView.setVisibility(View.VISIBLE); - TextView ouView = ((TextView)dialogView.findViewById(R.id.value_issuer_OU)); + TextView ouView = dialogView.findViewById(R.id.value_issuer_OU); ouView.setText(issuer.getUName()); ouView.setVisibility(View.VISIBLE); // SslCertificates don't offer this information - ((TextView)dialogView.findViewById(R.id.value_issuer_C)).setVisibility(View.GONE); - ((TextView)dialogView.findViewById(R.id.value_issuer_ST)).setVisibility(View.GONE); - ((TextView)dialogView.findViewById(R.id.value_issuer_L)).setVisibility(View.GONE); - ((TextView)dialogView.findViewById(R.id.label_issuer_C)).setVisibility(View.GONE); - ((TextView)dialogView.findViewById(R.id.label_issuer_ST)).setVisibility(View.GONE); - ((TextView)dialogView.findViewById(R.id.label_issuer_L)).setVisibility(View.GONE); + dialogView.findViewById(R.id.value_issuer_C).setVisibility(View.GONE); + dialogView.findViewById(R.id.value_issuer_ST).setVisibility(View.GONE); + dialogView.findViewById(R.id.value_issuer_L).setVisibility(View.GONE); + dialogView.findViewById(R.id.label_issuer_C).setVisibility(View.GONE); + dialogView.findViewById(R.id.label_issuer_ST).setVisibility(View.GONE); + dialogView.findViewById(R.id.label_issuer_L).setVisibility(View.GONE); } private void hideSignature(View dialogView) { - ((TextView)dialogView.findViewById(R.id.label_signature)).setVisibility(View.GONE); - ((TextView)dialogView.findViewById(R.id.label_signature_algorithm)).setVisibility(View.GONE); - ((TextView)dialogView.findViewById(R.id.value_signature_algorithm)).setVisibility(View.GONE); - ((TextView)dialogView.findViewById(R.id.value_signature)).setVisibility(View.GONE); + dialogView.findViewById(R.id.label_signature).setVisibility(View.GONE); + dialogView.findViewById(R.id.label_signature_algorithm).setVisibility(View.GONE); + dialogView.findViewById(R.id.value_signature_algorithm).setVisibility(View.GONE); + dialogView.findViewById(R.id.value_signature).setVisibility(View.GONE); } - } diff --git a/src/main/java/com/owncloud/android/ui/adapter/UploadListAdapter.java b/src/main/java/com/owncloud/android/ui/adapter/UploadListAdapter.java index 64a0191aca..1d8afcec30 100755 --- a/src/main/java/com/owncloud/android/ui/adapter/UploadListAdapter.java +++ b/src/main/java/com/owncloud/android/ui/adapter/UploadListAdapter.java @@ -303,14 +303,14 @@ public class UploadListAdapter extends SectionedRecyclerViewAdapter s = parsePrincipal(subject); - TextView cnView = ((TextView)dialogView.findViewById(R.id.value_subject_CN)); - TextView oView = ((TextView)dialogView.findViewById(R.id.value_subject_O)); - TextView ouView = ((TextView)dialogView.findViewById(R.id.value_subject_OU)); - TextView cView = ((TextView)dialogView.findViewById(R.id.value_subject_C)); - TextView stView = ((TextView)dialogView.findViewById(R.id.value_subject_ST)); - TextView lView = ((TextView)dialogView.findViewById(R.id.value_subject_L)); + TextView cnView = dialogView.findViewById(R.id.value_subject_CN); + TextView oView = dialogView.findViewById(R.id.value_subject_O); + TextView ouView = dialogView.findViewById(R.id.value_subject_OU); + TextView cView = dialogView.findViewById(R.id.value_subject_C); + TextView stView = dialogView.findViewById(R.id.value_subject_ST); + TextView lView = dialogView.findViewById(R.id.value_subject_L); if (s.get("CN") != null) { cnView.setText(s.get("CN")); @@ -190,12 +187,12 @@ public class X509CertificateViewAdapter implements SslUntrustedCertDialog.Certif private void showIssuer(X500Principal issuer, View dialogView) { Map s = parsePrincipal(issuer); - TextView cnView = ((TextView)dialogView.findViewById(R.id.value_issuer_CN)); - TextView oView = ((TextView)dialogView.findViewById(R.id.value_issuer_O)); - TextView ouView = ((TextView)dialogView.findViewById(R.id.value_issuer_OU)); - TextView cView = ((TextView)dialogView.findViewById(R.id.value_issuer_C)); - TextView stView = ((TextView)dialogView.findViewById(R.id.value_issuer_ST)); - TextView lView = ((TextView)dialogView.findViewById(R.id.value_issuer_L)); + TextView cnView = dialogView.findViewById(R.id.value_issuer_CN); + TextView oView = dialogView.findViewById(R.id.value_issuer_O); + TextView ouView = dialogView.findViewById(R.id.value_issuer_OU); + TextView cView = dialogView.findViewById(R.id.value_issuer_C); + TextView stView = dialogView.findViewById(R.id.value_issuer_ST); + TextView lView = dialogView.findViewById(R.id.value_issuer_L); if (s.get("CN") != null) { cnView.setText(s.get("CN")); @@ -237,18 +234,17 @@ public class X509CertificateViewAdapter implements SslUntrustedCertDialog.Certif private Map parsePrincipal(X500Principal principal) { - Map result = new HashMap(); + Map result = new HashMap<>(); String toParse = principal.getName(); String[] pieces = toParse.split(","); - String[] tokens = {"CN", "O", "OU", "C", "ST", "L"}; - for (int i=0; i < pieces.length ; i++) { - for (int j=0; j s = parsePrincipal(subject); - TextView cnView = ((TextView)mView.findViewById(R.id.value_subject_CN)); - TextView oView = ((TextView)mView.findViewById(R.id.value_subject_O)); - TextView ouView = ((TextView)mView.findViewById(R.id.value_subject_OU)); - TextView cView = ((TextView)mView.findViewById(R.id.value_subject_C)); - TextView stView = ((TextView)mView.findViewById(R.id.value_subject_ST)); - TextView lView = ((TextView)mView.findViewById(R.id.value_subject_L)); + TextView cnView = mView.findViewById(R.id.value_subject_CN); + TextView oView = mView.findViewById(R.id.value_subject_O); + TextView ouView = mView.findViewById(R.id.value_subject_OU); + TextView cView = mView.findViewById(R.id.value_subject_C); + TextView stView = mView.findViewById(R.id.value_subject_ST); + TextView lView = mView.findViewById(R.id.value_subject_L); if (s.get("CN") != null) { cnView.setText(s.get("CN")); @@ -274,12 +271,12 @@ public class SslValidatorDialog extends Dialog { private void showIssuer(X500Principal issuer) { Map s = parsePrincipal(issuer); - TextView cnView = ((TextView)mView.findViewById(R.id.value_issuer_CN)); - TextView oView = ((TextView)mView.findViewById(R.id.value_issuer_O)); - TextView ouView = ((TextView)mView.findViewById(R.id.value_issuer_OU)); - TextView cView = ((TextView)mView.findViewById(R.id.value_issuer_C)); - TextView stView = ((TextView)mView.findViewById(R.id.value_issuer_ST)); - TextView lView = ((TextView)mView.findViewById(R.id.value_issuer_L)); + TextView cnView = mView.findViewById(R.id.value_issuer_CN); + TextView oView = mView.findViewById(R.id.value_issuer_O); + TextView ouView = mView.findViewById(R.id.value_issuer_OU); + TextView cView = mView.findViewById(R.id.value_issuer_C); + TextView stView = mView.findViewById(R.id.value_issuer_ST); + TextView lView = mView.findViewById(R.id.value_issuer_L); if (s.get("CN") != null) { cnView.setText(s.get("CN")); @@ -321,7 +318,7 @@ public class SslValidatorDialog extends Dialog { private Map parsePrincipal(X500Principal principal) { - Map result = new HashMap(); + Map result = new HashMap<>(); String toParse = principal.getName(); String[] pieces = toParse.split(","); String[] tokens = {"CN", "O", "OU", "C", "ST", "L"}; @@ -341,11 +338,9 @@ public class SslValidatorDialog extends Dialog { NetworkUtils.addCertToKnownServersStore(mException.getServerCertificate(), getContext()); } } - public interface OnSslValidatorListener { public void onSavedCertificate(); public void onFailedSavingCertificate(); } } - diff --git a/src/main/java/com/owncloud/android/ui/fragment/EditShareFragment.java b/src/main/java/com/owncloud/android/ui/fragment/EditShareFragment.java index 402d186452..d1df216e2f 100644 --- a/src/main/java/com/owncloud/android/ui/fragment/EditShareFragment.java +++ b/src/main/java/com/owncloud/android/ui/fragment/EditShareFragment.java @@ -156,7 +156,7 @@ public class EditShareFragment extends Fragment { */ public void refreshCapabilitiesFromDB() { if (getActivity() instanceof FileActivity) { - FileActivity fileActivity = ((FileActivity) getActivity()); + FileActivity fileActivity = (FileActivity) getActivity(); if (fileActivity.getStorageManager() != null) { mCapabilities = fileActivity.getStorageManager().getCapability(mAccount.name); } @@ -202,26 +202,24 @@ public class EditShareFragment extends Fragment { // from checking when iOS is ready AppCompatCheckBox checkBox = editShareView.findViewById(R.id.canEditCreateCheckBox); checkBox.setChecked((sharePermissions & OCShare.CREATE_PERMISSION_FLAG) > 0); - checkBox.setVisibility((canEdit) ? View.VISIBLE : View.GONE); + checkBox.setVisibility(canEdit ? View.VISIBLE : View.GONE); ThemeUtils.tintCheckbox(checkBox, accentColor); checkBox = editShareView.findViewById(R.id.canEditChangeCheckBox); checkBox.setChecked((sharePermissions & OCShare.UPDATE_PERMISSION_FLAG) > 0); - checkBox.setVisibility((canEdit) ? View.VISIBLE : View.GONE); + checkBox.setVisibility(canEdit ? View.VISIBLE : View.GONE); ThemeUtils.tintCheckbox(checkBox, accentColor); checkBox = editShareView.findViewById(R.id.canEditDeleteCheckBox); checkBox.setChecked((sharePermissions & OCShare.DELETE_PERMISSION_FLAG) > 0); - checkBox.setVisibility((canEdit) ? View.VISIBLE : View.GONE); + checkBox.setVisibility(canEdit ? View.VISIBLE : View.GONE); ThemeUtils.tintCheckbox(checkBox, accentColor); } setPermissionsListening(editShareView, true); - } } - /** * Binds or unbinds listener for user actions to enable or disable a permission on the edited share * to the views receiving the user events. diff --git a/src/main/java/com/owncloud/android/ui/fragment/FileDetailActivitiesFragment.java b/src/main/java/com/owncloud/android/ui/fragment/FileDetailActivitiesFragment.java index a2d15db7d1..44707f8ff4 100644 --- a/src/main/java/com/owncloud/android/ui/fragment/FileDetailActivitiesFragment.java +++ b/src/main/java/com/owncloud/android/ui/fragment/FileDetailActivitiesFragment.java @@ -342,17 +342,11 @@ public class FileDetailActivitiesFragment extends Fragment implements ActivityLi } hideRefreshLayoutLoader(activity); - } catch (com.owncloud.android.lib.common.accounts.AccountUtils.AccountNotFoundException e) { - Log_OC.e(TAG, "Account not found", e); - } catch (IOException e) { - Log_OC.e(TAG, "IO error", e); - } catch (OperationCanceledException e) { - Log_OC.e(TAG, "Operation has been canceled", e); - } catch (AuthenticatorException e) { - Log_OC.e(TAG, "Authentication Exception", e); + } catch (com.owncloud.android.lib.common.accounts.AccountUtils.AccountNotFoundException | IOException | + OperationCanceledException | AuthenticatorException e) { + Log_OC.e(TAG, "Error fetching file details activities", e); } - } - ); + }); t.start(); } diff --git a/src/main/java/com/owncloud/android/ui/fragment/FileDetailFragment.java b/src/main/java/com/owncloud/android/ui/fragment/FileDetailFragment.java index d9c99b6ddd..6c88952ab8 100644 --- a/src/main/java/com/owncloud/android/ui/fragment/FileDetailFragment.java +++ b/src/main/java/com/owncloud/android/ui/fragment/FileDetailFragment.java @@ -457,7 +457,7 @@ public class FileDetailFragment extends FileFragment implements OnClickListener * @return True when the fragment was created with the empty layout. */ public boolean isEmpty() { - return (layout == R.layout.empty_list || getFile() == null || account == null); + return layout == R.layout.empty_list || getFile() == null || account == null; } /** diff --git a/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java b/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java index 3fb7d5c1e0..3e001bd4bf 100644 --- a/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java +++ b/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java @@ -1332,14 +1332,9 @@ public class OCFileListFragment extends ExtendedListFragment implements mAdapter.setFavoriteAttributeForItemID(event.remoteId, event.shouldFavorite); } - } catch (com.owncloud.android.lib.common.accounts.AccountUtils.AccountNotFoundException e) { - Log_OC.e(TAG, "Account not found", e); - } catch (AuthenticatorException e) { - Log_OC.e(TAG, "Authentication failed", e); - } catch (IOException e) { - Log_OC.e(TAG, "IO error", e); - } catch (OperationCanceledException e) { - Log_OC.e(TAG, "Operation has been canceled", e); + } catch (com.owncloud.android.lib.common.accounts.AccountUtils.AccountNotFoundException | AuthenticatorException + | IOException | OperationCanceledException e) { + Log_OC.e(TAG, "Error processing event", e); } } diff --git a/src/main/java/com/owncloud/android/ui/fragment/ShareFileFragment.java b/src/main/java/com/owncloud/android/ui/fragment/ShareFileFragment.java index 441f704eed..90e0a20656 100644 --- a/src/main/java/com/owncloud/android/ui/fragment/ShareFileFragment.java +++ b/src/main/java/com/owncloud/android/ui/fragment/ShareFileFragment.java @@ -695,9 +695,7 @@ public class ShareFileFragment extends Fragment implements ShareUserListAdapter. * @return 'True' when public share is disabled in the server */ private boolean isPublicShareDisabled() { - return (mCapabilities != null && - mCapabilities.getFilesSharingPublicEnabled().isFalse() - ); + return mCapabilities != null && mCapabilities.getFilesSharingPublicEnabled().isFalse(); } /** diff --git a/src/main/java/com/owncloud/android/ui/fragment/contactsbackup/ContactsBackupFragment.java b/src/main/java/com/owncloud/android/ui/fragment/contactsbackup/ContactsBackupFragment.java index 3a7cf36d8e..46cf2d015f 100644 --- a/src/main/java/com/owncloud/android/ui/fragment/contactsbackup/ContactsBackupFragment.java +++ b/src/main/java/com/owncloud/android/ui/fragment/contactsbackup/ContactsBackupFragment.java @@ -361,7 +361,7 @@ public class ContactsBackupFragment extends FileFragment implements DatePickerDi final ContactsPreferenceActivity contactsPreferenceActivity = (ContactsPreferenceActivity) getActivity(); // check permissions - if ((PermissionUtil.checkSelfPermission(contactsPreferenceActivity, Manifest.permission.READ_CONTACTS))) { + if (PermissionUtil.checkSelfPermission(contactsPreferenceActivity, Manifest.permission.READ_CONTACTS)) { return true; } else { // Check if we should show an explanation diff --git a/src/main/java/com/owncloud/android/ui/fragment/util/FileDetailSharingFragmentHelper.java b/src/main/java/com/owncloud/android/ui/fragment/util/FileDetailSharingFragmentHelper.java index 84b85fc013..188d26e51f 100644 --- a/src/main/java/com/owncloud/android/ui/fragment/util/FileDetailSharingFragmentHelper.java +++ b/src/main/java/com/owncloud/android/ui/fragment/util/FileDetailSharingFragmentHelper.java @@ -71,6 +71,6 @@ public class FileDetailSharingFragmentHelper { * @return 'True' when public share is disabled in the server. */ public static boolean isPublicShareDisabled(OCCapability capabilities) { - return (capabilities != null && capabilities.getFilesSharingPublicEnabled().isFalse()); + return capabilities != null && capabilities.getFilesSharingPublicEnabled().isFalse(); } } diff --git a/src/main/java/com/owncloud/android/ui/preview/PreviewImageActivity.java b/src/main/java/com/owncloud/android/ui/preview/PreviewImageActivity.java index 587efba70a..f571c1f769 100644 --- a/src/main/java/com/owncloud/android/ui/preview/PreviewImageActivity.java +++ b/src/main/java/com/owncloud/android/ui/preview/PreviewImageActivity.java @@ -424,18 +424,13 @@ public class PreviewImageActivity extends FileActivity implements } else { Log_OC.d(TAG, "Download finished, but the fragment is offscreen"); } - } removeStickyBroadcast(intent); } - } public boolean getSystemUIVisible() { - if (getSupportActionBar() != null) { - return (getSupportActionBar().isShowing()); - } - return true; + return getSupportActionBar() == null || getSupportActionBar().isShowing(); } public void toggleFullScreen() { diff --git a/src/main/java/com/owncloud/android/ui/preview/PreviewImageFragment.java b/src/main/java/com/owncloud/android/ui/preview/PreviewImageFragment.java index 0aa09b10f3..6fa0ce9634 100644 --- a/src/main/java/com/owncloud/android/ui/preview/PreviewImageFragment.java +++ b/src/main/java/com/owncloud/android/ui/preview/PreviewImageFragment.java @@ -697,10 +697,9 @@ public class PreviewImageFragment extends FileFragment { * @return 'True' if the file can be handled by the fragment. */ public static boolean canBePreviewed(OCFile file) { - return (file != null && MimeTypeUtil.isImage(file)); + return file != null && MimeTypeUtil.isImage(file); } - /** * Finishes the preview */ @@ -741,14 +740,12 @@ public class PreviewImageFragment extends FileFragment { } } - private static int convertDpToPixel(float dp, Context context) { Resources resources = context.getResources(); DisplayMetrics metrics = resources.getDisplayMetrics(); return (int) (dp * ((float) metrics.densityDpi / DisplayMetrics.DENSITY_DEFAULT)); } - public PhotoView getImageView() { return mImageView; } @@ -763,7 +760,5 @@ public class PreviewImageFragment extends FileFragment { this.drawable = drawable; this.ocFile = ocFile; } - } - } diff --git a/src/main/java/com/owncloud/android/ui/preview/PreviewTextFragment.java b/src/main/java/com/owncloud/android/ui/preview/PreviewTextFragment.java index d55bca551f..4de082dbc8 100644 --- a/src/main/java/com/owncloud/android/ui/preview/PreviewTextFragment.java +++ b/src/main/java/com/owncloud/android/ui/preview/PreviewTextFragment.java @@ -58,7 +58,7 @@ import java.util.LinkedList; import java.util.List; import java.util.Scanner; -public class PreviewTextFragment extends FileFragment { +public class PreviewTextFragment extends FileFragment { private static final String EXTRA_FILE = "FILE"; private static final String EXTRA_ACCOUNT = "ACCOUNT"; private static final String TAG = PreviewTextFragment.class.getSimpleName(); @@ -402,10 +402,9 @@ public class PreviewTextFragment extends FileFragment { unsupportedTypes.add("text/vnd.rn-realtext"); unsupportedTypes.add("text/vnd.wap.wml"); unsupportedTypes.add("text/vnd.wap.wmlscript"); - return (file != null && file.isDown() && MimeTypeUtil.isText(file) && + return file != null && file.isDown() && MimeTypeUtil.isText(file) && !unsupportedTypes.contains(file.getMimeType()) && - !unsupportedTypes.contains(MimeTypeUtil.getMimeTypeFromPath(file.getRemotePath())) - ); + !unsupportedTypes.contains(MimeTypeUtil.getMimeTypeFromPath(file.getRemotePath())); } /** diff --git a/src/main/java/com/owncloud/android/utils/ConnectivityUtils.java b/src/main/java/com/owncloud/android/utils/ConnectivityUtils.java index 8cd24cadef..9bb069e819 100644 --- a/src/main/java/com/owncloud/android/utils/ConnectivityUtils.java +++ b/src/main/java/com/owncloud/android/utils/ConnectivityUtils.java @@ -91,9 +91,7 @@ public class ConnectivityUtils { Log_OC.e(TAG, "Error checking internet connection", e); } catch (com.owncloud.android.lib.common.accounts.AccountUtils.AccountNotFoundException e) { Log_OC.e(TAG, "Account not found", e); - } catch (OperationCanceledException e) { - Log_OC.e(TAG, e.getMessage()); - } catch (AuthenticatorException e) { + } catch (OperationCanceledException | AuthenticatorException e) { Log_OC.e(TAG, e.getMessage()); } } else if (!Device.getNetworkType(context).equals(JobRequest.NetworkType.ANY)) { diff --git a/src/main/java/com/owncloud/android/utils/DisplayUtils.java b/src/main/java/com/owncloud/android/utils/DisplayUtils.java index f98a9ce7e2..4dfe72ee80 100644 --- a/src/main/java/com/owncloud/android/utils/DisplayUtils.java +++ b/src/main/java/com/owncloud/android/utils/DisplayUtils.java @@ -266,7 +266,7 @@ public class DisplayUtils { hostEnd = (hostEnd == -1 ? urlNoDots.length() : hostStart + hostEnd); String host = urlNoDots.substring(hostStart, hostEnd); - host = (toASCII ? IDN.toASCII(host) : IDN.toUnicode(host)); + host = toASCII ? IDN.toASCII(host) : IDN.toUnicode(host); return dots + urlNoDots.substring(0, hostStart) + host + urlNoDots.substring(hostEnd); } diff --git a/src/main/java/com/owncloud/android/utils/FilesSyncHelper.java b/src/main/java/com/owncloud/android/utils/FilesSyncHelper.java index 8f3eb9e485..94f8a4420a 100644 --- a/src/main/java/com/owncloud/android/utils/FilesSyncHelper.java +++ b/src/main/java/com/owncloud/android/utils/FilesSyncHelper.java @@ -113,7 +113,6 @@ public class FilesSyncHelper { } else { try { - if (dryRun) { arbitraryDataProvider.storeOrUpdateKeyValue(GLOBAL, syncedFolderInitiatedKey, currentTimeString); @@ -157,7 +156,7 @@ public class FilesSyncHelper { SyncedFolderProvider syncedFolderProvider = new SyncedFolderProvider(contentResolver); for (SyncedFolder syncedFolder : syncedFolderProvider.getSyncedFolders()) { - if ((syncedFolder.isEnabled()) && ((MediaFolderType.CUSTOM != syncedFolder.getType()) || !skipCustom)) { + if (syncedFolder.isEnabled() && (MediaFolderType.CUSTOM != syncedFolder.getType() || !skipCustom)) { insertAllDBEntriesForSyncedFolder(syncedFolder); } } diff --git a/src/main/java/com/owncloud/android/utils/MimeTypeUtil.java b/src/main/java/com/owncloud/android/utils/MimeTypeUtil.java index e660420897..a4a0dcf4c8 100644 --- a/src/main/java/com/owncloud/android/utils/MimeTypeUtil.java +++ b/src/main/java/com/owncloud/android/utils/MimeTypeUtil.java @@ -282,11 +282,10 @@ public class MimeTypeUtil { * @return 'True' if the file is simple text (e.g. not application-dependent, like .doc or .docx) */ public static boolean isText(OCFile file) { - return (MimeTypeUtil.isText(file.getMimeType()) - || MimeTypeUtil.isText(getMimeTypeFromPath(file.getRemotePath()))); + return MimeTypeUtil.isText(file.getMimeType()) + || MimeTypeUtil.isText(getMimeTypeFromPath(file.getRemotePath())); } - /** * @param file the file to be analyzed * @return 'True' if the file is a vcard diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index 9d850c1607..ac6aa97033 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -231,9 +231,7 @@ Attempt to play file timed out The media file can not be streamed The built-in media player is unable to play the media file - A security error was encountered trying to play %1$s - Input error while trying to play %1$s - Unexpected error while trying to play %1$s + Unexpected error while trying to play %1$s Rewind button Play or pause button Fast forward button