Remove extension for version check

Signed-off-by: alperozturk <alper_ozturk@proton.me>
This commit is contained in:
alperozturk 2024-07-29 14:27:44 +02:00
parent 033c073430
commit 730af29fe3
No known key found for this signature in database
GPG key ID: 4E577DC593B59BDF
3 changed files with 9 additions and 13 deletions

View file

@ -9,12 +9,6 @@ package com.nextcloud.utils.extensions
import android.accounts.Account import android.accounts.Account
import android.content.Context import android.content.Context
import com.nextcloud.client.account.UserAccountManager
import com.owncloud.android.R 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 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)
}

View file

@ -33,7 +33,7 @@ import com.owncloud.android.utils.theme.ViewThemeUtils
*/ */
@Suppress("LongParameterList") @Suppress("LongParameterList")
class UnifiedSearchListAdapter( class UnifiedSearchListAdapter(
private val isServerVersionThirtyOrAbove: Boolean, private val supportsOpeningCalendarContactsLocally: Boolean,
private val storageManager: FileDataStorageManager, private val storageManager: FileDataStorageManager,
private val listInterface: UnifiedSearchListInterface, private val listInterface: UnifiedSearchListInterface,
private val filesAction: UnifiedSearchItemViewHolder.FilesAction, private val filesAction: UnifiedSearchItemViewHolder.FilesAction,
@ -74,7 +74,7 @@ class UnifiedSearchListAdapter(
false false
) )
UnifiedSearchItemViewHolder( UnifiedSearchItemViewHolder(
isServerVersionThirtyOrAbove, supportsOpeningCalendarContactsLocally,
binding, binding,
user, user,
clientFactory, clientFactory,

View file

@ -30,7 +30,6 @@ import com.nextcloud.client.core.AsyncRunner
import com.nextcloud.client.di.Injectable import com.nextcloud.client.di.Injectable
import com.nextcloud.client.di.ViewModelFactory import com.nextcloud.client.di.ViewModelFactory
import com.nextcloud.client.network.ClientFactory import com.nextcloud.client.network.ClientFactory
import com.nextcloud.utils.extensions.isServerVersionNewerOrEqual
import com.owncloud.android.R import com.owncloud.android.R
import com.owncloud.android.databinding.ListFragmentBinding import com.owncloud.android.databinding.ListFragmentBinding
import com.owncloud.android.datamodel.FileDataStorageManager import com.owncloud.android.datamodel.FileDataStorageManager
@ -140,13 +139,16 @@ class UnifiedSearchFragment :
setupFileDisplayActivity() setupFileDisplayActivity()
setupAdapter() setupAdapter()
if (isServerVersionThirtyOrAbove()) { if (supportsOpeningCalendarContactsLocally()) {
checkPermissions() checkPermissions()
} }
} }
private fun isServerVersionThirtyOrAbove(): Boolean = private fun supportsOpeningCalendarContactsLocally(): Boolean =
accountManager.isServerVersionNewerOrEqual(NextcloudVersion.nextcloud_30) storageManager
.getCapability(accountManager.user)
.version
.isNewerOrEqual(NextcloudVersion.nextcloud_30)
@Deprecated("Deprecated in Java") @Deprecated("Deprecated in Java")
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) { override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
@ -259,7 +261,7 @@ class UnifiedSearchFragment :
private fun setupAdapter() { private fun setupAdapter() {
val gridLayoutManager = GridLayoutManager(requireContext(), 1) val gridLayoutManager = GridLayoutManager(requireContext(), 1)
adapter = UnifiedSearchListAdapter( adapter = UnifiedSearchListAdapter(
isServerVersionThirtyOrAbove(), supportsOpeningCalendarContactsLocally(),
storageManager, storageManager,
this, this,
this, this,