Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions changelog/unreleased/4936
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Enhancement: New UI for oCIS sharing

A new UI has been implemented for oCIS sharing. The app now distinguishes between the backend in
use: the new UI is displayed for oCIS, while the existing sharing UI is preserved for oC classic.

https://github.com/owncloud/android/issues/4839
https://github.com/owncloud/android/pull/4936
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
* @author David González Verdugo
* @author Abel García de Prada
* @author Juan Carlos Garrote Gascón
* @author Jorge Aguado Recio
*
* Copyright (C) 2024 ownCloud GmbH.
* Copyright (C) 2026 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,
Expand Down Expand Up @@ -74,6 +75,10 @@ class CapabilityViewModel(
)
)

fun isOcisServer(): Boolean = runBlocking(coroutineDispatcherProvider.io) {
getStoredCapabilitiesUseCase(GetStoredCapabilitiesUseCase.Params(accountName))?.isSpacesAllowed() == true
}
Comment thread
jesmrec marked this conversation as resolved.

fun checkMultiPersonal(): Boolean = runBlocking(CoroutinesDispatcherProvider().io) {
val capabilities = withContext(CoroutinesDispatcherProvider().io) {
getStoredCapabilitiesUseCase(GetStoredCapabilitiesUseCase.Params(accountName))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,28 @@ import android.view.KeyEvent
import android.view.Menu
import android.view.MenuItem
import android.view.View
import androidx.core.view.isVisible
import androidx.fragment.app.transaction
import com.owncloud.android.R
import com.owncloud.android.databinding.MembersActivityBinding
import com.owncloud.android.datamodel.ThumbnailsCacheManager
import com.owncloud.android.domain.files.model.OCFile
import com.owncloud.android.domain.sharing.shares.model.OCShare
import com.owncloud.android.domain.sharing.shares.model.ShareType
import com.owncloud.android.domain.utils.Event.EventObserver
import com.owncloud.android.extensions.adaptInfiniteEdges
import com.owncloud.android.extensions.showErrorInSnackbar
import com.owncloud.android.lib.resources.shares.RemoteShare
import com.owncloud.android.presentation.capabilities.CapabilityViewModel
import com.owncloud.android.presentation.common.UIResult
import com.owncloud.android.presentation.sharing.sharees.EditPrivateShareFragment
import com.owncloud.android.presentation.sharing.sharees.SearchShareesFragment
import com.owncloud.android.presentation.sharing.sharees.UsersAndGroupsSearchProvider
import com.owncloud.android.presentation.sharing.shares.PublicShareDialogFragment
import com.owncloud.android.ui.activity.FileActivity
import com.owncloud.android.extensions.showDialogFragment
import com.owncloud.android.utils.DisplayUtils
import com.owncloud.android.utils.MimetypeIconUtil
import org.koin.androidx.viewmodel.ext.android.viewModel
import org.koin.core.parameter.parametersOf
import timber.log.Timber
Expand All @@ -64,37 +70,63 @@ class ShareActivity : FileActivity(), ShareFragmentListener {
account?.name
)
}
private val capabilityViewModel: CapabilityViewModel by viewModel {
parametersOf(account?.name)
}

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

setContentView(R.layout.share_activity)
if (capabilityViewModel.isOcisServer()) {
setupOcisLayout()
} else {
setupLegacyLayout(savedInstanceState)
}

val shareRoot = findViewById<View>(R.id.share_activity_layout)
adaptInfiniteEdges(shareRoot)
observePrivateShareCreation()
observePrivateShareEdition()
observeShareDeletion()
}

setupStandardToolbar(
title = null,
displayHomeAsUpEnabled = true,
homeButtonEnabled = true,
displayShowTitleEnabled = true,
)
supportActionBar?.setHomeActionContentDescription(R.string.common_back)
private fun setupOcisLayout() {
val binding = MembersActivityBinding.inflate(layoutInflater)
setContentView(binding.root)
setupToolbar(binding.root)
setupFileHeader(binding)
}

supportFragmentManager.transaction {
if (savedInstanceState == null && file != null && account != null) {
// Add Share fragment on first creation
val fragment = ShareFileFragment.newInstance(file, account!!)
replace(
R.id.share_fragment_container, fragment,
TAG_SHARE_FRAGMENT
)
private fun setupLegacyLayout(savedInstanceState: Bundle?) {
setContentView(R.layout.share_activity)
setupToolbar(findViewById(R.id.share_activity_layout))
if (savedInstanceState == null && file != null && account != null) {
supportFragmentManager.transaction {
replace(R.id.share_fragment_container, ShareFileFragment.newInstance(file, account!!), TAG_SHARE_FRAGMENT)
}
}
}

observePrivateShareCreation()
observePrivateShareEdition()
observeShareDeletion()
private fun setupToolbar(root: View) {
adaptInfiniteEdges(root)
setupStandardToolbar(title = null, displayHomeAsUpEnabled = true, homeButtonEnabled = true, displayShowTitleEnabled = true)
supportActionBar?.setHomeActionContentDescription(R.string.common_back)
}

private fun setupFileHeader(binding: MembersActivityBinding) {
binding.itemIcon.setImageResource(MimetypeIconUtil.getFileTypeIconId(file.mimeType, file.fileName))
if (file.isImage) {
val thumbnail = ThumbnailsCacheManager.getBitmapFromDiskCache(file.remoteId.toString())
if (thumbnail != null) { binding.itemIcon.setImageBitmap(thumbnail) }
Comment thread
jesmrec marked this conversation as resolved.
}

binding.itemName.text = file.fileName

if (file.isFolder) {
binding.itemSize.isVisible = false
} else {
binding.itemSize.text = DisplayUtils.bytesToHumanReadable(file.length, this, true)
}

binding.permanentLinkButton.isVisible = false
}

/**************************************************************************************************************
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
* ownCloud Android client application
*
* @author Juan Carlos Garrote Gascón
* @author Jorge Aguado Recio
*
* Copyright (C) 2023 ownCloud GmbH.
* Copyright (C) 2026 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,
Expand All @@ -27,14 +28,12 @@ import com.owncloud.android.domain.capabilities.CapabilityRepository
import com.owncloud.android.domain.files.model.FileMenuOption
import com.owncloud.android.domain.files.model.OCFile
import com.owncloud.android.domain.files.model.OCFileSyncInfo
import com.owncloud.android.domain.spaces.usecases.GetSpaceWithSpecialsByIdForAccountUseCase
import com.owncloud.android.extensions.getRunningWorkInfosByTags
import com.owncloud.android.usecases.transfers.TRANSFER_TAG_DOWNLOAD

class FilterFileMenuOptionsUseCase(
private val workManager: WorkManager,
private val capabilityRepository: CapabilityRepository,
private val getSpaceWithSpecialsByIdForAccountUseCase: GetSpaceWithSpecialsByIdForAccountUseCase,
) : BaseUseCase<MutableList<FileMenuOption>, FilterFileMenuOptionsUseCase.Params>() {
override fun run(params: Params): MutableList<FileMenuOption> {
val optionsToShow = mutableListOf<FileMenuOption>()
Expand All @@ -46,11 +45,6 @@ class FilterFileMenuOptionsUseCase(

val filesSyncInfo = params.filesSyncInfo
val capability = capabilityRepository.getStoredCapabilities(params.accountName)
val space = getSpaceWithSpecialsByIdForAccountUseCase(GetSpaceWithSpecialsByIdForAccountUseCase.Params(
spaceId = files.first().spaceId,
accountName = params.accountName,
))

val isAnyFileSynchronizing: Boolean = if (filesSyncInfo.isEmpty()) {
anyFileSynchronizingLookingIntoWorkers(files, params.accountName)
} else {
Expand All @@ -70,7 +64,6 @@ class FilterFileMenuOptionsUseCase(
} else {
false
}
val isPersonalSpace = space?.isPersonal ?: true
val resharingAllowed = capability?.let { !anyFileSharedWithMe(files) || it.filesSharingResharing.isTrue } ?: false
val displaySelectAll = params.displaySelectAll
val displaySelectInverse = params.displaySelectInverse
Expand All @@ -95,7 +88,7 @@ class FilterFileMenuOptionsUseCase(
}
// Share
if (!onlyAvailableOfflineFiles && shareViaLinkOrWithUsersAllowed && resharingAllowed &&
isPersonalSpace && hasResharePermission) {
hasResharePermission) {
optionsToShow.add(FileMenuOption.SHARE)
}
// Open with (different to preview!)
Expand Down