diff --git a/app/src/main/java/com/nextcloud/utils/extensions/AccountExtensions.kt b/app/src/main/java/com/nextcloud/utils/extensions/AccountExtensions.kt index cc7ce75981..2f70ada3c9 100644 --- a/app/src/main/java/com/nextcloud/utils/extensions/AccountExtensions.kt +++ b/app/src/main/java/com/nextcloud/utils/extensions/AccountExtensions.kt @@ -9,12 +9,6 @@ package com.nextcloud.utils.extensions import android.accounts.Account import android.content.Context -import com.nextcloud.client.account.UserAccountManager import com.owncloud.android.R -import com.owncloud.android.lib.resources.status.NextcloudVersion fun Account.isAnonymous(context: Context): Boolean = type.equals(context.getString(R.string.anonymous_account_type)) - -fun UserAccountManager.isServerVersionNewerOrEqual(version: NextcloudVersion): Boolean { - return user.server.version.isNewerOrEqual(version) -} diff --git a/app/src/main/java/com/owncloud/android/ui/adapter/UnifiedSearchListAdapter.kt b/app/src/main/java/com/owncloud/android/ui/adapter/UnifiedSearchListAdapter.kt index 9ff02e939f..4e269eabca 100644 --- a/app/src/main/java/com/owncloud/android/ui/adapter/UnifiedSearchListAdapter.kt +++ b/app/src/main/java/com/owncloud/android/ui/adapter/UnifiedSearchListAdapter.kt @@ -33,7 +33,7 @@ import com.owncloud.android.utils.theme.ViewThemeUtils */ @Suppress("LongParameterList") class UnifiedSearchListAdapter( - private val isServerVersionThirtyOrAbove: Boolean, + private val supportsOpeningCalendarContactsLocally: Boolean, private val storageManager: FileDataStorageManager, private val listInterface: UnifiedSearchListInterface, private val filesAction: UnifiedSearchItemViewHolder.FilesAction, @@ -74,7 +74,7 @@ class UnifiedSearchListAdapter( false ) UnifiedSearchItemViewHolder( - isServerVersionThirtyOrAbove, + supportsOpeningCalendarContactsLocally, binding, user, clientFactory, diff --git a/app/src/main/java/com/owncloud/android/ui/fragment/UnifiedSearchFragment.kt b/app/src/main/java/com/owncloud/android/ui/fragment/UnifiedSearchFragment.kt index 7bb14bf51b..782f3049dc 100644 --- a/app/src/main/java/com/owncloud/android/ui/fragment/UnifiedSearchFragment.kt +++ b/app/src/main/java/com/owncloud/android/ui/fragment/UnifiedSearchFragment.kt @@ -30,7 +30,6 @@ import com.nextcloud.client.core.AsyncRunner import com.nextcloud.client.di.Injectable import com.nextcloud.client.di.ViewModelFactory import com.nextcloud.client.network.ClientFactory -import com.nextcloud.utils.extensions.isServerVersionNewerOrEqual import com.owncloud.android.R import com.owncloud.android.databinding.ListFragmentBinding import com.owncloud.android.datamodel.FileDataStorageManager @@ -140,13 +139,16 @@ class UnifiedSearchFragment : setupFileDisplayActivity() setupAdapter() - if (isServerVersionThirtyOrAbove()) { + if (supportsOpeningCalendarContactsLocally()) { checkPermissions() } } - private fun isServerVersionThirtyOrAbove(): Boolean = - accountManager.isServerVersionNewerOrEqual(NextcloudVersion.nextcloud_30) + private fun supportsOpeningCalendarContactsLocally(): Boolean = + storageManager + .getCapability(accountManager.user) + .version + .isNewerOrEqual(NextcloudVersion.nextcloud_30) @Deprecated("Deprecated in Java") override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) { @@ -259,7 +261,7 @@ class UnifiedSearchFragment : private fun setupAdapter() { val gridLayoutManager = GridLayoutManager(requireContext(), 1) adapter = UnifiedSearchListAdapter( - isServerVersionThirtyOrAbove(), + supportsOpeningCalendarContactsLocally(), storageManager, this, this,