Browse Source

Fix kotlin spotless check

Signed-off-by: alperozturk <alper_ozturk@proton.me>
alperozturk 1 year ago
parent
commit
ce8a853f14

+ 48 - 23
app/src/main/java/com/owncloud/android/files/services/FileDownloader.kt

@@ -250,7 +250,7 @@ class FileDownloader : Service(), OnDatatransferProgressListener, OnAccountsUpda
     }
     }
 
 
     override fun onAccountsUpdated(accounts: Array<Account>) {
     override fun onAccountsUpdated(accounts: Array<Account>) {
-        //review the current download and cancel it if its account doesn't exist
+        // review the current download and cancel it if its account doesn't exist
         if (mCurrentDownload != null && !accountManager!!.exists(mCurrentDownload!!.user.toPlatformAccount())) {
         if (mCurrentDownload != null && !accountManager!!.exists(mCurrentDownload!!.user.toPlatformAccount())) {
             mCurrentDownload!!.cancel()
             mCurrentDownload!!.cancel()
         }
         }
@@ -284,7 +284,9 @@ class FileDownloader : Service(), OnDatatransferProgressListener, OnAccountsUpda
                 download.cancel()
                 download.cancel()
             } else {
             } else {
                 if (mCurrentDownload != null && currentUser.isPresent &&
                 if (mCurrentDownload != null && currentUser.isPresent &&
-                    mCurrentDownload!!.remotePath.startsWith(file.remotePath) && account.name == currentUser.get().accountName
+                    mCurrentDownload!!
+                        .remotePath
+                        .startsWith(file.remotePath) && account.name == currentUser.get().accountName
                 ) {
                 ) {
                     mCurrentDownload!!.cancel()
                     mCurrentDownload!!.cancel()
                 }
                 }
@@ -350,13 +352,17 @@ class FileDownloader : Service(), OnDatatransferProgressListener, OnAccountsUpda
         }
         }
 
 
         override fun onTransferProgress(
         override fun onTransferProgress(
-            progressRate: Long, totalTransferredSoFar: Long,
-            totalToTransfer: Long, fileName: String
+            progressRate: Long,
+            totalTransferredSoFar: Long,
+            totalToTransfer: Long,
+            fileName: String
         ) {
         ) {
             val boundListener = mBoundListeners[mCurrentDownload!!.file.fileId]
             val boundListener = mBoundListeners[mCurrentDownload!!.file.fileId]
             boundListener?.onTransferProgress(
             boundListener?.onTransferProgress(
-                progressRate, totalTransferredSoFar,
-                totalToTransfer, fileName
+                progressRate,
+                totalTransferredSoFar,
+                totalToTransfer,
+                fileName
             )
             )
         }
         }
     }
     }
@@ -415,7 +421,7 @@ class FileDownloader : Service(), OnDatatransferProgressListener, OnAccountsUpda
                 notifyDownloadStart(mCurrentDownload!!)
                 notifyDownloadStart(mCurrentDownload!!)
                 var downloadResult: RemoteOperationResult<*>? = null
                 var downloadResult: RemoteOperationResult<*>? = null
                 try {
                 try {
-                    /// prepare client object to send the request to the ownCloud server
+                    // / prepare client object to send the request to the ownCloud server
                     val currentDownloadAccount = mCurrentDownload!!.user.toPlatformAccount()
                     val currentDownloadAccount = mCurrentDownload!!.user.toPlatformAccount()
                     val currentDownloadUser = accountManager!!.getUser(currentDownloadAccount.name)
                     val currentDownloadUser = accountManager!!.getUser(currentDownloadAccount.name)
                     if (currentUser != currentDownloadUser) {
                     if (currentUser != currentDownloadUser) {
@@ -428,7 +434,7 @@ class FileDownloader : Service(), OnDatatransferProgressListener, OnAccountsUpda
                     val ocAccount = currentDownloadUser.get().toOwnCloudAccount()
                     val ocAccount = currentDownloadUser.get().toOwnCloudAccount()
                     mDownloadClient = OwnCloudClientManagerFactory.getDefaultSingleton().getClientFor(ocAccount, this)
                     mDownloadClient = OwnCloudClientManagerFactory.getDefaultSingleton().getClientFor(ocAccount, this)
 
 
-                    /// perform the download
+                    // / perform the download
                     downloadResult = mCurrentDownload!!.execute(mDownloadClient)
                     downloadResult = mCurrentDownload!!.execute(mDownloadClient)
                     if (downloadResult.isSuccess && mCurrentDownload!!.downloadType === DownloadType.DOWNLOAD) {
                     if (downloadResult.isSuccess && mCurrentDownload!!.downloadType === DownloadType.DOWNLOAD) {
                         saveDownloadedFile()
                         saveDownloadedFile()
@@ -438,13 +444,14 @@ class FileDownloader : Service(), OnDatatransferProgressListener, OnAccountsUpda
                     downloadResult = RemoteOperationResult<Any?>(e)
                     downloadResult = RemoteOperationResult<Any?>(e)
                 } finally {
                 } finally {
                     val removeResult = mPendingDownloads.removePayload(
                     val removeResult = mPendingDownloads.removePayload(
-                        mCurrentDownload!!.user.accountName, mCurrentDownload!!.remotePath
+                        mCurrentDownload!!.user.accountName,
+                        mCurrentDownload!!.remotePath
                     )
                     )
                     if (downloadResult == null) {
                     if (downloadResult == null) {
                         downloadResult = RemoteOperationResult<Any?>(RuntimeException("Error downloading…"))
                         downloadResult = RemoteOperationResult<Any?>(RuntimeException("Error downloading…"))
                     }
                     }
 
 
-                    /// notify result
+                    // / notify result
                     notifyDownloadResult(mCurrentDownload!!, downloadResult)
                     notifyDownloadResult(mCurrentDownload!!, downloadResult)
                     sendBroadcastDownloadFinished(mCurrentDownload!!, downloadResult, removeResult.second)
                     sendBroadcastDownloadFinished(mCurrentDownload!!, downloadResult, removeResult.second)
                 }
                 }
@@ -499,14 +506,14 @@ class FileDownloader : Service(), OnDatatransferProgressListener, OnAccountsUpda
         val titlePrefix = getString(R.string.file_downloader_notification_title_prefix)
         val titlePrefix = getString(R.string.file_downloader_notification_title_prefix)
         val title = titlePrefix + fileName
         val title = titlePrefix + fileName
 
 
-        /// update status notification with a progress bar
+        // / update status notification with a progress bar
         mLastPercent = 0
         mLastPercent = 0
         notificationBuilder
         notificationBuilder
             ?.setContentTitle(title)
             ?.setContentTitle(title)
             ?.setTicker(title)
             ?.setTicker(title)
             ?.setProgress(100, 0, download.size < 0)
             ?.setProgress(100, 0, download.size < 0)
 
 
-        /// includes a pending intent in the notification showing the details view of the file
+        // / includes a pending intent in the notification showing the details view of the file
         val showDetailsIntent: Intent = if (PreviewImageFragment.canBePreviewed(download.file)) {
         val showDetailsIntent: Intent = if (PreviewImageFragment.canBePreviewed(download.file)) {
             Intent(this, PreviewImageActivity::class.java)
             Intent(this, PreviewImageActivity::class.java)
         } else {
         } else {
@@ -532,8 +539,10 @@ class FileDownloader : Service(), OnDatatransferProgressListener, OnAccountsUpda
      * Callback method to update the progress bar in the status notification.
      * Callback method to update the progress bar in the status notification.
      */
      */
     override fun onTransferProgress(
     override fun onTransferProgress(
-        progressRate: Long, totalTransferredSoFar: Long,
-        totalToTransfer: Long, filePath: String
+        progressRate: Long,
+        totalTransferredSoFar: Long,
+        totalToTransfer: Long,
+        filePath: String
     ) {
     ) {
         val percent = (100.0 * totalTransferredSoFar.toDouble() / totalToTransfer.toDouble()).toInt()
         val percent = (100.0 * totalTransferredSoFar.toDouble() / totalToTransfer.toDouble()).toInt()
         if (percent != mLastPercent) {
         if (percent != mLastPercent) {
@@ -564,10 +573,21 @@ class FileDownloader : Service(), OnDatatransferProgressListener, OnAccountsUpda
                 // Don't show notification except an error has occurred.
                 // Don't show notification except an error has occurred.
                 return
                 return
             }
             }
-            var tickerId =
-                if (downloadResult.isSuccess) R.string.downloader_download_succeeded_ticker else R.string.downloader_download_failed_ticker
+
+            var tickerId = if (downloadResult.isSuccess) {
+                R.string.downloader_download_succeeded_ticker
+            } else {
+                R.string.downloader_download_failed_ticker
+            }
+
             val needsToUpdateCredentials = ResultCode.UNAUTHORIZED == downloadResult.code
             val needsToUpdateCredentials = ResultCode.UNAUTHORIZED == downloadResult.code
-            tickerId = if (needsToUpdateCredentials) R.string.downloader_download_failed_credentials_error else tickerId
+
+            tickerId = if (needsToUpdateCredentials) {
+                R.string.downloader_download_failed_credentials_error
+            } else {
+                tickerId
+            }
+
             notificationBuilder
             notificationBuilder
                 ?.setSmallIcon(R.drawable.notification_icon)
                 ?.setSmallIcon(R.drawable.notification_icon)
                 ?.setTicker(getString(tickerId))
                 ?.setTicker(getString(tickerId))
@@ -582,15 +602,18 @@ class FileDownloader : Service(), OnDatatransferProgressListener, OnAccountsUpda
                 val showDetailsIntent = Intent()
                 val showDetailsIntent = Intent()
                 notificationBuilder?.setContentIntent(
                 notificationBuilder?.setContentIntent(
                     PendingIntent.getActivity(
                     PendingIntent.getActivity(
-                        this, System.currentTimeMillis().toInt(),
-                        showDetailsIntent, PendingIntent.FLAG_IMMUTABLE
+                        this,
+                        System.currentTimeMillis().toInt(),
+                        showDetailsIntent,
+                        PendingIntent.FLAG_IMMUTABLE
                     )
                     )
                 )
                 )
             }
             }
             notificationBuilder?.setContentText(
             notificationBuilder?.setContentText(
                 ErrorMessageAdapter.getErrorCauseMessage(
                 ErrorMessageAdapter.getErrorCauseMessage(
                     downloadResult,
                     downloadResult,
-                    download, resources
+                    download,
+                    resources
                 )
                 )
             )
             )
             if (notificationManager != null) {
             if (notificationManager != null) {
@@ -601,7 +624,8 @@ class FileDownloader : Service(), OnDatatransferProgressListener, OnAccountsUpda
                     // Sleep 2 seconds, so show the notification before remove it
                     // Sleep 2 seconds, so show the notification before remove it
                     NotificationUtils.cancelWithDelay(
                     NotificationUtils.cancelWithDelay(
                         notificationManager,
                         notificationManager,
-                        R.string.downloader_download_succeeded_ticker, 2000
+                        R.string.downloader_download_succeeded_ticker,
+                        2000
                     )
                     )
                 }
                 }
             }
             }
@@ -621,7 +645,8 @@ class FileDownloader : Service(), OnDatatransferProgressListener, OnAccountsUpda
         updateAccountCredentials.addFlags(Intent.FLAG_FROM_BACKGROUND)
         updateAccountCredentials.addFlags(Intent.FLAG_FROM_BACKGROUND)
         notificationBuilder!!.setContentIntent(
         notificationBuilder!!.setContentIntent(
             PendingIntent.getActivity(
             PendingIntent.getActivity(
-                this, System.currentTimeMillis().toInt(),
+                this,
+                System.currentTimeMillis().toInt(),
                 updateAccountCredentials,
                 updateAccountCredentials,
                 PendingIntent.FLAG_ONE_SHOT or PendingIntent.FLAG_IMMUTABLE
                 PendingIntent.FLAG_ONE_SHOT or PendingIntent.FLAG_IMMUTABLE
             )
             )
@@ -698,4 +723,4 @@ class FileDownloader : Service(), OnDatatransferProgressListener, OnAccountsUpda
         val downloadFinishMessage: String
         val downloadFinishMessage: String
             get() = FileDownloader::class.java.name + DOWNLOAD_FINISH_MESSAGE
             get() = FileDownloader::class.java.name + DOWNLOAD_FINISH_MESSAGE
     }
     }
-}
+}