Răsfoiți Sursa

Add toNextcloudClient extension to OwnCloudClient

Signed-off-by: ZetaTom <70907959+ZetaTom@users.noreply.github.com>
ZetaTom 1 an în urmă
părinte
comite
2c3b42445b

+ 37 - 0
app/src/main/java/com/nextcloud/utils/extensions/OwnCloudClientExtensions.kt

@@ -0,0 +1,37 @@
+/*
+ * Nextcloud Android client application
+ *
+ * @author ZetaTom
+ * Copyright (C) 2023 ZetaTom
+ * Copyright (C) 2023 Nextcloud GmbH
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+package com.nextcloud.utils.extensions
+
+import android.content.Context
+import com.nextcloud.common.NextcloudClient
+import com.owncloud.android.lib.common.OwnCloudClient
+import com.owncloud.android.lib.common.OwnCloudClientFactory
+
+fun OwnCloudClient.toNextcloudClient(context: Context): NextcloudClient {
+    return OwnCloudClientFactory.createNextcloudClient(
+        baseUri,
+        userId,
+        credentials.toOkHttpCredentials(),
+        context,
+        isFollowRedirects
+    )
+}