├── .codecov.yml ├── .drone.yml ├── .editorconfig ├── .github └── workflows │ ├── analysis.yml │ ├── assemble.yml │ ├── autoApproveSync.yml │ ├── check.yml │ ├── codeql.yml │ ├── detectNewJavaFiles.yml │ ├── detectSnaphost.yml │ ├── pr-feedback.yml │ ├── renovate-approve-merge.yml │ ├── reuse.yml │ ├── scorecard.yml │ └── stale.yml ├── .gitignore ├── .idea ├── codeStyles │ ├── Project.xml │ └── codeStyleConfig.xml ├── copyright │ ├── Nextcloud_Android_Library.xml │ └── profiles_settings.xml ├── icon.svg └── inspectionProfiles │ ├── ktlint.xml │ └── profiles_settings.xml ├── .pullapprove.yml ├── .tx ├── config └── config.license ├── LICENSE.md ├── LICENSES ├── Apache-2.0.txt ├── CC0-1.0.txt ├── GPL-3.0-or-later.txt └── MIT.txt ├── README.md ├── REUSE.toml ├── THIRD_PARTY.txt ├── build.gradle ├── gradle.properties ├── gradle ├── verification-keyring.keys ├── verification-metadata.xml └── wrapper │ ├── gradle-wrapper.jar │ ├── gradle-wrapper.properties │ └── gradle-wrapper.properties.license ├── gradlew ├── gradlew.bat ├── gradlew.bat.license ├── gradlew.license ├── jacoco.gradle ├── jitpack.yml ├── library ├── .gitignore ├── build.gradle ├── detekt.yml ├── lint.xml └── src │ ├── androidTest │ ├── assets │ │ ├── gps.jpg │ │ ├── imageFile.png │ │ ├── textFile.txt │ │ └── videoFile.mp4 │ ├── java │ │ └── com │ │ │ ├── nextcloud │ │ │ ├── android │ │ │ │ └── lib │ │ │ │ │ ├── resources │ │ │ │ │ ├── dashboard │ │ │ │ │ │ ├── DashboardGetWidgetItemsRemoteOperationIT.kt │ │ │ │ │ │ └── DashboardListWidgetsRemoteOperationIT.kt │ │ │ │ │ ├── directediting │ │ │ │ │ │ ├── DirectEditingCreateFileRemoteOperationIT.java │ │ │ │ │ │ ├── DirectEditingObtainListOfTemplatesRemoteOperationIT.java │ │ │ │ │ │ ├── DirectEditingObtainRemoteOperationIT.kt │ │ │ │ │ │ └── DirectEditingOpenFileRemoteOperationIT.java │ │ │ │ │ ├── files │ │ │ │ │ │ └── ToggleFileLockRemoteOperationIT.kt │ │ │ │ │ ├── groupfolders │ │ │ │ │ │ └── GetGroupfoldersRemoteOperationIT.kt │ │ │ │ │ ├── profile │ │ │ │ │ │ └── GetHoverCardRemoteOperationIT.kt │ │ │ │ │ ├── recommendations │ │ │ │ │ │ └── GetRecommendationsRemoteOperationIT.kt │ │ │ │ │ ├── search │ │ │ │ │ │ ├── SearchProvidersRemoteOperationIT.kt │ │ │ │ │ │ └── UnifiedSearchRemoteOperationIT.kt │ │ │ │ │ ├── tos │ │ │ │ │ │ └── TermsOfServicesIT.kt │ │ │ │ │ └── users │ │ │ │ │ │ └── GenerateAppPasswordRemoteOperationIT.java │ │ │ │ │ └── richWorkspace │ │ │ │ │ └── RichWorkspaceDirectEditingRemoteOperationIT.java │ │ │ ├── common │ │ │ │ └── NextcloudUriDelegateIT.kt │ │ │ ├── extensions │ │ │ │ ├── DavPropertyProcessorTest.kt │ │ │ │ ├── ElementCreator.kt │ │ │ │ └── XmlDataProcessorTest.kt │ │ │ ├── lib │ │ │ │ └── resources │ │ │ │ │ └── users │ │ │ │ │ ├── GetActivitiesRemoteOperationIT.kt │ │ │ │ │ └── GetUserInfoRemoteOperationIT.kt │ │ │ └── test │ │ │ │ └── RandomStringGenerator.kt │ │ │ └── owncloud │ │ │ └── android │ │ │ ├── AbstractIT.java │ │ │ ├── CopyFileIT.java │ │ │ ├── CreateFolderRemoteOperationIT.java │ │ │ ├── DeleteFileIT.java │ │ │ ├── FileIT.java │ │ │ ├── GetCapabilitiesRemoteOperationIT.java │ │ │ ├── OwnCloudClientManagerFactoryTest.java │ │ │ ├── PlainClientIT.kt │ │ │ ├── ResponseFormatDetectorTests.kt │ │ │ ├── RetryTestRule.kt │ │ │ ├── XMLExceptionParserTests.kt │ │ │ └── lib │ │ │ ├── common │ │ │ ├── OwnCloudAccountTest.java │ │ │ ├── OwnCloudBasicCredentialsTest.java │ │ │ ├── OwnCloudClientTest.kt │ │ │ ├── SearchResultEntryTest.kt │ │ │ ├── UsernameVariationsIT.kt │ │ │ ├── accounts │ │ │ │ └── ExternalLinksOperationIT.kt │ │ │ └── operations │ │ │ │ ├── CreateShareIT.java │ │ │ │ ├── GetSharesIT.java │ │ │ │ ├── GetUserQuotaIT.java │ │ │ │ └── RemoveShareIT.java │ │ │ └── resources │ │ │ ├── assistant │ │ │ ├── v1 │ │ │ │ └── AssistantV1Tests.kt │ │ │ └── v2 │ │ │ │ └── AssistantV2Tests.kt │ │ │ ├── comments │ │ │ └── CommentFileRemoteOperationIT.kt │ │ │ ├── e2ee │ │ │ ├── SendCSRRemoteOperationIT.kt │ │ │ └── UpdateMetadataRemoteOperationIT.java │ │ │ ├── files │ │ │ ├── CheckEtagRemoteOperationIT.kt │ │ │ ├── DownloadFileRemoteOperationIT.kt │ │ │ ├── ExistenceCheckRemoteOperationIT.kt │ │ │ ├── FilesDownloadLimitIT.kt │ │ │ ├── MoveFileRemoteOperationIT.kt │ │ │ ├── ReadFileRemoteOperationIT.kt │ │ │ ├── ReadFileVersionsRemoteOperationIT.kt │ │ │ ├── ReadFolderRemoteOperationIT.kt │ │ │ ├── RenameFileRemoteOperationIT.kt │ │ │ ├── SearchRemoteOperationIT.java │ │ │ ├── UploadFileRemoteOperationIT.kt │ │ │ └── webdav │ │ │ │ └── ChunkedFileUploadRemoteOperationIT.kt │ │ │ ├── notifications │ │ │ └── NotificationIT.kt │ │ │ ├── shares │ │ │ ├── CreateShareRemoteOperationIT.kt │ │ │ ├── GetSharesRemoteOperationIT.java │ │ │ ├── ShareXMLParserIT.kt │ │ │ └── UpdateShareRemoteOperationIT.kt │ │ │ ├── status │ │ │ └── OwnCloudVersionTest.java │ │ │ ├── tags │ │ │ └── GetTagsRemoteOperationIT.kt │ │ │ ├── trashbin │ │ │ └── ReadTrashbinFolderRemoteOperationIT.kt │ │ │ └── users │ │ │ ├── AppTokenRemoteOperationIT.kt │ │ │ ├── CheckRemoteWipeRemoteOperationIT.kt │ │ │ ├── SetUserInfoRemoteOperationIT.java │ │ │ └── StatusIT.kt │ └── oldTests │ │ ├── DownloadFileTest.java │ │ ├── GetShareesTest.java │ │ ├── MoveFileTest.java │ │ ├── OwnCloudClientTest.java │ │ ├── ReadFileTest.java │ │ ├── ReadFolderTest.java │ │ ├── RenameFileTest.java │ │ ├── SimpleFactoryManagerTest.java │ │ ├── SingleSessionManagerTest.java │ │ ├── UpdatePrivateShareTest.java │ │ ├── UpdatePublicShareTest.java │ │ └── UploadFileTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ ├── com │ │ │ ├── nextcloud │ │ │ │ ├── android │ │ │ │ │ └── lib │ │ │ │ │ │ ├── core │ │ │ │ │ │ ├── Clock.kt │ │ │ │ │ │ └── ClockImpl.kt │ │ │ │ │ │ ├── resources │ │ │ │ │ │ ├── dashboard │ │ │ │ │ │ │ ├── DashBoardButtonType.kt │ │ │ │ │ │ │ ├── DashboardButton.kt │ │ │ │ │ │ │ ├── DashboardGetWidgetItemsRemoteOperation.kt │ │ │ │ │ │ │ ├── DashboardListWidgetsRemoteOperation.kt │ │ │ │ │ │ │ ├── DashboardWidget.kt │ │ │ │ │ │ │ ├── DashboardWidgetItem.kt │ │ │ │ │ │ │ └── DashboardWidgetList.kt │ │ │ │ │ │ ├── directediting │ │ │ │ │ │ │ ├── DirectEditingCreateFileRemoteOperation.java │ │ │ │ │ │ │ ├── DirectEditingObtainListOfTemplatesRemoteOperation.java │ │ │ │ │ │ │ ├── DirectEditingObtainRemoteOperation.java │ │ │ │ │ │ │ └── DirectEditingOpenFileRemoteOperation.java │ │ │ │ │ │ ├── files │ │ │ │ │ │ │ ├── FileDownloadLimit.kt │ │ │ │ │ │ │ ├── GetFilesDownloadLimitRemoteOperation.kt │ │ │ │ │ │ │ ├── RemoveFilesDownloadLimitRemoteOperation.kt │ │ │ │ │ │ │ ├── SetFilesDownloadLimitRemoteOperation.kt │ │ │ │ │ │ │ └── ToggleFileLockRemoteOperation.kt │ │ │ │ │ │ ├── groupfolders │ │ │ │ │ │ │ ├── GetGroupfoldersRemoteOperation.kt │ │ │ │ │ │ │ └── Groupfolder.kt │ │ │ │ │ │ ├── profile │ │ │ │ │ │ │ ├── Action.kt │ │ │ │ │ │ │ ├── GetHoverCardRemoteOperation.kt │ │ │ │ │ │ │ └── HoverCard.kt │ │ │ │ │ │ ├── recommendations │ │ │ │ │ │ │ ├── GetRecommendationsRemoteOperation.kt │ │ │ │ │ │ │ ├── Recommendation.kt │ │ │ │ │ │ │ └── RecommendationResponse.kt │ │ │ │ │ │ ├── search │ │ │ │ │ │ │ ├── UnifiedSearchProvidersRemoteOperation.kt │ │ │ │ │ │ │ └── UnifiedSearchRemoteOperation.kt │ │ │ │ │ │ ├── tos │ │ │ │ │ │ │ ├── GetTermsRemoteOperation.kt │ │ │ │ │ │ │ ├── SignTermRemoteOperation.kt │ │ │ │ │ │ │ ├── Term.kt │ │ │ │ │ │ │ └── Terms.kt │ │ │ │ │ │ └── users │ │ │ │ │ │ │ └── GenerateAppPasswordRemoteOperation.java │ │ │ │ │ │ └── richWorkspace │ │ │ │ │ │ └── RichWorkspaceDirectEditingRemoteOperation.java │ │ │ │ ├── common │ │ │ │ │ ├── DNSCache.kt │ │ │ │ │ ├── JSONRequestBody.kt │ │ │ │ │ ├── NextcloudClient.kt │ │ │ │ │ ├── NextcloudUriDelegate.kt │ │ │ │ │ ├── NextcloudUriProvider.kt │ │ │ │ │ ├── OkHttpMethodBase.kt │ │ │ │ │ ├── PlainClient.kt │ │ │ │ │ ├── ResponseOrError.kt │ │ │ │ │ ├── SessionTimeOut.kt │ │ │ │ │ ├── User.kt │ │ │ │ │ └── UserIdEncoder.kt │ │ │ │ ├── extensions │ │ │ │ │ ├── ArrayListExtensions.kt │ │ │ │ │ ├── GsonExtensions.kt │ │ │ │ │ └── ParcelExtensions.kt │ │ │ │ └── operations │ │ │ │ │ ├── DeleteMethod.kt │ │ │ │ │ ├── GetMethod.kt │ │ │ │ │ ├── HeadMethod.kt │ │ │ │ │ ├── LockMethod.kt │ │ │ │ │ ├── PostMethod.kt │ │ │ │ │ ├── PutMethod.kt │ │ │ │ │ └── UnlockMethod.kt │ │ │ └── owncloud │ │ │ │ └── android │ │ │ │ └── lib │ │ │ │ ├── common │ │ │ │ ├── Creator.kt │ │ │ │ ├── DirectEditing.kt │ │ │ │ ├── Editor.kt │ │ │ │ ├── ExternalLink.kt │ │ │ │ ├── ExternalLinkType.java │ │ │ │ ├── OwnCloudAccount.java │ │ │ │ ├── OwnCloudAnonymousCredentials.java │ │ │ │ ├── OwnCloudBasicCredentials.java │ │ │ │ ├── OwnCloudClient.java │ │ │ │ ├── OwnCloudClientFactory.java │ │ │ │ ├── OwnCloudClientManager.java │ │ │ │ ├── OwnCloudClientManagerFactory.java │ │ │ │ ├── OwnCloudCredentials.java │ │ │ │ ├── OwnCloudCredentialsFactory.java │ │ │ │ ├── Quota.kt │ │ │ │ ├── SearchProvider.kt │ │ │ │ ├── SearchProviders.kt │ │ │ │ ├── SearchResult.kt │ │ │ │ ├── SearchResultEntry.kt │ │ │ │ ├── Template.kt │ │ │ │ ├── TemplateList.kt │ │ │ │ ├── UserInfo.kt │ │ │ │ ├── accounts │ │ │ │ │ ├── AccountTypeUtils.java │ │ │ │ │ ├── AccountUtils.java │ │ │ │ │ └── ExternalLinksOperation.java │ │ │ │ ├── network │ │ │ │ │ ├── AdvancedSslSocketFactory.java │ │ │ │ │ ├── AdvancedX509KeyManager.java │ │ │ │ │ ├── AdvancedX509TrustManager.java │ │ │ │ │ ├── CertificateCombinedException.java │ │ │ │ │ ├── ChunkFromFileChannelRequestEntity.java │ │ │ │ │ ├── FileRequestEntity.java │ │ │ │ │ ├── NetworkUtils.java │ │ │ │ │ ├── OnDatatransferProgressListener.java │ │ │ │ │ ├── ProgressiveDataTransfer.java │ │ │ │ │ ├── RedirectionPath.java │ │ │ │ │ ├── SelectClientCertificateHelperActivity.java │ │ │ │ │ ├── ServerNameIndicator.java │ │ │ │ │ ├── WebdavEntry.kt │ │ │ │ │ └── WebdavUtils.java │ │ │ │ ├── operations │ │ │ │ │ ├── OnRemoteOperationListener.java │ │ │ │ │ ├── OperationCancelledException.java │ │ │ │ │ ├── RemoteOperation.java │ │ │ │ │ ├── RemoteOperationResult.java │ │ │ │ │ └── XMLExceptionParser.java │ │ │ │ └── utils │ │ │ │ │ ├── HttpDeleteWithBody.java │ │ │ │ │ ├── Log_OC.java │ │ │ │ │ ├── WebDavFileUtils.java │ │ │ │ │ └── responseFormat │ │ │ │ │ ├── ResponseFormat.kt │ │ │ │ │ └── ResponseFormatDetector.kt │ │ │ │ ├── ocs │ │ │ │ ├── OCSMeta.java │ │ │ │ ├── OCSResponse.java │ │ │ │ ├── ServerResponse.java │ │ │ │ └── responses │ │ │ │ │ └── PrivateKey.java │ │ │ │ └── resources │ │ │ │ ├── OCSRemoteOperation.kt │ │ │ │ ├── activities │ │ │ │ ├── GetActivitiesRemoteOperation.java │ │ │ │ ├── model │ │ │ │ │ ├── Activity.kt │ │ │ │ │ ├── RichElement.kt │ │ │ │ │ ├── RichElementTypeAdapter.java │ │ │ │ │ └── RichObject.kt │ │ │ │ └── models │ │ │ │ │ ├── PreviewObject.kt │ │ │ │ │ └── PreviewObjectAdapter.java │ │ │ │ ├── assistant │ │ │ │ ├── v1 │ │ │ │ │ ├── CreateTaskRemoteOperationV1.kt │ │ │ │ │ ├── DeleteTaskRemoteOperationV1.kt │ │ │ │ │ ├── GetTaskListRemoteOperationV1.kt │ │ │ │ │ ├── GetTaskTypesRemoteOperationV1.kt │ │ │ │ │ └── model │ │ │ │ │ │ ├── TaskList.kt │ │ │ │ │ │ └── TaskTypes.kt │ │ │ │ └── v2 │ │ │ │ │ ├── CreateTaskRemoteOperationV2.kt │ │ │ │ │ ├── DeleteTaskRemoteOperationV2.kt │ │ │ │ │ ├── GetTaskListRemoteOperationV2.kt │ │ │ │ │ ├── GetTaskTypesRemoteOperationV2.kt │ │ │ │ │ └── model │ │ │ │ │ ├── TaskList.kt │ │ │ │ │ └── TaskTypes.kt │ │ │ │ ├── comments │ │ │ │ ├── CommentFileRemoteOperation.java │ │ │ │ └── MarkCommentsAsReadRemoteOperation.java │ │ │ │ ├── e2ee │ │ │ │ ├── CsrHelper.kt │ │ │ │ ├── GetMetadataRemoteOperation.java │ │ │ │ ├── LockFileRemoteOperation.java │ │ │ │ ├── MetadataResponse.kt │ │ │ │ ├── StoreMetadataRemoteOperation.java │ │ │ │ ├── StoreMetadataV2RemoteOperation.kt │ │ │ │ ├── ToggleEncryptionRemoteOperation.java │ │ │ │ ├── UnlockFileRemoteOperation.java │ │ │ │ ├── UnlockFileV1RemoteOperation.kt │ │ │ │ ├── UpdateMetadataRemoteOperation.java │ │ │ │ └── UpdateMetadataV2RemoteOperation.kt │ │ │ │ ├── files │ │ │ │ ├── CheckEtagRemoteOperation.java │ │ │ │ ├── Chunk.kt │ │ │ │ ├── ChunkedFileUploadRemoteOperation.java │ │ │ │ ├── CopyFileRemoteOperation.java │ │ │ │ ├── CreateFolderRemoteOperation.java │ │ │ │ ├── CreateLocalFileException.kt │ │ │ │ ├── DownloadFileRemoteOperation.java │ │ │ │ ├── ExistenceCheckRemoteOperation.java │ │ │ │ ├── FileUtils.java │ │ │ │ ├── LinkLivePhotoRemoteOperation.kt │ │ │ │ ├── MoveFileRemoteOperation.java │ │ │ │ ├── NcSearchMethod.java │ │ │ │ ├── ReadFileRemoteOperation.java │ │ │ │ ├── ReadFileVersionsRemoteOperation.java │ │ │ │ ├── ReadFolderRemoteOperation.java │ │ │ │ ├── RemoveFileRemoteOperation.java │ │ │ │ ├── RenameFileRemoteOperation.java │ │ │ │ ├── RestoreFileVersionRemoteOperation.java │ │ │ │ ├── SearchRemoteOperation.java │ │ │ │ ├── ToggleFavoriteRemoteOperation.java │ │ │ │ ├── UploadFileRemoteOperation.java │ │ │ │ └── model │ │ │ │ │ ├── FileLockType.kt │ │ │ │ │ ├── FileVersion.java │ │ │ │ │ ├── GeoLocation.kt │ │ │ │ │ ├── ImageDimension.kt │ │ │ │ │ ├── RemoteFile.kt │ │ │ │ │ └── ServerFileInterface.java │ │ │ │ ├── notifications │ │ │ │ ├── DeleteAllNotificationsRemoteOperation.java │ │ │ │ ├── DeleteNotificationRemoteOperation.java │ │ │ │ ├── GetNotificationRemoteOperation.java │ │ │ │ ├── GetNotificationsRemoteOperation.java │ │ │ │ ├── RegisterAccountDeviceForNotificationsOperation.java │ │ │ │ ├── RegisterAccountDeviceForProxyOperation.java │ │ │ │ ├── UnregisterAccountDeviceForNotificationsOperation.java │ │ │ │ ├── UnregisterAccountDeviceForProxyOperation.java │ │ │ │ └── models │ │ │ │ │ ├── Action.kt │ │ │ │ │ ├── Notification.java │ │ │ │ │ ├── PushResponse.kt │ │ │ │ │ └── RichObject.kt │ │ │ │ ├── shares │ │ │ │ ├── CreateShareRemoteOperation.java │ │ │ │ ├── GetShareRemoteOperation.java │ │ │ │ ├── GetShareesRemoteOperation.java │ │ │ │ ├── GetSharesForFileRemoteOperation.java │ │ │ │ ├── GetSharesRemoteOperation.java │ │ │ │ ├── OCShare.kt │ │ │ │ ├── RemoveShareRemoteOperation.java │ │ │ │ ├── SharePermissionsBuilder.java │ │ │ │ ├── ShareToRemoteOperationResultParser.java │ │ │ │ ├── ShareType.java │ │ │ │ ├── ShareUtils.java │ │ │ │ ├── ShareXMLParser.java │ │ │ │ ├── SharedWithMe.kt │ │ │ │ ├── ShareeUser.kt │ │ │ │ └── UpdateShareRemoteOperation.java │ │ │ │ ├── status │ │ │ │ ├── CapabilityBooleanType.kt │ │ │ │ ├── E2EVersion.kt │ │ │ │ ├── GetCapabilitiesRemoteOperation.java │ │ │ │ ├── GetStatusRemoteOperation.java │ │ │ │ ├── NextcloudVersion.kt │ │ │ │ ├── OCCapability.kt │ │ │ │ ├── OwnCloudVersion.java │ │ │ │ ├── Problem.kt │ │ │ │ └── SendClientDiagnosticRemoteOperation.kt │ │ │ │ ├── tags │ │ │ │ ├── CreateTagRemoteOperation.kt │ │ │ │ ├── GetTagsRemoteOperation.kt │ │ │ │ ├── PutTagRemoteOperation.kt │ │ │ │ └── Tag.kt │ │ │ │ ├── trashbin │ │ │ │ ├── EmptyTrashbinRemoteOperation.java │ │ │ │ ├── ReadTrashbinFolderRemoteOperation.java │ │ │ │ ├── RemoveTrashbinFileRemoteOperation.java │ │ │ │ ├── RestoreTrashbinFileRemoteOperation.java │ │ │ │ └── model │ │ │ │ │ └── TrashbinFile.java │ │ │ │ └── users │ │ │ │ ├── AppPassword.kt │ │ │ │ ├── CheckRemoteWipeRemoteOperation.java │ │ │ │ ├── ClearAt.kt │ │ │ │ ├── ClearStatusMessageRemoteOperation.java │ │ │ │ ├── ConvertAppTokenRemoteOperation.java │ │ │ │ ├── DeleteAppPasswordRemoteOperation.java │ │ │ │ ├── DeletePrivateKeyRemoteOperation.kt │ │ │ │ ├── DeletePublicKeyRemoteOperation.java │ │ │ │ ├── GetPredefinedStatusesRemoteOperation.java │ │ │ │ ├── GetPrivateKeyRemoteOperation.java │ │ │ │ ├── GetPublicKeyRemoteOperation.java │ │ │ │ ├── GetServerPublicKeyRemoteOperation.kt │ │ │ │ ├── GetStatusRemoteOperation.java │ │ │ │ ├── GetUserAvatarRemoteOperation.java │ │ │ │ ├── GetUserInfoRemoteOperation.java │ │ │ │ ├── PredefinedStatus.kt │ │ │ │ ├── RemoteWipeSuccessRemoteOperation.java │ │ │ │ ├── SendCSRRemoteOperation.java │ │ │ │ ├── SetPredefinedCustomStatusMessageRemoteOperation.java │ │ │ │ ├── SetStatusRemoteOperation.java │ │ │ │ ├── SetUserDefinedCustomStatusMessageRemoteOperation.java │ │ │ │ ├── SetUserInfoRemoteOperation.java │ │ │ │ ├── Status.kt │ │ │ │ ├── StatusType.kt │ │ │ │ └── StorePrivateKeyRemoteOperation.java │ │ └── org │ │ │ └── apache │ │ │ └── commons │ │ │ └── httpclient │ │ │ └── methods │ │ │ └── Utf8PostMethod.java │ └── res │ │ ├── values-ar │ │ └── strings.xml │ │ ├── values-b+en+001 │ │ └── strings.xml │ │ ├── values-ca │ │ └── strings.xml │ │ ├── values-cs-rCZ │ │ └── strings.xml │ │ ├── values-da │ │ └── strings.xml │ │ ├── values-de │ │ └── strings.xml │ │ ├── values-el │ │ └── strings.xml │ │ ├── values-es │ │ └── strings.xml │ │ ├── values-et-rEE │ │ └── strings.xml │ │ ├── values-eu │ │ └── strings.xml │ │ ├── values-fr │ │ └── strings.xml │ │ ├── values-ga │ │ └── strings.xml │ │ ├── values-gl │ │ └── strings.xml │ │ ├── values-hu-rHU │ │ └── strings.xml │ │ ├── values-pl │ │ └── strings.xml │ │ ├── values-pt-rBR │ │ └── strings.xml │ │ ├── values-ru │ │ └── strings.xml │ │ ├── values-sk-rSK │ │ └── strings.xml │ │ ├── values-sr │ │ └── strings.xml │ │ ├── values-sv │ │ └── strings.xml │ │ ├── values-tr │ │ └── strings.xml │ │ ├── values-uk │ │ └── strings.xml │ │ ├── values-uz │ │ └── strings.xml │ │ ├── values-zh-rHK │ │ └── strings.xml │ │ ├── values-zh-rTW │ │ └── strings.xml │ │ └── values │ │ ├── empty.xml │ │ └── strings.xml │ └── test │ ├── java │ └── com │ │ ├── nextcloud │ │ └── common │ │ │ ├── ClockStub.kt │ │ │ ├── DNSCacheTest.kt │ │ │ ├── NextcloudClientTest.kt │ │ │ └── OkHttpMethodBaseTest.kt │ │ └── owncloud │ │ └── android │ │ └── lib │ │ ├── common │ │ ├── network │ │ │ ├── AdvancedX509KeyManagerTests.kt │ │ │ └── WebdavEntryTest.kt │ │ └── operations │ │ │ └── RemoteOperationResultTest.kt │ │ └── resources │ │ ├── activities │ │ └── GetActivitiesRemoteOperationTest.java │ │ ├── files │ │ ├── ChunkedFileUploadRemoteOperationTest.kt │ │ ├── CreateLocalFileExceptionTest.kt │ │ └── FileUtilsTest.java │ │ └── status │ │ ├── CapabilityBooleanTypeTest.java │ │ ├── OCCapabilityTest.kt │ │ └── OwnCloudVersionTest.java │ └── resources │ └── mockito-extensions │ └── org.mockito.plugins.MockMaker ├── renovate.json5 ├── sample_client ├── build.gradle ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── lint.xml └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── owncloud │ │ └── android │ │ └── lib │ │ └── sampleclient │ │ └── ExampleInstrumentedTest.java │ └── main │ ├── AndroidManifest.xml │ ├── assets │ └── nc_logo.png │ ├── java │ └── com │ │ └── owncloud │ │ └── android │ │ └── lib │ │ └── sampleclient │ │ ├── FilesArrayAdapter.java │ │ └── MainActivity.java │ └── res │ ├── drawable-v26 │ ├── ic_launcher_background.xml │ └── ic_launcher_foreground.xml │ ├── layout │ ├── file_in_list.xml │ └── main.xml │ ├── mipmap-anydpi-v26 │ └── ic_launcher.xml │ ├── mipmap-hdpi │ └── ic_launcher.png │ ├── mipmap-mdpi │ └── ic_launcher.png │ ├── mipmap-xhdpi │ └── ic_launcher.png │ ├── mipmap-xxhdpi │ └── ic_launcher.png │ ├── mipmap-xxxhdpi │ └── ic_launcher.png │ ├── values-v11 │ └── styles.xml │ └── values │ ├── dimensions.xml │ ├── setup.xml │ ├── strings.xml │ └── styles.xml ├── scripts ├── analysis │ ├── analysis-wrapper.sh │ ├── detectSNAPSHOT.sh │ ├── findbugs-results.txt │ ├── getBranchBase.sh │ ├── getBranchName.sh │ ├── spotbugs-filter.xml │ ├── spotbugs-up.rb │ ├── spotbugsComparison.py │ └── spotbugsSummary.py ├── deleteOutdatedComments.sh ├── hooks │ ├── pre-commit │ └── pre-push ├── lib.sh ├── runOnDocker.sh ├── uploadReport.sh ├── wait_for_emulator.sh └── wait_for_server.sh └── settings.gradle /.codecov.yml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors 2 | # SPDX-License-Identifier: MIT 3 | codecov: 4 | branch: master 5 | ci: 6 | - drone.nextcloud.com 7 | 8 | coverage: 9 | precision: 2 10 | round: down 11 | range: "70...100" 12 | 13 | comment: 14 | layout: "header, diff, changes, uncovered, tree" 15 | behavior: default 16 | 17 | github_checks: 18 | annotations: false 19 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # .editorconfig 2 | 3 | # see http://EditorConfig.org 4 | 5 | # SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors 6 | # SPDX-License-Identifier: MIT 7 | 8 | # This is the file in the root of the project. 9 | # For sub folders you can have other files that override only some settings. 10 | # For these, this settings should be false. 11 | root=true 12 | 13 | [*] 14 | max_line_length=120 15 | # use spaces, not tabs. 16 | indent_style=space 17 | indent_size=4 18 | 19 | [*.yml] 20 | max_line_length=150 21 | 22 | charset=utf-8 23 | 24 | # Trimming is good for consistency 25 | trim_trailing_whitespace=true 26 | # I've seen cases where a missing new_line was ignored on *nix systems. 27 | # Never again with this setting! 28 | insert_final_newline=true 29 | 30 | [*.properties] 31 | # Exception for Java properties files should be encoded latin1 (aka iso8859-1) 32 | charset=latin1 33 | 34 | [*.{cmd,bat}] 35 | # batch files on Windows should stay with CRLF 36 | end_of_line=crlf 37 | 38 | [*.md] 39 | trim_trailing_whitespace=false 40 | 41 | [*.{kt,kts}] 42 | # IDE does not follow this Ktlint rule strictly, but the default ordering is pretty good anyway, so let's ditch it 43 | ktlint_standard_import-ordering = disabled 44 | ij_kotlin_allow_trailing_comma = false 45 | ij_kotlin_allow_trailing_comma_on_call_site = false 46 | -------------------------------------------------------------------------------- /.github/workflows/assemble.yml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2022-2024 Nextcloud GmbH and Nextcloud contributors 2 | # SPDX-FileCopyrightText: 2023 Andy Scherzinger 3 | # SPDX-FileCopyrightText: 2022 Tobias Kaminsky 4 | # SPDX-FileCopyrightText: 2022 Álvaro Brey 5 | # SPDX-License-Identifier: MIT 6 | 7 | name: Assemble 8 | 9 | on: 10 | pull_request: 11 | branches: [ master, stable-* ] 12 | push: 13 | branches: [ master, stable-* ] 14 | 15 | jobs: 16 | assemble: 17 | runs-on: ubuntu-latest 18 | steps: 19 | - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 20 | - name: Set up JDK 17 21 | uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1 22 | with: 23 | distribution: "temurin" 24 | java-version: 17 25 | - uses: gradle/actions/wrapper-validation@8379f6a1328ee0e06e2bb424dadb7b159856a326 # v4.4.0 26 | - name: Setup JVM options 27 | run: | 28 | mkdir -p "$HOME/.gradle" 29 | echo "org.gradle.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError" > "$HOME/.gradle/gradle.properties" 30 | - name: Setup Gradle 31 | uses: gradle/actions/setup-gradle@8379f6a1328ee0e06e2bb424dadb7b159856a326 # v4.4.0 32 | - name: Assemble 33 | run: ./gradlew assemble 34 | -------------------------------------------------------------------------------- /.github/workflows/autoApproveSync.yml: -------------------------------------------------------------------------------- 1 | # synced from @nextcloud/android-config 2 | 3 | # SPDX-FileCopyrightText: 2022-2024 Nextcloud GmbH and Nextcloud contributors 4 | # SPDX-FileCopyrightText: 2023 Álvaro Brey 5 | # SPDX-License-Identifier: GPL-3.0-or-later 6 | 7 | name: Auto approve sync 8 | on: 9 | pull_request_target: # zizmor: ignore[dangerous-triggers] 10 | branches: 11 | - master 12 | - main 13 | types: 14 | - opened 15 | - reopened 16 | - synchronize 17 | - labeled 18 | 19 | concurrency: 20 | group: sync-approve-${{ github.head_ref || github.run_id }} 21 | cancel-in-progress: true 22 | 23 | permissions: 24 | pull-requests: write 25 | 26 | jobs: 27 | auto-approve: 28 | name: Auto approve sync 29 | runs-on: ubuntu-latest 30 | if: ${{ contains(github.event.pull_request.labels.*.name, 'sync') && github.actor == 'nextcloud-android-bot' }} 31 | steps: 32 | - name: Disabled on forks 33 | if: ${{ github.event.pull_request.head.repo.full_name != github.repository }} 34 | run: | 35 | echo 'Can not approve PRs from forks' 36 | exit 1 37 | 38 | - uses: hmarr/auto-approve-action@f0939ea97e9205ef24d872e76833fa908a770363 # v4.0.0 39 | with: 40 | github-token: "${{ secrets.GITHUB_TOKEN }}" 41 | -------------------------------------------------------------------------------- /.github/workflows/check.yml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors 2 | # SPDX-FileCopyrightText: 2017 Tobias Kaminsky 3 | # SPDX-License-Identifier: GPL-3.0-or-later 4 | name: Check 5 | 6 | on: 7 | pull_request: 8 | branches: [ master, stable-* ] 9 | push: 10 | branches: [ master, stable-* ] 11 | 12 | jobs: 13 | check: 14 | runs-on: ubuntu-latest 15 | strategy: 16 | fail-fast: false 17 | matrix: 18 | task: [ detekt, spotlessKotlinCheck, lint ] 19 | steps: 20 | - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 21 | - name: Set up JDK 17 22 | uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1 23 | with: 24 | distribution: "temurin" 25 | java-version: 17 26 | - name: Setup JVM options 27 | run: | 28 | mkdir -p "$HOME/.gradle" 29 | echo "org.gradle.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError" > "$HOME/.gradle/gradle.properties" 30 | - name: Check ${{ matrix.task }} 31 | uses: gradle/gradle-build-action@ac2d340dc04d9e1113182899e983b5400c17cda1 # v3.5.0 32 | with: 33 | arguments: ${{ matrix.task }} 34 | - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 35 | if: ${{ always() }} 36 | with: 37 | name: ${{ matrix.task }}-report 38 | path: library/build/reports 39 | -------------------------------------------------------------------------------- /.github/workflows/detectNewJavaFiles.yml: -------------------------------------------------------------------------------- 1 | # synced from @nextcloud/android-config 2 | 3 | # SPDX-FileCopyrightText: 2022-2024 Nextcloud GmbH and Nextcloud contributors 4 | # SPDX-FileCopyrightText: 2023 Andy Scherzinger 5 | # SPDX-FileCopyrightText: 2022 Tobias Kaminsky 6 | # SPDX-FileCopyrightText: 2022 Álvaro Brey 7 | # SPDX-License-Identifier: GPL-3.0-or-later 8 | 9 | name: "Detect new java files" 10 | 11 | on: 12 | pull_request: 13 | branches: [ master, main, stable-* ] 14 | 15 | permissions: read-all 16 | 17 | concurrency: 18 | group: detect-new-java-files-${{ github.head_ref || github.run_id }} 19 | cancel-in-progress: true 20 | 21 | jobs: 22 | detectNewJavaFiles: 23 | runs-on: ubuntu-latest 24 | steps: 25 | - id: file_changes 26 | uses: trilom/file-changes-action@a6ca26c14274c33b15e6499323aac178af06ad4b # v1.2.4 27 | with: 28 | output: ',' 29 | - name: Detect new java files 30 | run: | 31 | if [ -z '${{ steps.file_changes.outputs.files_added }}' ]; then 32 | echo "No new files added" 33 | exit 0 34 | fi 35 | new_java=$(echo '${{ steps.file_changes.outputs.files_added }}' | tr ',' '\n' | grep '\.java$' | cat) 36 | if [ -n "$new_java" ]; then 37 | # shellcheck disable=SC2016 38 | printf 'New java files detected:\n```\n%s\n```\n' "$new_java" | tee "$GITHUB_STEP_SUMMARY" 39 | exit 1 40 | else 41 | echo "No new java files detected" 42 | exit 0 43 | fi 44 | -------------------------------------------------------------------------------- /.github/workflows/detectSnaphost.yml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors 2 | # SPDX-FileCopyrightText: 2017 Tobias Kaminsky 3 | # SPDX-License-Identifier: GPL-3.0-or-later 4 | name: "Detect snapshot" 5 | 6 | on: 7 | pull_request: 8 | branches: [ master, stable-* ] 9 | push: 10 | branches: [ master, stable-* ] 11 | 12 | # Declare default permissions as read only. 13 | permissions: read-all 14 | 15 | jobs: 16 | detekt: 17 | runs-on: ubuntu-latest 18 | 19 | steps: 20 | - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 21 | - name: Detect SNAPSHOT 22 | run: scripts/analysis/detectSNAPSHOT.sh 23 | -------------------------------------------------------------------------------- /.github/workflows/reuse.yml: -------------------------------------------------------------------------------- 1 | # This workflow is provided via the organization template repository 2 | # 3 | # https://github.com/nextcloud/.github 4 | # https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization 5 | 6 | # SPDX-FileCopyrightText: 2022 Free Software Foundation Europe e.V. 7 | # 8 | # SPDX-License-Identifier: CC0-1.0 9 | 10 | name: REUSE Compliance Check 11 | 12 | on: [pull_request] 13 | 14 | jobs: 15 | reuse-compliance-check: 16 | runs-on: ubuntu-latest 17 | steps: 18 | - name: Checkout 19 | uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 20 | with: 21 | persist-credentials: false 22 | 23 | - name: REUSE Compliance Check 24 | uses: fsfe/reuse-action@bb774aa972c2a89ff34781233d275075cbddf542 # v5.0.0 25 | -------------------------------------------------------------------------------- /.github/workflows/scorecard.yml: -------------------------------------------------------------------------------- 1 | # synced from @nextcloud/android-config 2 | 3 | # SPDX-FileCopyrightText: 2023-2024 Nextcloud GmbH and Nextcloud contributors 4 | # SPDX-FileCopyrightText: 2023 Andy Scherzinger 5 | # SPDX-License-Identifier: GPL-3.0-or-later 6 | 7 | name: Scorecard supply-chain security 8 | on: 9 | branch_protection_rule: 10 | schedule: 11 | - cron: '32 23 * * 4' 12 | push: 13 | branches: [ "main", "master" ] 14 | 15 | # Declare default permissions as read only. 16 | permissions: read-all 17 | 18 | concurrency: 19 | group: scorecard-supply-chain-security-${{ github.head_ref || github.run_id }} 20 | cancel-in-progress: true 21 | 22 | jobs: 23 | analysis: 24 | name: Scorecard analysis 25 | runs-on: ubuntu-latest 26 | permissions: 27 | # Needed to upload the results to code-scanning dashboard. 28 | security-events: write 29 | 30 | steps: 31 | - name: "Checkout code" 32 | uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 33 | with: 34 | persist-credentials: false 35 | 36 | - name: "Run analysis" 37 | uses: ossf/scorecard-action@05b42c624433fc40578a4040d5cf5e36ddca8cde # v2.4.2 38 | with: 39 | results_file: results.sarif 40 | results_format: sarif 41 | publish_results: false 42 | 43 | # Upload the results to GitHub's code scanning dashboard. 44 | - name: "Upload to code-scanning" 45 | uses: github/codeql-action/upload-sarif@fca7ace96b7d713c7035871441bd52efbe39e27e # v3.28.19 46 | with: 47 | sarif_file: results.sarif 48 | -------------------------------------------------------------------------------- /.github/workflows/stale.yml: -------------------------------------------------------------------------------- 1 | # synced from @nextcloud/android-config 2 | 3 | # SPDX-FileCopyrightText: 2023-2024 Nextcloud GmbH and Nextcloud contributors 4 | # SPDX-FileCopyrightText: 2023 Tobias Kaminsky 5 | # SPDX-FileCopyrightText: 2022 Álvaro Brey 6 | # SPDX-License-Identifier: GPL-3.0-or-later 7 | 8 | name: 'Close stale issues' 9 | on: 10 | schedule: 11 | - cron: '0 0 * * *' 12 | 13 | # Declare default permissions as read only. 14 | permissions: read-all 15 | 16 | jobs: 17 | stale: 18 | runs-on: ubuntu-latest 19 | permissions: 20 | issues: write 21 | pull-requests: write 22 | steps: 23 | - uses: actions/stale@5bef64f19d7facfb25b37b414482c7164d639639 # v9.1.0 24 | with: 25 | days-before-stale: 28 26 | days-before-close: 14 27 | days-before-pr-close: -1 28 | only-labels: 'bug,needs info' 29 | exempt-issue-labels: 'no-stale' 30 | stale-issue-message: >- 31 | This bug report did not receive an update in the last 4 weeks. 32 | Please take a look again and update the issue with new details, 33 | otherwise the issue will be automatically closed in 2 weeks. Thank you! 34 | exempt-all-pr-milestones: true 35 | labels-to-remove-when-unstale: 'needs info' 36 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors 2 | # SPDX-License-Identifier: MIT 3 | # built application files 4 | *.apk 5 | *.ap_ 6 | 7 | # files for the dex VM 8 | *.dex 9 | 10 | # Java class files 11 | *.class 12 | 13 | # generated files 14 | bin/ 15 | build/ 16 | gen/ 17 | target/ 18 | *.iml 19 | 20 | # Local configuration files (sdk path, etc) 21 | .idea/ 22 | .gradle/ 23 | local.properties 24 | sample_client/local.properties 25 | tests/local.properties 26 | tests/test_cases/local.properties 27 | 28 | # Mac .DS_Store files 29 | .DS_Store 30 | 31 | # Proguard README 32 | proguard-project.txt 33 | sample_client/proguard-project.txt 34 | tests/proguard-project.txt 35 | tests/test_cases/proguard-project.txt 36 | 37 | # Test files 38 | /test 39 | /gradle/verification-keyring.gpg 40 | -------------------------------------------------------------------------------- /.idea/codeStyles/Project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 11 | 12 | 14 | 15 | 16 | 18 | 19 | 20 | 31 | 32 | -------------------------------------------------------------------------------- /.idea/codeStyles/codeStyleConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/copyright/Nextcloud_Android_Library.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.idea/icon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/inspectionProfiles/ktlint.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/inspectionProfiles/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | -------------------------------------------------------------------------------- /.pullapprove.yml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors 2 | # SPDX-License-Identifier: MIT 3 | version: 2 4 | 5 | # General settings to apply 6 | always_pending: 7 | title_regex: '(WIP|wip)' 8 | labels: 9 | - 1. to develop 10 | - 2. developing 11 | # custom message that will be used for the GitHub status 12 | explanation: 'This PR is a work in progress...' 13 | 14 | # Group settings to apply to all groups by default, optionally being overridden later 15 | group_defaults: 16 | author_approval: 17 | ignored: true 18 | approve_by_comment: 19 | enabled: true 20 | approve_regex: '^(Approved|:shipit:|:\+1:|LGTM|Merge)' 21 | reject_regex: '^(Rejected|:-1:)' 22 | reset_on_push: 23 | enabled: false 24 | reset_on_reopened: 25 | enabled: true 26 | conditions: 27 | labels: 28 | exclude: 29 | - dependencies 30 | 31 | groups: 32 | code-review: 33 | required: 1 34 | reject_value: -99 35 | users: 36 | - AndyScherzinger 37 | - tobiasKaminsky 38 | - mario 39 | - przybylski 40 | -------------------------------------------------------------------------------- /.tx/config.license: -------------------------------------------------------------------------------- 1 | SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors 2 | SPDX-License-Identifier: MIT 3 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | 7 | ### License 8 | 9 | Nextcloud Android Library is available under MIT license 10 | 11 | Copyright (C) 2016 Nextcloud Project 12 | Copyright (C) 2014-2016 ownCloud Inc. 13 | Copyright (C) 2012 Bartosz Przybylski 14 | 15 | Permission is hereby granted, free of charge, to any person obtaining a copy 16 | of this software and associated documentation files (the "Software"), to deal 17 | in the Software without restriction, including without limitation the rights 18 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 19 | copies of the Software, and to permit persons to whom the Software is 20 | furnished to do so, subject to the following conditions: 21 | 22 | The above copyright notice and this permission notice shall be included in 23 | all copies or substantial portions of the Software. 24 | 25 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 26 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 27 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 28 | AUTHORS OR COPYRIGHT HOLDERSBE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 29 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 30 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 31 | SOFTWARE. 32 | -------------------------------------------------------------------------------- /LICENSES/MIT.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | -------------------------------------------------------------------------------- /REUSE.toml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors 2 | # SPDX-License-Identifier: MIT 3 | version = 1 4 | SPDX-PackageName = "android-library" 5 | SPDX-PackageSupplier = "Nextcloud Android team " 6 | SPDX-PackageDownloadLocation = "https://github.com/nextcloud/android-library" 7 | 8 | [[annotations]] 9 | path = ["gradle/wrapper/gradle-wrapper.jar", "sample_client/gradle/wrapper/gradle-wrapper.jar"] 10 | precedence = "aggregate" 11 | SPDX-FileCopyrightText = "2015-2021 the original authors" 12 | SPDX-License-Identifier = "Apache-2.0" 13 | 14 | [[annotations]] 15 | path = ["gradle/verification-keyring.keys", "gradle/verification-metadata.xml"] 16 | precedence = "aggregate" 17 | SPDX-FileCopyrightText = "none" 18 | SPDX-License-Identifier = "MIT" 19 | 20 | [[annotations]] 21 | path = ["renovate.json5", "**/.gitignore", ".library/src/androidTest/assets/**", ".idea/**", "library/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker", "sample_client/src/main/res/mipmap-**/**.png", "scripts/analysis/findbugs-results.txt", "sample_client/src/main/assets/nc_logo.png", "library/src/androidTest/assets/**"] 22 | precedence = "aggregate" 23 | SPDX-FileCopyrightText = "2024 Nextcloud GmbH and Nextcloud contributors" 24 | SPDX-License-Identifier = "MIT" 25 | 26 | [[annotations]] 27 | path = ["library/src/main/res/values-**/strings.xml"] 28 | precedence = "aggregate" 29 | SPDX-FileCopyrightText = "2024 Nextcloud GmbH and Nextcloud translators" 30 | SPDX-License-Identifier = "MIT" 31 | -------------------------------------------------------------------------------- /THIRD_PARTY.txt: -------------------------------------------------------------------------------- 1 | ############################################################################# 2 | Nextcloud Android Library 3 | 4 | SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors 5 | SPDX-FileCopyrightText: 2014 ownCloud Inc. 6 | SPDX-FileCopyrightText: 2012 Bartek Przybylski 7 | 8 | SPDX-License-Identifier: MIT 9 | ############################################################################# 10 | 11 | 12 | ########### 13 | # LICENSE # 14 | ########### 15 | 16 | This library is free software released under the MIT License. 17 | A full copy of the license can be found in the LICENSE.md file 18 | in this directory. 19 | 20 | 21 | ######################## 22 | # THIRD PARTY LICENSES # 23 | ######################## 24 | 25 | This library uses some third party software that must be included as a 26 | dependency in projects using the library. All the third party software 27 | included is redistributed under the terms and conditions of their 28 | original licenses. These licenses are compatible with the MIT license 29 | that govern this software, for the purposes they are being used. 30 | 31 | The third party software included and used by this project is: 32 | 33 | * Apache JackRabbit, version 2.12.6 34 | Copyright (C) 2004-2016 The Apache Software Foundation. 35 | Licensed under Apache License, Version 2.0. 36 | See http://jackrabbit.apache.org/ 37 | 38 | * gson, version 2.8.0 39 | Copyright (C) 2008 Google Inc. 40 | Licensed under Apache License, Version 2.0. 41 | See https://github.com/google/gson 42 | 43 | * Parceler, version 1.1.6 44 | Copyright (C) 2011-2017 John Ericksen 45 | Licensed under Apache License, Version 2.0. 46 | See http://parceler.org/ 47 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Common Library 3 | * 4 | * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2023 Unpublished 6 | * SPDX-FileCopyrightText: 2022 Tobias Kaminsky 7 | * SPDX-FileCopyrightText: 2022 Álvaro Brey Vilas 8 | * SPDX-FileCopyrightText: 2014-2016 ownCloud Inc. 9 | * SPDX-FileCopyrightText: 2014 Marcello Steiner 10 | * SPDX-License-Identifier: MIT 11 | */ 12 | 13 | buildscript { 14 | ext { 15 | kotlin_version = '2.1.21' 16 | jacoco_version = '0.8.13' 17 | } 18 | } 19 | 20 | subprojects { 21 | buildscript { 22 | repositories { 23 | gradlePluginPortal() 24 | google() 25 | mavenCentral() 26 | } 27 | } 28 | repositories { 29 | google() 30 | mavenCentral() 31 | maven { 32 | url "https://jitpack.io" 33 | content { 34 | includeGroup "com.github.bitfireAT" 35 | } 36 | } 37 | } 38 | } 39 | 40 | task clean(type: Delete) { 41 | delete rootProject.buildDir 42 | } 43 | 44 | task installGitHooks(type: Copy, group: "development") { 45 | def sourceFolder = "${rootProject.projectDir}/scripts/hooks" 46 | def destFolder = "${rootProject.projectDir}/.git/hooks" 47 | 48 | description = "Install git hooks" 49 | 50 | from(sourceFolder) { 51 | include '*' 52 | } 53 | into destFolder 54 | 55 | eachFile { file -> 56 | println "${sourceFolder}/${file.relativeSourcePath} -> ${destFolder}/${file.path}" 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2018-2024 Nextcloud GmbH and Nextcloud contributors 2 | # SPDX-FileCopyrightText: 2018-2023 Tobias Kaminsky 3 | # SPDX-FileCopyrightText: 2023 Andy Scherzinger 4 | # SPDX-FileCopyrightText: 2023 Alper Ozturk 5 | # SPDX-License-Identifier: MIT 6 | 7 | # can be overriden by ~/.gradle/gradle.properties 8 | NC_TEST_SERVER_BASEURL=https://server 9 | NC_TEST_SERVER_USERNAME=test 10 | NC_TEST_SERVER_PASSWORD=test 11 | NC_TEST_SERVER_USERNAME2=admin 12 | NC_TEST_SERVER_PASSWORD2=admin 13 | android.useAndroidX=true 14 | android.defaults.buildfeatures.buildconfig=true 15 | android.nonTransitiveRClass=false 16 | android.nonFinalResIds=false 17 | 18 | # JVM arguments to optimize heap usage, enable heap dump on out-of-memory errors, and set the file encoding 19 | org.gradle.jvmargs=-Xmx4g -XX:MaxMetaspaceSize=1g -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 20 | org.gradle.dependency.verification.console=verbose 21 | kotlin.daemon.jvmargs=-Xmx4096m 22 | org.gradle.caching=true 23 | org.gradle.parallel=true 24 | org.gradle.configureondemand=true 25 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nextcloud/android-library/13fb6e486d82696073cc1a56a8ff8371bba690de/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.2-all.zip 4 | networkTimeout=10000 5 | validateDistributionUrl=true 6 | zipStoreBase=GRADLE_USER_HOME 7 | zipStorePath=wrapper/dists 8 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties.license: -------------------------------------------------------------------------------- 1 | SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors 2 | SPDX-License-Identifier: MIT 3 | -------------------------------------------------------------------------------- /gradlew.bat.license: -------------------------------------------------------------------------------- 1 | SPDX-FileCopyrightText: 2015 the original author or authors. 2 | SPDX-License-Identifier: Apache-2.0 3 | -------------------------------------------------------------------------------- /gradlew.license: -------------------------------------------------------------------------------- 1 | SPDX-FileCopyrightText: 2015-2021 the original author or authors. 2 | SPDX-License-Identifier: Apache-2.0 3 | -------------------------------------------------------------------------------- /jitpack.yml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2021-2024 Nextcloud GmbH and Nextcloud contributors 2 | # SPDX-FileCopyrightText: 2021-2023 Tobias Kaminsky 3 | # SPDX-License-Identifier: MIT 4 | jdk: 5 | - openjdk17 6 | install: 7 | - ./gradlew :library:publishReleasePublicationToMavenLocal 8 | -------------------------------------------------------------------------------- /library/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | 3 | # Test files 4 | /test 5 | -------------------------------------------------------------------------------- /library/lint.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /library/src/androidTest/assets/gps.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nextcloud/android-library/13fb6e486d82696073cc1a56a8ff8371bba690de/library/src/androidTest/assets/gps.jpg -------------------------------------------------------------------------------- /library/src/androidTest/assets/imageFile.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nextcloud/android-library/13fb6e486d82696073cc1a56a8ff8371bba690de/library/src/androidTest/assets/imageFile.png -------------------------------------------------------------------------------- /library/src/androidTest/assets/textFile.txt: -------------------------------------------------------------------------------- 1 | This is a simple text file. 2 | 3 | To make some tests. 4 | -------------------------------------------------------------------------------- /library/src/androidTest/assets/videoFile.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nextcloud/android-library/13fb6e486d82696073cc1a56a8ff8371bba690de/library/src/androidTest/assets/videoFile.mp4 -------------------------------------------------------------------------------- /library/src/androidTest/java/com/nextcloud/android/lib/resources/dashboard/DashboardListWidgetsRemoteOperationIT.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2022-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2022 Tobias Kaminsky 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | package com.nextcloud.android.lib.resources.dashboard 9 | 10 | import com.owncloud.android.AbstractIT 11 | import com.owncloud.android.lib.resources.status.NextcloudVersion 12 | import org.junit.Assert.assertEquals 13 | import org.junit.Assert.assertTrue 14 | import org.junit.Test 15 | 16 | class DashboardListWidgetsRemoteOperationIT : AbstractIT() { 17 | @Test 18 | fun list() { 19 | // only on NC25+ 20 | testOnlyOnServer(NextcloudVersion.nextcloud_25) 21 | 22 | val result = DashboardListWidgetsRemoteOperation().execute(nextcloudClient) 23 | assertTrue(result.isSuccess) 24 | 25 | assertTrue(result.resultData.isNotEmpty()) 26 | 27 | assertTrue(result.resultData["recommendations"]?.buttons?.getOrNull(0) == null) 28 | 29 | assertEquals(1, result.resultData["activity"]?.buttons?.size) 30 | assertTrue( 31 | result.resultData["activity"] 32 | ?.buttons 33 | ?.getOrNull(0) 34 | ?.type == DashBoardButtonType.MORE 35 | ) 36 | assertTrue(result.resultData["activity"]?.roundIcons == false) 37 | 38 | assertTrue(result.resultData["user_status"]?.roundIcons == true) 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /library/src/androidTest/java/com/nextcloud/android/lib/resources/directediting/DirectEditingObtainListOfTemplatesRemoteOperationIT.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2019 Tobias Kaminsky 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | package com.nextcloud.android.lib.resources.directediting; 9 | 10 | import com.owncloud.android.AbstractIT; 11 | import com.owncloud.android.lib.common.TemplateList; 12 | import com.owncloud.android.lib.common.operations.RemoteOperationResult; 13 | 14 | import org.junit.Test; 15 | 16 | import java.util.Objects; 17 | 18 | import static org.junit.Assert.assertEquals; 19 | import static org.junit.Assert.assertTrue; 20 | 21 | public class DirectEditingObtainListOfTemplatesRemoteOperationIT extends AbstractIT { 22 | 23 | @Test 24 | public void testGetAll() { 25 | RemoteOperationResult result = new DirectEditingObtainListOfTemplatesRemoteOperation("text", 26 | "textdocument") 27 | .execute(nextcloudClient); 28 | assertTrue(result.isSuccess()); 29 | 30 | TemplateList templateList = (TemplateList) result.getResultData(); 31 | 32 | assertEquals("Empty file", Objects.requireNonNull(templateList.getTemplates().get("empty")).getTitle()); 33 | assertEquals("md", Objects.requireNonNull(templateList.getTemplates().get("empty")).getExtension()); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /library/src/androidTest/java/com/nextcloud/android/lib/resources/directediting/DirectEditingObtainRemoteOperationIT.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2022-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2022 Tobias Kaminsky 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | package com.nextcloud.android.lib.resources.directediting 9 | 10 | import com.owncloud.android.AbstractIT 11 | import junit.framework.Assert.assertEquals 12 | import junit.framework.Assert.assertFalse 13 | import junit.framework.Assert.assertNotNull 14 | import junit.framework.Assert.assertTrue 15 | import org.junit.Test 16 | 17 | class DirectEditingObtainRemoteOperationIT : AbstractIT() { 18 | @Test 19 | fun testGetAll() { 20 | val result = DirectEditingObtainRemoteOperation().run(nextcloudClient) 21 | assertTrue(result.isSuccess) 22 | 23 | val (editors, creators) = result.resultData 24 | assertTrue(editors.containsKey("text")) 25 | 26 | val textEditor = editors["text"] 27 | assertNotNull(textEditor) 28 | assertEquals("Nextcloud Text", textEditor!!.name) 29 | assertTrue(textEditor.mimetypes.contains("text/markdown")) 30 | assertTrue(textEditor.mimetypes.contains("text/plain")) 31 | assertEquals(0, textEditor.optionalMimetypes.size.toLong()) 32 | 33 | val creator = creators["textdocument"] 34 | assertNotNull(creator) 35 | assertFalse(creator!!.templates) 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /library/src/androidTest/java/com/nextcloud/android/lib/resources/groupfolders/GetGroupfoldersRemoteOperationIT.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2023-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2023 Tobias Kaminsky 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | package com.nextcloud.android.lib.resources.groupfolders 9 | 10 | import com.owncloud.android.AbstractIT 11 | import com.owncloud.android.lib.resources.status.GetCapabilitiesRemoteOperation 12 | import com.owncloud.android.lib.resources.status.OCCapability 13 | import org.junit.Assert.assertEquals 14 | import org.junit.Assume.assumeTrue 15 | import org.junit.Test 16 | 17 | class GetGroupfoldersRemoteOperationIT : AbstractIT() { 18 | @Test 19 | fun getGroupfolders() { 20 | val capability = GetCapabilitiesRemoteOperation().execute(client).singleData as OCCapability 21 | 22 | assumeTrue(capability.groupfolders.isTrue) 23 | 24 | val map = GetGroupfoldersRemoteOperation().execute(nextcloudClient).resultData 25 | assertEquals(1, map.size) 26 | assertEquals("groupfolder", map["1"]?.mountPoint) 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /library/src/androidTest/java/com/nextcloud/android/lib/resources/profile/GetHoverCardRemoteOperationIT.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2021-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2021 Tobias Kaminsky 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | package com.nextcloud.android.lib.resources.profile 9 | 10 | import com.owncloud.android.AbstractIT 11 | import com.owncloud.android.lib.resources.status.NextcloudVersion 12 | import org.junit.Assert.assertEquals 13 | import org.junit.Assert.assertTrue 14 | import org.junit.Before 15 | import org.junit.Test 16 | 17 | class GetHoverCardRemoteOperationIT : AbstractIT() { 18 | @Before 19 | fun before() { 20 | testOnlyOnServer(NextcloudVersion.nextcloud_23) 21 | } 22 | 23 | @Test 24 | fun testHoverCard() { 25 | val result = 26 | GetHoverCardRemoteOperation(nextcloudClient.userId) 27 | .execute(nextcloudClient) 28 | assertTrue(result.logMessage, result.isSuccess) 29 | val hoverCard = result.resultData 30 | assertEquals(nextcloudClient.userId, hoverCard?.userId) 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /library/src/androidTest/java/com/nextcloud/android/lib/resources/recommendations/GetRecommendationsRemoteOperationIT.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2024 Tobias Kaminsky 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | package com.nextcloud.android.lib.resources.recommendations 9 | 10 | import com.owncloud.android.AbstractIT 11 | import com.owncloud.android.lib.resources.files.CreateFolderRemoteOperation 12 | import com.owncloud.android.lib.resources.status.NextcloudVersion 13 | import org.junit.Assert.assertTrue 14 | import org.junit.Test 15 | 16 | class GetRecommendationsRemoteOperationIT : AbstractIT() { 17 | @Test 18 | fun getRecommendations() { 19 | testOnlyOnServer(NextcloudVersion.nextcloud_31) 20 | assertTrue(CreateFolderRemoteOperation("/test/", true).execute(client).isSuccess) 21 | 22 | val result = GetRecommendationsRemoteOperation().execute(nextcloudClient).resultData 23 | 24 | assertTrue(result.enabled) 25 | assertTrue(result.recommendations.isNotEmpty()) 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /library/src/androidTest/java/com/nextcloud/android/lib/resources/search/SearchProvidersRemoteOperationIT.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2022-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2022 Tobias Kaminsky 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | package com.nextcloud.android.lib.resources.search 9 | 10 | import com.owncloud.android.AbstractIT 11 | import com.owncloud.android.lib.resources.status.GetCapabilitiesRemoteOperation 12 | import com.owncloud.android.lib.resources.status.OCCapability 13 | import com.owncloud.android.lib.resources.status.OwnCloudVersion 14 | import org.junit.Assert.assertFalse 15 | import org.junit.Assert.assertNotNull 16 | import org.junit.Assert.assertNull 17 | import org.junit.Assert.assertTrue 18 | import org.junit.Assume.assumeTrue 19 | import org.junit.Test 20 | 21 | class SearchProvidersRemoteOperationIT : AbstractIT() { 22 | @Test 23 | fun getSearchProviders() { 24 | // only on NC20+ 25 | testOnlyOnServer(OwnCloudVersion.nextcloud_20) 26 | 27 | val result = nextcloudClient.execute(UnifiedSearchProvidersRemoteOperation()) 28 | assertTrue(result.isSuccess) 29 | 30 | val providers = result.resultData 31 | 32 | assertTrue(providers.eTag.isNotBlank()) 33 | assertTrue(providers.providers.isNotEmpty()) 34 | assertNotNull(providers.providers.find { it.name == "Files" }) 35 | assertNull(providers.providers.find { it.name == "RandomSearchProvider" }) 36 | } 37 | 38 | @Test 39 | fun getSearchProvidersOnOldServer() { 40 | // only on < NC20 41 | val ocCapability = 42 | GetCapabilitiesRemoteOperation() 43 | .execute(nextcloudClient) 44 | .singleData as OCCapability 45 | assumeTrue( 46 | ocCapability.version.isOlderThan(OwnCloudVersion.nextcloud_20) 47 | ) 48 | 49 | val result = nextcloudClient.execute(UnifiedSearchProvidersRemoteOperation()) 50 | assertFalse(result.isSuccess) 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /library/src/androidTest/java/com/nextcloud/android/lib/resources/tos/TermsOfServicesIT.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2024 Tobias Kaminsky 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | 9 | package com.nextcloud.android.lib.resources.tos 10 | 11 | import com.owncloud.android.AbstractIT 12 | import org.junit.Assert.assertFalse 13 | import org.junit.Assert.assertTrue 14 | 15 | class TermsOfServicesIT : AbstractIT() { 16 | // @Test disabled for now as no good way to test on CI 17 | fun getAndSignTerms() { 18 | // user 3 with ToS 19 | var result = GetTermsRemoteOperation().execute(nextcloudClient) 20 | assertTrue(result.isSuccess) 21 | 22 | var terms = result.resultData 23 | assertTrue(terms.terms.isNotEmpty()) 24 | assertFalse(terms.hasSigned) 25 | 26 | val id = terms.terms[0].id 27 | 28 | // sign 29 | assertTrue(SignTermRemoteOperation(id).execute(nextcloudClient).isSuccess) 30 | 31 | // signed terms 32 | result = GetTermsRemoteOperation().execute(nextcloudClient) 33 | assertTrue(result.isSuccess) 34 | 35 | terms = result.resultData 36 | assertTrue(terms.terms.isNotEmpty()) 37 | assertTrue(terms.hasSigned) 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /library/src/androidTest/java/com/nextcloud/common/NextcloudUriDelegateIT.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2022-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2022 Álvaro Brey 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | package com.nextcloud.common 9 | 10 | import android.net.Uri 11 | import org.junit.Assert.assertEquals 12 | import org.junit.Before 13 | import org.junit.Test 14 | 15 | class NextcloudUriDelegateIT { 16 | lateinit var sut: NextcloudUriDelegate 17 | 18 | @Before 19 | fun setUp() { 20 | sut = NextcloudUriDelegate(Uri.parse(BASEURL), USERID) 21 | } 22 | 23 | @Test 24 | fun testFilesDavUriLeadingSlashInPath() { 25 | val expected = "$EXPECTED_FILES_DAV/path/to/file.txt" 26 | val actual = sut.getFilesDavUri("/path/to/file.txt") 27 | assertEquals("Wrong URL", expected, actual) 28 | } 29 | 30 | @Test 31 | fun testFilesDavUriLoLeadingSlashInPath() { 32 | val expected = "$EXPECTED_FILES_DAV/path/to/file.txt" 33 | val actual = sut.getFilesDavUri("path/to/file.txt") 34 | assertEquals("Wrong URL", expected, actual) 35 | } 36 | 37 | @Test 38 | fun testFilesDavUriEmptyPath() { 39 | val expected = "$EXPECTED_FILES_DAV/" 40 | val actual = sut.getFilesDavUri("") 41 | assertEquals("Wrong URL", expected, actual) 42 | } 43 | 44 | @Test 45 | fun testFilesDavUriRootPath() { 46 | val expected = "$EXPECTED_FILES_DAV/" 47 | val actual = sut.getFilesDavUri("/") 48 | assertEquals("Wrong URL", expected, actual) 49 | } 50 | 51 | companion object { 52 | private const val USERID = "user" 53 | private const val BASEURL = "http://test.localhost" 54 | private const val EXPECTED_FILES_DAV = "$BASEURL/remote.php/dav/files/$USERID" 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /library/src/androidTest/java/com/nextcloud/extensions/ElementCreator.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2023-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2023 Alper Ozturk 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | 9 | package com.nextcloud.extensions 10 | 11 | import org.w3c.dom.Element 12 | import javax.xml.parsers.DocumentBuilderFactory 13 | 14 | fun createElement( 15 | xml: String, 16 | value: String 17 | ): Element { 18 | val builder = 19 | DocumentBuilderFactory.newInstance().run { 20 | newDocumentBuilder() 21 | } 22 | val document = builder.newDocument() 23 | val element = 24 | document.createElement(xml).apply { 25 | textContent = value 26 | } 27 | document.appendChild(element) 28 | return element 29 | } 30 | -------------------------------------------------------------------------------- /library/src/androidTest/java/com/nextcloud/lib/resources/users/GetActivitiesRemoteOperationIT.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2019 Tobias Kaminsky 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | package com.nextcloud.lib.resources.users 9 | 10 | import com.owncloud.android.AbstractIT 11 | import com.owncloud.android.lib.resources.activities.GetActivitiesRemoteOperation 12 | import com.owncloud.android.lib.resources.files.CreateFolderRemoteOperation 13 | import org.junit.Assert.assertTrue 14 | import org.junit.Test 15 | 16 | class GetActivitiesRemoteOperationIT : AbstractIT() { 17 | @Test 18 | fun getActivities() { 19 | // set-up, create a folder so there is an activity 20 | assertTrue(CreateFolderRemoteOperation("/test/123/1", true).execute(client).isSuccess) 21 | 22 | val result = nextcloudClient.execute(GetActivitiesRemoteOperation()) 23 | assertTrue(result.isSuccess) 24 | 25 | val activities = result.data[0] as ArrayList<*> 26 | val lastGiven = result.data[1] as Long 27 | 28 | assertTrue(activities.isNotEmpty()) 29 | assertTrue(lastGiven > 0) 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /library/src/androidTest/java/com/nextcloud/test/RandomStringGenerator.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2022-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2022 Álvaro Brey 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | package com.nextcloud.test 9 | 10 | object RandomStringGenerator { 11 | private const val DEFAULT_LENGTH = 8 12 | private val ALLOWED_CHARACTERS = ('A'..'Z') + ('a'..'z') + ('0'..'9') 13 | 14 | @JvmOverloads 15 | @JvmStatic 16 | fun make(length: Int = DEFAULT_LENGTH): String = 17 | (1..length) 18 | .map { ALLOWED_CHARACTERS.random() } 19 | .joinToString("") 20 | } 21 | -------------------------------------------------------------------------------- /library/src/androidTest/java/com/owncloud/android/OwnCloudClientManagerFactoryTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2019 Tobias Kaminsky 6 | * SPDX-FileCopyrightText: 2014 David A. Velasco 7 | * SPDX-License-Identifier: MIT 8 | */ 9 | package com.owncloud.android; 10 | 11 | import com.owncloud.android.lib.common.OwnCloudClientManager; 12 | import com.owncloud.android.lib.common.OwnCloudClientManagerFactory; 13 | 14 | import junit.framework.TestCase; 15 | 16 | /** 17 | * Unit test for OwnCloudClientManagerFactory 18 | * 19 | * @author David A. Velasco 20 | */ 21 | public class OwnCloudClientManagerFactoryTest extends TestCase { 22 | 23 | public void testGetDefaultSingleton() { 24 | OwnCloudClientManager mgr = OwnCloudClientManagerFactory.getDefaultSingleton(); 25 | assertNotNull("Returned NULL default singleton", mgr); 26 | 27 | OwnCloudClientManager mgr2 = OwnCloudClientManagerFactory.getDefaultSingleton(); 28 | assertSame("Not singleton", mgr, mgr2); 29 | 30 | mgr = OwnCloudClientManagerFactory.getDefaultSingleton(); 31 | assertNotNull("Returned NULL default singleton", mgr); 32 | 33 | mgr2 = OwnCloudClientManagerFactory.getDefaultSingleton(); 34 | assertSame("Not singleton", mgr, mgr2); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /library/src/androidTest/java/com/owncloud/android/PlainClientIT.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2020-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2020-2023 Tobias Kaminsky 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | package com.owncloud.android 9 | 10 | import com.nextcloud.common.PlainClient 11 | import com.nextcloud.operations.GetMethod 12 | import org.junit.Assert.assertEquals 13 | import org.junit.Assert.assertNotEquals 14 | import org.junit.Test 15 | import java.net.HttpURLConnection 16 | 17 | class PlainClientIT : AbstractIT() { 18 | @Test 19 | fun test204Success() { 20 | val sut = PlainClient(context) 21 | val getMethod = GetMethod("$url/index.php/204", false) 22 | 23 | val status = getMethod.execute(sut) 24 | 25 | assertEquals(HttpURLConnection.HTTP_NO_CONTENT, status) 26 | } 27 | 28 | @Test 29 | fun test204Error() { 30 | val sut = PlainClient(context) 31 | val getMethod = GetMethod("$url/index.php", false) 32 | 33 | val status = getMethod.execute(sut) 34 | 35 | assertNotEquals(HttpURLConnection.HTTP_NO_CONTENT, status) 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /library/src/androidTest/java/com/owncloud/android/ResponseFormatDetectorTests.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2025 Alper Ozturk 5 | * SPDX-License-Identifier: MIT 6 | */ 7 | 8 | package com.owncloud.android 9 | 10 | import com.owncloud.android.lib.common.utils.responseFormat.ResponseFormat 11 | import com.owncloud.android.lib.common.utils.responseFormat.ResponseFormatDetector 12 | import junit.framework.TestCase.assertEquals 13 | import org.junit.Test 14 | 15 | class ResponseFormatDetectorTests { 16 | @Test 17 | fun testJsonDetection() { 18 | val json = """{ "name": "Alice", "age": 30 }""" 19 | assertEquals(ResponseFormat.JSON, ResponseFormatDetector.detectFormat(json)) 20 | } 21 | 22 | @Test 23 | fun testJsonArrayDetection() { 24 | val jsonArray = """[{"name": "Alice"}, {"name": "Bob"}]""" 25 | assertEquals(ResponseFormat.JSON, ResponseFormatDetector.detectFormat(jsonArray)) 26 | } 27 | 28 | @Test 29 | fun testXmlDetection() { 30 | val xml = """Alice30""" 31 | assertEquals(ResponseFormat.XML, ResponseFormatDetector.detectFormat(xml)) 32 | } 33 | 34 | @Test 35 | fun testInvalidFormat() { 36 | val invalid = "Just a plain string" 37 | assertEquals(ResponseFormat.UNKNOWN, ResponseFormatDetector.detectFormat(invalid)) 38 | } 39 | 40 | @Test 41 | fun testEmptyString() { 42 | val empty = "" 43 | assertEquals(ResponseFormat.UNKNOWN, ResponseFormatDetector.detectFormat(empty)) 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /library/src/androidTest/java/com/owncloud/android/RetryTestRule.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2020-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2020-2022 Tobias Kaminsky 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | package com.owncloud.android 9 | 10 | import android.util.Log 11 | import org.junit.rules.TestRule 12 | import org.junit.runner.Description 13 | import org.junit.runners.model.Statement 14 | 15 | /** 16 | * C&p from https://stackoverflow.com/questions/45635833/how-can-i-use-flakytest-annotation-now on 18.03.2020 17 | */ 18 | class RetryTestRule( 19 | val retryCount: Int = 1 20 | ) : TestRule { 21 | companion object { 22 | private val TAG = RetryTestRule::class.java.simpleName 23 | } 24 | 25 | override fun apply( 26 | base: Statement, 27 | description: Description 28 | ): Statement = statement(base, description) 29 | 30 | @Suppress("TooGenericExceptionCaught") // and this exactly what we want here 31 | private fun statement(base: Statement, description: Description): Statement { 32 | return object : Statement() { 33 | override fun evaluate() { 34 | Log.e(TAG, "Evaluating ${description.methodName}") 35 | 36 | var caughtThrowable: Throwable? = null 37 | 38 | for (i in 0 until retryCount) { 39 | try { 40 | base.evaluate() 41 | return 42 | } catch (t: Throwable) { 43 | caughtThrowable = t 44 | Log.e(TAG, description.methodName + ": run " + (i + 1) + " failed") 45 | } 46 | } 47 | 48 | Log.e(TAG, description.methodName + ": giving up after " + retryCount + " failures") 49 | if (caughtThrowable != null) { 50 | throw caughtThrowable 51 | } 52 | } 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /library/src/androidTest/java/com/owncloud/android/lib/common/OwnCloudAccountTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2019-2022 Tobias Kaminsky 6 | * SPDX-FileCopyrightText: 2019 Chris Narkiewicz 7 | * SPDX-License-Identifier: MIT 8 | */ 9 | package com.owncloud.android.lib.common; 10 | 11 | import static org.junit.Assert.assertEquals; 12 | import static org.junit.Assert.assertNotSame; 13 | 14 | import android.net.Uri; 15 | import android.os.Parcel; 16 | 17 | import androidx.test.ext.junit.runners.AndroidJUnit4; 18 | 19 | import org.junit.Test; 20 | import org.junit.runner.RunWith; 21 | 22 | @RunWith(AndroidJUnit4.class) 23 | public class OwnCloudAccountTest { 24 | 25 | @Test 26 | public void parcelableIsImplemented() { 27 | Uri uri = Uri.parse("https://nextcloud.localhost.localdomain"); 28 | OwnCloudCredentials credentials = new OwnCloudBasicCredentials( 29 | "user", 30 | "pass", 31 | true 32 | ); 33 | OwnCloudAccount original = new OwnCloudAccount(uri, credentials); 34 | Parcel parcel = Parcel.obtain(); 35 | parcel.setDataPosition(0); 36 | parcel.writeParcelable(original, 0); 37 | parcel.setDataPosition(0); 38 | OwnCloudAccount retrieved = parcel.readParcelable(OwnCloudAccount.class.getClassLoader()); 39 | 40 | assertNotSame(original, retrieved); 41 | assertEquals(original, retrieved); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /library/src/androidTest/java/com/owncloud/android/lib/common/UsernameVariationsIT.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2022-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2022 Álvaro Brey Vilas 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | package com.owncloud.android.lib.common 9 | 10 | import com.owncloud.android.AbstractIT 11 | import com.owncloud.android.lib.resources.files.ExistenceCheckRemoteOperation 12 | import org.junit.Assert.assertTrue 13 | import org.junit.Test 14 | import org.junit.runner.RunWith 15 | import org.junit.runners.Parameterized 16 | 17 | @RunWith(Parameterized::class) 18 | class UsernameVariationsIT( 19 | private val username: String 20 | ) : AbstractIT() { 21 | companion object { 22 | @Parameterized.Parameters(name = "{0}") 23 | @JvmStatic 24 | fun data(): Collection> = 25 | listOf( 26 | arrayOf("test"), 27 | arrayOf("test test"), 28 | arrayOf("test@test") 29 | ) 30 | } 31 | 32 | @Test 33 | fun testExistenceCheckWithUsername() { 34 | val ocClient = OwnCloudClientFactory.createOwnCloudClient(url, context, true) 35 | ocClient.credentials = OwnCloudBasicCredentials(username, "test") 36 | ocClient.userId = username // for test same as userId 37 | 38 | val existenceCheck = ExistenceCheckRemoteOperation("/", false).execute(ocClient) 39 | assertTrue(existenceCheck.isSuccess) 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /library/src/androidTest/java/com/owncloud/android/lib/common/accounts/ExternalLinksOperationIT.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2022-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2022 Tobias Kaminsky 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | package com.owncloud.android.lib.common.accounts 9 | 10 | import com.owncloud.android.AbstractIT 11 | import com.owncloud.android.lib.common.ExternalLink 12 | import junit.framework.Assert.assertEquals 13 | import junit.framework.Assert.assertTrue 14 | import org.junit.Test 15 | 16 | class ExternalLinksOperationIT : AbstractIT() { 17 | @Test 18 | fun retrieveExternalLinks() { 19 | val result = ExternalLinksOperation().execute(client) 20 | assertTrue(result.isSuccess) 21 | 22 | val data = result.data as ArrayList 23 | assertEquals(2, data.size) 24 | 25 | assertEquals("Nextcloud", data[0].name) 26 | assertEquals("https://www.nextcloud.com", data[0].url) 27 | 28 | assertEquals("Forum", data[1].name) 29 | assertEquals("https://help.nextcloud.com", data[1].url) 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /library/src/androidTest/java/com/owncloud/android/lib/resources/comments/CommentFileRemoteOperationIT.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2021-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2021 Tobias Kaminsky 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | package com.owncloud.android.lib.resources.comments 9 | 10 | import com.owncloud.android.AbstractIT 11 | import com.owncloud.android.lib.resources.files.ReadFileRemoteOperation 12 | import com.owncloud.android.lib.resources.files.UploadFileRemoteOperation 13 | import com.owncloud.android.lib.resources.files.model.RemoteFile 14 | import junit.framework.Assert.assertTrue 15 | import org.junit.Test 16 | 17 | class CommentFileRemoteOperationIT : AbstractIT() { 18 | @Test 19 | fun comment() { 20 | val filePath: String = createFile("commentFile") 21 | val remotePath = "/commentFile.txt" 22 | assertTrue( 23 | UploadFileRemoteOperation(filePath, remotePath, "image/jpg", RANDOM_MTIME) 24 | .execute(client) 25 | .isSuccess 26 | ) 27 | 28 | val readResult = ReadFileRemoteOperation(remotePath).execute(client) 29 | val remoteFile = readResult.data.get(0) as RemoteFile 30 | 31 | assertTrue( 32 | CommentFileRemoteOperation("test", remoteFile.localId) 33 | .execute(nextcloudClient) 34 | .isSuccess 35 | ) 36 | 37 | assertTrue( 38 | MarkCommentsAsReadRemoteOperation(remoteFile.localId) 39 | .execute(client) 40 | .isSuccess 41 | ) 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /library/src/androidTest/java/com/owncloud/android/lib/resources/e2ee/SendCSRRemoteOperationIT.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2023-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2023-2024 Tobias Kaminsky 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | package com.owncloud.android.lib.resources.e2ee 9 | 10 | import com.owncloud.android.AbstractIT 11 | import com.owncloud.android.lib.common.OwnCloudClientManagerFactory 12 | import com.owncloud.android.lib.resources.users.GetPublicKeyRemoteOperation 13 | import com.owncloud.android.lib.resources.users.SendCSRRemoteOperation 14 | import junit.framework.TestCase 15 | import junit.framework.TestCase.assertTrue 16 | import org.junit.Before 17 | import org.junit.Test 18 | import java.security.KeyPairGenerator 19 | import java.security.SecureRandom 20 | 21 | class SendCSRRemoteOperationIT : AbstractIT() { 22 | @Before 23 | fun init() { 24 | // E2E server app checks for official NC client with >=3.13.0, 25 | // and blocks all other clients, e.g. 3rd party apps using this lib 26 | OwnCloudClientManagerFactory.setUserAgent("Mozilla/5.0 (Android) Nextcloud-android/3.13.0") 27 | } 28 | 29 | @Throws(Throwable::class) 30 | @Test 31 | fun publicKey() { 32 | val keyGen = KeyPairGenerator.getInstance("RSA") 33 | keyGen.initialize(KEY_SIZE, SecureRandom()) 34 | 35 | val keyPair = keyGen.genKeyPair() 36 | 37 | // create CSR 38 | val urlEncoded: String = CsrHelper().generateCsrPemEncodedString(keyPair, client.userId) 39 | 40 | val operation = SendCSRRemoteOperation(urlEncoded) 41 | var result = operation.execute(nextcloudClient) 42 | 43 | assertTrue(result.isSuccess) 44 | 45 | // verify public key 46 | result = GetPublicKeyRemoteOperation(client.userId).execute(nextcloudClient) 47 | assertTrue(result.isSuccess) 48 | TestCase.assertNotNull(result.resultData) 49 | } 50 | 51 | companion object { 52 | const val KEY_SIZE = 2048 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /library/src/androidTest/java/com/owncloud/android/lib/resources/files/CheckEtagRemoteOperationIT.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2021-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2021 Tobias Kaminsky 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | package com.owncloud.android.lib.resources.files 9 | 10 | import com.owncloud.android.AbstractIT 11 | import com.owncloud.android.lib.common.operations.RemoteOperationResult 12 | import com.owncloud.android.lib.resources.files.model.RemoteFile 13 | import org.junit.Assert.assertEquals 14 | import org.junit.Assert.assertTrue 15 | import org.junit.Test 16 | 17 | class CheckEtagRemoteOperationIT : AbstractIT() { 18 | @Test 19 | fun checkEtag() { 20 | val filePath = createFile("eTagFile") 21 | val remotePath = "/eTagFile.txt" 22 | assertTrue( 23 | @Suppress("Detekt.MagicNumber") 24 | UploadFileRemoteOperation(filePath, remotePath, "image/jpg", 1464818400) 25 | .execute(client) 26 | .isSuccess 27 | ) 28 | 29 | val readResult = ReadFileRemoteOperation(remotePath).execute(client) 30 | val remoteFile = readResult.data[0] as RemoteFile 31 | val eTag = remoteFile.etag 32 | 33 | var eTagResult = CheckEtagRemoteOperation(remotePath, eTag).execute(client) 34 | assertEquals(RemoteOperationResult.ResultCode.ETAG_UNCHANGED, eTagResult.code) 35 | 36 | eTagResult = CheckEtagRemoteOperation(remotePath, "wrongEtag").execute(client) 37 | assertEquals(RemoteOperationResult.ResultCode.ETAG_CHANGED, eTagResult.code) 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /library/src/androidTest/java/com/owncloud/android/lib/resources/files/DownloadFileRemoteOperationIT.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2021-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2021 Tobias Kaminsky 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | package com.owncloud.android.lib.resources.files 9 | 10 | import com.owncloud.android.AbstractIT 11 | import org.junit.Assert.assertSame 12 | import org.junit.Assert.assertTrue 13 | import org.junit.Test 14 | import java.io.File 15 | 16 | class DownloadFileRemoteOperationIT : AbstractIT() { 17 | @Test 18 | fun download() { 19 | val filePath = createFile("download") 20 | val remotePath = "/download.jpg" 21 | assertTrue( 22 | @Suppress("Detekt.MagicNumber") 23 | UploadFileRemoteOperation(filePath, remotePath, "image/jpg", 1464818400) 24 | .execute(client) 25 | .isSuccess 26 | ) 27 | 28 | assertTrue( 29 | DownloadFileRemoteOperation(remotePath, context.externalCacheDir?.absolutePath) 30 | .execute(client) 31 | .isSuccess 32 | ) 33 | 34 | val oldFile = File(filePath) 35 | val newFile = File(context.externalCacheDir?.absolutePath + remotePath) 36 | assertSame(oldFile.length(), newFile.length()) 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /library/src/androidTest/java/com/owncloud/android/lib/resources/files/ExistenceCheckRemoteOperationIT.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2021-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2021 Tobias Kaminsky 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | package com.owncloud.android.lib.resources.files 9 | 10 | import com.owncloud.android.AbstractIT 11 | import org.junit.Assert.assertFalse 12 | import org.junit.Assert.assertTrue 13 | import org.junit.Test 14 | 15 | class ExistenceCheckRemoteOperationIT : AbstractIT() { 16 | @Test 17 | fun checkFile() { 18 | val filePath = createFile("existenceCheckFile") 19 | val remotePath = "/existenceCheckFile.jpg" 20 | val notExistingRemotePath = "/notExistingCheckFile.jpg" 21 | assertTrue( 22 | UploadFileRemoteOperation(filePath, remotePath, "image/jpg", RANDOM_MTIME) 23 | .execute(client) 24 | .isSuccess 25 | ) 26 | 27 | var existenceResult = 28 | ExistenceCheckRemoteOperation(remotePath, false) 29 | .execute(client) 30 | assertTrue(existenceResult.isSuccess) 31 | 32 | existenceResult = 33 | ExistenceCheckRemoteOperation(notExistingRemotePath, false) 34 | .execute(client) 35 | assertFalse(existenceResult.isSuccess) 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /library/src/androidTest/java/com/owncloud/android/lib/resources/notifications/NotificationIT.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2023-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2023 Tobias Kaminsky 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | package com.owncloud.android.lib.resources.notifications 9 | 10 | import com.owncloud.android.AbstractIT 11 | import junit.framework.TestCase.assertEquals 12 | import junit.framework.TestCase.assertTrue 13 | import org.junit.Test 14 | 15 | class NotificationIT : AbstractIT() { 16 | @Test 17 | fun getNotification() { 18 | // get all 19 | val all = GetNotificationsRemoteOperation().execute(nextcloudClient) 20 | assertTrue(all.isSuccess) 21 | 22 | val count = all.resultData.size 23 | 24 | // get one 25 | val firstNotification = all.resultData[0] 26 | val first = GetNotificationRemoteOperation(firstNotification.notificationId).execute(nextcloudClient) 27 | assertTrue(first.isSuccess) 28 | assertEquals(firstNotification.message, first.resultData.message) 29 | 30 | // delete one 31 | assertTrue( 32 | DeleteNotificationRemoteOperation(first.resultData.notificationId) 33 | .execute(nextcloudClient) 34 | .isSuccess 35 | ) 36 | 37 | // get all, second run 38 | val all2 = GetNotificationsRemoteOperation().execute(nextcloudClient) 39 | assertTrue(all2.isSuccess) 40 | 41 | assertEquals(count - 1, all2.resultData.size) 42 | 43 | // delete all 44 | assertTrue(DeleteAllNotificationsRemoteOperation().execute(nextcloudClient).isSuccess) 45 | 46 | // get all, third run 47 | val all3 = GetNotificationsRemoteOperation().execute(nextcloudClient) 48 | assertTrue(all3.isSuccess) 49 | 50 | assertEquals(0, all3.resultData.size) 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /library/src/androidTest/java/com/owncloud/android/lib/resources/status/OwnCloudVersionTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2022 Tobias Kaminsky 6 | * SPDX-FileCopyrightText: 2019 Chris Narkiewicz 7 | * SPDX-License-Identifier: MIT 8 | */ 9 | package com.owncloud.android.lib.resources.status; 10 | 11 | import static org.junit.Assert.assertEquals; 12 | import static org.junit.Assert.assertNotSame; 13 | 14 | import android.os.Parcel; 15 | 16 | import androidx.test.ext.junit.runners.AndroidJUnit4; 17 | 18 | import org.junit.Test; 19 | import org.junit.runner.RunWith; 20 | 21 | @RunWith(AndroidJUnit4.class) 22 | public class OwnCloudVersionTest { 23 | 24 | @Test 25 | public void parcelableIsImplemented() { 26 | OwnCloudVersion original = new OwnCloudVersion(42); 27 | 28 | Parcel parcel = Parcel.obtain(); 29 | parcel.setDataPosition(0); 30 | parcel.writeParcelable(original, 0); 31 | 32 | parcel.setDataPosition(0); 33 | OwnCloudVersion retrieved = parcel.readParcelable(OwnCloudVersion.class.getClassLoader()); 34 | 35 | assertNotSame(original, retrieved); 36 | assertEquals(original, retrieved); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /library/src/androidTest/java/com/owncloud/android/lib/resources/trashbin/ReadTrashbinFolderRemoteOperationIT.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2023-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2023 Tobias Kaminsky 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | package com.owncloud.android.lib.resources.trashbin 9 | 10 | import com.owncloud.android.AbstractIT 11 | import com.owncloud.android.lib.resources.files.RemoveFileRemoteOperation 12 | import com.owncloud.android.lib.resources.files.UploadFileRemoteOperation 13 | import junit.framework.TestCase.assertEquals 14 | import junit.framework.TestCase.assertTrue 15 | import org.junit.Test 16 | 17 | class ReadTrashbinFolderRemoteOperationIT : AbstractIT() { 18 | @Test 19 | fun trashbin() { 20 | assertTrue(EmptyTrashbinRemoteOperation().execute(nextcloudClient).isSuccess) 21 | 22 | val sut = ReadTrashbinFolderRemoteOperation("/") 23 | 24 | assertEquals(0, sut.execute(client).resultData.size) 25 | 26 | val fileName = "trashbinFile.txt" 27 | val filePath = createFile(fileName) 28 | val remotePath = "/$fileName" 29 | 30 | @Suppress("Detekt.MagicNumber") 31 | assertTrue( 32 | UploadFileRemoteOperation( 33 | filePath, 34 | remotePath, 35 | "image/jpg", 36 | 1464818400 37 | ).execute(client) 38 | .isSuccess 39 | ) 40 | 41 | // delete file 42 | assertTrue( 43 | RemoveFileRemoteOperation(remotePath) 44 | .execute(client) 45 | .isSuccess 46 | ) 47 | 48 | val result = sut.execute(client) 49 | 50 | assertEquals(1, result.resultData.size) 51 | assertEquals(fileName, result.resultData[0].fileName) 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /library/src/androidTest/java/com/owncloud/android/lib/resources/users/CheckRemoteWipeRemoteOperationIT.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2020-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2023 Tobias Kaminsky 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | 9 | package com.owncloud.android.lib.resources.users 10 | 11 | import android.text.TextUtils 12 | import com.nextcloud.android.lib.resources.users.GenerateAppPasswordRemoteOperation 13 | import com.owncloud.android.AbstractIT 14 | import com.owncloud.android.lib.common.OwnCloudBasicCredentials 15 | import org.junit.Assert.assertFalse 16 | import org.junit.Assert.assertTrue 17 | import org.junit.Test 18 | 19 | class CheckRemoteWipeRemoteOperationIT : AbstractIT() { 20 | @Test 21 | fun testCheckWipe() { 22 | val appTokenResult = GenerateAppPasswordRemoteOperation().execute(client) 23 | assertTrue(appTokenResult.isSuccess) 24 | 25 | val appPassword = appTokenResult.resultData 26 | assertFalse(TextUtils.isEmpty(appPassword)) 27 | 28 | client.credentials = 29 | OwnCloudBasicCredentials( 30 | client.credentials.username, 31 | appPassword, 32 | true 33 | ) 34 | 35 | val wipeResult = CheckRemoteWipeRemoteOperation().execute(client) 36 | 37 | // device should not be wiped 38 | assertFalse(wipeResult.isSuccess) 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /library/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 13 | 14 | 15 | 17 | 19 | 21 | 23 | 24 | 25 | 27 | 28 | 29 | 32 | 33 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /library/src/main/java/com/nextcloud/android/lib/core/Clock.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2022-2023 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2022 Álvaro Brey 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | package com.nextcloud.android.lib.core 9 | 10 | interface Clock { 11 | /** 12 | * Current epoch time in millis 13 | */ 14 | val currentTimeMillis: Long 15 | } 16 | -------------------------------------------------------------------------------- /library/src/main/java/com/nextcloud/android/lib/core/ClockImpl.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2022-2023 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2022 Álvaro Brey 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | package com.nextcloud.android.lib.core 9 | 10 | class ClockImpl : Clock { 11 | override val currentTimeMillis: Long 12 | get() = System.currentTimeMillis() 13 | } 14 | -------------------------------------------------------------------------------- /library/src/main/java/com/nextcloud/android/lib/resources/dashboard/DashBoardButtonType.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2022-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2022-2024 Tobias Kaminsky 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | package com.nextcloud.android.lib.resources.dashboard 9 | 10 | import com.google.gson.annotations.SerializedName 11 | 12 | enum class DashBoardButtonType { 13 | @SerializedName("new") 14 | NEW, 15 | 16 | @SerializedName("more") 17 | MORE, 18 | 19 | @SerializedName("setup") 20 | SETUP 21 | } 22 | -------------------------------------------------------------------------------- /library/src/main/java/com/nextcloud/android/lib/resources/dashboard/DashboardButton.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2022-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2022-2024 Tobias Kaminsky 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | package com.nextcloud.android.lib.resources.dashboard 9 | 10 | import android.os.Parcelable 11 | import kotlinx.parcelize.Parcelize 12 | 13 | @Parcelize 14 | data class DashboardButton( 15 | val type: DashBoardButtonType, 16 | val text: String, 17 | val link: String 18 | ) : Parcelable 19 | -------------------------------------------------------------------------------- /library/src/main/java/com/nextcloud/android/lib/resources/dashboard/DashboardWidget.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2022-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2022-2024 Tobias Kaminsky 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | package com.nextcloud.android.lib.resources.dashboard 9 | 10 | import android.os.Parcelable 11 | import com.google.gson.annotations.SerializedName 12 | import kotlinx.parcelize.Parcelize 13 | 14 | @Parcelize 15 | data class DashboardWidget( 16 | val id: String, 17 | val title: String, 18 | val order: Int, 19 | @SerializedName("icon_url") val iconUrl: String, 20 | @SerializedName("item_icons_round") val roundIcons: Boolean, 21 | val buttons: List? 22 | ) : Parcelable 23 | -------------------------------------------------------------------------------- /library/src/main/java/com/nextcloud/android/lib/resources/dashboard/DashboardWidgetItem.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2022-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2022-2024 Tobias Kaminsky 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | package com.nextcloud.android.lib.resources.dashboard 9 | 10 | data class DashboardWidgetItem( 11 | val title: String, 12 | val subtitle: String, 13 | val link: String, 14 | val iconUrl: String 15 | ) 16 | -------------------------------------------------------------------------------- /library/src/main/java/com/nextcloud/android/lib/resources/dashboard/DashboardWidgetList.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2022-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2022-2024 Tobias Kaminsky 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | package com.nextcloud.android.lib.resources.dashboard 9 | 10 | import android.os.Parcelable 11 | import kotlinx.parcelize.Parcelize 12 | 13 | @Parcelize 14 | data class DashboardWidgetList( 15 | val widgets: Map = HashMap() 16 | ) : Parcelable 17 | -------------------------------------------------------------------------------- /library/src/main/java/com/nextcloud/android/lib/resources/files/FileDownloadLimit.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2024 ZetaTom <70907959+zetatom@users.noreply.github.com> 5 | * SPDX-License-Identifier: MIT 6 | */ 7 | 8 | package com.nextcloud.android.lib.resources.files 9 | 10 | import java.io.Serializable 11 | 12 | data class FileDownloadLimit( 13 | val token: String, 14 | val limit: Int, 15 | val count: Int 16 | ) : Serializable 17 | -------------------------------------------------------------------------------- /library/src/main/java/com/nextcloud/android/lib/resources/files/RemoveFilesDownloadLimitRemoteOperation.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2024 ZetaTom <70907959+zetatom@users.noreply.github.com> 5 | * SPDX-License-Identifier: MIT 6 | */ 7 | 8 | package com.nextcloud.android.lib.resources.files 9 | 10 | import com.nextcloud.common.NextcloudClient 11 | import com.nextcloud.operations.DeleteMethod 12 | import com.owncloud.android.lib.common.operations.RemoteOperationResult 13 | import com.owncloud.android.lib.common.utils.Log_OC 14 | import com.owncloud.android.lib.resources.OCSRemoteOperation 15 | import org.apache.commons.httpclient.HttpStatus 16 | 17 | class RemoveFilesDownloadLimitRemoteOperation( 18 | val token: String 19 | ) : OCSRemoteOperation() { 20 | override fun run(client: NextcloudClient): RemoteOperationResult { 21 | val result: RemoteOperationResult 22 | 23 | val url = client.baseUri.toString() + String.format(FILES_DOWNLOAD_LIMIT_ENDPOINT, token) + JSON_FORMAT 24 | val deleteMethod = DeleteMethod(url, true) 25 | 26 | val status = deleteMethod.execute(client) 27 | 28 | if (status == HttpStatus.SC_OK) { 29 | result = RemoteOperationResult(true, deleteMethod) 30 | } else { 31 | result = RemoteOperationResult(false, deleteMethod) 32 | Log_OC.e(TAG, "Failed to remove download limit") 33 | Log_OC.e(TAG, "*** status code: " + status + "; response: " + deleteMethod.getResponseBodyAsString()) 34 | } 35 | 36 | deleteMethod.releaseConnection() 37 | 38 | return result 39 | } 40 | 41 | companion object { 42 | private val TAG = RemoveFilesDownloadLimitRemoteOperation::class.java.simpleName 43 | private const val FILES_DOWNLOAD_LIMIT_ENDPOINT = "/ocs/v2.php/apps/files_downloadlimit/api/v1/%s/limit" 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /library/src/main/java/com/nextcloud/android/lib/resources/files/SetFilesDownloadLimitRemoteOperation.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2024 ZetaTom <70907959+zetatom@users.noreply.github.com> 5 | * SPDX-License-Identifier: MIT 6 | */ 7 | 8 | package com.nextcloud.android.lib.resources.files 9 | 10 | import com.nextcloud.common.JSONRequestBody 11 | import com.nextcloud.common.NextcloudClient 12 | import com.nextcloud.operations.PutMethod 13 | import com.owncloud.android.lib.common.operations.RemoteOperationResult 14 | import com.owncloud.android.lib.common.utils.Log_OC 15 | import com.owncloud.android.lib.resources.OCSRemoteOperation 16 | import org.apache.commons.httpclient.HttpStatus 17 | 18 | class SetFilesDownloadLimitRemoteOperation( 19 | val token: String, 20 | val limit: Int 21 | ) : OCSRemoteOperation() { 22 | override fun run(client: NextcloudClient): RemoteOperationResult { 23 | val result: RemoteOperationResult 24 | 25 | val url = client.baseUri.toString() + String.format(FILES_DOWNLOAD_LIMIT_ENDPOINT, token) 26 | val jsonRequestBody = JSONRequestBody("limit", limit.toString()) 27 | val putMethod = PutMethod(url, true, jsonRequestBody.get()) 28 | 29 | val status = putMethod.execute(client) 30 | 31 | if (status == HttpStatus.SC_OK) { 32 | result = RemoteOperationResult(true, putMethod) 33 | } else { 34 | result = RemoteOperationResult(false, putMethod) 35 | Log_OC.e(TAG, "Failed to set download limit") 36 | Log_OC.e(TAG, "*** status code: " + status + "; response: " + putMethod.getResponseBodyAsString()) 37 | } 38 | 39 | putMethod.releaseConnection() 40 | 41 | return result 42 | } 43 | 44 | companion object { 45 | private val TAG = SetFilesDownloadLimitRemoteOperation::class.java.simpleName 46 | private const val FILES_DOWNLOAD_LIMIT_ENDPOINT = "/ocs/v2.php/apps/files_downloadlimit/api/v1/%s/limit" 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /library/src/main/java/com/nextcloud/android/lib/resources/groupfolders/Groupfolder.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2023-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2023-2024 Tobias Kaminsky 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | package com.nextcloud.android.lib.resources.groupfolders 9 | 10 | import com.google.gson.annotations.SerializedName 11 | 12 | data class Groupfolder( 13 | val id: Long, 14 | @SerializedName("mount_point") 15 | val mountPoint: String 16 | ) 17 | -------------------------------------------------------------------------------- /library/src/main/java/com/nextcloud/android/lib/resources/profile/Action.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2021-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2021-2024 Tobias Kaminsky 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | package com.nextcloud.android.lib.resources.profile 9 | 10 | /** 11 | * Action of HoverCard data model 12 | */ 13 | data class Action( 14 | var appId: String, 15 | var title: String, 16 | var icon: String, 17 | var hyperlink: String 18 | ) 19 | -------------------------------------------------------------------------------- /library/src/main/java/com/nextcloud/android/lib/resources/profile/HoverCard.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2021-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2021-2024 Tobias Kaminsky 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | package com.nextcloud.android.lib.resources.profile 9 | 10 | import java.util.ArrayList 11 | 12 | /** 13 | * HoverCard data model 14 | */ 15 | data class HoverCard( 16 | val userId: String, 17 | val displayName: String, 18 | val actions: List = ArrayList() 19 | ) 20 | -------------------------------------------------------------------------------- /library/src/main/java/com/nextcloud/android/lib/resources/recommendations/Recommendation.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2024 Tobias Kaminsky 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | 9 | package com.nextcloud.android.lib.resources.recommendations 10 | 11 | data class Recommendation( 12 | val id: Long, 13 | val timestamp: Long, 14 | val name: String, 15 | val directory: String, 16 | val extension: String, 17 | val mimeType: String, 18 | val hasPreview: Boolean, 19 | val reason: String 20 | ) 21 | -------------------------------------------------------------------------------- /library/src/main/java/com/nextcloud/android/lib/resources/recommendations/RecommendationResponse.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2024 Tobias Kaminsky 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | 9 | package com.nextcloud.android.lib.resources.recommendations 10 | 11 | data class RecommendationResponse( 12 | val enabled: Boolean, 13 | val recommendations: ArrayList 14 | ) 15 | -------------------------------------------------------------------------------- /library/src/main/java/com/nextcloud/android/lib/resources/tos/SignTermRemoteOperation.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2024 Tobias Kaminsky 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | package com.nextcloud.android.lib.resources.tos 9 | 10 | import com.nextcloud.common.NextcloudClient 11 | import com.nextcloud.operations.PostMethod 12 | import com.owncloud.android.lib.common.operations.RemoteOperation 13 | import com.owncloud.android.lib.common.operations.RemoteOperationResult 14 | import okhttp3.MediaType.Companion.toMediaTypeOrNull 15 | import okhttp3.RequestBody.Companion.toRequestBody 16 | import org.apache.commons.httpclient.HttpStatus 17 | 18 | /** 19 | * Sign terms of services 20 | */ 21 | class SignTermRemoteOperation( 22 | val id: Int 23 | ) : RemoteOperation() { 24 | @Suppress("TooGenericExceptionCaught") 25 | override fun run(client: NextcloudClient): RemoteOperationResult { 26 | val requestBody = hashMapOf("termId" to id) 27 | 28 | val json = gson.toJson(requestBody) 29 | 30 | val request = json.toRequestBody("application/json".toMediaTypeOrNull()) 31 | 32 | val postMethod = PostMethod(client.baseUri.toString() + ENDPOINT, true, request) 33 | 34 | val status = postMethod.execute(client) 35 | 36 | return if (status == HttpStatus.SC_OK) { 37 | RemoteOperationResult(true, postMethod) 38 | } else { 39 | RemoteOperationResult(false, postMethod) 40 | } 41 | } 42 | 43 | companion object { 44 | private const val ENDPOINT = "/ocs/v2.php/apps/terms_of_service/sign" 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /library/src/main/java/com/nextcloud/android/lib/resources/tos/Term.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2024 Tobias Kaminsky 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | 9 | package com.nextcloud.android.lib.resources.tos 10 | 11 | data class Term( 12 | val id: Int, 13 | val countryCode: String, 14 | val languageCode: String, 15 | val body: String, 16 | val renderedBody: String 17 | ) 18 | -------------------------------------------------------------------------------- /library/src/main/java/com/nextcloud/android/lib/resources/tos/Terms.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2024 Tobias Kaminsky 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | 9 | package com.nextcloud.android.lib.resources.tos 10 | 11 | data class Terms( 12 | val terms: List, 13 | val hasSigned: Boolean, 14 | val languages: Map 15 | ) 16 | -------------------------------------------------------------------------------- /library/src/main/java/com/nextcloud/common/JSONRequestBody.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2024 ZetaTom <70907959+zetatom@users.noreply.github.com> 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | package com.nextcloud.common 9 | 10 | import com.google.gson.Gson 11 | import okhttp3.MediaType.Companion.toMediaType 12 | import okhttp3.RequestBody 13 | import okhttp3.RequestBody.Companion.toRequestBody 14 | 15 | class JSONRequestBody() { 16 | private val content = mutableMapOf() 17 | 18 | constructor(key: String, value: String) : this() { 19 | put(key, value) 20 | } 21 | 22 | fun put( 23 | key: String, 24 | value: String 25 | ) { 26 | content[key] = value 27 | } 28 | 29 | fun get(): RequestBody { 30 | val json = Gson().toJson(content) 31 | return json.toRequestBody(JSON_MEDIATYPE) 32 | } 33 | 34 | override fun toString(): String = content.toString() 35 | 36 | companion object { 37 | private val JSON_MEDIATYPE = "application/json; charset=utf-8".toMediaType() 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /library/src/main/java/com/nextcloud/common/NextcloudUriDelegate.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2022-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2022 Álvaro Brey 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | package com.nextcloud.common 9 | 10 | import android.net.Uri 11 | import androidx.core.net.toUri 12 | import com.owncloud.android.lib.common.accounts.AccountUtils 13 | import com.owncloud.android.lib.common.network.WebdavUtils 14 | 15 | /** 16 | * Transitory class to share uri logic between [com.owncloud.android.lib.common.OwnCloudClient] 17 | * and [com.nextcloud.common.NextcloudClient]. 18 | * 19 | * When finally getting rid of [com.owncloud.android.lib.common.OwnCloudClient], 20 | * this should be separate from the client. 21 | */ 22 | class NextcloudUriDelegate( 23 | override var baseUri: Uri, 24 | var userId: String? 25 | ) : NextcloudUriProvider { 26 | constructor(baseUri: Uri) : this(baseUri, null) 27 | 28 | val userIdEncoded: String? 29 | get() = userId?.let { UserIdEncoder.encode(it) } 30 | 31 | override val filesDavUri: Uri 32 | get() = "$davUri/files/$userIdEncoded".toUri() 33 | override val uploadUri: Uri 34 | get() = (baseUri.toString() + AccountUtils.DAV_UPLOAD).toUri() 35 | override val davUri: Uri 36 | get() = (baseUri.toString() + AccountUtils.WEBDAV_PATH_9_0).toUri() 37 | 38 | override fun getFilesDavUri(path: String): String { 39 | // encodePath already adds leading slash if needed 40 | return "$filesDavUri${WebdavUtils.encodePath(path)}" 41 | } 42 | 43 | override fun getCommentsUri(fileId: Long): String = "$davUri/comments/files/$fileId" 44 | } 45 | -------------------------------------------------------------------------------- /library/src/main/java/com/nextcloud/common/NextcloudUriProvider.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2022-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2022 Álvaro Brey 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | package com.nextcloud.common 9 | 10 | import android.net.Uri 11 | 12 | interface NextcloudUriProvider { 13 | /** 14 | * Root URI of the Nextcloud server 15 | */ 16 | var baseUri: Uri 17 | val filesDavUri: Uri 18 | val uploadUri: Uri 19 | val davUri: Uri 20 | 21 | fun getFilesDavUri(path: String): String 22 | 23 | fun getCommentsUri(fileId: Long): String 24 | } 25 | -------------------------------------------------------------------------------- /library/src/main/java/com/nextcloud/common/ResponseOrError.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2020-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2020 Chris Narkiewicz 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | package com.nextcloud.common 9 | 10 | import okhttp3.Response 11 | 12 | internal data class ResponseOrError private constructor( 13 | val result: Response?, 14 | val error: Exception? 15 | ) { 16 | constructor(result: Response) : this(result, null) 17 | constructor(error: Exception) : this(null, error) 18 | } 19 | -------------------------------------------------------------------------------- /library/src/main/java/com/nextcloud/common/SessionTimeOut.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2024 Alper Ozturk 5 | * SPDX-License-Identifier: MIT 6 | */ 7 | 8 | package com.nextcloud.common 9 | 10 | data class SessionTimeOut( 11 | val readTimeOut: Int, 12 | val connectionTimeOut: Int 13 | ) 14 | 15 | @Suppress("Detekt.MagicNumber") 16 | val defaultSessionTimeOut = SessionTimeOut(60000, 15000) 17 | -------------------------------------------------------------------------------- /library/src/main/java/com/nextcloud/common/User.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2022-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2022 Chris Narkiewicz 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | package com.nextcloud.common 9 | 10 | import android.accounts.Account 11 | 12 | interface User { 13 | val accountName: String 14 | 15 | @Deprecated("Temporary workaround") 16 | fun toPlatformAccount(): Account 17 | } 18 | -------------------------------------------------------------------------------- /library/src/main/java/com/nextcloud/common/UserIdEncoder.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2022-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2022 Álvaro Brey 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | package com.nextcloud.common 9 | 10 | import android.net.Uri 11 | 12 | object UserIdEncoder { 13 | /** 14 | * Characters to skip during userID encoding 15 | */ 16 | private const val ALLOWED_USERID_CHARACTERS = "@+" 17 | 18 | @JvmStatic 19 | fun encode(userId: String): String = 20 | Uri 21 | .encode(userId, ALLOWED_USERID_CHARACTERS) 22 | // single quote is not automatically encoded by Uri but is encoded in NC server 23 | .replace("'", "%27") 24 | } 25 | -------------------------------------------------------------------------------- /library/src/main/java/com/nextcloud/extensions/ArrayListExtensions.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2023-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2023 Alper Ozturk 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | 9 | package com.nextcloud.extensions 10 | 11 | import org.w3c.dom.Element 12 | 13 | @Suppress("ReturnCount", "NestedBlockDepth") 14 | inline fun ArrayList<*>.processXmlData(tagName: String): T? { 15 | this.forEach { 16 | val element = it as? Element 17 | if (element != null && element.tagName == tagName) { 18 | val textContent = element.firstChild.textContent 19 | return when (T::class) { 20 | Float::class -> { 21 | textContent.toFloatOrNull() as? T 22 | } 23 | Double::class -> { 24 | textContent.toDoubleOrNull() as? T 25 | } 26 | else -> textContent as? T 27 | } 28 | } 29 | } 30 | 31 | return null 32 | } 33 | -------------------------------------------------------------------------------- /library/src/main/java/com/nextcloud/extensions/GsonExtensions.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2023-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2023 Alper Ozturk 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | package com.nextcloud.extensions 9 | 10 | import com.google.gson.Gson 11 | import com.google.gson.JsonSyntaxException 12 | import org.apache.jackrabbit.webdav.property.DavProperty 13 | 14 | inline fun Gson.fromDavProperty(davProperty: DavProperty<*>?): T? = 15 | if (davProperty != null && davProperty.value != null) { 16 | try { 17 | fromJson(davProperty.value.toString(), T::class.java) 18 | } catch (e: JsonSyntaxException) { 19 | null 20 | } 21 | } else { 22 | null 23 | } 24 | -------------------------------------------------------------------------------- /library/src/main/java/com/nextcloud/extensions/ParcelExtensions.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2024 ZetaTom <70907959+zetatom@users.noreply.github.com> 5 | * SPDX-License-Identifier: MIT 6 | */ 7 | 8 | package com.nextcloud.extensions 9 | 10 | import android.os.Build 11 | import android.os.Parcel 12 | import java.io.Serializable 13 | 14 | inline fun Parcel.readSerializableCompat(): T? = 15 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { 16 | readSerializable(T::class.java.classLoader, T::class.java) 17 | } else { 18 | @Suppress("DEPRECATION") 19 | readSerializable() as? T 20 | } 21 | -------------------------------------------------------------------------------- /library/src/main/java/com/nextcloud/operations/DeleteMethod.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2020 Tobias Kaminsky 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | package com.nextcloud.operations 9 | 10 | import com.nextcloud.common.OkHttpMethodBase 11 | import okhttp3.Request 12 | 13 | /** 14 | * HTTP DELETE method that uses OkHttp with new NextcloudClient 15 | */ 16 | class DeleteMethod( 17 | uri: String, 18 | useOcsApiRequestHeader: Boolean 19 | ) : OkHttpMethodBase(uri, useOcsApiRequestHeader) { 20 | override fun applyType(temp: Request.Builder) { 21 | temp.delete() 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /library/src/main/java/com/nextcloud/operations/GetMethod.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2019 Tobias Kaminsky 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | package com.nextcloud.operations 9 | 10 | import com.nextcloud.common.OkHttpMethodBase 11 | import okhttp3.Request 12 | 13 | /** 14 | * HTTP GET method that uses OkHttp with new NextcloudClient 15 | */ 16 | class GetMethod( 17 | uri: String, 18 | useOcsApiRequestHeader: Boolean 19 | ) : OkHttpMethodBase(uri, useOcsApiRequestHeader) { 20 | override fun applyType(temp: Request.Builder) { 21 | temp.get() 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /library/src/main/java/com/nextcloud/operations/HeadMethod.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2024 ZetaTom <70907959+zetatom@users.noreply.github.com> 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | package com.nextcloud.operations 9 | 10 | import com.nextcloud.common.OkHttpMethodBase 11 | import okhttp3.Request 12 | 13 | /** 14 | * HTTP HEAD method that uses OkHttp with new NextcloudClient 15 | */ 16 | class HeadMethod( 17 | uri: String, 18 | useOcsApiRequestHeader: Boolean 19 | ) : OkHttpMethodBase(uri, useOcsApiRequestHeader) { 20 | override fun applyType(temp: Request.Builder) { 21 | temp.head() 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /library/src/main/java/com/nextcloud/operations/LockMethod.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2022-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2022 Álvaro Brey 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | package com.nextcloud.operations 9 | 10 | import com.nextcloud.common.OkHttpMethodBase 11 | import okhttp3.Request 12 | 13 | /** 14 | * HTTP LOCK method that uses OkHttp with new NextcloudClient 15 | */ 16 | class LockMethod( 17 | uri: String, 18 | useOcsApiRequestHeader: Boolean 19 | ) : OkHttpMethodBase(uri, useOcsApiRequestHeader) { 20 | override fun applyType(temp: Request.Builder) { 21 | temp.method("LOCK", null) 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /library/src/main/java/com/nextcloud/operations/PostMethod.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2023 Tobias Kaminsky 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | package com.nextcloud.operations 9 | 10 | import com.nextcloud.common.OkHttpMethodBase 11 | import okhttp3.Request 12 | import okhttp3.RequestBody 13 | 14 | /** 15 | * HTTP POST method that uses OkHttp with new NextcloudClient 16 | * UTF8 by default 17 | */ 18 | class PostMethod( 19 | uri: String, 20 | useOcsApiRequestHeader: Boolean, 21 | val body: RequestBody 22 | ) : OkHttpMethodBase(uri, useOcsApiRequestHeader) { 23 | override fun applyType(temp: Request.Builder) { 24 | temp.post(body) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /library/src/main/java/com/nextcloud/operations/PutMethod.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2020-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2020 Tobias Kaminsky 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | package com.nextcloud.operations 9 | 10 | import com.nextcloud.common.OkHttpMethodBase 11 | import okhttp3.Request 12 | import okhttp3.RequestBody 13 | 14 | /** 15 | * HTTP PUT method that uses OkHttp with new NextcloudClient 16 | */ 17 | class PutMethod( 18 | uri: String, 19 | useOcsApiRequestHeader: Boolean, 20 | val body: RequestBody? = null 21 | ) : OkHttpMethodBase(uri, useOcsApiRequestHeader) { 22 | override fun applyType(temp: Request.Builder) { 23 | body?.let { 24 | temp.put(it) 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /library/src/main/java/com/nextcloud/operations/UnlockMethod.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2022-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2022 Álvaro Brey 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | package com.nextcloud.operations 9 | 10 | import com.nextcloud.common.OkHttpMethodBase 11 | import okhttp3.Request 12 | 13 | /** 14 | * HTTP UNLOCK method that uses OkHttp with new NextcloudClient 15 | */ 16 | class UnlockMethod( 17 | uri: String, 18 | useOcsApiRequestHeader: Boolean 19 | ) : OkHttpMethodBase(uri, useOcsApiRequestHeader) { 20 | override fun applyType(temp: Request.Builder) { 21 | temp.method("UNLOCK", null) 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /library/src/main/java/com/owncloud/android/lib/common/Creator.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2022-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2022 Tobias Kaminsky 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | package com.owncloud.android.lib.common 9 | 10 | import android.os.Parcelable 11 | import kotlinx.parcelize.Parcelize 12 | 13 | @Parcelize 14 | data class Creator( 15 | val id: String, 16 | val editor: String, 17 | val name: String, 18 | val extension: String, 19 | val mimetype: String, 20 | val templates: Boolean 21 | ) : Parcelable 22 | -------------------------------------------------------------------------------- /library/src/main/java/com/owncloud/android/lib/common/DirectEditing.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2022 Unpublished 6 | * SPDX-FileCopyrightText: 2019 Tobias Kaminsky 7 | * SPDX-License-Identifier: MIT 8 | */ 9 | package com.owncloud.android.lib.common 10 | 11 | import android.os.Parcelable 12 | import kotlinx.parcelize.Parcelize 13 | 14 | /** 15 | * Direct editing data model 16 | */ 17 | @Parcelize 18 | data class DirectEditing( 19 | val editors: Map = HashMap(), 20 | val creators: Map = HashMap() 21 | ) : Parcelable 22 | -------------------------------------------------------------------------------- /library/src/main/java/com/owncloud/android/lib/common/Editor.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2022 Unpublished 6 | * SPDX-FileCopyrightText: 2019 Tobias Kaminsky 7 | * SPDX-License-Identifier: MIT 8 | */ 9 | package com.owncloud.android.lib.common 10 | 11 | import android.os.Parcelable 12 | import kotlinx.parcelize.Parcelize 13 | 14 | /** 15 | * Editor for direct editing data model 16 | */ 17 | @Parcelize 18 | data class Editor( 19 | val id: String, 20 | val name: String, 21 | val mimetypes: ArrayList, 22 | val optionalMimetypes: ArrayList, 23 | val secure: Boolean 24 | ) : Parcelable 25 | -------------------------------------------------------------------------------- /library/src/main/java/com/owncloud/android/lib/common/ExternalLink.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2022 Unpublished 6 | * SPDX-FileCopyrightText: 2017 Tobias Kaminsky 7 | * SPDX-License-Identifier: MIT 8 | */ 9 | package com.owncloud.android.lib.common 10 | 11 | import android.os.Parcelable 12 | import kotlinx.parcelize.Parcelize 13 | 14 | /** 15 | * Quota data model 16 | */ 17 | @Parcelize 18 | data class ExternalLink( 19 | val id: Int, 20 | val iconUrl: String, 21 | val language: String, 22 | val type: ExternalLinkType, 23 | val name: String, 24 | val url: String, 25 | val redirect: Boolean 26 | ) : Parcelable 27 | -------------------------------------------------------------------------------- /library/src/main/java/com/owncloud/android/lib/common/ExternalLinkType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2017 Tobias Kaminsky 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | package com.owncloud.android.lib.common; 9 | 10 | public enum ExternalLinkType { 11 | LINK, SETTINGS, QUOTA, UNKNOWN 12 | } 13 | -------------------------------------------------------------------------------- /library/src/main/java/com/owncloud/android/lib/common/OwnCloudClientManagerFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2018-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2019-2020 Tobias Kaminsky 6 | * SPDX-FileCopyrightText: 2014-2015 ownCloud Inc. 7 | * SPDX-FileCopyrightText: 2015 masensio 8 | * SPDX-FileCopyrightText: 2014 David A. Velasco 9 | * SPDX-License-Identifier: MIT 10 | */ 11 | package com.owncloud.android.lib.common; 12 | 13 | public class OwnCloudClientManagerFactory { 14 | private static OwnCloudClientManager sDefaultSingleton; 15 | private static String sUserAgent = "Mozilla/5.0 (Android) Nextcloud-android"; 16 | private static String proxyHost = ""; 17 | private static int proxyPort = -1; 18 | 19 | public static OwnCloudClientManager getDefaultSingleton() { 20 | if (sDefaultSingleton == null) { 21 | sDefaultSingleton = new OwnCloudClientManager(); 22 | } 23 | return sDefaultSingleton; 24 | } 25 | 26 | public static void setUserAgent(String userAgent) { 27 | sUserAgent = userAgent; 28 | } 29 | 30 | public static String getUserAgent() { 31 | return sUserAgent; 32 | } 33 | 34 | public static void setProxyHost(String host) { 35 | proxyHost = host; 36 | } 37 | 38 | public static String getProxyHost() { 39 | return proxyHost; 40 | } 41 | 42 | public static void setProxyPort(int port) { 43 | proxyPort = port; 44 | } 45 | 46 | public static int getProxyPort() { 47 | return proxyPort; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /library/src/main/java/com/owncloud/android/lib/common/OwnCloudCredentials.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2018-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2019 Chris Narkiewicz 6 | * SPDX-FileCopyrightText: 2018 Tobias Kaminsky 7 | * SPDX-FileCopyrightText: 2014 David A. Velasco 8 | * SPDX-FileCopyrightText: 2014 ownCloud Inc. 9 | * SPDX-License-Identifier: MIT 10 | */ 11 | package com.owncloud.android.lib.common; 12 | 13 | import android.os.Parcelable; 14 | 15 | public interface OwnCloudCredentials extends Parcelable { 16 | 17 | void applyTo(OwnCloudClient ownCloudClient); 18 | 19 | String getUsername(); 20 | 21 | String getAuthToken(); 22 | 23 | boolean authTokenExpires(); 24 | 25 | String toOkHttpCredentials(); 26 | } 27 | -------------------------------------------------------------------------------- /library/src/main/java/com/owncloud/android/lib/common/OwnCloudCredentialsFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2017 Tobias Kaminsky 6 | * SPDX-FileCopyrightText: 2014-2016 David A. Velasco 7 | * SPDX-FileCopyrightText: 2014-2016 ownCloud Inc. 8 | * SPDX-License-Identifier: MIT 9 | */ 10 | package com.owncloud.android.lib.common; 11 | 12 | public class OwnCloudCredentialsFactory { 13 | public static final String CREDENTIAL_CHARSET = "UTF-8"; 14 | 15 | private static OwnCloudAnonymousCredentials sAnonymousCredentials; 16 | 17 | public static OwnCloudCredentials newBasicCredentials(String username, String password) { 18 | return new OwnCloudBasicCredentials(username, password); 19 | } 20 | 21 | public static final OwnCloudCredentials getAnonymousCredentials() { 22 | if (sAnonymousCredentials == null) { 23 | sAnonymousCredentials = new OwnCloudAnonymousCredentials(); 24 | } 25 | return sAnonymousCredentials; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /library/src/main/java/com/owncloud/android/lib/common/Quota.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2022 Unpublished 6 | * SPDX-FileCopyrightText: 2022 Álvaro Brey 7 | * SPDX-License-Identifier: MIT 8 | */ 9 | package com.owncloud.android.lib.common 10 | 11 | import android.os.Parcelable 12 | import kotlinx.parcelize.Parcelize 13 | 14 | /** 15 | * Quota data model 16 | */ 17 | 18 | @Parcelize 19 | data class Quota( 20 | val free: Long = 0, 21 | val used: Long = 0, 22 | val total: Long = 0, 23 | val relative: Double = 0.0, 24 | val quota: Long = 0 25 | ) : Parcelable { 26 | constructor(quota: Long) : this(0, quota = quota) 27 | } 28 | -------------------------------------------------------------------------------- /library/src/main/java/com/owncloud/android/lib/common/SearchProvider.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2020-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2020 Tobias Kaminsky 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | package com.owncloud.android.lib.common 9 | 10 | /** 11 | * Search provider for unified search 12 | */ 13 | data class SearchProvider( 14 | var id: String, 15 | var name: String, 16 | var order: Int 17 | ) 18 | -------------------------------------------------------------------------------- /library/src/main/java/com/owncloud/android/lib/common/SearchProviders.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2020-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2020 Tobias Kaminsky 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | package com.owncloud.android.lib.common 9 | 10 | /** 11 | * Search providers for unified search 12 | */ 13 | data class SearchProviders( 14 | var eTag: String = "", 15 | var providers: List = emptyList() 16 | ) 17 | -------------------------------------------------------------------------------- /library/src/main/java/com/owncloud/android/lib/common/SearchResult.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2020-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2021 Álvaro Brey 6 | * SPDX-FileCopyrightText: 2020 Tobias Kaminsky 7 | * SPDX-License-Identifier: MIT 8 | */ 9 | package com.owncloud.android.lib.common 10 | 11 | /** 12 | * Search result of an unified search 13 | */ 14 | data class SearchResult( 15 | var name: String = "", 16 | var isPaginated: Boolean = false, 17 | var entries: List = emptyList(), 18 | var cursor: String? = "" 19 | ) 20 | -------------------------------------------------------------------------------- /library/src/main/java/com/owncloud/android/lib/common/SearchResultEntry.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2020-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2022 Álvaro Brey 6 | * SPDX-FileCopyrightText: 2020 Tobias Kaminsky 7 | * SPDX-License-Identifier: MIT 8 | */ 9 | package com.owncloud.android.lib.common 10 | 11 | import android.net.UrlQuerySanitizer 12 | 13 | /** 14 | * One search result entry of an unified search 15 | */ 16 | data class SearchResultEntry( 17 | var thumbnailUrl: String = "", 18 | var title: String = "", 19 | var subline: String = "", 20 | var resourceUrl: String = "", 21 | var icon: String = "", 22 | var rounded: Boolean = false, 23 | var attributes: Map = emptyMap() 24 | ) { 25 | companion object { 26 | private const val PARAM_DIR = "dir" 27 | private const val PARAM_FILE = "scrollto" 28 | private const val DIR_ROOT = "/" 29 | } 30 | 31 | val isFile: Boolean 32 | get() = fileId() != null || listOf(PARAM_DIR, PARAM_FILE).all { resourceUrl.contains(it) } 33 | 34 | fun fileId(): String? = attributes["fileId"] 35 | 36 | fun remotePath(): String = attributes["path"] ?: parseRemotePath() 37 | 38 | private fun parseRemotePath(): String { 39 | val sanitizer = 40 | UrlQuerySanitizer().apply { 41 | allowUnregisteredParamaters = true 42 | unregisteredParameterValueSanitizer = UrlQuerySanitizer.getAllButNulLegal() 43 | } 44 | 45 | sanitizer.parseUrl(resourceUrl) 46 | 47 | val dirParam = sanitizer.getValue(PARAM_DIR) 48 | val dir = 49 | when (dirParam) { 50 | DIR_ROOT -> "" 51 | else -> dirParam 52 | } 53 | 54 | val file = sanitizer.getValue(PARAM_FILE) 55 | 56 | return "$dir/$file" 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /library/src/main/java/com/owncloud/android/lib/common/Template.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2022 Álvaro Brey 6 | * SPDX-FileCopyrightText: 2022 Unpublished 7 | * SPDX-License-Identifier: MIT 8 | */ 9 | package com.owncloud.android.lib.common 10 | 11 | import android.os.Parcelable 12 | import kotlinx.parcelize.Parcelize 13 | 14 | /** 15 | * Template for direct editing data model 16 | */ 17 | @Parcelize 18 | data class Template( 19 | val id: String, 20 | val extension: String, 21 | val title: String, 22 | val preview: String 23 | ) : Parcelable 24 | -------------------------------------------------------------------------------- /library/src/main/java/com/owncloud/android/lib/common/TemplateList.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2022 Álvaro Brey 6 | * SPDX-FileCopyrightText: 2022 Unpublished 7 | * SPDX-License-Identifier: MIT 8 | */ 9 | package com.owncloud.android.lib.common 10 | 11 | import android.os.Parcelable 12 | import kotlinx.parcelize.Parcelize 13 | 14 | /** 15 | * List of templates data model 16 | */ 17 | @Parcelize 18 | data class TemplateList( 19 | val templates: Map = HashMap() 20 | ) : Parcelable 21 | -------------------------------------------------------------------------------- /library/src/main/java/com/owncloud/android/lib/common/UserInfo.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2022 Unpublished 6 | * SPDX-FileCopyrightText: 2017 Mario Danic 7 | * SPDX-License-Identifier: MIT 8 | */ 9 | package com.owncloud.android.lib.common 10 | 11 | import android.os.Parcelable 12 | import com.google.gson.annotations.SerializedName 13 | import kotlinx.parcelize.Parcelize 14 | 15 | /** 16 | * User information data model 17 | */ 18 | @Parcelize 19 | data class UserInfo( 20 | var id: String?, 21 | var enabled: Boolean?, 22 | @SerializedName(value = "display-name", alternate = ["displayname"]) 23 | var displayName: String?, 24 | var email: String?, 25 | var phone: String?, 26 | var address: String?, 27 | @SerializedName(value = "website", alternate = ["webpage"]) 28 | var website: String?, 29 | var twitter: String?, 30 | var quota: Quota?, 31 | var groups: ArrayList? 32 | ) : Parcelable 33 | -------------------------------------------------------------------------------- /library/src/main/java/com/owncloud/android/lib/common/accounts/AccountTypeUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2014-2016 ownCloud Inc. and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2014 David A. Velasco 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | package com.owncloud.android.lib.common.accounts; 9 | 10 | /** 11 | * @author masensio 12 | * @author David A. Velasco 13 | */ 14 | public class AccountTypeUtils { 15 | 16 | public static String getAuthTokenTypePass(String accountType) { 17 | return accountType + ".password"; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /library/src/main/java/com/owncloud/android/lib/common/network/OnDatatransferProgressListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2018-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2018 Tobias Kaminsky 6 | * SPDX-FileCopyrightText: 2014-2015 ownCloud Inc. 7 | * SPDX-FileCopyrightText: 2014 David A. Velasco 8 | * SPDX-FileCopyrightText: 2012 Bartosz Przybylski 9 | * SPDX-License-Identifier: MIT 10 | */ 11 | package com.owncloud.android.lib.common.network; 12 | 13 | public interface OnDatatransferProgressListener { 14 | void onTransferProgress(long progressRate, long totalTransferredSoFar, long totalToTransfer, String fileAbsoluteName); 15 | } 16 | -------------------------------------------------------------------------------- /library/src/main/java/com/owncloud/android/lib/common/network/ProgressiveDataTransfer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2019 Tobias Kaminsky 6 | * SPDX-FileCopyrightText: 2014-2015 ownCloud Inc. 7 | * SPDX-FileCopyrightText: 2014 David A. Velasco 8 | * SPDX-License-Identifier: MIT 9 | */ 10 | package com.owncloud.android.lib.common.network; 11 | 12 | import java.util.Collection; 13 | 14 | 15 | 16 | public interface ProgressiveDataTransfer { 17 | void addDataTransferProgressListener(OnDatatransferProgressListener listener); 18 | 19 | void addDataTransferProgressListeners(Collection listeners); 20 | 21 | void removeDataTransferProgressListener(OnDatatransferProgressListener listener); 22 | } 23 | -------------------------------------------------------------------------------- /library/src/main/java/com/owncloud/android/lib/common/operations/OnRemoteOperationListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2014-2015 ownCloud Inc. 5 | * SPDX-FileCopyrightText: 2014 David A. Velasco 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | package com.owncloud.android.lib.common.operations; 9 | 10 | 11 | public interface OnRemoteOperationListener { 12 | 13 | void onRemoteOperationFinish(RemoteOperation caller, RemoteOperationResult result); 14 | 15 | } 16 | -------------------------------------------------------------------------------- /library/src/main/java/com/owncloud/android/lib/common/operations/OperationCancelledException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2014-2015 ownCloud Inc. 5 | * SPDX-FileCopyrightText: 2014 David A. Velasco 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | package com.owncloud.android.lib.common.operations; 9 | 10 | public class OperationCancelledException extends Exception { 11 | 12 | /** 13 | * Generated serial version - to avoid Java warning 14 | */ 15 | private static final long serialVersionUID = -6350981497740424983L; 16 | 17 | } 18 | -------------------------------------------------------------------------------- /library/src/main/java/com/owncloud/android/lib/common/utils/HttpDeleteWithBody.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2017 Mario Danic 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | package com.owncloud.android.lib.common.utils; 9 | 10 | import org.apache.commons.httpclient.methods.Utf8PostMethod; 11 | 12 | 13 | public class HttpDeleteWithBody extends Utf8PostMethod { 14 | 15 | public HttpDeleteWithBody(String url) { 16 | super(url); 17 | } 18 | 19 | @Override 20 | public String getName() { 21 | return "DELETE"; 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /library/src/main/java/com/owncloud/android/lib/common/utils/responseFormat/ResponseFormat.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2025 Alper Ozturk 5 | * SPDX-License-Identifier: MIT 6 | */ 7 | 8 | package com.owncloud.android.lib.common.utils.responseFormat 9 | 10 | enum class ResponseFormat { 11 | JSON, 12 | XML, 13 | UNKNOWN 14 | } 15 | -------------------------------------------------------------------------------- /library/src/main/java/com/owncloud/android/lib/common/utils/responseFormat/ResponseFormatDetector.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2025 Alper Ozturk 5 | * SPDX-License-Identifier: MIT 6 | */ 7 | 8 | package com.owncloud.android.lib.common.utils.responseFormat 9 | 10 | import com.owncloud.android.lib.common.utils.Log_OC 11 | import org.json.JSONArray 12 | import org.json.JSONException 13 | import org.json.JSONObject 14 | import java.io.ByteArrayInputStream 15 | import javax.xml.parsers.DocumentBuilderFactory 16 | 17 | object ResponseFormatDetector { 18 | private const val TAG = "ResponseFormatDetector" 19 | 20 | fun detectFormat(input: String): ResponseFormat = 21 | when { 22 | isJSON(input) -> ResponseFormat.JSON 23 | isXML(input) -> ResponseFormat.XML 24 | else -> ResponseFormat.UNKNOWN 25 | } 26 | 27 | private fun isJSON(input: String): Boolean = 28 | try { 29 | JSONObject(input) 30 | true 31 | } catch (e: JSONException) { 32 | try { 33 | Log_OC.i(TAG, "Info it's not JSONObject: $e") 34 | JSONArray(input) 35 | true 36 | } catch (e: JSONException) { 37 | Log_OC.e(TAG, "Exception it's not JSONArray: $e") 38 | false 39 | } 40 | } 41 | 42 | @Suppress("TooGenericExceptionCaught") 43 | private fun isXML(input: String): Boolean = 44 | try { 45 | val factory = DocumentBuilderFactory.newInstance() 46 | val builder = factory.newDocumentBuilder() 47 | val stream = ByteArrayInputStream(input.toByteArray()) 48 | builder.parse(stream) 49 | true 50 | } catch (e: Exception) { 51 | Log_OC.e(TAG, "Exception isXML: $e") 52 | false 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /library/src/main/java/com/owncloud/android/lib/ocs/OCSMeta.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2023-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2023 Álvaro Brey 6 | * SPDX-FileCopyrightText: 2018 Bartosz Przybylski 7 | * SPDX-License-Identifier: MIT 8 | */ 9 | package com.owncloud.android.lib.ocs; 10 | 11 | import com.google.gson.annotations.SerializedName; 12 | 13 | /** 14 | * A meta class which is a part of OCS response from server 15 | * 16 | * @author Bartosz Przybylski 17 | */ 18 | public class OCSMeta { 19 | @SerializedName("status") 20 | public String status; 21 | @SerializedName("statuscode") 22 | public int statusCode; 23 | @SerializedName("message") 24 | public String message; 25 | 26 | public String getStatus() { 27 | return this.status; 28 | } 29 | 30 | public int getStatusCode() { 31 | return this.statusCode; 32 | } 33 | 34 | public String getMessage() { 35 | return this.message; 36 | } 37 | // TODO(bp): add paging information 38 | } 39 | -------------------------------------------------------------------------------- /library/src/main/java/com/owncloud/android/lib/ocs/OCSResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2023-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2023 Álvaro Brey 6 | * SPDX-FileCopyrightText: 2018 Bartosz Przybylski 7 | * SPDX-License-Identifier: MIT 8 | */ 9 | package com.owncloud.android.lib.ocs; 10 | 11 | import com.google.gson.annotations.SerializedName; 12 | 13 | /** 14 | * Wrapper for server OCS response 15 | * 16 | * @author Bartosz Przybylski 17 | */ 18 | public class OCSResponse { 19 | 20 | @SerializedName("data") 21 | public T data; 22 | 23 | @SerializedName("meta") 24 | public OCSMeta meta; 25 | 26 | public T getData() { 27 | return this.data; 28 | } 29 | 30 | public OCSMeta getMeta() { 31 | return this.meta; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /library/src/main/java/com/owncloud/android/lib/ocs/ServerResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2023-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2023 Álvaro Brey 6 | * SPDX-FileCopyrightText: 2018 Bartosz Przybylski 7 | * SPDX-License-Identifier: MIT 8 | */ 9 | package com.owncloud.android.lib.ocs; 10 | 11 | import com.google.gson.annotations.SerializedName; 12 | 13 | /** 14 | * Wrapper for server response 15 | * 16 | * @author Bartosz Przybylski 17 | */ 18 | public class ServerResponse { 19 | @SerializedName("ocs") 20 | public OCSResponse ocs; 21 | 22 | public OCSResponse getOcs() { 23 | return this.ocs; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /library/src/main/java/com/owncloud/android/lib/ocs/responses/PrivateKey.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2018 Bartosz Przybylski 5 | * SPDX-License-Identifier: MIT 6 | */ 7 | package com.owncloud.android.lib.ocs.responses; 8 | 9 | import com.google.gson.annotations.SerializedName; 10 | 11 | /** 12 | * @author Bartosz Przybylski 13 | */ 14 | public class PrivateKey { 15 | 16 | @SerializedName("private-key") 17 | public String key; 18 | 19 | public String getKey() { 20 | return key; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /library/src/main/java/com/owncloud/android/lib/resources/OCSRemoteOperation.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2019-2020 Tobias Kaminsky 6 | * SPDX-FileCopyrightText: 2018 Bartosz Przybylski 7 | * SPDX-License-Identifier: MIT 8 | */ 9 | package com.owncloud.android.lib.resources 10 | 11 | import com.google.gson.JsonElement 12 | import com.google.gson.JsonParser 13 | import com.google.gson.JsonSyntaxException 14 | import com.google.gson.reflect.TypeToken 15 | import com.nextcloud.common.OkHttpMethodBase 16 | import com.owncloud.android.lib.common.operations.RemoteOperation 17 | import org.apache.commons.httpclient.HttpMethodBase 18 | import java.io.IOException 19 | 20 | /** 21 | * Base class for OCS remote operations with convenient methods 22 | * 23 | * @author Bartosz Przybylski 24 | */ 25 | abstract class OCSRemoteOperation : RemoteOperation() { 26 | @Deprecated("Use OkHttpMethodBase variant instead") 27 | fun getServerResponse( 28 | method: HttpMethodBase, 29 | type: TypeToken 30 | ): T? = 31 | try { 32 | val response = method.responseBodyAsString 33 | val element: JsonElement = JsonParser.parseString(response) 34 | gson.fromJson(element, type.type) 35 | } catch (ioException: IOException) { 36 | null 37 | } catch (syntaxException: JsonSyntaxException) { 38 | null 39 | } 40 | 41 | fun getServerResponse( 42 | method: OkHttpMethodBase, 43 | type: TypeToken 44 | ): T? = 45 | try { 46 | val response = method.getResponseBodyAsString() 47 | val element: JsonElement = JsonParser.parseString(response) 48 | gson.fromJson(element, type.type) 49 | } catch (syntaxException: JsonSyntaxException) { 50 | null 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /library/src/main/java/com/owncloud/android/lib/resources/activities/model/Activity.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2022 Tobias Kaminsky 6 | * SPDX-FileCopyrightText: 2017 Alejandro Bautista 7 | * SPDX-License-Identifier: MIT 8 | */ 9 | package com.owncloud.android.lib.resources.activities.model 10 | 11 | import com.google.gson.annotations.SerializedName 12 | import com.owncloud.android.lib.resources.activities.models.PreviewObject 13 | import java.util.Date 14 | 15 | /** 16 | * Activity Data Model 17 | */ 18 | data class Activity( 19 | @SerializedName("activity_id") 20 | val activityId: Int, 21 | val datetime: Date, 22 | // legacy purposes 23 | val date: Date, 24 | val app: String, 25 | val type: String, 26 | val user: String, 27 | @SerializedName("affecteduser") 28 | val affectedUser: String, 29 | val subject: String, 30 | val message: String, 31 | val icon: String, 32 | val link: String, 33 | @SerializedName("object_type") 34 | val objectType: String, 35 | @SerializedName("object_id") 36 | val objectId: String, 37 | @SerializedName("object_name") 38 | val objectName: String, 39 | val previews: List, 40 | @SerializedName("subject_rich") 41 | val richSubjectElement: RichElement 42 | ) 43 | -------------------------------------------------------------------------------- /library/src/main/java/com/owncloud/android/lib/resources/activities/model/RichElement.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2022 Álvaro Brey 6 | * SPDX-FileCopyrightText: 2018 Tobias Kaminsky 7 | * SPDX-FileCopyrightText: 2017 Alejandro Bautista 8 | * SPDX-License-Identifier: MIT 9 | */ 10 | package com.owncloud.android.lib.resources.activities.model 11 | 12 | /** 13 | * RichElement Data Model 14 | */ 15 | data class RichElement( 16 | var richSubject: String, 17 | var richObjectList: MutableList 18 | ) { 19 | constructor() : this("", mutableListOf()) 20 | } 21 | -------------------------------------------------------------------------------- /library/src/main/java/com/owncloud/android/lib/resources/activities/model/RichObject.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2022 Álvaro Brey 6 | * SPDX-FileCopyrightText: 2017 Alejandro Bautista 7 | * SPDX-License-Identifier: MIT 8 | */ 9 | package com.owncloud.android.lib.resources.activities.model 10 | 11 | /** 12 | * RichObject Data Model 13 | */ 14 | class RichObject() { 15 | var type: String? = null 16 | var id: String? = null 17 | var name: String? = null 18 | var path: String? = null 19 | var link: String? = null 20 | var tag: String? = null 21 | 22 | @Suppress("LongParameterList") 23 | constructor(type: String?, id: String?, name: String?, path: String?, link: String?, tag: String?) : this() { 24 | this.type = type 25 | this.id = id 26 | this.name = name 27 | this.path = path 28 | this.link = link 29 | this.tag = tag 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /library/src/main/java/com/owncloud/android/lib/resources/activities/models/PreviewObject.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2022 Álvaro Brey 6 | * SPDX-FileCopyrightText: 2017 Joas Schilling 7 | * SPDX-License-Identifier: MIT 8 | */ 9 | package com.owncloud.android.lib.resources.activities.models 10 | 11 | /** 12 | * PreviewObject Data Model 13 | */ 14 | class PreviewObject() { 15 | var fileId = 0 16 | var source: String? = null 17 | var link: String? = null 18 | var mimeTypeIcon: Boolean? = null 19 | var mimeType: String? = null 20 | var view: String? = null 21 | var filename: String? = null 22 | 23 | @Suppress("LongParameterList") 24 | constructor( 25 | fileId: Int, 26 | source: String?, 27 | link: String?, 28 | mimeTypeIcon: Boolean?, 29 | mimeType: String?, 30 | view: String?, 31 | filename: String? 32 | ) : this() { 33 | this.fileId = fileId 34 | this.source = source 35 | this.link = link 36 | this.mimeTypeIcon = mimeTypeIcon 37 | this.mimeType = mimeType 38 | this.view = view 39 | this.filename = filename 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /library/src/main/java/com/owncloud/android/lib/resources/assistant/v1/CreateTaskRemoteOperationV1.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2024 Alper Ozturk 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | 9 | package com.owncloud.android.lib.resources.assistant.v1 10 | 11 | import com.nextcloud.common.NextcloudClient 12 | import com.nextcloud.operations.PostMethod 13 | import com.owncloud.android.lib.common.operations.RemoteOperation 14 | import com.owncloud.android.lib.common.operations.RemoteOperationResult 15 | import okhttp3.MediaType.Companion.toMediaTypeOrNull 16 | import okhttp3.RequestBody.Companion.toRequestBody 17 | import org.apache.commons.httpclient.HttpStatus 18 | 19 | class CreateTaskRemoteOperationV1( 20 | private val input: String, 21 | private val type: String 22 | ) : RemoteOperation() { 23 | override fun run(client: NextcloudClient): RemoteOperationResult { 24 | val requestBody = 25 | hashMapOf( 26 | "input" to input, 27 | "type" to type, 28 | "appId" to "assistant", 29 | "identifier" to "" 30 | ) 31 | 32 | val json = gson.toJson(requestBody) 33 | 34 | val request = json.toRequestBody("application/json".toMediaTypeOrNull()) 35 | 36 | val postMethod = PostMethod(client.baseUri.toString() + TAG_URL, true, request) 37 | 38 | val status = postMethod.execute(client) 39 | 40 | return if (status == HttpStatus.SC_OK) { 41 | RemoteOperationResult(true, postMethod) 42 | } else { 43 | RemoteOperationResult(false, postMethod) 44 | } 45 | } 46 | 47 | companion object { 48 | const val TAG_URL = "/ocs/v2.php/textprocessing/schedule" 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /library/src/main/java/com/owncloud/android/lib/resources/assistant/v1/DeleteTaskRemoteOperationV1.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2024 Alper Ozturk 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | 9 | package com.owncloud.android.lib.resources.assistant.v1 10 | 11 | import com.nextcloud.common.NextcloudClient 12 | import com.nextcloud.operations.DeleteMethod 13 | import com.owncloud.android.lib.common.operations.RemoteOperation 14 | import com.owncloud.android.lib.common.operations.RemoteOperationResult 15 | import com.owncloud.android.lib.common.utils.Log_OC 16 | import com.owncloud.android.lib.resources.users.DeletePrivateKeyRemoteOperation 17 | import java.io.IOException 18 | import java.net.HttpURLConnection 19 | 20 | class DeleteTaskRemoteOperationV1( 21 | private val appId: Long 22 | ) : RemoteOperation() { 23 | override fun run(client: NextcloudClient): RemoteOperationResult { 24 | var postMethod: DeleteMethod? = null 25 | var result: RemoteOperationResult 26 | try { 27 | postMethod = 28 | DeleteMethod( 29 | client.baseUri.toString() + DIRECT_ENDPOINT + appId, 30 | true 31 | ) 32 | val status = client.execute(postMethod) 33 | result = RemoteOperationResult(status == HttpURLConnection.HTTP_OK, postMethod) 34 | } catch (e: IOException) { 35 | result = RemoteOperationResult(e) 36 | Log_OC.e(TAG, "Deletion of task failed: " + result.logMessage, result.exception) 37 | } finally { 38 | postMethod?.releaseConnection() 39 | } 40 | 41 | return result 42 | } 43 | 44 | companion object { 45 | private val TAG = DeletePrivateKeyRemoteOperation::class.java.simpleName 46 | private const val DIRECT_ENDPOINT = 47 | "/ocs/v2.php/textprocessing/task/" 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /library/src/main/java/com/owncloud/android/lib/resources/assistant/v1/model/TaskTypes.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2024 Alper Ozturk 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | 9 | package com.owncloud.android.lib.resources.assistant.v1.model 10 | 11 | import com.owncloud.android.lib.resources.assistant.v2.model.TaskTypeData 12 | 13 | data class TaskTypes( 14 | var types: List 15 | ) 16 | 17 | data class TaskType( 18 | val id: String?, 19 | val name: String?, 20 | val description: String? 21 | ) 22 | 23 | fun TaskTypes.toV2(): List = 24 | types.map { taskType -> 25 | TaskTypeData( 26 | id = taskType.id, 27 | name = taskType.name, 28 | description = taskType.description, 29 | inputShape = null, 30 | outputShape = null 31 | ) 32 | } 33 | -------------------------------------------------------------------------------- /library/src/main/java/com/owncloud/android/lib/resources/assistant/v2/CreateTaskRemoteOperationV2.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2024 Alper Ozturk 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | 9 | package com.owncloud.android.lib.resources.assistant.v2 10 | 11 | import com.nextcloud.common.NextcloudClient 12 | import com.nextcloud.operations.PostMethod 13 | import com.owncloud.android.lib.common.operations.RemoteOperation 14 | import com.owncloud.android.lib.common.operations.RemoteOperationResult 15 | import com.owncloud.android.lib.resources.assistant.v2.model.TaskTypeData 16 | import okhttp3.MediaType.Companion.toMediaTypeOrNull 17 | import okhttp3.RequestBody.Companion.toRequestBody 18 | import org.apache.commons.httpclient.HttpStatus 19 | 20 | class CreateTaskRemoteOperationV2( 21 | private val input: String, 22 | private val taskType: TaskTypeData 23 | ) : RemoteOperation() { 24 | override fun run(client: NextcloudClient): RemoteOperationResult { 25 | val inputField = hashMapOf("input" to input) 26 | 27 | val requestBody = 28 | hashMapOf( 29 | "input" to inputField, 30 | "type" to taskType.id, 31 | "appId" to "assistant", 32 | "customId" to "" 33 | ) 34 | 35 | val json = gson.toJson(requestBody) 36 | 37 | val request = json.toRequestBody("application/json".toMediaTypeOrNull()) 38 | 39 | val postMethod = PostMethod(client.baseUri.toString() + TAG_URL, true, request) 40 | 41 | val status = postMethod.execute(client) 42 | 43 | return if (status == HttpStatus.SC_OK) { 44 | RemoteOperationResult(true, postMethod) 45 | } else { 46 | RemoteOperationResult(false, postMethod) 47 | } 48 | } 49 | 50 | companion object { 51 | const val TAG_URL = "/ocs/v2.php/taskprocessing/schedule" 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /library/src/main/java/com/owncloud/android/lib/resources/assistant/v2/DeleteTaskRemoteOperationV2.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2024 Alper Ozturk 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | 9 | package com.owncloud.android.lib.resources.assistant.v2 10 | 11 | import com.nextcloud.common.NextcloudClient 12 | import com.nextcloud.operations.DeleteMethod 13 | import com.owncloud.android.lib.common.operations.RemoteOperation 14 | import com.owncloud.android.lib.common.operations.RemoteOperationResult 15 | import com.owncloud.android.lib.common.utils.Log_OC 16 | import java.io.IOException 17 | import java.net.HttpURLConnection 18 | 19 | class DeleteTaskRemoteOperationV2( 20 | private val appId: Long 21 | ) : RemoteOperation() { 22 | override fun run(client: NextcloudClient): RemoteOperationResult { 23 | var postMethod: DeleteMethod? = null 24 | var result: RemoteOperationResult 25 | try { 26 | postMethod = 27 | DeleteMethod( 28 | client.baseUri.toString() + DIRECT_ENDPOINT + appId, 29 | true 30 | ) 31 | val status = client.execute(postMethod) 32 | result = RemoteOperationResult(status == HttpURLConnection.HTTP_OK, postMethod) 33 | } catch (e: IOException) { 34 | result = RemoteOperationResult(e) 35 | Log_OC.e(TAG, "Deletion of task failed: " + result.logMessage, result.exception) 36 | } finally { 37 | postMethod?.releaseConnection() 38 | } 39 | 40 | return result 41 | } 42 | 43 | companion object { 44 | private val TAG = DeleteTaskRemoteOperationV2::class.java.simpleName 45 | private const val DIRECT_ENDPOINT = "/ocs/v2.php/taskprocessing/task/" 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /library/src/main/java/com/owncloud/android/lib/resources/assistant/v2/model/TaskList.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2024 Alper Ozturk 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | 9 | package com.owncloud.android.lib.resources.assistant.v2.model 10 | 11 | data class TaskList( 12 | var tasks: List 13 | ) 14 | 15 | data class Task( 16 | val id: Long, 17 | val type: String?, 18 | val status: String?, 19 | val userId: String?, 20 | val appId: String?, 21 | val input: TaskInput?, 22 | val output: TaskOutput?, 23 | val completionExpectedAt: Int? = null, 24 | var progress: Int? = null, 25 | val lastUpdated: Int? = null, 26 | val scheduledAt: Int? = null, 27 | val endedAt: Int? = null 28 | ) 29 | 30 | data class TaskInput( 31 | var input: String? = null 32 | ) 33 | 34 | data class TaskOutput( 35 | var output: String? = null 36 | ) 37 | -------------------------------------------------------------------------------- /library/src/main/java/com/owncloud/android/lib/resources/assistant/v2/model/TaskTypes.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2024 Alper Ozturk 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | 9 | package com.owncloud.android.lib.resources.assistant.v2.model 10 | 11 | data class TaskTypes( 12 | val types: Map 13 | ) 14 | 15 | data class TaskTypeData( 16 | val id: String?, 17 | val name: String?, 18 | val description: String?, 19 | val inputShape: TaskInputShape?, 20 | val outputShape: TaskOutputShape? 21 | ) 22 | 23 | data class TaskInputShape( 24 | val input: Shape? 25 | ) 26 | 27 | data class TaskOutputShape( 28 | val output: Shape? 29 | ) 30 | 31 | data class Shape( 32 | val name: String, 33 | val description: String, 34 | val type: String 35 | ) 36 | -------------------------------------------------------------------------------- /library/src/main/java/com/owncloud/android/lib/resources/e2ee/MetadataResponse.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2023-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2023 Tobias Kaminsky 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | package com.owncloud.android.lib.resources.e2ee 9 | 10 | data class MetadataResponse( 11 | val signature: String, 12 | val metadata: String 13 | ) 14 | -------------------------------------------------------------------------------- /library/src/main/java/com/owncloud/android/lib/resources/files/Chunk.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2023-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2023 ZetaTom <70907959+zetatom@users.noreply.github.com> 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | package com.owncloud.android.lib.resources.files 9 | 10 | data class Chunk( 11 | val id: Int, 12 | val start: Long, 13 | val length: Long 14 | ) 15 | -------------------------------------------------------------------------------- /library/src/main/java/com/owncloud/android/lib/resources/files/CreateLocalFileException.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2023-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2023 Álvaro Brey 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | package com.owncloud.android.lib.resources.files 9 | 10 | import java.io.IOException 11 | 12 | class CreateLocalFileException( 13 | val path: String, 14 | cause: Throwable 15 | ) : Exception(cause) { 16 | override val message: String = "File could not be created" 17 | 18 | /** 19 | * Checks if the path associated to the exception contains invalid characters. 20 | * There is no better way to check this, as `Paths` is not available in API < 26, and since this lib has a very low 21 | * minSdk, that can't even be worked around with an `if` block. 22 | */ 23 | fun isCausedByInvalidPath(): Boolean = 24 | cause is IOException && 25 | ( 26 | path.isEmpty() || 27 | INVALID_CHARS.any { 28 | path.contains(it) 29 | } 30 | ) 31 | 32 | companion object { 33 | private const val INVALID_CHARS = "\\:*?\"<>|" 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /library/src/main/java/com/owncloud/android/lib/resources/files/FileUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2015 ownCloud Inc. 5 | * SPDX-License-Identifier: MIT 6 | */ 7 | package com.owncloud.android.lib.resources.files; 8 | 9 | import java.io.File; 10 | import java.math.BigInteger; 11 | import java.security.MessageDigest; 12 | import java.security.NoSuchAlgorithmException; 13 | 14 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; 15 | 16 | public class FileUtils { 17 | 18 | private static final String TAG = FileUtils.class.getSimpleName(); 19 | 20 | public static final String PATH_SEPARATOR = "/"; 21 | 22 | 23 | public static String getParentPath(String remotePath) { 24 | String parentPath = new File(remotePath).getParent(); 25 | parentPath = parentPath.endsWith(PATH_SEPARATOR) ? parentPath : parentPath + PATH_SEPARATOR; 26 | return parentPath; 27 | } 28 | 29 | /** 30 | * Validate the fileName to detect if path separator "/" is used 31 | * 32 | * @param fileName name to check 33 | * @return true if if no path separator is used 34 | */ 35 | public static boolean isValidName(String fileName) { 36 | 37 | return !fileName.contains(PATH_SEPARATOR); 38 | } 39 | 40 | @SuppressFBWarnings("WEAK_MESSAGE_DIGEST_MD5") 41 | /* 42 | * ATTENTION: Do not use this for security critical purpose! 43 | */ 44 | public static String md5Sum(File file) throws NoSuchAlgorithmException { 45 | String temp = file.getName() + file.lastModified() + file.length(); 46 | 47 | MessageDigest messageDigest = MessageDigest.getInstance("MD5"); 48 | messageDigest.update(temp.getBytes()); 49 | byte[] digest = messageDigest.digest(); 50 | StringBuilder md5String = new StringBuilder(new BigInteger(1, digest).toString(16)); 51 | 52 | while (md5String.length() < 32) { 53 | md5String.insert(0, "0"); 54 | } 55 | 56 | return md5String.toString(); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /library/src/main/java/com/owncloud/android/lib/resources/files/model/FileLockType.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2022-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2022 Álvaro Brey 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | package com.owncloud.android.lib.resources.files.model 9 | 10 | enum class FileLockType( 11 | val value: Int 12 | ) { 13 | MANUAL(0), 14 | COLLABORATIVE(1), 15 | TOKEN(2); 16 | 17 | companion object { 18 | @JvmStatic 19 | fun fromValue(v: Int): FileLockType? = values().firstOrNull { it.value == v } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /library/src/main/java/com/owncloud/android/lib/resources/files/model/GeoLocation.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2023-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2023 Tobias Kaminsky 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | package com.owncloud.android.lib.resources.files.model 9 | 10 | data class GeoLocation( 11 | var latitude: Double = -1.0, 12 | var longitude: Double = -1.0 13 | ) 14 | -------------------------------------------------------------------------------- /library/src/main/java/com/owncloud/android/lib/resources/files/model/ImageDimension.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2023-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2023 Tobias Kaminsky 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | package com.owncloud.android.lib.resources.files.model 9 | 10 | data class ImageDimension( 11 | var width: Float = -1f, 12 | var height: Float = -1f 13 | ) 14 | -------------------------------------------------------------------------------- /library/src/main/java/com/owncloud/android/lib/resources/files/model/ServerFileInterface.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2018-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2018-2022 Tobias Kaminsky 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | package com.owncloud.android.lib.resources.files.model; 9 | 10 | public interface ServerFileInterface { 11 | 12 | String getFileName(); 13 | 14 | String getMimeType(); 15 | 16 | String getRemotePath(); 17 | 18 | long getLocalId(); 19 | 20 | String getRemoteId(); 21 | 22 | boolean isFavorite(); 23 | 24 | boolean isFolder(); 25 | 26 | long getFileLength(); 27 | } 28 | -------------------------------------------------------------------------------- /library/src/main/java/com/owncloud/android/lib/resources/notifications/models/Action.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2017 Andy Scherzinger 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | package com.owncloud.android.lib.resources.notifications.models 9 | 10 | /** 11 | * Action data model. 12 | */ 13 | class Action() { 14 | /** 15 | * Translated short label of the action/button that should be presented to the user. 16 | */ 17 | @JvmField 18 | var label: String? = null 19 | 20 | /** 21 | * A link that should be followed when the action is performed/clicked. 22 | */ 23 | @JvmField 24 | var link: String? = null 25 | 26 | /** 27 | * HTTP method that should be used for the request against the link: GET, POST, DELETE. 28 | */ 29 | @JvmField 30 | var type: String? = null 31 | 32 | /** 33 | * If the action is the primary action for the notification or not. 34 | */ 35 | @JvmField 36 | var primary = false 37 | 38 | constructor(label: String?, link: String?, type: String?, primary: Boolean) : this() { 39 | this.label = label 40 | this.link = link 41 | this.type = type 42 | this.primary = primary 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /library/src/main/java/com/owncloud/android/lib/resources/notifications/models/PushResponse.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2017 Mario Danic 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | package com.owncloud.android.lib.resources.notifications.models 9 | 10 | class PushResponse() { 11 | var publicKey: String? = null 12 | var deviceIdentifier: String? = null 13 | var signature: String? = null 14 | 15 | @Suppress("unused") // used by json parser 16 | constructor(publicKey: String?, deviceIdentifier: String?, signature: String?) : this() { 17 | this.publicKey = publicKey 18 | this.deviceIdentifier = deviceIdentifier 19 | this.signature = signature 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /library/src/main/java/com/owncloud/android/lib/resources/notifications/models/RichObject.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2017 Andy Scherzinger 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | package com.owncloud.android.lib.resources.notifications.models 9 | 10 | /** 11 | * Rich object data model providing rich data to be used within rich content, e.g. 12 | * in [Notification]s. 13 | */ 14 | class RichObject() { 15 | /** 16 | * A unique identifier for the object type. 17 | */ 18 | var type: String? = null 19 | 20 | /** 21 | * A short identifier of the object on the server (int or string). 22 | */ 23 | @JvmField 24 | var id: String? = null 25 | 26 | /** 27 | * A name which should be used in the visual representation. 28 | */ 29 | var name: String? = null 30 | 31 | constructor(type: String?, id: String?, name: String?) : this() { 32 | this.type = type 33 | this.id = id 34 | this.name = name 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /library/src/main/java/com/owncloud/android/lib/resources/shares/ShareUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2022-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2022 Tobias Kaminsky 6 | * SPDX-FileCopyrightText: 2015 ownCloud Inc. 7 | * SPDX-FileCopyrightText: 2014 masensio 8 | * SPDX-License-Identifier: MIT 9 | */ 10 | package com.owncloud.android.lib.resources.shares; 11 | 12 | /** 13 | * Contains Constants for Share Operation 14 | * 15 | * @author masensio 16 | * 17 | */ 18 | 19 | public class ShareUtils { 20 | 21 | // OCS Route 22 | public static final String SHARING_API_PATH = "/ocs/v2.php/apps/files_sharing/api/v1/shares"; 23 | 24 | public static final String INCLUDE_TAGS = "include_tags=true"; 25 | 26 | // String to build the link with the token of a share: 27 | public static final String SHARING_LINK_PATH_AFTER_VERSION_8 = "/index.php/s/"; 28 | 29 | public static String getSharingLinkPath() { 30 | return SHARING_LINK_PATH_AFTER_VERSION_8; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /library/src/main/java/com/owncloud/android/lib/resources/shares/SharedWithMe.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2022-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2022 Álvaro Brey 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | package com.owncloud.android.lib.resources.shares 9 | 10 | class SharedWithMe( 11 | val ownerUID: String?, 12 | val ownerDisplayName: String?, 13 | val note: String? 14 | ) 15 | -------------------------------------------------------------------------------- /library/src/main/java/com/owncloud/android/lib/resources/shares/ShareeUser.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2019 Tobias Kaminsky 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | package com.owncloud.android.lib.resources.shares 9 | 10 | import android.os.Parcelable 11 | import kotlinx.parcelize.Parcelize 12 | 13 | @Parcelize 14 | data class ShareeUser( 15 | val userId: String?, 16 | var displayName: String?, 17 | val shareType: ShareType? 18 | ) : Parcelable 19 | -------------------------------------------------------------------------------- /library/src/main/java/com/owncloud/android/lib/resources/status/CapabilityBooleanType.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2018-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2022 Álvaro Brey 6 | * SPDX-FileCopyrightText: 2015 ownCloud Inc. 7 | * SPDX-FileCopyrightText: 2014 masensio 8 | * SPDX-License-Identifier: MIT 9 | */ 10 | package com.owncloud.android.lib.resources.status 11 | 12 | /** 13 | * Enum for Boolean Type in OCCapability parameters, with values: 14 | * -1 - Unknown 15 | * 0 - False 16 | * 1 - True 17 | */ 18 | enum class CapabilityBooleanType( 19 | val value: Int 20 | ) { 21 | UNKNOWN(-1), 22 | FALSE(0), 23 | TRUE(1); 24 | 25 | val isUnknown: Boolean 26 | get() = value == -1 27 | val isFalse: Boolean 28 | get() = value == 0 29 | val isTrue: Boolean 30 | get() = value == 1 31 | 32 | companion object { 33 | @JvmStatic 34 | fun fromValue(value: Int): CapabilityBooleanType = 35 | when (value) { 36 | -1 -> UNKNOWN 37 | 0 -> FALSE 38 | 1 -> TRUE 39 | else -> UNKNOWN 40 | } 41 | 42 | @JvmStatic 43 | fun fromBooleanValue(boolValue: Boolean): CapabilityBooleanType = 44 | when { 45 | boolValue -> TRUE 46 | else -> FALSE 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /library/src/main/java/com/owncloud/android/lib/resources/status/E2EVersion.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2023-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2023 Tobias Kaminsky 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | package com.owncloud.android.lib.resources.status 9 | 10 | enum class E2EVersion( 11 | val value: String 12 | ) { 13 | V1_0("1.0"), 14 | V1_1("1.1"), 15 | V1_2("1.2"), 16 | V2_0("2.0"), 17 | UNKNOWN(""); 18 | 19 | companion object { 20 | @JvmStatic 21 | fun fromValue(v: String): E2EVersion = E2EVersion.values().firstOrNull { it.value == v } ?: UNKNOWN 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /library/src/main/java/com/owncloud/android/lib/resources/status/NextcloudVersion.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2020-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2020 Tobias Kaminsky 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | package com.owncloud.android.lib.resources.status 9 | 10 | class NextcloudVersion : OwnCloudVersion { 11 | companion object { 12 | @JvmField 13 | val nextcloud_21 = NextcloudVersion(0x15000000) // 21.0 14 | 15 | @JvmField 16 | val nextcloud_22 = NextcloudVersion(0x16000000) // 22.0 17 | 18 | @JvmField 19 | val nextcloud_23 = NextcloudVersion(0x17000000) // 23.0 20 | 21 | @JvmField 22 | val nextcloud_24 = NextcloudVersion(0x18000000) // 24.0 23 | 24 | @JvmField 25 | val nextcloud_25 = NextcloudVersion(0x19000000) // 25.0 26 | 27 | @JvmField 28 | val nextcloud_26 = NextcloudVersion(0x1A000000) // 26.0 29 | 30 | @JvmField 31 | val nextcloud_27 = NextcloudVersion(0x1B000000) // 27.0 32 | 33 | @JvmField 34 | val nextcloud_28 = NextcloudVersion(0x1C000000) // 28.0 35 | 36 | @JvmField 37 | val nextcloud_29 = NextcloudVersion(0x1D000000) // 29.0 38 | 39 | @JvmField 40 | val nextcloud_30 = NextcloudVersion(0x1E000000) // 30.0 41 | 42 | @JvmField 43 | val nextcloud_31 = NextcloudVersion(0x1F000000) // 31.0 44 | } 45 | 46 | constructor(string: String) : super(string) 47 | constructor(version: Int) : super(version) 48 | } 49 | -------------------------------------------------------------------------------- /library/src/main/java/com/owncloud/android/lib/resources/status/Problem.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2023-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2023 Tobias Kaminsky 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | package com.owncloud.android.lib.resources.status 9 | 10 | data class Problem( 11 | val type: String, 12 | val count: Int, 13 | val oldestTimestamp: Long 14 | ) { 15 | fun toJsonWithTypeString(): String = """"$type": {"count": $count, "oldest": $oldestTimestamp}""" 16 | } 17 | -------------------------------------------------------------------------------- /library/src/main/java/com/owncloud/android/lib/resources/tags/CreateTagRemoteOperation.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2023-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2023 Tobias Kaminsky 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | package com.owncloud.android.lib.resources.tags 9 | 10 | import com.google.gson.Gson 11 | import com.nextcloud.common.NextcloudClient 12 | import com.nextcloud.operations.PostMethod 13 | import com.owncloud.android.lib.common.operations.RemoteOperation 14 | import com.owncloud.android.lib.common.operations.RemoteOperationResult 15 | import okhttp3.MediaType.Companion.toMediaTypeOrNull 16 | import okhttp3.RequestBody 17 | import org.apache.commons.httpclient.HttpStatus 18 | 19 | class CreateTagRemoteOperation( 20 | val name: String 21 | ) : RemoteOperation() { 22 | override fun run(client: NextcloudClient): RemoteOperationResult { 23 | val map = HashMap() 24 | map["name"] = name 25 | 26 | val json = Gson().toJson(map) 27 | 28 | val request = RequestBody.create("application/json".toMediaTypeOrNull(), json) 29 | 30 | val postMethod = PostMethod(client.baseUri.toString() + TAG_URL, true, request) 31 | 32 | val status = postMethod.execute(client) 33 | 34 | return if (status == HttpStatus.SC_CREATED) { 35 | RemoteOperationResult(true, postMethod) 36 | } else { 37 | RemoteOperationResult(false, postMethod) 38 | } 39 | } 40 | 41 | companion object { 42 | const val TAG_URL = "/remote.php/dav/systemtags/" 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /library/src/main/java/com/owncloud/android/lib/resources/tags/PutTagRemoteOperation.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2023-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2023 Tobias Kaminsky 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | package com.owncloud.android.lib.resources.tags 9 | 10 | import com.nextcloud.common.NextcloudClient 11 | import com.nextcloud.operations.PutMethod 12 | import com.owncloud.android.lib.common.operations.RemoteOperation 13 | import com.owncloud.android.lib.common.operations.RemoteOperationResult 14 | import okhttp3.RequestBody 15 | import okhttp3.RequestBody.Companion.toRequestBody 16 | import okhttp3.internal.EMPTY_BYTE_ARRAY 17 | import org.apache.commons.httpclient.HttpStatus 18 | 19 | class PutTagRemoteOperation( 20 | val id: String, 21 | val fileId: Long 22 | ) : RemoteOperation() { 23 | override fun run(client: NextcloudClient): RemoteOperationResult { 24 | val empty: RequestBody = EMPTY_BYTE_ARRAY.toRequestBody() 25 | val putMethod = 26 | PutMethod( 27 | client.baseUri.toString() + TAG_URL + fileId + "/" + id, 28 | true, 29 | empty 30 | ) 31 | 32 | val status = putMethod.execute(client) 33 | 34 | return if (status == HttpStatus.SC_CREATED) { 35 | RemoteOperationResult(true, putMethod) 36 | } else { 37 | RemoteOperationResult(false, putMethod) 38 | } 39 | } 40 | 41 | companion object { 42 | const val TAG_URL = "/remote.php/dav/systemtags-relations/files/" 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /library/src/main/java/com/owncloud/android/lib/resources/tags/Tag.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2023-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2023 Tobias Kaminsky 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | package com.owncloud.android.lib.resources.tags 9 | 10 | data class Tag( 11 | val id: String, 12 | val name: String, 13 | val color: String? 14 | ) 15 | -------------------------------------------------------------------------------- /library/src/main/java/com/owncloud/android/lib/resources/users/AppPassword.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2021-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2021 Tobias Kaminsky 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | package com.owncloud.android.lib.resources.users 9 | 10 | import com.google.gson.annotations.SerializedName 11 | 12 | class AppPassword( 13 | @SerializedName("apppassword") val appPassword: String 14 | ) 15 | -------------------------------------------------------------------------------- /library/src/main/java/com/owncloud/android/lib/resources/users/ClearAt.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2020-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2020 Tobias Kaminsky 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | package com.owncloud.android.lib.resources.users 9 | 10 | class ClearAt( 11 | val type: String, 12 | val time: String 13 | ) 14 | -------------------------------------------------------------------------------- /library/src/main/java/com/owncloud/android/lib/resources/users/PredefinedStatus.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2020-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2020 Tobias Kaminsky 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | package com.owncloud.android.lib.resources.users 9 | 10 | class PredefinedStatus( 11 | val id: String, 12 | val icon: String, 13 | val message: String, 14 | val clearAt: ClearAt? 15 | ) 16 | -------------------------------------------------------------------------------- /library/src/main/java/com/owncloud/android/lib/resources/users/Status.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2020-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2020 Tobias Kaminsky 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | package com.owncloud.android.lib.resources.users 9 | 10 | import android.os.Parcel 11 | import android.os.Parcelable 12 | 13 | class Status( 14 | val status: StatusType, 15 | val message: String?, 16 | val icon: String, 17 | val clearAt: Long 18 | ) : Parcelable { 19 | constructor(parcel: Parcel) : this( 20 | StatusType.valueOf(parcel.readString().orEmpty()), 21 | parcel.readString(), 22 | parcel.readString().orEmpty(), 23 | parcel.readLong() 24 | ) 25 | 26 | override fun writeToParcel( 27 | parcel: Parcel, 28 | flags: Int 29 | ) { 30 | parcel.writeString(status.name) 31 | parcel.writeString(message) 32 | parcel.writeString(icon) 33 | parcel.writeLong(clearAt) 34 | } 35 | 36 | override fun describeContents(): Int = 0 37 | 38 | companion object CREATOR : Parcelable.Creator { 39 | override fun createFromParcel(parcel: Parcel): Status = Status(parcel) 40 | 41 | override fun newArray(size: Int): Array = arrayOfNulls(size) 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /library/src/main/java/com/owncloud/android/lib/resources/users/StatusType.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2020-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2020 Tobias Kaminsky 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | package com.owncloud.android.lib.resources.users 9 | 10 | import com.google.gson.annotations.SerializedName 11 | 12 | enum class StatusType( 13 | val string: String 14 | ) { 15 | @SerializedName("online") 16 | ONLINE("online"), 17 | 18 | @SerializedName("offline") 19 | OFFLINE("offline"), 20 | 21 | @SerializedName("dnd") 22 | DND("dnd"), 23 | 24 | @SerializedName("away") 25 | AWAY("away"), 26 | 27 | @SerializedName("invisible") 28 | INVISIBLE("invisible") 29 | } 30 | -------------------------------------------------------------------------------- /library/src/main/java/org/apache/commons/httpclient/methods/Utf8PostMethod.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2020-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2020 Tobias Kaminsky 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | package org.apache.commons.httpclient.methods; 9 | 10 | public class Utf8PostMethod extends PostMethod { 11 | public Utf8PostMethod(String uri) { 12 | super(uri); 13 | getParams().setContentCharset("utf-8"); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /library/src/main/res/values-hu-rHU/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | A fiók már létezik, mikor létrehozza azt. 4 | Másik fiókkal jelentkezett be mint amelyik frissül 5 | Helytelen Nextcloud verzió a szerveren 6 | Időtúllépési hiba 7 | Hiba a fiók használata alatt 8 | A fájl hozzáférése blokkolt egy másik felhasználó vagy folyamat által 9 | A helyi fájl nem létezik 10 | HTTP hiba 11 | Nextcloud szerver nincs beállítva 12 | A fájlnév tiltott karaktert tartalmaz 13 | JSON hiba 14 | A helyi tároló megtelt 15 | Hiba a fájl mozgatása közben 16 | URL formátum hiba 17 | Telepíteni akarja a TLS kliens tanusítványát\? 18 | Nincs hálózati kapcsolat 19 | Nextcloud kapcsolat 20 | Válassza ki a kliens tanúsítványtát %1$s:%2$d 21 | 22 | -------------------------------------------------------------------------------- /library/src/main/res/values-pl/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Konto już istnieje 4 | Uwierzytelniono inne konto niż to użyte do aktualizacji 5 | Na serwerze nie znaleziono wymaganej wersji Nextcloud 6 | Przekroczono limit czasu połączenia 7 | Plik jest aktualnie otwarty przez innego użytkownika lub proces 8 | Plik lokalny nie istnieje 9 | Naruszenie protokołu HTTP 10 | Serwer Nextcloud nie został skonfigurowany! 11 | Pamięć lokalna pełna 12 | Czy chcesz zainstalować certyfikat klienta TLS\? 13 | Brak połączenia sieciowego 14 | Połączenie Nextcloud 15 | Wybierz certyfikat klienta dla %1$s:%2$d 16 | Wybierz certyfikat klienta 17 | Operacja anulowana przez dzwoniącego 18 | Operacja anulowana przez dzwoniącego 19 | Zapytanie HTTP nie powiodło się z kodem: %1$d (%2$s) 20 | Wyjątek 21 | Nie znaleziono certyfikatu klienta 22 | 23 | -------------------------------------------------------------------------------- /library/src/main/res/values/empty.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | -------------------------------------------------------------------------------- /library/src/test/java/com/nextcloud/common/ClockStub.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2022-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2022 Álvaro Brey 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | package com.nextcloud.common 9 | 10 | import com.nextcloud.android.lib.core.Clock 11 | 12 | class ClockStub( 13 | private val currentTimeValue: Long 14 | ) : Clock { 15 | override val currentTimeMillis: Long 16 | get() = currentTimeValue 17 | } 18 | -------------------------------------------------------------------------------- /library/src/test/java/com/owncloud/android/lib/resources/files/FileUtilsTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2019-2022 Tobias Kaminsky 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | package com.owncloud.android.lib.resources.files; 9 | 10 | import static org.junit.Assert.assertEquals; 11 | import static org.junit.Assert.assertTrue; 12 | 13 | import org.junit.Test; 14 | 15 | import java.io.File; 16 | import java.io.FileWriter; 17 | import java.io.IOException; 18 | import java.security.NoSuchAlgorithmException; 19 | import java.util.Random; 20 | import java.util.regex.Pattern; 21 | 22 | public class FileUtilsTest { 23 | 24 | @Test 25 | public void md5Sum() throws IOException, NoSuchAlgorithmException { 26 | Pattern pattern = Pattern.compile("^[0-9a-f]*$", Pattern.CASE_INSENSITIVE); 27 | File file; 28 | 29 | for (int i = 0; i < 10; i++) { 30 | file = new File("test"); 31 | FileWriter writer = new FileWriter(file); 32 | 33 | for (int j = 0; j < new Random().nextInt(100); j++) { 34 | writer.write("123123123123123123123123123\n"); 35 | } 36 | writer.flush(); 37 | writer.close(); 38 | 39 | String md5sum = FileUtils.md5Sum(file); 40 | 41 | System.out.println(md5sum); 42 | 43 | assertEquals(32, md5sum.length()); 44 | assertTrue(md5sum, pattern.matcher(md5sum).matches()); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /library/src/test/java/com/owncloud/android/lib/resources/status/CapabilityBooleanTypeTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2020-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2020-2023 Tobias Kaminsky 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | package com.owncloud.android.lib.resources.status; 9 | 10 | import static org.junit.Assert.assertTrue; 11 | 12 | import org.junit.Test; 13 | 14 | public class CapabilityBooleanTypeTest { 15 | 16 | @Test 17 | public void test() { 18 | assertTrue(CapabilityBooleanType.fromBooleanValue(true).isTrue()); 19 | assertTrue(CapabilityBooleanType.fromBooleanValue(false).isFalse()); 20 | 21 | assertTrue(CapabilityBooleanType.fromValue(-2).isUnknown()); 22 | assertTrue(CapabilityBooleanType.fromValue(-1).isUnknown()); 23 | assertTrue(CapabilityBooleanType.fromValue(-0).isFalse()); 24 | assertTrue(CapabilityBooleanType.fromValue(1).isTrue()); 25 | assertTrue(CapabilityBooleanType.fromValue(2).isUnknown()); 26 | 27 | assertTrue(CapabilityBooleanType.valueOf("UNKNOWN").isUnknown()); 28 | assertTrue(CapabilityBooleanType.valueOf("FALSE").isFalse()); 29 | assertTrue(CapabilityBooleanType.valueOf("TRUE").isTrue()); 30 | } 31 | 32 | @Test(expected = IllegalArgumentException.class) 33 | public void testException() { 34 | CapabilityBooleanType.valueOf("wrongValue"); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /library/src/test/java/com/owncloud/android/lib/resources/status/OCCapabilityTest.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2022-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2022 Álvaro Brey 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | package com.owncloud.android.lib.resources.status 9 | 10 | import org.junit.Test 11 | 12 | class OCCapabilityTest { 13 | /** 14 | * This won't compile if the fields below are not nullable. This is sort of redundant, 15 | * but it's meant to prevent a crash in client apps when trying to assign null from Java. 16 | */ 17 | @Test 18 | fun testFieldNullability() { 19 | OCCapability().apply { 20 | accountName = null 21 | versionString = null 22 | versionEdition = null 23 | serverName = null 24 | serverSlogan = null 25 | serverColor = null 26 | serverTextColor = null 27 | serverElementColor = null 28 | serverElementColorBright = null 29 | serverElementColorDark = null 30 | serverLogo = null 31 | serverBackground = null 32 | richDocumentsMimeTypeList = null 33 | richDocumentsOptionalMimeTypeList = null 34 | richDocumentsProductName = null 35 | directEditingEtag = null 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /library/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker: -------------------------------------------------------------------------------- 1 | mock-maker-inline 2 | -------------------------------------------------------------------------------- /renovate.json5: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://docs.renovatebot.com/renovate-schema.json", 3 | "extends": [ 4 | "config:recommended", 5 | ":gitSignOff" 6 | ], 7 | "timezone": "Europe/Berlin", 8 | "labels": [ 9 | "dependencies", 10 | "3. to review" 11 | ], 12 | } 13 | -------------------------------------------------------------------------------- /sample_client/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nextcloud/android-library/13fb6e486d82696073cc1a56a8ff8371bba690de/sample_client/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /sample_client/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2018-2024 Nextcloud GmbH and Nextcloud contributors 2 | # SPDX-License-Identifier: MIT 3 | #Tue Apr 03 16:56:17 CEST 2018 4 | distributionBase=GRADLE_USER_HOME 5 | distributionPath=wrapper/dists 6 | zipStoreBase=GRADLE_USER_HOME 7 | zipStorePath=wrapper/dists 8 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.2-all.zip 9 | -------------------------------------------------------------------------------- /sample_client/lint.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /sample_client/src/androidTest/java/com/owncloud/android/lib/sampleclient/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2022-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2022 Tobias Kaminsky 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | package com.owncloud.android.lib.sampleclient; 9 | 10 | import static org.junit.Assert.assertEquals; 11 | 12 | import android.content.Context; 13 | 14 | import androidx.test.ext.junit.runners.AndroidJUnit4; 15 | import androidx.test.platform.app.InstrumentationRegistry; 16 | 17 | import org.junit.Test; 18 | import org.junit.runner.RunWith; 19 | 20 | @RunWith(AndroidJUnit4.class) 21 | public class ExampleInstrumentedTest { 22 | @Test 23 | public void useAppContext() { 24 | // Context of the app under test. 25 | Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); 26 | assertEquals("com.owncloud.android.lib.sampleclient", appContext.getPackageName()); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /sample_client/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 17 | 18 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /sample_client/src/main/assets/nc_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nextcloud/android-library/13fb6e486d82696073cc1a56a8ff8371bba690de/sample_client/src/main/assets/nc_logo.png -------------------------------------------------------------------------------- /sample_client/src/main/java/com/owncloud/android/lib/sampleclient/FilesArrayAdapter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Library 3 | * 4 | * SPDX-FileCopyrightText: 2015 ownCloud Inc. 5 | * SPDX-FileCopyrightText: 2015 David A. Velasco 6 | * SPDX-License-Identifier: MIT 7 | */ 8 | package com.owncloud.android.lib.sampleclient; 9 | 10 | import android.content.Context; 11 | import android.view.View; 12 | import android.view.ViewGroup; 13 | import android.widget.ArrayAdapter; 14 | import android.widget.TextView; 15 | 16 | import com.owncloud.android.lib.resources.files.model.RemoteFile; 17 | 18 | public class FilesArrayAdapter extends ArrayAdapter { 19 | 20 | public FilesArrayAdapter(Context context, int resource) { 21 | super(context, resource); 22 | } 23 | 24 | public View getView(int position, View convertView, ViewGroup parent) { 25 | TextView textView = (TextView)super.getView(position, convertView, parent); 26 | textView.setText(getItem(position).getRemotePath()); 27 | return textView; 28 | } 29 | } 30 | 31 | -------------------------------------------------------------------------------- /sample_client/src/main/res/drawable-v26/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 8 | 13 | 16 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /sample_client/src/main/res/layout/file_in_list.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 12 | -------------------------------------------------------------------------------- /sample_client/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /sample_client/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nextcloud/android-library/13fb6e486d82696073cc1a56a8ff8371bba690de/sample_client/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample_client/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nextcloud/android-library/13fb6e486d82696073cc1a56a8ff8371bba690de/sample_client/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample_client/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nextcloud/android-library/13fb6e486d82696073cc1a56a8ff8371bba690de/sample_client/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample_client/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nextcloud/android-library/13fb6e486d82696073cc1a56a8ff8371bba690de/sample_client/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample_client/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nextcloud/android-library/13fb6e486d82696073cc1a56a8ff8371bba690de/sample_client/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample_client/src/main/res/values-v11/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 16 | 17 | 22 | 23 | -------------------------------------------------------------------------------- /sample_client/src/main/res/values/dimensions.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 120dp 11 | 12 | -------------------------------------------------------------------------------- /sample_client/src/main/res/values/setup.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | Mozilla/5.0 (Android) ownCloud sample 14 | 15 | -------------------------------------------------------------------------------- /sample_client/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | Nextcloud Sample Client 11 | Refresh 12 | Upload 13 | Delete remote file 14 | Download 15 | Delete local file 16 | You\'re doing it wrong 17 | TODO: start refresh 18 | TODO: start upload 19 | TODO: start remote deletion 20 | TODO: start download 21 | TODO: start local deletion 22 | TODO: operation finished in success 23 | TODO: operation finished in fail 24 | to_upload 25 | downloaded 26 | Sample file could not be saved in temporal folder; upload will not work 27 | nc_logo.png 28 | image/png 29 | Downloaded file could not be deleted 30 | 31 | -------------------------------------------------------------------------------- /sample_client/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 16 | 17 | 22 | 23 | -------------------------------------------------------------------------------- /scripts/analysis/detectSNAPSHOT.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors 4 | # SPDX-FileCopyrightText: 2017 Tobias Kaminsky 5 | # SPDX-License-Identifier: GPL-3.0-or-later 6 | 7 | count=$(./gradlew dependencies | grep SNAPSHOT -c) 8 | 9 | if [ $count -eq 0 ] ; then 10 | exit 0 11 | else 12 | exit 1 13 | fi 14 | 15 | -------------------------------------------------------------------------------- /scripts/analysis/findbugs-results.txt: -------------------------------------------------------------------------------- 1 | 167 -------------------------------------------------------------------------------- /scripts/analysis/getBranchBase.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors 4 | # SPDX-FileCopyrightText: 2017 Tobias Kaminsky 5 | # SPDX-License-Identifier: GPL-3.0-or-later 6 | 7 | # $1: username, $2: password/token, $3: pull request number 8 | 9 | if [ -z $3 ] ; then 10 | echo "master"; 11 | else 12 | curl 2>/dev/null -u $1:$2 https://api.github.com/repos/nextcloud/android-library/pulls/$3 | jq .base.ref 13 | fi 14 | -------------------------------------------------------------------------------- /scripts/analysis/getBranchName.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors 4 | # SPDX-FileCopyrightText: 2017 Tobias Kaminsky 5 | # SPDX-License-Identifier: GPL-3.0-or-later 6 | 7 | # $1: username, $2: password/token, $3: pull request number 8 | 9 | if [ -z $3 ] ; then 10 | echo "master"; 11 | else 12 | curl 2>/dev/null -u $1:$2 https://api.github.com/repos/nextcloud/android-library/pulls/$3 | grep \"ref\": | grep -v '"master"' | cut -d"\"" -f4 13 | fi 14 | -------------------------------------------------------------------------------- /scripts/analysis/spotbugs-filter.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /scripts/analysis/spotbugs-up.rb: -------------------------------------------------------------------------------- 1 | ## Script originally from https://github.com/tir38/android-lint-entropy-reducer at 07.05.2017 2 | # heavily modified since then 3 | 4 | # SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors 5 | # SPDX-FileCopyrightText: 2017 Jason Atwood 6 | # SPDX-FileCopyrightText: 2017 Tobias Kaminsky 7 | # SPDX-License-Identifier: GPL-3.0-or-later 8 | 9 | Encoding.default_external = Encoding::UTF_8 10 | Encoding.default_internal = Encoding::UTF_8 11 | 12 | puts "=================== starting Android Spotbugs Entropy Reducer ====================" 13 | 14 | # get args 15 | base_branch = ARGV[0] 16 | 17 | require 'fileutils' 18 | require 'pathname' 19 | require 'open3' 20 | 21 | # run Spotbugs 22 | puts "running Spotbugs..." 23 | system './gradlew spotbugsDebug' 24 | 25 | # find number of warnings 26 | current_warning_count = `./scripts/analysis/spotbugsSummary.py --file library/build/reports/spotbugs/debug.xml --total`.to_i 27 | puts "found warnings: " + current_warning_count.to_s 28 | 29 | # get warning counts from target branch 30 | previous_xml = "/tmp/#{base_branch}.xml" 31 | previous_results = File.file?(previous_xml) 32 | 33 | if previous_results == true 34 | previous_warning_count = `./scripts/analysis/spotbugsSummary.py --total --file #{previous_xml}`.to_i 35 | puts "previous warnings: " + previous_warning_count.to_s 36 | end 37 | 38 | # compare previous warning count with current warning count 39 | if previous_results == true && current_warning_count > previous_warning_count 40 | puts "FAIL: warning count increased" 41 | exit 1 42 | end 43 | 44 | # check if warning and error count stayed the same 45 | if previous_results == true && current_warning_count == previous_warning_count 46 | puts "SUCCESS: count stayed the same" 47 | exit 0 48 | end 49 | 50 | # warning count DECREASED 51 | if previous_results == true && current_warning_count < previous_warning_count 52 | puts "SUCCESS: count decreased from " + previous_warning_count.to_s + " to " + current_warning_count.to_s 53 | end 54 | -------------------------------------------------------------------------------- /scripts/deleteOutdatedComments.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors 4 | # SPDX-FileCopyrightText: 2017 Tobias Kaminsky 5 | # SPDX-License-Identifier: GPL-3.0-or-later 6 | 7 | BRANCH=$1 8 | TYPE=$2 9 | PR=$3 10 | GITHUB_USER=$4 11 | GITHUB_PASSWORD=$5 12 | BRANCH_TYPE=$BRANCH-$TYPE 13 | REPO="android-library" 14 | 15 | # delete all old comments, matching this type 16 | oldComments=$(curl 2>/dev/null -u $GITHUB_USER:$GITHUB_PASSWORD -X GET https://api.github.com/repos/nextcloud/$REPO/issues/$PR/comments | jq --arg TYPE $BRANCH_TYPE '.[] | (.id |tostring) + "|" + (.user.login | test("nextcloud-android-bot") | tostring) + "|" + (.body | test([$TYPE]) | tostring)'| grep "true|true" | tr -d "\"" | cut -f1 -d"|") 17 | 18 | echo $oldComments | while read comment ; do 19 | curl 2>/dev/null -u $GITHUB_USER:$GITHUB_PASSWORD -X DELETE https://api.github.com/repos/nextcloud/$REPO/issues/comments/$comment 20 | done 21 | 22 | exit 0 23 | -------------------------------------------------------------------------------- /scripts/hooks/pre-commit: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Pre-commit hook: don't allow commits if detekt or ktlint fail. Skip with "git commit --no-verify". 3 | 4 | # SPDX-FileCopyrightText: 2021-2024 Nextcloud GmbH and Nextcloud contributors 5 | # SPDX-FileCopyrightText: 2021 Álvaro Brey Vilas 6 | # SPDX-License-Identifier: GPL-3.0-or-later 7 | 8 | echo "Running pre-commit checks..." 9 | 10 | if ! ./gradlew --daemon spotlessKotlinCheck &>/dev/null; then 11 | echo >&2 "ktlint failed! Run ./gradlew spotlessKotlinCheck for details" 12 | echo >&2 "Hint: fix most lint errors with ./gradlew spotlessKotlinApply" 13 | exit 1 14 | fi 15 | 16 | if ! ./gradlew --daemon detekt &>/dev/null; then 17 | echo >&2 "Detekt failed! See report at file://$(pwd)/library/build/reports/detekt/detekt.html" 18 | exit 1 19 | fi 20 | -------------------------------------------------------------------------------- /scripts/hooks/pre-push: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Pre-push: Don't allow commits without Signed-off-by. Skip with "git push --no-verify". 3 | 4 | # SPDX-FileCopyrightText: 2021-2024 Nextcloud GmbH and Nextcloud contributors 5 | # SPDX-FileCopyrightText: 2021 Álvaro Brey Vilas 6 | # SPDX-License-Identifier: GPL-3.0-or-later 7 | 8 | set -euo pipefail 9 | 10 | z40=0000000000000000000000000000000000000000 # magic deleted ref 11 | 12 | while read local_ref local_sha remote_ref remote_sha; do 13 | if [ "$local_sha" != $z40 ]; then 14 | if [ "$remote_sha" = $z40 ]; then 15 | # New branch, examine all commits 16 | range="$(git merge-base master $local_sha)..$local_sha" 17 | else 18 | # Update to existing branch, examine new commits 19 | range="$remote_sha..$local_sha" 20 | fi 21 | 22 | # Check for commits without sign-off 23 | commit=$(git rev-list --no-merges --grep 'Signed-off-by' --invert-grep "$range") 24 | if [ -n "$commit" ]; then 25 | echo >&2 "Found commits without sign-off in $local_ref. Aborting push. Offending commits:" 26 | echo >&2 "$commit" 27 | exit 1 28 | fi 29 | fi 30 | done 31 | 32 | exit 0 33 | -------------------------------------------------------------------------------- /scripts/lib.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # Nextcloud Android Library 4 | # SPDX-FileCopyrightText: 2022-2024 Nextcloud GmbH and Nextcloud contributors 5 | # SPDX-FileCopyrightText: 2022 Álvaro Brey 6 | # SPDX-License-Identifier: MIT 7 | 8 | ## This file is intended to be sourced by other scripts 9 | 10 | 11 | function err() { 12 | echo >&2 "$@" 13 | } 14 | 15 | 16 | function curl_gh() { 17 | if [[ -n "$GITHUB_TOKEN" ]] 18 | then 19 | curl \ 20 | --silent \ 21 | --header "Authorization: token $GITHUB_TOKEN" \ 22 | "$@" 23 | else 24 | err "WARNING: No GITHUB_TOKEN found. Skipping API call" 25 | fi 26 | 27 | } 28 | -------------------------------------------------------------------------------- /scripts/uploadReport.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors 4 | # SPDX-FileCopyrightText: 2017 Tobias Kaminsky 5 | # SPDX-License-Identifier: GPL-3.0-or-later 6 | 7 | USER=$1 8 | PASS=$2 9 | ID=$3 10 | BRANCH=$4 11 | TYPE=$5 12 | PR_ID=$6 13 | GIT_USERNAME=$7 14 | GIT_TOKEN=$8 15 | REMOTE_FOLDER=$ID-$TYPE-$BRANCH-$(date +%H-%M) 16 | BRANCH_TYPE=$BRANCH-$TYPE 17 | URL=https://nextcloud.kaminsky.me/remote.php/dav/files/$USER/android-library-integrationTests 18 | 19 | # upload logcat 20 | log_filename=$ID"_logcat.txt.xz" 21 | log_file="${log_filename}" 22 | upload_path="https://nextcloud.kaminsky.me/remote.php/webdav/library-logcat/$log_filename" 23 | xz logcat.txt 24 | mv logcat.txt.xz "$log_file" 25 | curl -u "$USER:$PASS" -X PUT "$upload_path" --upload-file "$log_file" 26 | echo >&2 "Uploaded logcat to https://www.kaminsky.me/nc-dev/library-logcat/$log_filename" 27 | 28 | if [ $TYPE = "IT" ]; then 29 | cd library/build/reports/androidTests/connected 30 | else 31 | cd library/build/reports/tests/testDebugUnitTest 32 | fi 33 | 34 | if [ $? -ne 0 ]; then 35 | echo "No reports folder available! Perhaps compilation failed." 36 | exit 1 37 | fi 38 | 39 | find . -type d -exec curl -u $USER:$PASS -X MKCOL $URL/$REMOTE_FOLDER/$(echo {} | sed s#\./##) \; 40 | find . -type f -exec curl -u $USER:$PASS -X PUT $URL/$REMOTE_FOLDER/$(echo {} | sed s#\./##) --upload-file {} \; 41 | 42 | echo "Uploaded failing library tests to https://www.kaminsky.me/nc-dev/android-library-integrationTests/$REMOTE_FOLDER" 43 | 44 | curl -u $GIT_USERNAME:$GIT_TOKEN -X POST https://api.github.com/repos/nextcloud/android-library/issues/$PR_ID/comments -d "{ \"body\" : \"$BRANCH_TYPE test failed: https://www.kaminsky.me/nc-dev/android-library-integrationTests/$REMOTE_FOLDER/debug/ \" }" 45 | exit 1 46 | -------------------------------------------------------------------------------- /scripts/wait_for_emulator.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # SPDX-FileCopyrightText: Ralf Kistner 4 | # SPDX-License-Identifier: CC0-1.0 5 | 6 | # Originally written by Ralf Kistner , but placed in the public domain 7 | 8 | bootanim="" 9 | failcounter=0 10 | checkcounter=0 11 | 12 | until [[ "$bootanim" =~ "stopped" ]]; do 13 | bootanim=`adb -e shell getprop init.svc.bootanim 2>&1` 14 | echo "($checkcounter) $bootanim" 15 | if [[ "$bootanim" =~ "not found" ]]; then 16 | let "failcounter += 1" 17 | if [[ $failcounter -gt 3 ]]; then 18 | echo "Failed to start emulator" 19 | exit 1 20 | fi 21 | fi 22 | let "checkcounter += 1" 23 | sleep 10 24 | done 25 | echo "($checkcounter) Done" 26 | adb -e shell input keyevent 82 27 | echo "($checkcounter) Unlocked emulator screen" -------------------------------------------------------------------------------- /scripts/wait_for_server.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors 4 | # SPDX-FileCopyrightText: 2017 Tobias Kaminsky 5 | # SPDX-License-Identifier: GPL-3.0-or-later 6 | 7 | counter=0 8 | status="" 9 | 10 | until [[ $status = "false" ]]; do 11 | status=$(curl 2>/dev/null "http://$1/status.php" | jq .maintenance) 12 | 13 | echo "($counter) $status" 14 | 15 | if [[ "$status" =~ "false" || "$status" = "" ]]; then 16 | let "counter += 1" 17 | if [[ $counter -gt 50 ]]; then 18 | echo "Failed to wait for server" 19 | exit 1 20 | fi 21 | fi 22 | 23 | sleep 10 24 | done 25 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * Nextcloud Android Common Library 3 | * 4 | * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors 5 | * SPDX-FileCopyrightText: 2022 Tobias Kaminsky 6 | * SPDX-FileCopyrightText: 2022 Álvaro Brey Vilas 7 | * SPDX-License-Identifier: MIT 8 | */ 9 | include ':library' 10 | include ':sample_client' 11 | --------------------------------------------------------------------------------