Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use android-library, streamline dav4jvm #2497

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
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
9 changes: 5 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ ext {
daggerVersion = "2.48.1"
emojiVersion = "1.4.0"
lifecycleVersion = '2.6.2'
okhttpVersion = "4.11.0"
okhttpVersion = "5.0.0-alpha.10"
markwonVersion = "4.6.2"
materialDialogsVersion = "3.3.0"
parcelerVersion = "1.1.13"
Expand Down Expand Up @@ -184,9 +184,6 @@ dependencies {
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
androidTestImplementation "androidx.work:work-testing:${workVersion}"
implementation 'com.google.android.flexbox:flexbox:3.0.0'
implementation ('com.gitlab.bitfireAT:dav4jvm:2.1.3', {
exclude group: 'org.ogce', module: 'xpp3' // Android comes with its own XmlPullParser
})
implementation 'org.conscrypt:conscrypt-android:2.5.2'

implementation "androidx.camera:camera-core:${androidxCameraVersion}"
Expand Down Expand Up @@ -311,6 +308,10 @@ dependencies {
implementation 'com.github.nextcloud.android-common:ui:0.12.0'

implementation 'com.github.nextcloud-deps:android-talk-webrtc:110.5481.0'

api("com.github.nextcloud:android-library:$androidLibraryVersion") {
exclude group: 'org.ogce', module: 'xpp3' // unused in Android and brings wrong Junit version
}
}

task installGitHooks(type: Copy, group: "development") {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.nextcloud.talk.components.filebrowser.webdav

import android.net.Uri
import androidx.test.platform.app.InstrumentationRegistry
import com.nextcloud.talk.components.filebrowser.models.BrowserFile
import com.nextcloud.talk.data.user.model.User
import junit.framework.Assert.assertEquals
import okhttp3.OkHttpClient
import org.junit.Test

class ReadFilesystemOperationIT {
@Test
fun showContent() {
val arguments = InstrumentationRegistry.getArguments()
val url = Uri.parse(arguments.getString("TEST_SERVER_URL"))
val username = arguments.getString("TEST_SERVER_USERNAME")
val password = arguments.getString("TEST_SERVER_PASSWORD")

val client = OkHttpClient()
val user = User().apply {
baseUrl = url.toString()
userId = username
this.username = username
token = password
}
val sut = ReadFilesystemOperation(client, user, "/", 1)
val data = sut.readRemotePath().data as List<BrowserFile>
assertEquals(1, data.size)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ import com.nextcloud.android.common.ui.theme.utils.ColorRole
import com.nextcloud.talk.R
import com.nextcloud.talk.application.NextcloudTalkApplication
import com.nextcloud.talk.application.NextcloudTalkApplication.Companion.sharedApplication
import com.nextcloud.talk.components.filebrowser.models.BrowserFile
import com.nextcloud.talk.components.filebrowser.webdav.ReadFilesystemOperation
import com.nextcloud.talk.data.user.model.User
import com.nextcloud.talk.databinding.ReactionsInsideMessageBinding
Expand All @@ -56,6 +55,7 @@ import com.nextcloud.talk.utils.DisplayUtils
import com.nextcloud.talk.utils.DrawableUtils.getDrawableResourceIdForMimeType
import com.nextcloud.talk.utils.FileViewerUtils
import com.nextcloud.talk.utils.FileViewerUtils.ProgressUi
import com.owncloud.android.lib.resources.files.model.RemoteFile
import com.stfalcon.chatkit.messages.MessageHolders.IncomingImageMessageViewHolder
import io.reactivex.Single
import io.reactivex.SingleObserver
Expand Down Expand Up @@ -287,7 +287,7 @@ abstract class PreviewMessageViewHolder(itemView: View?, payload: Any?) :
override fun onSuccess(readFilesystemOperation: ReadFilesystemOperation) {
val davResponse = readFilesystemOperation.readRemotePath()
if (davResponse.data != null) {
val browserFileList = davResponse.data as List<BrowserFile>
val browserFileList = davResponse.data as List<RemoteFile>
if (browserFileList.isNotEmpty()) {
Handler(context!!.mainLooper).post {
val resourceId = getDrawableResourceIdForMimeType(browserFileList[0].mimeType)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ import coil.decode.SvgDecoder
import coil.memory.MemoryCache
import coil.util.DebugLogger
import com.nextcloud.talk.BuildConfig
import com.nextcloud.talk.components.filebrowser.webdav.DavUtils
import com.nextcloud.talk.dagger.modules.BusModule
import com.nextcloud.talk.dagger.modules.ContextModule
import com.nextcloud.talk.dagger.modules.DatabaseModule
Expand All @@ -70,6 +69,7 @@ import com.nextcloud.talk.utils.database.arbitrarystorage.ArbitraryStorageModule
import com.nextcloud.talk.utils.database.user.UserModule
import com.nextcloud.talk.utils.preferences.AppPreferences
import com.nextcloud.talk.webrtc.MagicWebRTCUtils
import com.owncloud.android.lib.common.network.WebdavUtils
import com.vanniktech.emoji.EmojiManager
import com.vanniktech.emoji.google.GoogleEmojiProvider
import de.cotech.hw.SecurityKeyManager
Expand Down Expand Up @@ -164,7 +164,7 @@ class NextcloudTalkApplication : MultiDexApplication(), LifecycleObserver {

initializeWebRtc()
buildComponent()
DavUtils.registerCustomFactories()
WebdavUtils.registerCustomFactories()

componentApplication.inject(this)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,19 @@ import at.bitfire.dav4jvm.property.GetLastModified
import at.bitfire.dav4jvm.property.ResourceType
import at.bitfire.dav4jvm.property.ResourceType.Companion.COLLECTION
import com.bluelinelabs.logansquare.annotation.JsonObject
import com.nextcloud.talk.components.filebrowser.models.properties.NCEncrypted
import com.nextcloud.talk.components.filebrowser.models.properties.NCPermission
import com.nextcloud.talk.components.filebrowser.models.properties.NCPreview
import com.nextcloud.talk.components.filebrowser.models.properties.OCFavorite
import com.nextcloud.talk.components.filebrowser.models.properties.OCId
import com.nextcloud.talk.components.filebrowser.models.properties.OCSize
import com.nextcloud.talk.utils.Mimetype.FOLDER
import com.owncloud.android.lib.resources.files.webdav.NCEncrypted
import com.owncloud.android.lib.resources.files.webdav.NCFavorite
import com.owncloud.android.lib.resources.files.webdav.NCPermissions
import com.owncloud.android.lib.resources.files.webdav.NCPreview
import kotlinx.parcelize.Parcelize
import java.io.File

@Parcelize
@JsonObject
@Deprecated("Use library", replaceWith = ReplaceWith("RemoteFile"))
data class BrowserFile(
var path: String? = null,
var displayName: String? = null,
Expand Down Expand Up @@ -93,15 +94,15 @@ data class BrowserFile(
browserFile.modifiedTimestamp = property.lastModified
}
is GetContentType -> {
browserFile.mimeType = property.type
browserFile.mimeType = property.type?.toString()
}
is OCSize -> {
browserFile.size = property.ocSize
}
is NCPreview -> {
browserFile.hasPreview = property.isNcPreview
}
is OCFavorite -> {
is NCFavorite -> {
browserFile.isFavorite = property.isOcFavorite
}
is DisplayName -> {
Expand All @@ -110,8 +111,8 @@ data class BrowserFile(
is NCEncrypted -> {
browserFile.isEncrypted = property.isNcEncrypted
}
is NCPermission -> {
browserFile.permissions = property.ncPermission
is NCPermissions -> {
browserFile.permissions = property.permissions
}
}
}
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Loading