From def9982f3fce97027d6e7502098dec958196c1b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Abel=20Garc=C3=ADa=20de=20Prada?= Date: Thu, 12 Dec 2019 12:43:13 +0100 Subject: [PATCH] Fix kotlin warnings --- .../datamodel/FileDataStorageManager.kt | 28 +++--- .../sharing/UsersAndGroupsSearchProvider.kt | 1 - .../fragments/ShareFragmentListener.kt | 2 +- .../android/ui/activity/LogHistoryActivity.kt | 1 - .../android/ui/adapter/LogListAdapter.kt | 97 ------------------- .../data/sharing/shares/db/OCShareEntity.kt | 59 +---------- 6 files changed, 16 insertions(+), 172 deletions(-) delete mode 100644 owncloudApp/src/main/java/com/owncloud/android/ui/adapter/LogListAdapter.kt diff --git a/owncloudApp/src/main/java/com/owncloud/android/datamodel/FileDataStorageManager.kt b/owncloudApp/src/main/java/com/owncloud/android/datamodel/FileDataStorageManager.kt index b781af01948..10ed4b7a321 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/datamodel/FileDataStorageManager.kt +++ b/owncloudApp/src/main/java/com/owncloud/android/datamodel/FileDataStorageManager.kt @@ -179,9 +179,9 @@ class FileDataStorageManager { val sharedByLinkFilesFromCurrentAccount: Vector get() { - val allSharedFiles = Vector(); - val result = Vector(); - var cursorOnShared: Cursor? = null; + val allSharedFiles = Vector() + val result = Vector() + var cursorOnShared: Cursor? = null try { cursorOnShared = contentResolver?.query( CONTENT_URI, @@ -191,33 +191,33 @@ class FileDataStorageManager { null ) if (cursorOnShared != null && cursorOnShared.moveToFirst()) { - var file: OCFile?; + var file: OCFile? do { - file = createFileInstance(cursorOnShared); - allSharedFiles.add(file); - } while (cursorOnShared.moveToNext()); + file = createFileInstance(cursorOnShared) + allSharedFiles.add(file) + } while (cursorOnShared.moveToNext()) } } catch (exception: Exception) { - Log_OC.e(TAG, "Exception retrieving all the shared by link files", exception); + Log_OC.e(TAG, "Exception retrieving all the shared by link files", exception) } finally { cursorOnShared?.close() } if (allSharedFiles.isNotEmpty()) { - val allSharedDirs = Vector(); + val allSharedDirs = Vector() for (file in allSharedFiles) { if (file.isFolder) { - allSharedDirs.add(file.fileId); + allSharedDirs.add(file.fileId) } } for (file in allSharedFiles) { if (file.isFolder || (!file.isFolder && !allSharedDirs.contains(file.parentId))) { - result.add(file); + result.add(file) } } } - result.sort(); - return result; + result.sort() + return result } fun getFileByPath(path: String): OCFile? { @@ -914,7 +914,7 @@ class FileDataStorageManager { val reqUri = Uri.withAppendedPath(CONTENT_URI_DIR, parentId.toString()) - val selection: String = "$FILE_PARENT=?" + val selection = "$FILE_PARENT=?" val selectionArgs: Array = arrayOf(parentId.toString()) val c: Cursor? = try { diff --git a/owncloudApp/src/main/java/com/owncloud/android/presentation/providers/sharing/UsersAndGroupsSearchProvider.kt b/owncloudApp/src/main/java/com/owncloud/android/presentation/providers/sharing/UsersAndGroupsSearchProvider.kt index 4775ce2f2a2..516786eb6e2 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/presentation/providers/sharing/UsersAndGroupsSearchProvider.kt +++ b/owncloudApp/src/main/java/com/owncloud/android/presentation/providers/sharing/UsersAndGroupsSearchProvider.kt @@ -266,7 +266,6 @@ class UsersAndGroupsSearchProvider : ContentProvider() { /** * Show error genericErrorMessage * - * @param resource Resource with the failure information. */ private fun showErrorMessage(genericErrorMessage: String, throwable: Throwable?) { val errorMessage = throwable?.parseError(genericErrorMessage, context.resources) diff --git a/owncloudApp/src/main/java/com/owncloud/android/presentation/ui/sharing/fragments/ShareFragmentListener.kt b/owncloudApp/src/main/java/com/owncloud/android/presentation/ui/sharing/fragments/ShareFragmentListener.kt index cdea52a6fb8..a10bfb9e8aa 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/presentation/ui/sharing/fragments/ShareFragmentListener.kt +++ b/owncloudApp/src/main/java/com/owncloud/android/presentation/ui/sharing/fragments/ShareFragmentListener.kt @@ -29,7 +29,7 @@ import com.owncloud.android.domain.sharing.shares.model.OCShare /** * This interface must be implemented by activities that contain this - * fragment to allow an interaction in fragments handling [OCShareEntity]s + * fragment to allow an interaction in fragments handling [OCShare]s * to be communicated to the parent activity and potentially other fragments * contained in that activity. * diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/activity/LogHistoryActivity.kt b/owncloudApp/src/main/java/com/owncloud/android/ui/activity/LogHistoryActivity.kt index ed9d17b9bdb..c575f3c904f 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/activity/LogHistoryActivity.kt +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/activity/LogHistoryActivity.kt @@ -27,7 +27,6 @@ import com.owncloud.android.R import info.hannes.logcat.BothLogsFragment import info.hannes.logcat.LogcatFragment import info.hannes.timber.fileLoggingTree -import timber.log.Timber class LogHistoryActivity : ToolbarActivity() { diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/adapter/LogListAdapter.kt b/owncloudApp/src/main/java/com/owncloud/android/ui/adapter/LogListAdapter.kt deleted file mode 100644 index 6af3de31501..00000000000 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/adapter/LogListAdapter.kt +++ /dev/null @@ -1,97 +0,0 @@ -/* - * ownCloud Android client application - * - * @author David González Verdugo - * Copyright (C) 2019 ownCloud GmbH. - *

- * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - *

- * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - *

- * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.owncloud.android.ui.adapter - -import android.content.Context -import android.graphics.Color -import android.view.LayoutInflater -import android.view.View -import android.view.ViewGroup -import android.widget.TextView -import androidx.core.content.ContextCompat -import androidx.recyclerview.widget.RecyclerView -import com.owncloud.android.R -import java.util.* - -/** - * Built a logs container which will be displayed as a list - */ -class LogListAdapter(private val completeLogs: ArrayList, filter: String, val context: Context) : RecyclerView.Adapter() { - private var filterLogs: List = ArrayList() - - init { - setFilter(filter) - } - - fun setFilter(filter: String) { - filterLogs = completeLogs.filter { it.contains(filter) } - notifyDataSetChanged() - } - - /** - * Define the view for each log in the list - */ - class LogViewHolder(view: View) : RecyclerView.ViewHolder(view) { - - val logContent: TextView = view.findViewById(R.id.logContent) - - } - - /** - * Create the view for each log in the list - * - * @param viewGroup - * @param i - * @return - */ - override fun onCreateViewHolder(viewGroup: ViewGroup, i: Int): LogViewHolder { - val view = LayoutInflater.from(viewGroup.context).inflate(R.layout.log_item, viewGroup, false) - return LogViewHolder(view) - } - - /** - * Fill in each log in the list - * - * @param holder - * @param position - */ - override fun onBindViewHolder(holder: LogViewHolder, position: Int) { - holder.logContent.text = filterLogs[position] - when { - filterLogs[position].contains(" E: ") -> { - holder.logContent.setTextColor(Color.RED) - } - filterLogs[position].contains(" W: ") -> { - holder.logContent.setTextColor(Color.MAGENTA) - } - filterLogs[position].contains(" V: ") -> { - holder.logContent.setTextColor(Color.GRAY) - } - else -> { - holder.logContent.setTextColor(ContextCompat.getColor(context, R.color.primary_dark)) - } - } - } - - override fun getItemCount(): Int { - return filterLogs.size - } - -} diff --git a/owncloudData/src/main/java/com/owncloud/android/data/sharing/shares/db/OCShareEntity.kt b/owncloudData/src/main/java/com/owncloud/android/data/sharing/shares/db/OCShareEntity.kt index ca606b80001..8fd21a429d7 100644 --- a/owncloudData/src/main/java/com/owncloud/android/data/sharing/shares/db/OCShareEntity.kt +++ b/owncloudData/src/main/java/com/owncloud/android/data/sharing/shares/db/OCShareEntity.kt @@ -67,31 +67,9 @@ data class OCShareEntity( val name: String?, @ColumnInfo(name = ProviderTableMeta.OCSHARES_URL) val shareLink: String? -) : Parcelable { +) { @PrimaryKey(autoGenerate = true) var id: Int = 0 - constructor(parcel: Parcel) : this( - parcel.readLong(), - parcel.readLong(), - parcel.readInt(), - parcel.readString(), - parcel.readString(), - parcel.readInt(), - parcel.readLong(), - parcel.readLong(), - parcel.readString(), - parcel.readString(), - parcel.readString(), - parcel.readByte() != 0.toByte(), - parcel.readLong(), - parcel.readLong(), - parcel.readString(), - parcel.readString(), - parcel.readString() - ) { - id = parcel.readInt() - } - companion object { fun fromCursor(cursor: Cursor): OCShareEntity { @@ -137,40 +115,5 @@ data class OCShareEntity( values.getAsString(ProviderTableMeta.OCSHARES_URL) ) } - - /** - * Parcelable Methods - */ - @JvmField - val CREATOR: Parcelable.Creator = object : Parcelable.Creator { - override fun createFromParcel(source: Parcel): OCShareEntity { - return OCShareEntity(source) - } - - override fun newArray(size: Int): Array { - return arrayOfNulls(size) - } - } - } - - override fun describeContents(): Int = this.hashCode() - - override fun writeToParcel(dest: Parcel?, flags: Int) { - dest?.writeInt(id) - dest?.writeString(shareWith) - dest?.writeString(path) - dest?.writeString(token) - dest?.writeString(sharedWithDisplayName) - dest?.writeString(sharedWithAdditionalInfo) - dest?.writeString(name) - dest?.writeString(shareLink) - dest?.writeLong(fileSource) - dest?.writeLong(itemSource) - dest?.writeInt(shareType) - dest?.writeInt(permissions) - dest?.writeLong(sharedDate) - dest?.writeLong(expirationDate) - dest?.writeInt(if (isFolder) 1 else 0) - dest?.writeLong(userId) } }