From cabde4e77925328586bdcedb13c1bebbaf2e601d Mon Sep 17 00:00:00 2001 From: alperozturk Date: Mon, 4 Mar 2024 16:39:34 +0100 Subject: [PATCH] Update ui library, add jetpack compose preview capability Signed-off-by: alperozturk --- app/build.gradle | 3 ++ .../client/assistant/component/TaskView.kt | 45 ++++++++++++++++--- .../ui/composeActivity/ComposeActivity.kt | 2 +- app/src/main/res/values/strings.xml | 2 - settings.gradle | 7 --- 5 files changed, 43 insertions(+), 16 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index f9bc33210a..44e3873660 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -265,6 +265,8 @@ dependencies { implementation("androidx.compose.ui:ui") implementation("androidx.compose.ui:ui-graphics") implementation("androidx.compose.material3:material3") + implementation("androidx.compose.ui:ui-tooling-preview:1.6.2") + compileOnly 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2' // remove after entire switch to lib v2 @@ -304,6 +306,7 @@ dependencies { implementation "com.github.nextcloud-deps.hwsecurity:hwsecurity-fido:$fidoVersion" implementation "com.github.nextcloud-deps.hwsecurity:hwsecurity-fido2:$fidoVersion" + debugImplementation 'androidx.compose.ui:ui-tooling:1.6.2' // document scanner not available on FDroid (generic) due to OpenCV binaries gplayImplementation project(':appscan') diff --git a/app/src/main/java/com/nextcloud/client/assistant/component/TaskView.kt b/app/src/main/java/com/nextcloud/client/assistant/component/TaskView.kt index a94b5a86d7..1fd0116b0f 100644 --- a/app/src/main/java/com/nextcloud/client/assistant/component/TaskView.kt +++ b/app/src/main/java/com/nextcloud/client/assistant/component/TaskView.kt @@ -46,6 +46,7 @@ import androidx.compose.ui.draw.clip import androidx.compose.ui.graphics.Color import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.style.TextAlign +import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import com.nextcloud.ui.composeComponents.bottomSheet.MoreActionsBottomSheet @@ -78,9 +79,9 @@ fun TaskView( task.input?.let { Text( - text = stringResource(id = R.string.assistant_screen_task_view_input, it), + text = it, color = Color.White, - fontSize = 18.sp, + fontSize = 18.sp ) } @@ -90,10 +91,7 @@ fun TaskView( HorizontalDivider(modifier = Modifier.padding(horizontal = 4.dp, vertical = 8.dp)) Text( - text = stringResource( - id = R.string.assistant_screen_task_view_output, - if (expanded) it else it.take(100) + "..." - ), + text = if (expanded) it else it.take(100) + "...", fontSize = 12.sp, color = Color.White, modifier = Modifier @@ -139,3 +137,38 @@ fun TaskView( } } } + +@Preview +@Composable +private fun TaskViewPreview() { + val output = + "Lorem Ipsum is simply dummy text of the printing and " + + "typesetting industry. Lorem Ipsum has been the " + + "industry's standard dummy text ever since the 1500s, " + + "when an unknown printer took a galley of type and " + + "scrambled it to make a type specimen book. " + + "It has survived not only five centuries, but also " + + "the leap into electronic typesetting, remaining" + + " essentially unchanged. It wLorem Ipsum is simply dummy" + + " text of the printing and typesetting industry. " + + "Lorem Ipsum has been the industry's standard dummy " + + "text ever since the 1500s, when an unknown printer took a" + + " galley of type and scrambled it to make a type specimen book. " + + "It has survived not only five centuries, but also the leap " + + "into electronic typesetting, remaining essentially unchanged." + + TaskView( + task = Task( + 1, + "Free Prompt", + 0, + "1", + "1", + "Give me text", + output, + "", + "" + ) + ) { + } +} diff --git a/app/src/main/java/com/nextcloud/ui/composeActivity/ComposeActivity.kt b/app/src/main/java/com/nextcloud/ui/composeActivity/ComposeActivity.kt index 23ff8b5d31..573f11ce62 100644 --- a/app/src/main/java/com/nextcloud/ui/composeActivity/ComposeActivity.kt +++ b/app/src/main/java/com/nextcloud/ui/composeActivity/ComposeActivity.kt @@ -71,7 +71,7 @@ class ComposeActivity : DrawerActivity() { binding.composeView.setContent { MaterialTheme( - // colorScheme = viewThemeUtils.getColorScheme(this), + colorScheme = viewThemeUtils.getColorScheme(this), content = { Content(destination, storageManager.user, this) } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 24f983e212..b875deb946 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -35,8 +35,6 @@ Type some text All - Input %s - Output\n%s Show more Show less diff --git a/settings.gradle b/settings.gradle index 92f7c0215a..5c2438e2ad 100644 --- a/settings.gradle +++ b/settings.gradle @@ -14,10 +14,3 @@ include ':appscan' // substitute module('com.github.nextcloud:android-library') using project(':library') // } //} - - -includeBuild('/Users/alperozturk/Desktop/nextcloud/nextcloud_android_common') { - dependencySubstitution { - substitute module('com.github.nextcloud.android-common:ui') using project(':ui') - } -} \ No newline at end of file