-
Notifications
You must be signed in to change notification settings - Fork 95
Declarative UI #1836
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
tobiasKaminsky
wants to merge
8
commits into
master
Choose a base branch
from
declarative-ui
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Declarative UI #1836
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
6a99c2c
Client integration
tobiasKaminsky ccb9ccf
make orientation parcable and add tests
alperozturk96 3850470
update
tobiasKaminsky cbd6a22
ClientIntegrationUI root might be null
tobiasKaminsky 570185d
change layout item names
alperozturk96 1639bf8
remove unused element
alperozturk96 3a1dbec
fix adapter
alperozturk96 16fc939
fix adapter
alperozturk96 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
library/src/main/java/com/nextcloud/android/lib/resources/clientintegration/App.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| /* | ||
| * Nextcloud Android Library | ||
| * | ||
| * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors | ||
| * SPDX-FileCopyrightText: 2025 Tobias Kaminsky <[email protected]> | ||
| * SPDX-License-Identifier: MIT | ||
| */ | ||
|
|
||
| package com.nextcloud.android.lib.resources.clientintegration | ||
|
|
||
| import com.google.gson.annotations.SerializedName | ||
|
|
||
| data class App( | ||
| val version: Double, | ||
| @SerializedName("context-menu") | ||
| val contextMenu: List<Endpoint>, | ||
| @SerializedName("create-new") | ||
| val createNew: List<Endpoint> | ||
| ) | ||
18 changes: 18 additions & 0 deletions
18
...rc/main/java/com/nextcloud/android/lib/resources/clientintegration/ClientIntegrationUI.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| /* | ||
| * Nextcloud Android Library | ||
| * | ||
| * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors | ||
| * SPDX-FileCopyrightText: 2025 Tobias Kaminsky <[email protected]> | ||
| * SPDX-License-Identifier: MIT | ||
| */ | ||
|
|
||
| package com.nextcloud.android.lib.resources.clientintegration | ||
|
|
||
| import android.os.Parcelable | ||
| import kotlinx.parcelize.Parcelize | ||
|
|
||
| @Parcelize | ||
| data class ClientIntegrationUI( | ||
| val version: Double, | ||
| val root: Layout? | ||
| ) : Parcelable |
13 changes: 13 additions & 0 deletions
13
library/src/main/java/com/nextcloud/android/lib/resources/clientintegration/Element.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| /* | ||
| * Nextcloud Android Library | ||
| * | ||
| * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors | ||
| * SPDX-FileCopyrightText: 2025 Tobias Kaminsky <[email protected]> | ||
| * SPDX-License-Identifier: MIT | ||
| */ | ||
|
|
||
| package com.nextcloud.android.lib.resources.clientintegration | ||
|
|
||
| import android.os.Parcelable | ||
|
|
||
| interface Element : Parcelable |
68 changes: 68 additions & 0 deletions
68
...src/main/java/com/nextcloud/android/lib/resources/clientintegration/ElementTypeAdapter.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| /* | ||
| * Nextcloud Android Library | ||
| * | ||
| * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors | ||
| * SPDX-FileCopyrightText: 2025 Tobias Kaminsky <[email protected]> | ||
| * SPDX-License-Identifier: MIT | ||
| */ | ||
|
|
||
| package com.nextcloud.android.lib.resources.clientintegration | ||
|
|
||
| import com.google.gson.Gson | ||
| import com.google.gson.JsonDeserializationContext | ||
| import com.google.gson.JsonDeserializer | ||
| import com.google.gson.JsonElement | ||
| import com.google.gson.JsonParseException | ||
| import com.google.gson.JsonSerializationContext | ||
| import com.google.gson.JsonSerializer | ||
| import java.lang.reflect.Type | ||
|
|
||
| class ElementTypeAdapter : | ||
| JsonSerializer<Element>, | ||
| JsonDeserializer<Element> { | ||
| override fun serialize( | ||
| src: Element, | ||
| type: Type, | ||
| context: JsonSerializationContext | ||
| ): JsonElement { | ||
| // needs to be a new Gson instance, otherwise we end up in a loop | ||
| val element = Gson().toJsonTree(src) | ||
| element.asJsonObject.addProperty("element", src.javaClass.name) | ||
|
|
||
| return element | ||
| } | ||
|
|
||
| @Throws(JsonParseException::class, ClassNotFoundException::class, Throwable::class) | ||
| override fun deserialize( | ||
| json: JsonElement, | ||
| type: Type, | ||
| context: JsonDeserializationContext | ||
| ): Element? { | ||
| val jsonObject = json.asJsonObject | ||
| val typeName = jsonObject.get("element").asString | ||
|
|
||
| try { | ||
| val prefix = "com.nextcloud.android.lib.resources.clientintegration" | ||
| val cls: Class<out Element> = | ||
| when (typeName) { | ||
| "Button" -> | ||
| Class.forName("$prefix.LayoutButton") as Class<out Element> | ||
|
|
||
| "Text" -> | ||
| Class.forName("$prefix.LayoutText") as Class<out Element> | ||
|
|
||
| "Image" -> | ||
| Class.forName("$prefix.LayoutImage") as Class<out Element> | ||
|
|
||
| "URL" -> | ||
| Class.forName("$prefix.LayoutURL") as Class<out Element> | ||
|
|
||
| else -> return null | ||
| } | ||
|
|
||
| return Gson().fromJson(json, cls) | ||
tobiasKaminsky marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } catch (e: ClassNotFoundException) { | ||
| throw JsonParseException(e) | ||
| } | ||
| } | ||
| } | ||
26 changes: 26 additions & 0 deletions
26
library/src/main/java/com/nextcloud/android/lib/resources/clientintegration/Endpoint.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| /* | ||
| * Nextcloud Android Library | ||
| * | ||
| * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors | ||
| * SPDX-FileCopyrightText: 2025 Tobias Kaminsky <[email protected]> | ||
| * SPDX-License-Identifier: MIT | ||
| */ | ||
|
|
||
| package com.nextcloud.android.lib.resources.clientintegration | ||
|
|
||
| import android.os.Parcelable | ||
| import com.google.gson.annotations.SerializedName | ||
| import com.owncloud.android.lib.resources.status.Method | ||
| import kotlinx.parcelize.Parcelize | ||
|
|
||
| @Parcelize | ||
| data class Endpoint( | ||
| val name: String, | ||
| val url: String, | ||
| var method: Method?, | ||
| @SerializedName("mimetype_filters") | ||
| val mimetypeFilter: String?, | ||
| val params: Map<String, String>?, | ||
| val icon: String?, | ||
| val filter: String? | ||
| ) : Parcelable |
20 changes: 20 additions & 0 deletions
20
library/src/main/java/com/nextcloud/android/lib/resources/clientintegration/Layout.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| /* | ||
| * Nextcloud Android Library | ||
| * | ||
| * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors | ||
| * SPDX-FileCopyrightText: 2025 Tobias Kaminsky <[email protected]> | ||
| * SPDX-License-Identifier: MIT | ||
| */ | ||
|
|
||
| package com.nextcloud.android.lib.resources.clientintegration | ||
|
|
||
| import android.os.Parcelable | ||
| import com.google.gson.annotations.SerializedName | ||
| import kotlinx.parcelize.Parcelize | ||
|
|
||
| @Parcelize | ||
| data class Layout( | ||
| @SerializedName("orientation") | ||
| var orientation: LayoutOrientation, | ||
| var rows: List<LayoutRow> | ||
| ) : Parcelable |
19 changes: 19 additions & 0 deletions
19
library/src/main/java/com/nextcloud/android/lib/resources/clientintegration/LayoutButton.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| /* | ||
| * Nextcloud Android Library | ||
| * | ||
| * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors | ||
| * SPDX-FileCopyrightText: 2025 Tobias Kaminsky <[email protected]> | ||
| * SPDX-License-Identifier: MIT | ||
| */ | ||
|
|
||
| package com.nextcloud.android.lib.resources.clientintegration | ||
|
|
||
| import android.os.Parcelable | ||
| import kotlinx.parcelize.Parcelize | ||
|
|
||
| @Parcelize | ||
| data class LayoutButton( | ||
| val label: String, | ||
| val type: String | ||
| ) : Element, | ||
| Parcelable |
17 changes: 17 additions & 0 deletions
17
library/src/main/java/com/nextcloud/android/lib/resources/clientintegration/LayoutImage.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| /* | ||
| * Nextcloud Android Library | ||
| * | ||
| * SPDX-FileCopyrightText: 2025 Alper Ozturk <[email protected]> | ||
| * SPDX-License-Identifier: MIT | ||
| */ | ||
|
|
||
| package com.nextcloud.android.lib.resources.clientintegration | ||
|
|
||
| import android.os.Parcelable | ||
| import kotlinx.parcelize.Parcelize | ||
|
|
||
| @Parcelize | ||
| data class LayoutImage( | ||
| val url: String | ||
| ) : Element, | ||
| Parcelable |
22 changes: 22 additions & 0 deletions
22
.../src/main/java/com/nextcloud/android/lib/resources/clientintegration/LayoutOrientation.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| /* | ||
| * Nextcloud Android Library | ||
| * | ||
| * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors | ||
| * SPDX-FileCopyrightText: 2025 Tobias Kaminsky <[email protected]> | ||
| * SPDX-License-Identifier: MIT | ||
| */ | ||
|
|
||
| package com.nextcloud.android.lib.resources.clientintegration | ||
|
|
||
| import android.os.Parcelable | ||
| import com.google.gson.annotations.SerializedName | ||
| import kotlinx.parcelize.Parcelize | ||
|
|
||
| @Parcelize | ||
| enum class LayoutOrientation : Parcelable { | ||
| @SerializedName("horizontal") | ||
| HORIZONTAL, | ||
|
|
||
| @SerializedName("vertical") | ||
| VERTICAL | ||
| } |
17 changes: 17 additions & 0 deletions
17
library/src/main/java/com/nextcloud/android/lib/resources/clientintegration/LayoutRow.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| /* | ||
| * Nextcloud Android Library | ||
| * | ||
| * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors | ||
| * SPDX-FileCopyrightText: 2025 Tobias Kaminsky <[email protected]> | ||
| * SPDX-License-Identifier: MIT | ||
| */ | ||
|
|
||
| package com.nextcloud.android.lib.resources.clientintegration | ||
|
|
||
| import android.os.Parcelable | ||
| import kotlinx.parcelize.Parcelize | ||
|
|
||
| @Parcelize | ||
| data class LayoutRow( | ||
| val children: List<Element> | ||
| ) : Parcelable |
18 changes: 18 additions & 0 deletions
18
library/src/main/java/com/nextcloud/android/lib/resources/clientintegration/LayoutText.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| /* | ||
| * Nextcloud Android Library | ||
| * | ||
| * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors | ||
| * SPDX-FileCopyrightText: 2025 Tobias Kaminsky <[email protected]> | ||
| * SPDX-License-Identifier: MIT | ||
| */ | ||
|
|
||
| package com.nextcloud.android.lib.resources.clientintegration | ||
|
|
||
| import android.os.Parcelable | ||
| import kotlinx.parcelize.Parcelize | ||
|
|
||
| @Parcelize | ||
| data class LayoutText( | ||
| val text: String | ||
| ) : Element, | ||
| Parcelable |
19 changes: 19 additions & 0 deletions
19
library/src/main/java/com/nextcloud/android/lib/resources/clientintegration/LayoutURL.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| /* | ||
| * Nextcloud Android Library | ||
| * | ||
| * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors | ||
| * SPDX-FileCopyrightText: 2025 Tobias Kaminsky <[email protected]> | ||
| * SPDX-License-Identifier: MIT | ||
| */ | ||
|
|
||
| package com.nextcloud.android.lib.resources.clientintegration | ||
|
|
||
| import android.os.Parcelable | ||
| import kotlinx.parcelize.Parcelize | ||
|
|
||
| @Parcelize | ||
| data class LayoutURL( | ||
| val text: String, | ||
| val url: String | ||
| ) : Element, | ||
| Parcelable |
14 changes: 14 additions & 0 deletions
14
...ry/src/main/java/com/nextcloud/android/lib/resources/clientintegration/TooltipResponse.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| /* | ||
| * Nextcloud Android Library | ||
| * | ||
| * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors | ||
| * SPDX-FileCopyrightText: 2025 Tobias Kaminsky <[email protected]> | ||
| * SPDX-License-Identifier: MIT | ||
| */ | ||
|
|
||
| package com.nextcloud.android.lib.resources.clientintegration | ||
|
|
||
| data class TooltipResponse( | ||
| val version: Double, | ||
| val tooltip: String | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this is not using
kotlinx.parcelize.Parcelizeas well ?