Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/android-library.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortobiasKaminsky <tobias@kaminsky.me>2022-08-23 09:34:50 +0300
committerÁlvaro Brey (Rebase PR Action) <AlvaroBrey@users.noreply.github.com>2022-09-29 18:16:57 +0300
commit26556f69747c367759941e75c2a3ec1e62a5233f (patch)
tree23ae8ee4fe13212d9f0d69edc66d4d68216c2c48
parent1edee0d314d2324ee38cac8f607654403e860b72 (diff)
wip
Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
-rw-r--r--library/src/androidTest/java/com/nextcloud/android/lib/resources/dashboard/DashboardListWidgetsRemoteOperationIT.kt37
-rw-r--r--library/src/main/java/com/nextcloud/android/lib/resources/dashboard/DashboardListWidgetsRemoteOperation.kt60
-rw-r--r--library/src/main/java/com/nextcloud/android/lib/resources/dashboard/DashboardWidget.kt30
-rw-r--r--library/src/main/java/com/nextcloud/android/lib/resources/dashboard/DashboardWidgetItem.kt35
-rw-r--r--library/src/main/java/com/nextcloud/android/lib/resources/dashboard/DashboardWidgetList.kt31
5 files changed, 193 insertions, 0 deletions
diff --git a/library/src/androidTest/java/com/nextcloud/android/lib/resources/dashboard/DashboardListWidgetsRemoteOperationIT.kt b/library/src/androidTest/java/com/nextcloud/android/lib/resources/dashboard/DashboardListWidgetsRemoteOperationIT.kt
new file mode 100644
index 00000000..c2ad4dfe
--- /dev/null
+++ b/library/src/androidTest/java/com/nextcloud/android/lib/resources/dashboard/DashboardListWidgetsRemoteOperationIT.kt
@@ -0,0 +1,37 @@
+/*
+ *
+ * Nextcloud Android client application
+ *
+ * @author Tobias Kaminsky
+ * Copyright (C) 2022 Tobias Kaminsky
+ * Copyright (C) 2022 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.android.lib.resources.dashboard
+
+import com.owncloud.android.AbstractIT
+import org.junit.Assert.assertTrue
+import org.junit.Test
+
+class DashboardListWidgetsRemoteOperationIT : AbstractIT() {
+ @Test
+ fun list() {
+ val result = DashboardListWidgetsRemoteOperation().execute(nextcloudClient)
+ assertTrue(result.isSuccess)
+
+ assertTrue(result.resultData.widgets.isNotEmpty())
+ }
+}
diff --git a/library/src/main/java/com/nextcloud/android/lib/resources/dashboard/DashboardListWidgetsRemoteOperation.kt b/library/src/main/java/com/nextcloud/android/lib/resources/dashboard/DashboardListWidgetsRemoteOperation.kt
new file mode 100644
index 00000000..20fcb7d3
--- /dev/null
+++ b/library/src/main/java/com/nextcloud/android/lib/resources/dashboard/DashboardListWidgetsRemoteOperation.kt
@@ -0,0 +1,60 @@
+/*
+ * Nextcloud Android client application
+ *
+ * @author Tobias Kaminsky
+ * Copyright (C) 2022 Tobias Kaminsky
+ * Copyright (C) 2022 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.android.lib.resources.dashboard
+
+import com.google.gson.reflect.TypeToken
+import com.nextcloud.common.NextcloudClient
+import com.nextcloud.operations.GetMethod
+import com.owncloud.android.lib.common.operations.RemoteOperationResult
+import com.owncloud.android.lib.ocs.ServerResponse
+import com.owncloud.android.lib.resources.OCSRemoteOperation
+import org.apache.commons.httpclient.HttpStatus
+
+class DashboardListWidgetsRemoteOperation : OCSRemoteOperation<DashboardWidgetList>() {
+ private val LIST_ENDPOINT = "/ocs/v2.php/apps/dashboard/api/v1/list"
+
+ override fun run(client: NextcloudClient): RemoteOperationResult<DashboardWidgetList> {
+ lateinit var result: RemoteOperationResult<DashboardWidgetList>
+ lateinit var get: GetMethod
+
+ try {
+ get = GetMethod(client.baseUri.toString() + LIST_ENDPOINT, true)
+ val status = client.execute(get)
+
+ if (status == HttpStatus.SC_OK) {
+ val list = getServerResponse(get,
+ object : TypeToken<ServerResponse<DashboardWidgetList>?>() {}
+ )?.ocs?.data
+
+ result = RemoteOperationResult<DashboardWidgetList>(true, get)
+ result.resultData = list
+ } else {
+ result = RemoteOperationResult<DashboardWidgetList>(false, get)
+ }
+ } catch (e: Exception) {
+ result = RemoteOperationResult<DashboardWidgetList>(e)
+ }
+
+ return result
+ }
+}
diff --git a/library/src/main/java/com/nextcloud/android/lib/resources/dashboard/DashboardWidget.kt b/library/src/main/java/com/nextcloud/android/lib/resources/dashboard/DashboardWidget.kt
new file mode 100644
index 00000000..a2c0fba7
--- /dev/null
+++ b/library/src/main/java/com/nextcloud/android/lib/resources/dashboard/DashboardWidget.kt
@@ -0,0 +1,30 @@
+/*
+ *
+ * Nextcloud Android client application
+ *
+ * @author Tobias Kaminsky
+ * Copyright (C) 2022 Tobias Kaminsky
+ * Copyright (C) 2022 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.android.lib.resources.dashboard
+
+import android.os.Parcelable
+import androidx.annotation.DrawableRes
+import kotlinx.parcelize.Parcelize
+
+@Parcelize
+data class DashboardWidget(val id: String, val title: String, @DrawableRes val icon: Int) : Parcelable
diff --git a/library/src/main/java/com/nextcloud/android/lib/resources/dashboard/DashboardWidgetItem.kt b/library/src/main/java/com/nextcloud/android/lib/resources/dashboard/DashboardWidgetItem.kt
new file mode 100644
index 00000000..a806daa1
--- /dev/null
+++ b/library/src/main/java/com/nextcloud/android/lib/resources/dashboard/DashboardWidgetItem.kt
@@ -0,0 +1,35 @@
+/*
+ *
+ * Nextcloud Android client application
+ *
+ * @author Tobias Kaminsky
+ * Copyright (C) 2022 Tobias Kaminsky
+ * Copyright (C) 2022 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.android.lib.resources.dashboard
+
+import com.owncloud.android.lib.resources.users.StatusType
+
+data class DashboardWidgetItem(
+ val headline: String,
+ val subline: String,
+ val url: String? = null,
+ val userName: String? = null,
+ val icon: String? = null,
+ val statusType: StatusType? = null
+)
+
diff --git a/library/src/main/java/com/nextcloud/android/lib/resources/dashboard/DashboardWidgetList.kt b/library/src/main/java/com/nextcloud/android/lib/resources/dashboard/DashboardWidgetList.kt
new file mode 100644
index 00000000..1a9942bf
--- /dev/null
+++ b/library/src/main/java/com/nextcloud/android/lib/resources/dashboard/DashboardWidgetList.kt
@@ -0,0 +1,31 @@
+/*
+ *
+ * Nextcloud Android client application
+ *
+ * @author Tobias Kaminsky
+ * Copyright (C) 2022 Tobias Kaminsky
+ * Copyright (C) 2022 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.android.lib.resources.dashboard
+
+import android.os.Parcelable
+import kotlinx.parcelize.Parcelize
+
+@Parcelize
+data class DashboardWidgetList(
+ val widgets: Map<String, DashboardWidget> = HashMap()
+) : Parcelable