Browse Source

improve findbugs score bug making literals the left part of string comparisons

Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
Andy Scherzinger 6 years ago
parent
commit
a90f71e600

+ 3 - 4
src/main/java/com/owncloud/android/authentication/PassCodeManager.java

@@ -110,8 +110,7 @@ public final class PassCodeManager {
     }
 
     private void setUnlockTimestamp(Activity activity) {
-        Long timestamp = System.currentTimeMillis();
-        PreferenceManager.setLockTimestamp(activity, timestamp);
+        PreferenceManager.setLockTimestamp(activity, System.currentTimeMillis());
     }
 
     private boolean passCodeShouldBeRequested(Long timestamp) {
@@ -120,7 +119,7 @@ public final class PassCodeManager {
     }
 
     private boolean passCodeIsEnabled() {
-        return PreferenceManager.getLockPreference(MainApp.getAppContext()).equals(Preferences.LOCK_PASSCODE);
+        return Preferences.LOCK_PASSCODE.equals(PreferenceManager.getLockPreference(MainApp.getAppContext()));
     }
 
     private boolean deviceCredentialsShouldBeRequested(Long timestamp, Activity activity) {
@@ -129,7 +128,7 @@ public final class PassCodeManager {
     }
 
     private boolean deviceCredentialsAreEnabled(Activity activity) {
-        return PreferenceManager.getLockPreference(MainApp.getAppContext()).equals(Preferences.LOCK_DEVICE_CREDENTIALS)
+        return Preferences.LOCK_DEVICE_CREDENTIALS.equals(PreferenceManager.getLockPreference(MainApp.getAppContext()))
                 || Build.VERSION.SDK_INT >= Build.VERSION_CODES.M &&
                         (PreferenceManager.isUseFingerprint(MainApp.getAppContext())
                                 && DeviceCredentialUtils.areCredentialsAvailable(activity));

+ 1 - 1
src/main/java/com/owncloud/android/datamodel/FileDataStorageManager.java

@@ -259,7 +259,7 @@ public class FileDataStorageManager {
      * @return the parent file
      */
     public OCFile saveFileWithParent(OCFile file, Context context) {
-        if (file.getParentId() == 0 && !file.getRemotePath().equals("/")) {
+        if (file.getParentId() == 0 && !"/".equals(file.getRemotePath())) {
             String remotePath = file.getRemotePath();
             String parentPath = remotePath.substring(0, remotePath.lastIndexOf(file.getFileName()));
 

+ 6 - 6
src/main/java/com/owncloud/android/datamodel/ThumbnailsCacheManager.java

@@ -289,7 +289,7 @@ public final class ThumbnailsCacheManager {
 
                     if (bitmap != null) {
                         // Handle PNG
-                        if (file.getMimeType().equalsIgnoreCase(PNG_MIMETYPE)) {
+                        if (PNG_MIMETYPE.equalsIgnoreCase(file.getMimeType())) {
                             bitmap = handlePNG(bitmap, pxW, pxH);
                         }
 
@@ -318,7 +318,7 @@ public final class ThumbnailsCacheManager {
                             }
 
                                 // Handle PNG
-                                if (thumbnail != null && file.getMimeType().equalsIgnoreCase(PNG_MIMETYPE)) {
+                                if (thumbnail != null && PNG_MIMETYPE.equalsIgnoreCase(file.getMimeType())) {
                                     thumbnail = handlePNG(thumbnail, thumbnail.getWidth(), thumbnail.getHeight());
                                 }
 
@@ -536,7 +536,7 @@ public final class ThumbnailsCacheManager {
 
                         if (bitmap != null) {
                             // Handle PNG
-                            if (ocFile.getMimeType().equalsIgnoreCase(PNG_MIMETYPE)) {
+                            if (PNG_MIMETYPE.equalsIgnoreCase(ocFile.getMimeType())) {
                                 bitmap = handlePNG(bitmap, pxW, pxH);
                             }
 
@@ -588,7 +588,7 @@ public final class ThumbnailsCacheManager {
                                 }
 
                                 // Handle PNG
-                                if (file.getMimeType().equalsIgnoreCase(PNG_MIMETYPE)) {
+                                if (PNG_MIMETYPE.equalsIgnoreCase(file.getMimeType())) {
                                     thumbnail = handlePNG(thumbnail, pxW, pxH);
                                 }
                             } catch (Exception e) {
@@ -1173,7 +1173,7 @@ public final class ThumbnailsCacheManager {
 
         if (bitmap != null) {
             // Handle PNG
-            if (file.getMimeType().equalsIgnoreCase(PNG_MIMETYPE)) {
+            if (PNG_MIMETYPE.equalsIgnoreCase(file.getMimeType())) {
                 bitmap = handlePNG(bitmap, pxW, pxH);
             }
 
@@ -1214,7 +1214,7 @@ public final class ThumbnailsCacheManager {
             // Add thumbnail to cache
             if (thumbnail != null) {
                 // Handle PNG
-                if (file.getMimeType().equalsIgnoreCase(PNG_MIMETYPE)) {
+                if (PNG_MIMETYPE.equalsIgnoreCase(file.getMimeType())) {
                     thumbnail = handlePNG(thumbnail, pxW, pxH);
                 }
 

+ 1 - 1
src/main/java/com/owncloud/android/ui/activity/PassCodeActivity.java

@@ -197,7 +197,7 @@ public class    PassCodeActivity extends AppCompatActivity {
 
     private void onPassCodeEditTextFocusChange(final int passCodeIndex) {
         for (int i = 0; i < passCodeIndex; i++) {
-            if (mPassCodeEditTexts[i].getText().toString().equals("")) {
+            if ("".equals(mPassCodeEditTexts[i].getText().toString())) {
                 mPassCodeEditTexts[i].requestFocus();
                 break;
             }

+ 1 - 1
src/main/java/com/owncloud/android/ui/adapter/OCFileListAdapter.java

@@ -1,4 +1,4 @@
-/*
+    /*
  * Nextcloud Android client application
  *
  * @author Tobias Kaminsky