فهرست منبع

codacy: put fields on top; they should be declared at the top of the class, before any method declarations, constructors, initializers or inner classes.

AndyScherzinger 8 سال پیش
والد
کامیت
0592eac9bf

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

@@ -50,6 +50,9 @@ public class PassCodeManager {
 
     public static PassCodeManager mPassCodeManagerInstance = null;
 
+    private Long mTimestamp = 0l;
+    private int mVisibleActivitiesCounter = 0;
+
     public static PassCodeManager getPassCodeManager() {
         if (mPassCodeManagerInstance == null) {
             mPassCodeManagerInstance = new PassCodeManager();
@@ -57,9 +60,6 @@ public class PassCodeManager {
         return mPassCodeManagerInstance;
     }
 
-    private Long mTimestamp = 0l;
-    private int mVisibleActivitiesCounter = 0;
-
     protected PassCodeManager() {};
 
     public void onActivityCreated(Activity activity) {

+ 5 - 7
src/main/java/com/owncloud/android/authentication/SsoWebViewClient.java

@@ -55,18 +55,17 @@ import java.security.cert.X509Certificate;
 public class SsoWebViewClient extends WebViewClient {
         
     private static final String TAG = SsoWebViewClient.class.getSimpleName();
-    
-    public interface SsoWebViewClientListener {
-        public void onSsoFinished(String sessionCookie);
-    }
-    
+
     private Context mContext;
     private Handler mListenerHandler;
     private WeakReference<SsoWebViewClientListener> mListenerRef;
     private String mTargetUrl;
     private String mLastReloadedUrlAtError;
-
     
+    public interface SsoWebViewClientListener {
+        public void onSsoFinished(String sessionCookie);
+    }
+
     public SsoWebViewClient (Context context, Handler listenerHandler, SsoWebViewClientListener listener) {
         mContext = context;
         mListenerHandler = listenerHandler;
@@ -191,5 +190,4 @@ public class SsoWebViewClient extends WebViewClient {
 
         ((AuthenticatorActivity)mContext).createAuthenticationDialog(view, handler);
     }
-
 }

+ 32 - 31
src/main/java/com/owncloud/android/operations/UploadFileOperation.java

@@ -72,43 +72,17 @@ import java.util.concurrent.atomic.AtomicBoolean;
  */
 public class UploadFileOperation extends SyncOperation {
 
+    private static final String TAG = UploadFileOperation.class.getSimpleName();
+
     public static final int CREATED_BY_USER = 0;
     public static final int CREATED_AS_INSTANT_PICTURE = 1;
     public static final int CREATED_AS_INSTANT_VIDEO = 2;
 
-    public static OCFile obtainNewOCFileToUpload(String remotePath, String localPath, String mimeType) {
-
-        // MIME type
-        if (mimeType == null || mimeType.length() <= 0) {
-            mimeType = MimeTypeUtil.getBestMimeTypeByFilename(localPath);
-        }
-
-        OCFile newFile = new OCFile(remotePath);
-        newFile.setStoragePath(localPath);
-        newFile.setLastSyncDateForProperties(0);
-        newFile.setLastSyncDateForData(0);
-
-        // size
-        if (localPath != null && localPath.length() > 0) {
-            File localFile = new File(localPath);
-            newFile.setFileLength(localFile.length());
-            newFile.setLastSyncDateForData(localFile.lastModified());
-        } // don't worry about not assigning size, the problems with localPath
-        // are checked when the UploadFileOperation instance is created
-
-
-        newFile.setMimetype(mimeType);
-
-        return newFile;
-    }
-
-    private static final String TAG = UploadFileOperation.class.getSimpleName();
-
-    private Account mAccount;
     /**
      * OCFile which is to be uploaded.
      */
     private OCFile mFile;
+
     /**
      * Original OCFile which is to be uploaded in case file had to be renamed
      * (if forceOverwrite==false and remote file already exists).
@@ -139,6 +113,34 @@ public class UploadFileOperation extends SyncOperation {
 
     protected RequestEntity mEntity = null;
 
+    private Account mAccount;
+
+    public static OCFile obtainNewOCFileToUpload(String remotePath, String localPath, String mimeType) {
+
+        // MIME type
+        if (mimeType == null || mimeType.length() <= 0) {
+            mimeType = MimeTypeUtil.getBestMimeTypeByFilename(localPath);
+        }
+
+        OCFile newFile = new OCFile(remotePath);
+        newFile.setStoragePath(localPath);
+        newFile.setLastSyncDateForProperties(0);
+        newFile.setLastSyncDateForData(0);
+
+        // size
+        if (localPath != null && localPath.length() > 0) {
+            File localFile = new File(localPath);
+            newFile.setFileLength(localFile.length());
+            newFile.setLastSyncDateForData(localFile.lastModified());
+        } // don't worry about not assigning size, the problems with localPath
+        // are checked when the UploadFileOperation instance is created
+
+
+        newFile.setMimetype(mimeType);
+
+        return newFile;
+    }
+
     public UploadFileOperation(Account account,
                                OCFile file,
                                OCUpload upload,
@@ -148,8 +150,7 @@ public class UploadFileOperation extends SyncOperation {
                                Context context
     ) {
         if (account == null) {
-            throw new IllegalArgumentException("Illegal NULL account in UploadFileOperation " +
-                    "creation");
+            throw new IllegalArgumentException("Illegal NULL account in UploadFileOperation " + "creation");
         }
         if (upload == null) {
             throw new IllegalArgumentException("Illegal NULL file in UploadFileOperation creation");

+ 7 - 13
src/main/java/com/owncloud/android/services/OperationsService.java

@@ -117,15 +117,16 @@ public class OperationsService extends Service {
     public static final String ACTION_COPY_FILE = "COPY_FILE";
     public static final String ACTION_CHECK_CURRENT_CREDENTIALS = "CHECK_CURRENT_CREDENTIALS";
 
-    public static final String ACTION_OPERATION_ADDED = OperationsService.class.getName() +
-            ".OPERATION_ADDED";
-    public static final String ACTION_OPERATION_FINISHED = OperationsService.class.getName() +
-            ".OPERATION_FINISHED";
+    public static final String ACTION_OPERATION_ADDED = OperationsService.class.getName() + ".OPERATION_ADDED";
+    public static final String ACTION_OPERATION_FINISHED = OperationsService.class.getName() + ".OPERATION_FINISHED";
 
+    private ServiceHandler mOperationsHandler;
+    private OperationsServiceBinder mOperationsBinder;
+
+    private SyncFolderHandler mSyncFolderHandler;
 
     private ConcurrentMap<Integer, Pair<RemoteOperation, RemoteOperationResult>>
-            mUndispatchedFinishedOperations =
-            new ConcurrentHashMap<Integer, Pair<RemoteOperation, RemoteOperationResult>>();
+            mUndispatchedFinishedOperations = new ConcurrentHashMap<>();
 
     private static class Target {
         public Uri mServerUrl = null;
@@ -138,11 +139,6 @@ public class OperationsService extends Service {
             mCookie = cookie;
         }
     }
-
-    private ServiceHandler mOperationsHandler;
-    private OperationsServiceBinder mOperationsBinder;
-    
-    private SyncFolderHandler mSyncFolderHandler;
     
     /**
      * Service initialization
@@ -165,7 +161,6 @@ public class OperationsService extends Service {
         mSyncFolderHandler = new SyncFolderHandler(thread.getLooper(), this);
     }
 
-
     /**
      * Entry point to add a new operation to the queue of operations.
      * <p/>
@@ -709,7 +704,6 @@ public class OperationsService extends Service {
         }
     }
 
-
     /**
      * Notifies the currently subscribed listeners about the end of an operation.
      *

+ 4 - 3
src/main/java/com/owncloud/android/ui/adapter/ExpandableUploadListAdapter.java

@@ -67,11 +67,14 @@ import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 public class ExpandableUploadListAdapter extends BaseExpandableListAdapter implements Observer {
 
     private static final String TAG = ExpandableUploadListAdapter.class.getSimpleName();
+
+    public ProgressListener mProgressListener;
+
     private FileActivity mParentActivity;
 
     private UploadsStorageManager mUploadsStorageManager;
 
-    public ProgressListener mProgressListener;
+    private UploadGroup[] mUploadGroups = null;
 
     interface Refresh {
         public void refresh();
@@ -141,8 +144,6 @@ public class ExpandableUploadListAdapter extends BaseExpandableListAdapter imple
         abstract public int getGroupIcon();
     }
 
-    private UploadGroup[] mUploadGroups = null;
-
     public ExpandableUploadListAdapter(FileActivity parentActivity) {
         Log_OC.d(TAG, "ExpandableUploadListAdapter");
         mParentActivity = parentActivity;

+ 14 - 15
src/main/java/com/owncloud/android/ui/asynctasks/CopyAndUploadContentUrisTask.java

@@ -48,6 +48,20 @@ public class CopyAndUploadContentUrisTask extends AsyncTask<Object, Void, Result
 
     private final String TAG = CopyAndUploadContentUrisTask.class.getSimpleName();
 
+    /**
+     * Listener in main thread to be notified when the task ends. Held in a WeakReference assuming that its
+     * lifespan is associated with an Activity context, that could be finished by the user before the AsyncTask
+     * ends.
+     */
+    private WeakReference<OnCopyTmpFilesTaskListener> mListener;
+
+    /**
+     * Reference to application context, used to access app resources. Holding it should not be a problem,
+     * since it needs to exist until the end of the AsyncTask although the caller Activity were finished
+     * before.
+     */
+    private final Context mAppContext;
+
     /**
      * Helper method building a correct array of parameters to be passed to {@link #execute(Object[])} )}
      *
@@ -93,21 +107,6 @@ public class CopyAndUploadContentUrisTask extends AsyncTask<Object, Void, Result
         };
     }
 
-    /**
-     * Listener in main thread to be notified when the task ends. Held in a WeakReference assuming that its
-     * lifespan is associated with an Activity context, that could be finished by the user before the AsyncTask
-     * ends.
-     */
-    private WeakReference<OnCopyTmpFilesTaskListener> mListener;
-
-    /**
-     * Reference to application context, used to access app resources. Holding it should not be a problem,
-     * since it needs to exist until the end of the AsyncTask although the caller Activity were finished
-     * before.
-     */
-    private final Context mAppContext;
-
-
     public CopyAndUploadContentUrisTask(
         OnCopyTmpFilesTaskListener listener,
         Context context