Skip to content

edit tags#16672

Open
tobiasKaminsky wants to merge 2 commits intomasterfrom
editTags
Open

edit tags#16672
tobiasKaminsky wants to merge 2 commits intomasterfrom
editTags

Conversation

@tobiasKaminsky
Copy link
Member

Disclaimer: Claude AI

Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
@github-actions
Copy link

Codacy

SpotBugs

CategoryBaseNew
Bad practice4041
Correctness7275
Dodgy code236241
Experimental11
Internationalization77
Malicious code vulnerability22
Multithreaded correctness3434
Performance4343
Security1818
Total453462

SpotBugs increased!

@github-actions
Copy link

blue-Light-Screenshot test failed, but no output was generated. Maybe a preliminary stage failed.

@github-actions
Copy link

APK file: https://www.kaminsky.me/nc-dev/android-artifacts/16672.apk

qrcode

To test this change/fix you can simply download above APK file and install and test it in parallel to your existing Nextcloud app.

Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
)
}
} else {
_uiState.update { TagUiState.Error("Failed to load tags") }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add hardcoded strings in xml.

private val currentAccountProvider: CurrentAccountProvider
) : ViewModel() {

sealed interface TagUiState {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add sealed interface in com.nextcloud.ui.tags.model

import com.owncloud.android.R
import com.owncloud.android.lib.resources.tags.Tag

class TagListAdapter(private val onTagChecked: (Tag, Boolean) -> Unit, private val onCreateTag: (String) -> Unit) :
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move adapter inside com.nextcloud.ui.tags.adapter

}
}

inner class TagViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move inner classes inside com.nextcloud.ui.tags.adapter.viewholder and make it class.

object Loading : TagUiState
data class Loaded(val allTags: List<Tag>, val assignedTagIds: Set<String>, val query: String = "") : TagUiState

data class Error(val message: String) : TagUiState
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of using String directly we can use Int that represents translated strings.

viewModelScope.launch(Dispatchers.IO) {
try {
val client = clientFactory.createNextcloudClient(currentAccountProvider.user)
val result = PutTagRemoteOperation(tag.id, fileId).execute(client)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to create repository for TagManagementViewModel e.g. TagManagementRepository and handle network call there and inject inside ViewModel instead of doing network call directly inside the ViewModel.

You can check AssistantViewModel as an example.

}
}
} catch (e: ClientFactory.CreationException) {
// ignore
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Always log errors.

val nextcloudClient = clientFactory.createNextcloudClient(currentAccountProvider.user)
val createResult = CreateTagRemoteOperation(name).execute(nextcloudClient)

if (createResult.isSuccess) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apply fail fast princible instead of nested ifs.

.show(fragmentManager, "actions");
}

private void refreshTagChips(Context context) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FileDetailFragment already 900+ lines of code. Let's not make it more harder to maintain. Please create a new Kotlin class and pass reference and handle the refresh tag chips there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants