Skip to content

Commit

Permalink
Fix code analytics
Browse files Browse the repository at this point in the history
Signed-off-by: alperozturk <[email protected]>
  • Loading branch information
alperozturk96 committed Aug 27, 2024
1 parent 49ecd26 commit b679c20
Show file tree
Hide file tree
Showing 9 changed files with 1,343 additions and 30 deletions.
1,301 changes: 1,301 additions & 0 deletions app/schemas/com.nextcloud.client.database.NextcloudDatabase/84.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ open class WorkerNotificationManager(
val notificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager

var notificationBuilder: NotificationCompat.Builder =
NotificationUtils.newNotificationBuilder(context, NotificationUtils.NOTIFICATION_CHANNEL_BACKGROUND_OPERATIONS, viewThemeUtils).apply {
NotificationUtils.newNotificationBuilder(
context,
NotificationUtils.NOTIFICATION_CHANNEL_BACKGROUND_OPERATIONS,
viewThemeUtils
).apply {
setTicker(context.getString(tickerId))
setSmallIcon(R.drawable.notification_icon)
setLargeIcon(BitmapFactory.decodeResource(context.resources, R.drawable.notification_icon))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,7 @@ class FileOperationHelper(
private val client = clientFactory.create(user)

@Suppress("TooGenericExceptionCaught", "Deprecation")
suspend fun removeFile(
file: OCFile,
onlyLocalCopy: Boolean,
inBackground: Boolean
): Boolean {
suspend fun removeFile(file: OCFile, onlyLocalCopy: Boolean, inBackground: Boolean): Boolean {
return withContext(Dispatchers.IO) {
try {
val operation = async {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ interface NetworkChangeListener {

class NetworkChangeReceiver(
private val listener: NetworkChangeListener,
private val connectivityService: ConnectivityService,
private val connectivityService: ConnectivityService
) : BroadcastReceiver() {

private val scope = CoroutineScope(Dispatchers.IO)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,19 @@ fun OfflineOperationEntity.updatePathsIfParentPathMatches(oldPath: String?, newT
}
}

@Suppress("ReturnCount")
fun OfflineOperationEntity.updatePath(newParentPath: String?): String? {
if (newParentPath.isNullOrEmpty() || path.isNullOrEmpty()) return null

val segments = path!!.trim(DELIMITER).split(DELIMITER).toMutableList()
val segments = path?.trim(DELIMITER)?.split(DELIMITER)?.toMutableList()

if (segments.size == 1) {
if (segments?.size == 1) {
return newParentPath
}

segments.removeAt(0)
segments?.removeAt(0)

return newParentPath + segments.joinToString(separator = DELIMITER.toString()) + DELIMITER
return newParentPath + segments?.joinToString(separator = DELIMITER.toString()) + DELIMITER
}

fun OfflineOperationEntity.getParentPathFromPath(): String? = path?.getParentPathFromPath()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ import com.owncloud.android.lib.resources.files.model.RemoteFile
import com.owncloud.android.utils.ErrorMessageAdapter
import com.owncloud.android.utils.FileStorageUtils

@Suppress("ReturnCount")
fun Pair<RemoteOperationResult<*>?, RemoteOperation<*>?>?.getErrorMessage(): String {
val result = this?.first ?: return MainApp.string(R.string.unexpected_error_occurred)
val operation = this.second ?: return MainApp.string(R.string.unexpected_error_occurred)
return ErrorMessageAdapter.getErrorCauseMessage(result, operation, MainApp.getAppContext().resources)
}

@Suppress("NestedBlockDepth")
fun RemoteOperationResult<*>?.getConflictedRemoteIdsWithOfflineOperations(
offlineOperations: List<OfflineOperationEntity>,
fileDataStorageManager: FileDataStorageManager
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,12 +299,7 @@ class ConflictsResolveDialog : DialogFragment(), Injectable {
private const val ARG_USER = "USER"

@JvmStatic
fun newInstance(
context: Context,
leftFile: OCFile,
rightFile: OCFile,
user: User?
): ConflictsResolveDialog {
fun newInstance(context: Context, leftFile: OCFile, rightFile: OCFile, user: User?): ConflictsResolveDialog {
val file = File(leftFile.storagePath)
val conflictData = getFileConflictData(file, rightFile, context)

Expand All @@ -324,7 +319,7 @@ class ConflictsResolveDialog : DialogFragment(), Injectable {
fun newInstance(
context: Context,
offlineOperation: OfflineOperationEntity,
rightFile: OCFile,
rightFile: OCFile
): ConflictsResolveDialog {
val conflictData = getFolderConflictData(offlineOperation, rightFile, context)

Expand All @@ -338,6 +333,7 @@ class ConflictsResolveDialog : DialogFragment(), Injectable {
}
}

@Suppress("MagicNumber")
@JvmStatic
private fun getFolderConflictData(
offlineOperation: OfflineOperationEntity,
Expand All @@ -363,11 +359,7 @@ class ConflictsResolveDialog : DialogFragment(), Injectable {
}

@JvmStatic
private fun getFileConflictData(
file: File,
rightFile: OCFile,
context: Context
): ConflictDialogData {
private fun getFileConflictData(file: File, rightFile: OCFile, context: Context): ConflictDialogData {
val parentFile = File(rightFile.remotePath).parentFile
val folderName = if (parentFile != null) {
String.format(context.getString(R.string.in_folder), parentFile.absolutePath)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ data class ConflictDialogData(
data class ConflictFileData(
val title: String,
val timestamp: String,
val fileSize: String,
val fileSize: String
) : Parcelable {
constructor(parcel: Parcel) : this(
parcel.readString() ?: "",
Expand Down
29 changes: 23 additions & 6 deletions app/src/main/res/drawable/ic_retry.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,24 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#000000" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp">

<path android:fillColor="@android:color/white" android:pathData="M12,5V2L8,6l4,4V7c3.31,0 6,2.69 6,6c0,2.97 -2.17,5.43 -5,5.91v2.02c3.95,-0.49 7,-3.85 7,-7.93C20,8.58 16.42,5 12,5z"/>

<path android:fillColor="@android:color/white" android:pathData="M6,13c0,-1.65 0.67,-3.15 1.76,-4.24L6.34,7.34C4.9,8.79 4,10.79 4,13c0,4.08 3.05,7.44 7,7.93v-2.02C8.17,18.43 6,15.97 6,13z"/>

<!--
~ Nextcloud - Android Client
~
~ SPDX-FileCopyrightText: 2024 Alper Ozturk <[email protected]>
~ SPDX-FileCopyrightText: 2024 Nextcloud GmbH
~ SPDX-FileCopyrightText: 2018-2024 Google LLC
~ SPDX-License-Identifier: Apache-2.0
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="#000000"
android:viewportWidth="24"
android:viewportHeight="24">

<path
android:fillColor="@android:color/white"
android:pathData="M12,5V2L8,6l4,4V7c3.31,0 6,2.69 6,6c0,2.97 -2.17,5.43 -5,5.91v2.02c3.95,-0.49 7,-3.85 7,-7.93C20,8.58 16.42,5 12,5z" />

<path
android:fillColor="@android:color/white"
android:pathData="M6,13c0,-1.65 0.67,-3.15 1.76,-4.24L6.34,7.34C4.9,8.79 4,10.79 4,13c0,4.08 3.05,7.44 7,7.93v-2.02C8.17,18.43 6,15.97 6,13z" />

</vector>

0 comments on commit b679c20

Please sign in to comment.