Skip to content

Commit 7ed9478

Browse files
committed
handle lib
Signed-off-by: alperozturk <alper_ozturk@proton.me>
1 parent 11116dc commit 7ed9478

4 files changed

Lines changed: 56 additions & 33 deletions

File tree

app/src/main/java/com/nextcloud/ui/ClientIntegrationScreen.kt

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import androidx.compose.foundation.layout.Arrangement
1212
import androidx.compose.foundation.layout.Row
1313
import androidx.compose.foundation.layout.fillMaxSize
1414
import androidx.compose.foundation.layout.fillMaxWidth
15+
import androidx.compose.foundation.layout.padding
1516
import androidx.compose.foundation.lazy.LazyColumn
1617
import androidx.compose.foundation.lazy.LazyRow
1718
import androidx.compose.foundation.lazy.items
@@ -20,17 +21,19 @@ import androidx.compose.material.icons.filled.Close
2021
import androidx.compose.material3.Icon
2122
import androidx.compose.material3.IconButton
2223
import androidx.compose.material3.Scaffold
24+
import androidx.compose.material3.Text
2325
import androidx.compose.material3.TextButton
2426
import androidx.compose.runtime.Composable
2527
import androidx.compose.ui.Modifier
2628
import androidx.compose.ui.platform.LocalContext
2729
import androidx.compose.ui.tooling.preview.Preview
28-
import com.nextcloud.android.lib.resources.clientintegration.Button
2930
import com.nextcloud.android.lib.resources.clientintegration.ClientIntegrationUI
3031
import com.nextcloud.android.lib.resources.clientintegration.Element
3132
import com.nextcloud.android.lib.resources.clientintegration.Layout
32-
import com.nextcloud.android.lib.resources.clientintegration.Orientation
33-
import com.nextcloud.android.lib.resources.clientintegration.Text
33+
import com.nextcloud.android.lib.resources.clientintegration.LayoutButton
34+
import com.nextcloud.android.lib.resources.clientintegration.LayoutOrientation
35+
import com.nextcloud.android.lib.resources.clientintegration.LayoutRow
36+
import com.nextcloud.android.lib.resources.clientintegration.LayoutText
3437
import com.nextcloud.android.lib.resources.clientintegration.URL
3538
import com.nextcloud.utils.extensions.getActivity
3639
import com.owncloud.android.lib.resources.status.OCCapability
@@ -39,6 +42,7 @@ import com.owncloud.android.utils.DisplayUtils
3942
@Composable
4043
fun ClientIntegrationScreen(clientIntegrationUI: ClientIntegrationUI, baseUrl: String) {
4144
val activity = LocalContext.current.getActivity()
45+
val layoutRows = clientIntegrationUI.root?.layoutRows ?: listOf()
4246

4347
Scaffold(topBar = {
4448
Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.End) {
@@ -50,10 +54,10 @@ fun ClientIntegrationScreen(clientIntegrationUI: ClientIntegrationUI, baseUrl: S
5054
}
5155
}
5256
}, modifier = Modifier.fillMaxSize()) {
53-
when (clientIntegrationUI.root.orientation) {
54-
Orientation.VERTICAL -> {
55-
LazyColumn {
56-
items(clientIntegrationUI.root.rows) { row ->
57+
when (clientIntegrationUI.root?.orientation) {
58+
LayoutOrientation.VERTICAL -> {
59+
LazyColumn(modifier = Modifier.padding(it)) {
60+
items(layoutRows) { row ->
5761
LazyRow {
5862
items(row.children) { element ->
5963
DisplayElement(element, baseUrl, activity)
@@ -63,8 +67,8 @@ fun ClientIntegrationScreen(clientIntegrationUI: ClientIntegrationUI, baseUrl: S
6367
}
6468
}
6569
else -> {
66-
LazyRow {
67-
items(clientIntegrationUI.root.rows) { row ->
70+
LazyRow(modifier = Modifier.padding(it)) {
71+
items(layoutRows) { row ->
6872
LazyColumn {
6973
items(row.children) { element ->
7074
DisplayElement(element, baseUrl, activity)
@@ -80,15 +84,15 @@ fun ClientIntegrationScreen(clientIntegrationUI: ClientIntegrationUI, baseUrl: S
8084
@Composable
8185
private fun DisplayElement(element: Element, baseUrl: String, activity: Activity?) {
8286
when (element) {
83-
is Button -> androidx.compose.material3.Button(onClick = { }) {
84-
androidx.compose.material3.Text(element.label)
87+
is LayoutButton -> androidx.compose.material3.Button(onClick = { }) {
88+
Text(element.label)
8589
}
8690

8791
is URL -> TextButton({
8892
openLink(activity, baseUrl, element.url)
89-
}) { androidx.compose.material3.Text(element.text) }
93+
}) { Text(element.text) }
9094

91-
is Text -> androidx.compose.material3.Text(element.text)
95+
is LayoutText -> Text(element.text)
9296
}
9397
}
9498

@@ -104,15 +108,15 @@ private fun ClientIntegrationScreenPreviewVertical() {
104108
val clientIntegrationUI = ClientIntegrationUI(
105109
OCCapability.CLIENT_INTEGRATION_VERSION,
106110
Layout(
107-
Orientation.VERTICAL,
111+
LayoutOrientation.VERTICAL,
108112
mutableListOf(
109-
com.nextcloud.android.lib.resources.clientintegration.Row(
110-
listOf(Button("Click", "Primary"), Text("123"))
113+
LayoutRow(
114+
listOf(LayoutButton("Click", "Primary"), LayoutText("123"))
111115
),
112-
com.nextcloud.android.lib.resources.clientintegration.Row(
113-
listOf(Button("Click2", "Primary"))
116+
LayoutRow(
117+
listOf(LayoutButton("Click2", "Primary"))
114118
),
115-
com.nextcloud.android.lib.resources.clientintegration.Row(
119+
LayoutRow(
116120
listOf(URL("Analytics report created", "https://nextcloud.com"))
117121
)
118122
)
@@ -131,15 +135,15 @@ private fun ClientIntegrationScreenPreviewHorizontal() {
131135
val clientIntegrationUI = ClientIntegrationUI(
132136
OCCapability.CLIENT_INTEGRATION_VERSION,
133137
Layout(
134-
Orientation.HORIZONTAL,
138+
LayoutOrientation.HORIZONTAL,
135139
mutableListOf(
136-
com.nextcloud.android.lib.resources.clientintegration.Row(
137-
listOf(Button("Click", "Primary"), Text("123"))
140+
LayoutRow(
141+
listOf(LayoutButton("Click", "Primary"), LayoutText("123"))
138142
),
139-
com.nextcloud.android.lib.resources.clientintegration.Row(
140-
listOf(Button("Click2", "Primary"))
143+
LayoutRow(
144+
listOf(LayoutButton("Click2", "Primary"))
141145
),
142-
com.nextcloud.android.lib.resources.clientintegration.Row(
146+
LayoutRow(
143147
listOf(URL("Analytics report created", "https://nextcloud.com"))
144148
)
145149
)
@@ -155,7 +159,7 @@ private fun ClientIntegrationScreenPreviewEmpty() {
155159
val clientIntegrationUI = ClientIntegrationUI(
156160
OCCapability.CLIENT_INTEGRATION_VERSION,
157161
Layout(
158-
Orientation.HORIZONTAL,
162+
LayoutOrientation.HORIZONTAL,
159163
emptyList()
160164
)
161165
)

app/src/main/java/com/nextcloud/ui/fileactions/ClientIntegration.kt

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ import com.nextcloud.operations.PostMethod
3737
import com.nextcloud.ui.composeActivity.ComposeActivity
3838
import com.nextcloud.ui.composeActivity.ComposeDestination
3939
import com.nextcloud.utils.GlideHelper
40-
import com.nextcloud.utils.extensions.showToast
4140
import com.owncloud.android.R
4241
import com.owncloud.android.databinding.FileActionsBottomSheetBinding
4342
import com.owncloud.android.databinding.FileActionsBottomSheetItemBinding
@@ -165,30 +164,34 @@ class ClientIntegration(
165164
val result = try {
166165
client.execute(method)
167166
} catch (_: IOException) {
168-
context.showToast(context.resources.getString(R.string.failed_to_start_action))
167+
showMessage(context.resources.getString(R.string.failed_to_start_action))
169168
}
170169
val response = method.getResponseBodyAsString()
171170

172171
var output: ClientIntegrationUI?
173172
try {
174173
output = parseClientIntegrationResult(response)
175-
if (output.root != null) {
174+
if (output.root != null && output.root?.layoutRows != null) {
176175
startClientIntegration(endpoint, output)
177176
} else {
178177
val tooltipResponse = parseTooltipResult(response)
179-
context.showToast(tooltipResponse.tooltip)
178+
showMessage(tooltipResponse.tooltip)
180179
}
181180
} catch (_: JsonSyntaxException) {
182181
if (result == HttpStatus.SC_OK) {
183-
context.showToast(context.resources.getString(R.string.action_triggered))
182+
showMessage(context.resources.getString(R.string.action_triggered))
184183
} else {
185-
context.showToast(context.resources.getString(R.string.failed_to_start_action))
184+
showMessage(context.resources.getString(R.string.failed_to_start_action))
186185
}
187186
}
188187
sheet.dismiss()
189188
}
190189
}
191190

191+
private suspend fun showMessage(message: String) = withContext(Dispatchers.Main) {
192+
DisplayUtils.showSnackMessage(sheet.view, message)
193+
}
194+
192195
private fun parseTooltipResult(response: String?): TooltipResponse {
193196
val element: JsonElement = JsonParser.parseString(response)
194197
return Gson()

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
androidCommonLibraryVersion = "0.30.0"
66
androidGifDrawableVersion = "1.2.29"
77
androidImageCropperVersion = "4.7.0"
8-
androidLibraryVersion = "264b979b78f04ed2885c0c06f589fbf4080be932"
8+
androidLibraryVersion = "f51ba3bf5f"
99
androidPluginVersion = '8.13.2'
1010
androidsvgVersion = "1.4"
1111
androidxMediaVersion = "1.5.1"

gradle/verification-metadata.xml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18995,6 +18995,14 @@
1899518995
<sha256 value="e7ab2429aded8474972439b212bc68e7bd7dd9663abf0cdbd1d448df2476acab" origin="Generated by Gradle" reason="Artifact is not signed"/>
1899618996
</artifact>
1899718997
</component>
18998+
<component group="com.github.nextcloud" name="android-library" version="264b979b78f04ed2885c0c06f589fbf4080be932">
18999+
<artifact name="android-library-264b979b78f04ed2885c0c06f589fbf4080be932.aar">
19000+
<sha256 value="94784ab20e947be2b8d08cca16a1bc6ea393d1f7513c6df38d04ff6b61ddb846" origin="Generated by Gradle" reason="Artifact is not signed"/>
19001+
</artifact>
19002+
<artifact name="android-library-264b979b78f04ed2885c0c06f589fbf4080be932.module">
19003+
<sha256 value="ae6135f63a2a5162f51832ed658697cac2de05963c31a28d04bdd085ab2f765f" origin="Generated by Gradle" reason="Artifact is not signed"/>
19004+
</artifact>
19005+
</component>
1899819006
<component group="com.github.nextcloud" name="android-library" version="26dc8477962f12356db840bb1a774f0186b38e4d">
1899919007
<artifact name="android-library-26dc8477962f12356db840bb1a774f0186b38e4d.aar">
1900019008
<sha256 value="57ab4fd7c922875a7e0b5feac20aa27ab5df0fd3b4e042f92ed727c0b6316e81" origin="Generated by Gradle" reason="Artifact is not signed"/>
@@ -19784,6 +19792,14 @@
1978419792
<sha256 value="7a2189a2b81f8210d6431a7cfc2911be36a9cf42d030101106d5577a099c28d9" origin="Generated by Gradle" reason="Artifact is not signed"/>
1978519793
</artifact>
1978619794
</component>
19795+
<component group="com.github.nextcloud" name="android-library" version="f51ba3bf5f">
19796+
<artifact name="android-library-f51ba3bf5f.aar">
19797+
<sha256 value="75607676864cdc7d3bdc09072d184c7802f3bda19c1f63cd1654fa90bf2e5802" origin="Generated by Gradle" reason="Artifact is not signed"/>
19798+
</artifact>
19799+
<artifact name="android-library-f51ba3bf5f.module">
19800+
<sha256 value="0b9b634b3edb02c01c93424bf58ec7fab9b44da769049b3d3a177445971535f3" origin="Generated by Gradle" reason="Artifact is not signed"/>
19801+
</artifact>
19802+
</component>
1978719803
<component group="com.github.nextcloud" name="android-library" version="f5b31bddd9">
1978819804
<artifact name="android-library-f5b31bddd9.aar">
1978919805
<sha256 value="22671ff27454feb4dbff6114fbbd5f0396d0f21d5e545b66ff6258900c2e135c" origin="Generated by Gradle" reason="Artifact is not signed"/>

0 commit comments

Comments
 (0)