Prechádzať zdrojové kódy

codacy: All methods are static. Consider using a utility class instead.

AndyScherzinger 6 rokov pred
rodič
commit
1ccccb1ffe

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

@@ -44,7 +44,7 @@ import javax.annotation.Nullable;
 /**
  * Media queries to gain access to media lists for the device.
  */
-public class MediaProvider {
+public final class MediaProvider {
     private static final String TAG = MediaProvider.class.getSimpleName();
 
     // fixed query parameters
@@ -58,6 +58,10 @@ public class MediaProvider {
     private static final String[] VIDEOS_FOLDER_PROJECTION = {"Distinct " + MediaStore.Video.Media.BUCKET_ID,
             MediaStore.Video.Media.BUCKET_DISPLAY_NAME};
 
+    private MediaProvider() {
+        // utility class -> private constructor
+    }
+
     /**
      * Getting All Images Paths.
      *

+ 5 - 1
src/main/java/com/owncloud/android/ui/fragment/util/SharingMenuHelper.java

@@ -32,7 +32,11 @@ import java.util.Date;
 /**
  * Helper calls for visibility logic of the sharing menu.
  */
-public class SharingMenuHelper {
+public final class SharingMenuHelper {
+
+    private SharingMenuHelper() {
+        // utility class -> private constructor
+    }
 
     /**
      * Sets checked/visiblity state on the given {@link MenuItem} based on the given criteria.

+ 5 - 1
src/main/java/com/owncloud/android/ui/notifications/NotificationUtils.java

@@ -32,7 +32,7 @@ import java.util.Random;
 
 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 
-public class NotificationUtils {
+public final class NotificationUtils {
 
     public static final String NOTIFICATION_CHANNEL_GENERAL = "NOTIFICATION_CHANNEL_GENERAL";
     public static final String NOTIFICATION_CHANNEL_DOWNLOAD = "NOTIFICATION_CHANNEL_DOWNLOAD";
@@ -42,6 +42,10 @@ public class NotificationUtils {
     public static final String NOTIFICATION_CHANNEL_FILE_OBSERVER = "NOTIFICATION_CHANNEL_FILE_OBSERVER";
     public static final String NOTIFICATION_CHANNEL_PUSH = "NOTIFICATION_CHANNEL_PUSH";
 
+    private NotificationUtils() {
+        // utility class -> private constructor
+    }
+
     /**
      * Factory method for {@link android.support.v4.app.NotificationCompat.Builder} instances.
      *

+ 4 - 1
src/main/java/com/owncloud/android/utils/BitmapUtils.java

@@ -41,9 +41,12 @@ import java.util.Locale;
 /**
  * Utility class with methods for decoding Bitmaps.
  */
-public class BitmapUtils {
+public final class BitmapUtils {
     public static final String TAG = BitmapUtils.class.getSimpleName();
 
+    private BitmapUtils() {
+        // utility class -> private constructor
+    }
 
     /**
      * Decodes a bitmap from a file containing it minimizing the memory use, known that the bitmap

+ 5 - 1
src/main/java/com/owncloud/android/utils/ConnectivityUtils.java

@@ -44,10 +44,14 @@ import org.json.JSONObject;
 
 import java.io.IOException;
 
-public class ConnectivityUtils {
+public final class ConnectivityUtils {
 
     private final static String TAG = ConnectivityUtils.class.getName();
 
+    private ConnectivityUtils() {
+        // utility class -> private constructor
+    }
+
     public static boolean isInternetWalled(Context context) {
         if (isOnlineWithWifi(context)) {
             try {

+ 5 - 1
src/main/java/com/owncloud/android/utils/CsrHelper.java

@@ -28,7 +28,11 @@ import java.security.KeyPair;
  * Own parts are licensed unter GPLv3+.
  */
 
-public class CsrHelper {
+public final class CsrHelper {
+
+    private CsrHelper() {
+        // utility class -> private constructor
+    }
 
     /**
      * Generate CSR with PEM encoding

+ 5 - 1
src/main/java/com/owncloud/android/utils/DeviceCredentialUtils.java

@@ -53,7 +53,7 @@ import javax.crypto.SecretKey;
  * Utility class with methods for handling device credentials.
  */
 @RequiresApi(Build.VERSION_CODES.M)
-public class DeviceCredentialUtils {
+public final class DeviceCredentialUtils {
 
     private static final String TAG = DeviceCredentialUtils.class.getSimpleName();
 
@@ -61,6 +61,10 @@ public class DeviceCredentialUtils {
 
     private static final String ANDROID_KEY_STORE = "AndroidKeyStore";
 
+    private DeviceCredentialUtils() {
+        // utility class -> private constructor
+    }
+
     public static boolean areCredentialsAvailable(Context context) {
         KeyguardManager keyguardManager = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE);
         

+ 5 - 1
src/main/java/com/owncloud/android/utils/DisplayUtils.java

@@ -102,7 +102,7 @@ import java.util.Set;
 /**
  * A helper class for UI/display related operations.
  */
-public class DisplayUtils {
+public final class DisplayUtils {
     private static final String TAG = DisplayUtils.class.getSimpleName();
 
     private static final String[] sizeSuffixes = {"B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"};
@@ -131,6 +131,10 @@ public class DisplayUtils {
         mimeType2HumanReadable.put("application/ogg", "OGG music file");
     }
 
+    private DisplayUtils() {
+        // utility class -> private constructor
+    }
+
     /**
      * Converts the file size in bytes to human readable output.
      * <ul>

+ 5 - 1
src/main/java/com/owncloud/android/utils/EncryptionUtils.java

@@ -87,7 +87,7 @@ import javax.crypto.spec.SecretKeySpec;
  * Utils for encryption
  */
 
-public class EncryptionUtils {
+public final class EncryptionUtils {
     private static String TAG = EncryptionUtils.class.getSimpleName();
 
     public static final String PUBLIC_KEY = "PUBLIC_KEY";
@@ -105,6 +105,10 @@ public class EncryptionUtils {
     private static final String RSA_CIPHER = "RSA/ECB/OAEPWithSHA-256AndMGF1Padding";
     private static final String RSA = "RSA";
 
+    private EncryptionUtils() {
+        // utility class -> private constructor
+    }
+
     /*
     JSON
      */

+ 6 - 1
src/main/java/com/owncloud/android/utils/ErrorMessageAdapter.java

@@ -53,7 +53,12 @@ import java.net.SocketTimeoutException;
  * Class to choose proper error messages to show to the user depending on the results of operations,
  * always following the same policy
  */
-public class ErrorMessageAdapter {
+public final class ErrorMessageAdapter {
+
+    private ErrorMessageAdapter() {
+        // utility class -> private constructor
+    }
+
     /**
      * Return an internationalized user message corresponding to an operation result
      * and the operation performed.

+ 5 - 1
src/main/java/com/owncloud/android/utils/FileStorageUtils.java

@@ -50,11 +50,15 @@ import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 /**
  * Static methods to help in access to local file system.
  */
-public class FileStorageUtils {
+public final class FileStorageUtils {
     private static final String TAG = FileStorageUtils.class.getSimpleName();
 
     public static final String PATTERN_YYYY_MM = "yyyy/MM/";
 
+    private FileStorageUtils() {
+        // utility class -> private constructor
+    }
+
     /**
      * Get local owncloud storage path for accountName.
      */

+ 7 - 3
src/main/java/com/owncloud/android/utils/FilesSyncHelper.java

@@ -63,10 +63,10 @@ import java.io.IOException;
 import java.util.Set;
 import java.util.concurrent.TimeUnit;
 
-/*
-    Various utilities that make auto upload tick
+/**
+ * Various utilities that make auto upload tick
  */
-public class FilesSyncHelper {
+public final class FilesSyncHelper {
     public static final String TAG = "FileSyncHelper";
 
     public static final String GLOBAL = "global";
@@ -74,6 +74,10 @@ public class FilesSyncHelper {
 
     public static final int ContentSyncJobId = 315;
 
+    private FilesSyncHelper() {
+        // utility class -> private constructor
+    }
+
     public static void insertAllDBEntriesForSyncedFolder(SyncedFolder syncedFolder) {
         final Context context = MainApp.getAppContext();
         final ContentResolver contentResolver = context.getContentResolver();

+ 5 - 1
src/main/java/com/owncloud/android/utils/MimeTypeUtil.java

@@ -64,7 +64,7 @@ import javax.annotation.Nullable;
  * </ol>
  */
 @SuppressWarnings("PMD.AvoidDuplicateLiterals")
-public class MimeTypeUtil {
+public final class MimeTypeUtil {
     /** Mapping: icon for mime type */
     private static final Map<String, Integer> MIMETYPE_TO_ICON_MAPPING = new HashMap<>();
     /** Mapping: icon for main mime type (first part of a mime type declaration). */
@@ -78,6 +78,10 @@ public class MimeTypeUtil {
         populateMainMimeTypeMapping();
     }
 
+    private MimeTypeUtil() {
+        // utility class -> private constructor
+    }
+
     /**
      * Returns the Drawable of an image to use as icon associated to a known MIME type.
      *

+ 5 - 1
src/main/java/com/owncloud/android/utils/PermissionUtil.java

@@ -9,12 +9,16 @@ import android.support.v4.content.ContextCompat;
 /**
  * Created by scherzia on 29.12.2015.
  */
-public class PermissionUtil {
+public final class PermissionUtil {
     public static final int PERMISSIONS_WRITE_EXTERNAL_STORAGE = 1;
     public static final int PERMISSIONS_READ_CONTACTS_AUTOMATIC = 2;
     public static final int PERMISSIONS_READ_CONTACTS_MANUALLY = 3;
     public static final int PERMISSIONS_WRITE_CONTACTS = 4;
 
+    private PermissionUtil() {
+        // utility class -> private constructor
+    }
+
     /**
      * Wrapper method for ContextCompat.checkSelfPermission().
      * Determine whether <em>the app</em> has been granted a particular permission.

+ 5 - 1
src/main/java/com/owncloud/android/utils/PowerUtils.java

@@ -5,7 +5,11 @@ import android.content.Context;
 import android.os.Build;
 import android.os.PowerManager;
 
-public class PowerUtils {
+public final class PowerUtils {
+
+    private PowerUtils() {
+        // utility class -> private constructor
+    }
 
     /**
      * Checks if device is in power save mode. For older devices that do not support this API, returns false.

+ 7 - 3
src/main/java/com/owncloud/android/utils/ReceiversHelper.java

@@ -29,10 +29,14 @@ import com.evernote.android.job.JobRequest;
 import com.evernote.android.job.util.Device;
 import com.owncloud.android.MainApp;
 
-/*
-    Helper for setting up network and power receivers
+/**
+ * Helper for setting up network and power receivers
  */
-public class ReceiversHelper {
+public final class ReceiversHelper {
+
+    private ReceiversHelper() {
+        // utility class -> private constructor
+    }
 
     public static void registerNetworkChangeReceiver() {
         Context context = MainApp.getAppContext();

+ 5 - 1
src/main/java/com/owncloud/android/utils/ThemeUtils.java

@@ -62,7 +62,11 @@ import com.owncloud.android.ui.activity.ToolbarActivity;
 /**
  * Utility class with methods for client side theming.
  */
-public class ThemeUtils {
+public final class ThemeUtils {
+
+    private ThemeUtils() {
+        // utility class -> private constructor
+    }
 
     public static int primaryAccentColor(Context context) {
         OCCapability capability = getCapability(context);

+ 4 - 1
src/main/java/com/owncloud/android/utils/UriUtils.java

@@ -40,12 +40,15 @@ import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 /**
  * A helper class for some Uri operations.
  */
-public class UriUtils {
+public final class UriUtils {
 
     public static final String TAG = UriUtils.class.getSimpleName();
 
     public static final String URI_CONTENT_SCHEME = "content://";
 
+    private UriUtils() {
+        // utility class -> private constructor
+    }
 
     /**
      * Get the value of the data column for this Uri. This is useful for