diff --git a/.gitignore b/.gitignore index 204ae1b1..188bba2b 100644 --- a/.gitignore +++ b/.gitignore @@ -81,3 +81,8 @@ lint/reports/ /gradle/libs.versions_app.toml app/google-services_1.json app/google-services_2.json +/alfresco-auth/ +/gradle/libs.versions-app.toml +/gradle/libs.versions-other.toml +/build-app.gradle +/build-other.gradle diff --git a/actions/src/main/kotlin/com/alfresco/content/actions/ContextualActionsBarFragment.kt b/actions/src/main/kotlin/com/alfresco/content/actions/ContextualActionsBarFragment.kt index e51d78ab..9c003f59 100644 --- a/actions/src/main/kotlin/com/alfresco/content/actions/ContextualActionsBarFragment.kt +++ b/actions/src/main/kotlin/com/alfresco/content/actions/ContextualActionsBarFragment.kt @@ -48,20 +48,24 @@ class ContextualActionsBarFragment : Fragment(), MavericksView, EntryListener { } override fun invalidate() = withState(viewModel) { - it.entries.first().let { entry -> - (requireActivity() as AppCompatActivity).supportActionBar?.title = entry.name - } + val entry = it.entries.first() + + (requireActivity() as AppCompatActivity).supportActionBar?.title = entry.name view.removeAllViews() - addButtons(view, it.topActions) + addButtons(view, it.topActions, entry) } - private fun addButtons(container: LinearLayout, actions: List) { + private fun addButtons(container: LinearLayout, actions: List, entry: Entry) { container.addView(createSeparator()) + for (action in actions) { - container.addView(createButton(action)) - container.addView(createSeparator()) + if (action !is ActionDownload || entry.canCreateUpdate) { + container.addView(createButton(action)) + container.addView(createSeparator()) + } } + if (actions.isNotEmpty()) { container.addView(createMoreButton()) container.addView(createSeparator()) diff --git a/actions/src/main/kotlin/com/alfresco/content/actions/ContextualActionsViewModel.kt b/actions/src/main/kotlin/com/alfresco/content/actions/ContextualActionsViewModel.kt index c2aa3d7e..6c4b8820 100644 --- a/actions/src/main/kotlin/com/alfresco/content/actions/ContextualActionsViewModel.kt +++ b/actions/src/main/kotlin/com/alfresco/content/actions/ContextualActionsViewModel.kt @@ -237,7 +237,7 @@ class ContextualActionsViewModel( listOf(if (entry.isFavorite) ActionRemoveFavorite(entry) else ActionAddFavorite(entry)) private fun externalActionsFor(entry: Entry) = - if (entry.isFile) { + if (entry.isFile && entry.canCreateUpdate) { listOf(ActionOpenWith(entry), ActionDownload(entry)) } else { listOf() diff --git a/data/src/main/kotlin/com/alfresco/content/data/Entry.kt b/data/src/main/kotlin/com/alfresco/content/data/Entry.kt index cc6f92b9..75b64d9c 100644 --- a/data/src/main/kotlin/com/alfresco/content/data/Entry.kt +++ b/data/src/main/kotlin/com/alfresco/content/data/Entry.kt @@ -59,6 +59,8 @@ data class Entry( @Transient val canCreate: Boolean = false, @Transient + val canCreateUpdate: Boolean = false, + @Transient val isTrashed: Boolean = false, @Transient val otherId: String? = null, @@ -193,6 +195,7 @@ data class Entry( node.isFavorite ?: false, canDelete(node.allowableOperations), canCreate(node.allowableOperations), + canCreateUpdate = canCreateUpdate(node.allowableOperations), ).withOfflineStatus() } @@ -210,6 +213,7 @@ data class Entry( result.isFavorite ?: false, canDelete(result.allowableOperations), canCreate(result.allowableOperations), + canCreateUpdate = canCreateUpdate(result.allowableOperations), parentPaths = result.path?.elements?.map { it.id!! }?.toMutableList() ?: mutableListOf(), ).withOfflineStatus() } @@ -231,6 +235,7 @@ data class Entry( result.isFavorite ?: false, canDelete(result.allowableOperations), canCreate(result.allowableOperations), + canCreateUpdate = canCreateUpdate(result.allowableOperations), isExtension = isExtension, parentPaths = result.path?.elements?.map { it.id!! }?.toMutableList() ?: mutableListOf(), ).withOfflineStatus() @@ -250,6 +255,7 @@ data class Entry( node.isFavorite ?: false, canDelete(node.allowableOperations), canCreate(node.allowableOperations), + canCreateUpdate = canCreateUpdate(node.allowableOperations), otherId = node.properties?.get("cm:destination") as String?, ).withOfflineStatus() } @@ -271,6 +277,7 @@ data class Entry( node.isFavorite ?: false, canDelete(node.allowableOperations), canCreate(node.allowableOperations), + canCreateUpdate = canCreateUpdate(node.allowableOperations), otherId = node.properties?.get("cm:destination") as String?, isExtension = isExtension, ).withOfflineStatus() @@ -292,6 +299,7 @@ data class Entry( file.allowableOperations == null, true, canDelete(favorite.allowableOperations), + canCreateUpdate = canCreateUpdate(favorite.allowableOperations), ).withOfflineStatus() } if (map.folder != null) { @@ -309,6 +317,7 @@ data class Entry( true, canDelete(favorite.allowableOperations), canCreate(favorite.allowableOperations), + canCreateUpdate = canCreateUpdate(favorite.allowableOperations), ).withOfflineStatus() } if (map.site != null) { @@ -502,6 +511,9 @@ data class Entry( private fun canCreate(operations: List?) = operations?.contains("create") ?: false + private fun canCreateUpdate(operations: List?) = + listOf("create", "update").any { operations?.contains(it) == true } + private fun propertiesCompat(src: Map?): MutableMap { val map = mutableMapOf()