mirror of
https://github.com/nextcloud/android.git
synced 2024-11-29 18:59:18 +03:00
Remove extension for version check
Signed-off-by: alperozturk <alper_ozturk@proton.me>
This commit is contained in:
parent
033c073430
commit
730af29fe3
3 changed files with 9 additions and 13 deletions
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue