Эх сурвалжийг харах

reformat code

Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
Andy Scherzinger 2 жил өмнө
parent
commit
c7d0d0f47d
21 өөрчлөгдсөн 100 нэмэгдсэн , 45 устгасан
  1. 2 2
      app/src/androidTest/java/com/owncloud/android/providers/DocumentsStorageProviderIT.kt
  2. 2 1
      app/src/androidTest/java/com/owncloud/android/ui/fragment/FileDetailSharingFragmentIT.kt
  3. 1 3
      app/src/main/java/com/nextcloud/client/documentscan/DocumentScanViewModel.kt
  4. 4 2
      app/src/main/java/com/nextcloud/client/jobs/AccountRemovalWork.kt
  5. 2 1
      app/src/main/java/com/nextcloud/client/jobs/CalendarBackupWork.kt
  6. 4 2
      app/src/main/java/com/nextcloud/client/jobs/ContactsBackupWork.kt
  7. 2 1
      app/src/main/java/com/nextcloud/client/jobs/NotificationWork.kt
  8. 3 3
      app/src/main/java/com/nextcloud/client/media/ErrorFormat.kt
  9. 3 1
      app/src/main/java/com/nextcloud/client/media/PlayerStateMachine.kt
  10. 35 9
      app/src/main/java/com/nextcloud/client/mixins/ActivityMixin.kt
  11. 6 2
      app/src/main/java/com/owncloud/android/datamodel/ContentResolverHelper.kt
  12. 6 3
      app/src/main/java/com/owncloud/android/files/services/FileUploader.java
  13. 2 1
      app/src/main/java/com/owncloud/android/operations/CreateFolderOperation.java
  14. 4 2
      app/src/main/java/com/owncloud/android/providers/DocumentsStorageProvider.java
  15. 2 1
      app/src/main/java/com/owncloud/android/ui/activity/FileActivity.java
  16. 4 2
      app/src/main/java/com/owncloud/android/ui/activity/FolderPickerActivity.kt
  17. 2 1
      app/src/main/java/com/owncloud/android/ui/adapter/UploadListAdapter.java
  18. 8 4
      app/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java
  19. 2 1
      app/src/main/java/com/owncloud/android/utils/FileStorageUtils.java
  20. 4 2
      app/src/main/java/third_parties/sufficientlysecure/ProcessVEvent.java
  21. 2 1
      app/src/test/java/com/nextcloud/client/logger/ui/LogsViewModelTest.kt

+ 2 - 2
app/src/androidTest/java/com/owncloud/android/providers/DocumentsStorageProviderIT.kt

@@ -76,8 +76,8 @@ class DocumentsStorageProviderIT : AbstractOnServerIT() {
         val file1 = rootDir.createFile(type1, name1)!!
 
         // check assumptions
-        @Suppress("ForbiddenComment")
-        file1.assertRegularFile(name1, 0L, null/* FIXME: type1 */, rootDir)
+        /* FIXME: mimeType */
+        file1.assertRegularFile(name1, 0L, null, rootDir)
         file1.assertRecentlyModified()
 
         // file1 is found in root

+ 2 - 1
app/src/androidTest/java/com/owncloud/android/ui/fragment/FileDetailSharingFragmentIT.kt

@@ -352,7 +352,8 @@ class FileDetailSharingFragmentIT : AbstractIT() {
         val secondary = FileDetailFragment.newInstance(file, parentFolder, user)
         activity.addSecondaryFragment(secondary, FileDisplayActivity.TAG_LIST_OF_FILES)
         activity.addView(
-            FloatingActionButton(activity).apply { // needed for some reason
+            FloatingActionButton(activity).apply {
+                // needed for some reason
                 visibility = View.GONE
                 id = R.id.fab_main
             }

+ 1 - 3
app/src/main/java/com/nextcloud/client/documentscan/DocumentScanViewModel.kt

@@ -210,9 +210,7 @@ class DocumentScanViewModel @Inject constructor(
         }
     }
 
-    private
-
-    companion object {
+    private companion object {
         private const val TAG = "DocumentScanViewModel"
     }
 

+ 4 - 2
app/src/main/java/com/nextcloud/client/jobs/AccountRemovalWork.kt

@@ -81,11 +81,13 @@ class AccountRemovalWork(
     @Suppress("ReturnCount") // legacy code
     override fun doWork(): Result {
         val accountName = inputData.getString(ACCOUNT) ?: ""
-        if (TextUtils.isEmpty(accountName)) { // didn't receive account to delete
+        if (TextUtils.isEmpty(accountName)) {
+            // didn't receive account to delete
             return Result.failure()
         }
         val optionalUser = userAccountManager.getUser(accountName)
-        if (!optionalUser.isPresent) { // trying to delete non-existing user
+        if (!optionalUser.isPresent) {
+            // trying to delete non-existing user
             return Result.failure()
         }
         val remoteWipe = inputData.getBoolean(REMOTE_WIPE, false)

+ 2 - 1
app/src/main/java/com/nextcloud/client/jobs/CalendarBackupWork.kt

@@ -52,7 +52,8 @@ class CalendarBackupWork(
     override fun doWork(): Result {
         val accountName = inputData.getString(ACCOUNT) ?: ""
         val optionalUser = accountManager.getUser(accountName)
-        if (!optionalUser.isPresent || TextUtils.isEmpty(accountName)) { // no account provided
+        if (!optionalUser.isPresent || TextUtils.isEmpty(accountName)) {
+            // no account provided
             Log_OC.d(TAG, "User not present")
             return Result.failure()
         }

+ 4 - 2
app/src/main/java/com/nextcloud/client/jobs/ContactsBackupWork.kt

@@ -81,7 +81,8 @@ class ContactsBackupWork(
     @Suppress("ReturnCount") // pre-existing issue
     override fun doWork(): Result {
         val accountName = inputData.getString(KEY_ACCOUNT) ?: ""
-        if (TextUtils.isEmpty(accountName)) { // no account provided
+        if (TextUtils.isEmpty(accountName)) {
+            // no account provided
             return Result.failure()
         }
         val optionalUser = accountManager.getUser(accountName)
@@ -175,7 +176,8 @@ class ContactsBackupWork(
         connection.enqueue(request)
     }
 
-    private fun expireFiles(daysToExpire: Int, backupFolderString: String, user: User) { // -1 disables expiration
+    private fun expireFiles(daysToExpire: Int, backupFolderString: String, user: User) {
+        // -1 disables expiration
         if (daysToExpire > -1) {
             val storageManager = FileDataStorageManager(
                 user,

+ 2 - 1
app/src/main/java/com/nextcloud/client/jobs/NotificationWork.kt

@@ -198,7 +198,8 @@ class NotificationWork constructor(
                     disableIntent
                 )
             )
-        } else { // Actions
+        } else {
+            // Actions
             for (action in notification.getActions()) {
                 val actionIntent = Intent(context, NotificationReceiver::class.java)
                 actionIntent.putExtra(NUMERIC_NOTIFICATION_ID, notification.getNotificationId())

+ 3 - 3
app/src/main/java/com/nextcloud/client/media/ErrorFormat.kt

@@ -67,21 +67,21 @@ object ErrorFormat {
             /*  Added in API level 17
                 Some operation takes too long to complete, usually more than 3-5 seconds.
                 Constant Value: -110 (0xffffff92)
-            */
+             */
             messageId = R.string.media_err_timeout
         } else if (what == MediaPlayer.MEDIA_ERROR_NOT_VALID_FOR_PROGRESSIVE_PLAYBACK) {
             /*  Added in API level 3
                 The video is streamed and its container is not valid for progressive playback i.e the video's index
                 (e.g moov atom) is not at the start of the file.
                 Constant Value: 200 (0x000000c8)
-            */
+             */
             messageId = R.string.media_err_invalid_progressive_playback
         } else {
             /*  MediaPlayer.MEDIA_ERROR_UNKNOWN
                 Added in API level 1
                 Unspecified media player error.
                 Constant Value: 1 (0x00000001)
-            */
+             */
             /*  MediaPlayer.MEDIA_ERROR_SERVER_DIED)
                 Added in API level 1
                 Media server died. In this case, the application must release the MediaPlayer

+ 3 - 1
app/src/main/java/com/nextcloud/client/media/PlayerStateMachine.kt

@@ -184,7 +184,9 @@ internal class PlayerStateMachine(initialState: State, private val delegate: Del
             .onExit(Action { delegate.onAudioDuck(false) })
 
         stateMachine = StateMachine(initialState, config)
-        stateMachine.onUnhandledTrigger { _, _ -> /* ignore unhandled event */ }
+        stateMachine.onUnhandledTrigger { _, _ ->
+            /* ignore unhandled event */
+        }
     }
 
     private fun immediateTransition() {

+ 35 - 9
app/src/main/java/com/nextcloud/client/mixins/ActivityMixin.kt

@@ -28,13 +28,39 @@ import android.os.Bundle
  * a mix-in.
  */
 interface ActivityMixin {
-    fun onNewIntent(intent: Intent) { /* no-op */ }
-    fun onSaveInstanceState(outState: Bundle) { /* no-op */ }
-    fun onCreate(savedInstanceState: Bundle?) { /* no-op */ }
-    fun onRestart() { /* no-op */ }
-    fun onStart() { /* no-op */ }
-    fun onResume() { /* no-op */ }
-    fun onPause() { /* no-op */ }
-    fun onStop() { /* no-op */ }
-    fun onDestroy() { /* no-op */ }
+    fun onNewIntent(intent: Intent) {
+        /* no-op */
+    }
+
+    fun onSaveInstanceState(outState: Bundle) {
+        /* no-op */
+    }
+
+    fun onCreate(savedInstanceState: Bundle?) {
+        /* no-op */
+    }
+
+    fun onRestart() {
+        /* no-op */
+    }
+
+    fun onStart() {
+        /* no-op */
+    }
+
+    fun onResume() {
+        /* no-op */
+    }
+
+    fun onPause() {
+        /* no-op */
+    }
+
+    fun onStop() {
+        /* no-op */
+    }
+
+    fun onDestroy() {
+        /* no-op */
+    }
 }

+ 6 - 2
app/src/main/java/com/owncloud/android/datamodel/ContentResolverHelper.kt

@@ -91,8 +91,12 @@ object ContentResolverHelper {
     }
 
     @RequiresApi(Build.VERSION_CODES.R)
-    private fun
-    getQueryArgsBundle(selection: String?, sortColumn: String?, sortDirection: String?, limit: Int?): Bundle {
+    private fun getQueryArgsBundle(
+        selection: String?,
+        sortColumn: String?,
+        sortDirection: String?,
+        limit: Int?
+    ): Bundle {
         return Bundle().apply {
             if (selection != null) {
                 putString(ContentResolver.QUERY_ARG_SQL_SELECTION, selection)

+ 6 - 3
app/src/main/java/com/owncloud/android/files/services/FileUploader.java

@@ -332,13 +332,15 @@ public class FileUploader extends Service
         boolean onWifiOnly = intent.getBooleanExtra(KEY_WHILE_ON_WIFI_ONLY, false);
         boolean whileChargingOnly = intent.getBooleanExtra(KEY_WHILE_CHARGING_ONLY, false);
 
-        if (retry) { // Retry uploads
+        if (retry) {
+            // Retry uploads
             if (!intent.hasExtra(KEY_ACCOUNT) || !intent.hasExtra(KEY_RETRY_UPLOAD)) {
                 Log_OC.e(TAG, "Not enough information provided in intent: no KEY_RETRY_UPLOAD_KEY");
                 return START_NOT_STICKY;
             }
             retryUploads(intent, user, requestedUploads);
-        } else { // Start new uploads
+        } else {
+            // Start new uploads
             if (!(intent.hasExtra(KEY_LOCAL_FILE) || intent.hasExtra(KEY_FILE))) {
                 Log_OC.e(TAG, "Not enough information provided in intent");
                 return Service.START_NOT_STICKY;
@@ -793,7 +795,8 @@ public class FileUploader extends Service
             boolean needsToUpdateCredentials = uploadResult.getCode() == ResultCode.UNAUTHORIZED;
             if (needsToUpdateCredentials) {
                 tickerId = R.string.uploader_upload_failed_credentials_error;
-            } else if (uploadResult.getCode() == ResultCode.SYNC_CONFLICT) { // check file conflict
+            } else if (uploadResult.getCode() == ResultCode.SYNC_CONFLICT) {
+                // check file conflict
                 tickerId = R.string.uploader_upload_failed_sync_conflict_error;
             }
 

+ 2 - 1
app/src/main/java/com/owncloud/android/operations/CreateFolderOperation.java

@@ -336,7 +336,8 @@ public class CreateFolderOperation extends SyncOperation implements OnRemoteOper
                     saveFolderInDB();
                 }
             }
-        } else { // Create directory on DB
+        } else {
+            // Create directory on DB
             OCFile newDir = new OCFile(remotePath);
             newDir.setMimeType(MimeType.DIRECTORY);
             long parentId = getStorageManager().getFileByPath(FileStorageUtils.getParentPath(remotePath)).getFileId();

+ 4 - 2
app/src/main/java/com/owncloud/android/providers/DocumentsStorageProvider.java

@@ -260,7 +260,8 @@ public class DocumentsStorageProvider extends DocumentsProvider {
             Handler handler = new Handler(context.getMainLooper());
             try {
                 return ParcelFileDescriptor.open(file, accessMode, handler, error -> {
-                    if (error == null) { // no error
+                    if (error == null) {
+                        // no error
                         // As we can't upload the file synchronously, let's at least update its metadata here already.
                         ocFile.setFileLength(file.length());
                         ocFile.setModificationTimestamp(System.currentTimeMillis());
@@ -275,7 +276,8 @@ public class DocumentsStorageProvider extends DocumentsProvider {
                             LOCAL_BEHAVIOUR_DELETE,
                             NameCollisionPolicy.OVERWRITE,
                             false);
-                    } else { // error, no upload needed
+                    } else {
+                        // error, no upload needed
                         Log_OC.e(TAG, "File was closed with an error: " + ocFile.getFileName(), error);
                     }
                 });

+ 2 - 1
app/src/main/java/com/owncloud/android/ui/activity/FileActivity.java

@@ -823,7 +823,8 @@ public abstract class FileActivity extends DrawerActivity
                 // Was tried without password, but not sure that it's optional.
 
                 // Try with password before giving up; see also ShareFileFragment#OnShareViaLinkListener
-                if (sharingFragment != null && sharingFragment.isAdded()) { // only if added to the view hierarchy
+                if (sharingFragment != null && sharingFragment.isAdded()) {
+                    // only if added to the view hierarchy
 
                     sharingFragment.requestPasswordForShareViaLink(true,
                                                                    getCapabilities().getFilesSharingPublicAskForOptionalPassword()

+ 4 - 2
app/src/main/java/com/owncloud/android/ui/activity/FolderPickerActivity.kt

@@ -320,7 +320,8 @@ open class FolderPickerActivity :
 
     fun browseToRoot() {
         val listOfFiles = listOfFilesFragment
-        if (listOfFiles != null) { // should never be null, indeed
+        if (listOfFiles != null) {
+            // should never be null, indeed
             val root = storageManager.getFileByPath(OCFile.ROOT_PATH)
             listOfFiles.listDirectory(root, false, false)
             file = listOfFiles.currentFile
@@ -331,7 +332,8 @@ open class FolderPickerActivity :
 
     override fun onBackPressed() {
         val listOfFiles = listOfFilesFragment
-        if (listOfFiles != null) { // should never be null, indeed
+        if (listOfFiles != null) {
+            // should never be null, indeed
             val levelsUp = listOfFiles.onBrowseUp()
             if (levelsUp == 0) {
                 finish()

+ 2 - 1
app/src/main/java/com/owncloud/android/ui/adapter/UploadListAdapter.java

@@ -497,7 +497,8 @@ public class UploadListAdapter extends SectionedRecyclerViewAdapter<SectionedVie
         String remotePath = item.getRemotePath();
         OCFile ocFile = storageManager.getFileByPath(remotePath);
 
-        if (ocFile == null) { // Remote file doesn't exist, try to refresh folder
+        if (ocFile == null) {
+            // Remote file doesn't exist, try to refresh folder
             OCFile folder = storageManager.getFileByPath(new File(remotePath).getParent() + "/");
             if (folder != null && folder.isFolder()) {
                 this.refreshFolder(itemViewHolder, user, folder, (caller, result) -> {

+ 8 - 4
app/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java

@@ -328,7 +328,8 @@ public class OCFileListFragment extends ExtendedListFragment implements
 
         mFabMain = requireActivity().findViewById(R.id.fab_main);
 
-        if (mFabMain != null) { // is not available in FolderPickerActivity
+        if (mFabMain != null) {
+            // is not available in FolderPickerActivity
             viewThemeUtils.material.themeFAB(mFabMain);
         }
 
@@ -387,7 +388,8 @@ public class OCFileListFragment extends ExtendedListFragment implements
             registerFabListener();
         }
 
-        if (!searchFragment) { // do not touch search event if previously searched
+        if (!searchFragment) {
+            // do not touch search event if previously searched
             if (getArguments() == null) {
                 searchEvent = null;
             } else {
@@ -478,7 +480,8 @@ public class OCFileListFragment extends ExtendedListFragment implements
     public void registerFabListener() {
         FileActivity activity = (FileActivity) getActivity();
 
-        if (mFabMain != null) { // is not available in FolderPickerActivity
+        if (mFabMain != null) {
+            // is not available in FolderPickerActivity
             viewThemeUtils.material.themeFAB(mFabMain);
             mFabMain.setOnClickListener(v -> {
                 final OCFileListBottomSheetDialog dialog =
@@ -1028,7 +1031,8 @@ public class OCFileListFragment extends ExtendedListFragment implements
                     intent.putExtra(FolderPickerActivity.EXTRA_FILES, file);
                     getActivity().setResult(Activity.RESULT_OK, intent);
                     getActivity().finish();
-                } else if (!mOnlyFoldersClickable) { // Click on a file
+                } else if (!mOnlyFoldersClickable) {
+                    // Click on a file
                     if (PreviewImageFragment.canBePreviewed(file)) {
                         // preview image - it handles the download, if needed
                         if (searchFragment) {

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

@@ -583,7 +583,8 @@ public final class FileStorageUtils {
         }
 
         FileStorageUtils.StandardDirectory standardDirectory = FileStorageUtils.StandardDirectory.fromPath(storageFolder);
-        if (standardDirectory != null) { // Friendly name of standard directory
+        if (standardDirectory != null) {
+            // Friendly name of standard directory
             storageFolder = " " + resources.getString(standardDirectory.getDisplayName());
         }
 

+ 4 - 2
app/src/main/java/third_parties/sufficientlysecure/ProcessVEvent.java

@@ -433,13 +433,15 @@ public class ProcessVEvent {
             //        - Check the calendars max number of alarms
             if (t.getDateTime() != null) {
                 alarmMs = t.getDateTime().getTime(); // Absolute
-            } else if (t.getDuration() != null && t.getDuration().isNegative()) { //alarm trigger before start of event
+            } else if (t.getDuration() != null && t.getDuration().isNegative()) {
+                //alarm trigger before start of event
                 Related rel = (Related) t.getParameter(Parameter.RELATED);
                 if (rel != null && rel == Related.END) {
                     alarmStartMs = e.getEndDate().getDate().getTime();
                 }
                 alarmMs = alarmStartMs - durationToMs(t.getDuration()); // Relative "-"
-            } else if (t.getDuration() != null && !t.getDuration().isNegative()) { //alarm trigger after start of event
+            } else if (t.getDuration() != null && !t.getDuration().isNegative()) {
+                //alarm trigger after start of event
                 Related rel = (Related) t.getParameter(Parameter.RELATED);
                 if (rel != null && rel == Related.END) {
                     alarmStartMs = e.getEndDate().getDate().getTime();

+ 2 - 1
app/src/test/java/com/nextcloud/client/logger/ui/LogsViewModelTest.kt

@@ -69,7 +69,8 @@ class LogsViewModelTest {
 
         override val lostEntries: Boolean = false
         override fun load(onLoaded: OnLogsLoaded) { this.onLoadedCallback = onLoaded; loadRequestCount++ }
-        override fun deleteAll() { /* no implementation neeeded */
+        override fun deleteAll() {
+            /* no implementation needed */
         }
     }