From 3ef25ab48cf877db44173ebd847efac7660af163 Mon Sep 17 00:00:00 2001 From: Florina Muntenescu Date: Tue, 13 Oct 2020 09:40:53 +0100 Subject: [PATCH 1/2] [Jetsurvey] Bump to alpha05 --- Jetsurvey/app/build.gradle | 7 +++++++ .../compose/jetsurvey/signinsignup/SignInScreen.kt | 4 ++-- .../compose/jetsurvey/signinsignup/SignInSignUp.kt | 12 ++++++------ .../compose/jetsurvey/signinsignup/SignUpScreen.kt | 4 ++-- .../compose/jetsurvey/signinsignup/WelcomeScreen.kt | 12 ++++++------ Jetsurvey/build.gradle | 6 ++---- .../compose/jetsurvey/buildsrc/dependencies.kt | 11 +++++++---- 7 files changed, 32 insertions(+), 24 deletions(-) diff --git a/Jetsurvey/app/build.gradle b/Jetsurvey/app/build.gradle index 2e2cf1f5e7..fb712e6938 100644 --- a/Jetsurvey/app/build.gradle +++ b/Jetsurvey/app/build.gradle @@ -65,6 +65,13 @@ android { buildFeatures { compose true + + // Disable unused AGP features + buildConfig false + aidl false + renderScript false + resValues false + shaders false } composeOptions { diff --git a/Jetsurvey/app/src/main/java/com/example/compose/jetsurvey/signinsignup/SignInScreen.kt b/Jetsurvey/app/src/main/java/com/example/compose/jetsurvey/signinsignup/SignInScreen.kt index d339d1190c..4f3761b0d8 100644 --- a/Jetsurvey/app/src/main/java/com/example/compose/jetsurvey/signinsignup/SignInScreen.kt +++ b/Jetsurvey/app/src/main/java/com/example/compose/jetsurvey/signinsignup/SignInScreen.kt @@ -16,8 +16,8 @@ package com.example.compose.jetsurvey.signinsignup +import androidx.compose.foundation.AmbientContentColor import androidx.compose.foundation.Text -import androidx.compose.foundation.contentColor import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Spacer @@ -167,7 +167,7 @@ fun ErrorSnackbar( data.actionLabel?.let { TextButton( onClick = onDismiss, - contentColor = contentColor() + contentColor = AmbientContentColor.current ) { Text( text = stringResource(id = R.string.dismiss), diff --git a/Jetsurvey/app/src/main/java/com/example/compose/jetsurvey/signinsignup/SignInSignUp.kt b/Jetsurvey/app/src/main/java/com/example/compose/jetsurvey/signinsignup/SignInSignUp.kt index c16530986d..1209e2a7b9 100644 --- a/Jetsurvey/app/src/main/java/com/example/compose/jetsurvey/signinsignup/SignInSignUp.kt +++ b/Jetsurvey/app/src/main/java/com/example/compose/jetsurvey/signinsignup/SignInSignUp.kt @@ -16,10 +16,10 @@ package com.example.compose.jetsurvey.signinsignup +import androidx.compose.foundation.AmbientTextStyle import androidx.compose.foundation.Icon import androidx.compose.foundation.ScrollableColumn import androidx.compose.foundation.Text -import androidx.compose.foundation.currentTextStyle import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row @@ -30,7 +30,7 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.preferredHeight import androidx.compose.foundation.layout.preferredWidth import androidx.compose.foundation.layout.wrapContentSize -import androidx.compose.material.EmphasisAmbient +import androidx.compose.material.AmbientEmphasisLevels import androidx.compose.material.IconButton import androidx.compose.material.MaterialTheme import androidx.compose.material.OutlinedButton @@ -117,7 +117,7 @@ fun Email( emailState.text = it }, label = { - ProvideEmphasis(emphasis = EmphasisAmbient.current.medium) { + ProvideEmphasis(emphasis = AmbientEmphasisLevels.current.medium) { Text( text = stringResource(id = R.string.email), style = MaterialTheme.typography.body2 @@ -170,7 +170,7 @@ fun Password( }, textStyle = MaterialTheme.typography.body2, label = { - ProvideEmphasis(emphasis = EmphasisAmbient.current.medium) { + ProvideEmphasis(emphasis = AmbientEmphasisLevels.current.medium) { Text( text = label, style = MaterialTheme.typography.body2 @@ -216,7 +216,7 @@ fun TextFieldError(textError: String) { Text( text = textError, modifier = Modifier.fillMaxWidth(), - style = currentTextStyle().copy(color = MaterialTheme.colors.error) + style = AmbientTextStyle.current.copy(color = MaterialTheme.colors.error) ) } } @@ -231,7 +231,7 @@ fun OrSignInAsGuest( horizontalAlignment = Alignment.CenterHorizontally ) { Surface { - ProvideEmphasis(emphasis = EmphasisAmbient.current.medium) { + ProvideEmphasis(emphasis = AmbientEmphasisLevels.current.medium) { Text( text = stringResource(id = R.string.or), style = MaterialTheme.typography.subtitle2 diff --git a/Jetsurvey/app/src/main/java/com/example/compose/jetsurvey/signinsignup/SignUpScreen.kt b/Jetsurvey/app/src/main/java/com/example/compose/jetsurvey/signinsignup/SignUpScreen.kt index ce7e0ba762..3b043fd158 100644 --- a/Jetsurvey/app/src/main/java/com/example/compose/jetsurvey/signinsignup/SignUpScreen.kt +++ b/Jetsurvey/app/src/main/java/com/example/compose/jetsurvey/signinsignup/SignUpScreen.kt @@ -21,8 +21,8 @@ import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.preferredHeight +import androidx.compose.material.AmbientEmphasisLevels import androidx.compose.material.Button -import androidx.compose.material.EmphasisAmbient import androidx.compose.material.MaterialTheme import androidx.compose.material.ProvideEmphasis import androidx.compose.material.Scaffold @@ -103,7 +103,7 @@ fun SignUpContent( ) Spacer(modifier = Modifier.preferredHeight(16.dp)) - ProvideEmphasis(emphasis = EmphasisAmbient.current.medium) { + ProvideEmphasis(emphasis = AmbientEmphasisLevels.current.medium) { Text( text = stringResource(id = R.string.terms_and_conditions), style = MaterialTheme.typography.caption diff --git a/Jetsurvey/app/src/main/java/com/example/compose/jetsurvey/signinsignup/WelcomeScreen.kt b/Jetsurvey/app/src/main/java/com/example/compose/jetsurvey/signinsignup/WelcomeScreen.kt index 78ff9aea6a..047c8a7da0 100644 --- a/Jetsurvey/app/src/main/java/com/example/compose/jetsurvey/signinsignup/WelcomeScreen.kt +++ b/Jetsurvey/app/src/main/java/com/example/compose/jetsurvey/signinsignup/WelcomeScreen.kt @@ -26,8 +26,8 @@ import androidx.compose.foundation.layout.offsetPx import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.preferredHeight import androidx.compose.foundation.layout.wrapContentHeight +import androidx.compose.material.AmbientEmphasisLevels import androidx.compose.material.Button -import androidx.compose.material.EmphasisAmbient import androidx.compose.material.MaterialTheme import androidx.compose.material.ProvideEmphasis import androidx.compose.material.Surface @@ -39,7 +39,7 @@ import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.layout.boundsInParent -import androidx.compose.ui.onPositioned +import androidx.compose.ui.onGloballyPositioned import androidx.compose.ui.platform.DensityAmbient import androidx.compose.ui.res.stringResource import androidx.compose.ui.res.vectorResource @@ -72,14 +72,14 @@ fun WelcomeScreen(onEvent: (WelcomeEvent) -> Unit) { modifier = Modifier.fillMaxWidth() .brandingPreferredHeight(showBranding, heightDp) .offsetPx(y = currentOffsetHolder) - .onPositioned { + .onGloballyPositioned { if (showBranding) { heightWithBranding = it.size.height } } ) { Branding( - modifier = Modifier.fillMaxWidth().weight(1f).onPositioned { + modifier = Modifier.fillMaxWidth().weight(1f).onGloballyPositioned { if (brandingBottom == 0f) { brandingBottom = it.boundsInParent.bottom } @@ -112,7 +112,7 @@ private fun Branding(modifier: Modifier = Modifier) { modifier = modifier.wrapContentHeight(align = Alignment.CenterVertically) ) { Logo(modifier = Modifier.align(Alignment.CenterHorizontally).padding(horizontal = 76.dp)) - ProvideEmphasis(emphasis = EmphasisAmbient.current.high) { + ProvideEmphasis(emphasis = AmbientEmphasisLevels.current.high) { Text( text = stringResource(id = R.string.app_tagline), style = MaterialTheme.typography.subtitle1, @@ -147,7 +147,7 @@ private fun SignInCreateAccount( ) { val emailState = remember { EmailState() } Column(modifier = modifier, horizontalAlignment = Alignment.CenterHorizontally) { - ProvideEmphasis(emphasis = EmphasisAmbient.current.medium) { + ProvideEmphasis(emphasis = AmbientEmphasisLevels.current.medium) { Text( text = stringResource(id = R.string.sign_in_create_account), style = MaterialTheme.typography.subtitle2, diff --git a/Jetsurvey/build.gradle b/Jetsurvey/build.gradle index dc1c110111..8963493a05 100644 --- a/Jetsurvey/build.gradle +++ b/Jetsurvey/build.gradle @@ -38,10 +38,8 @@ subprojects { mavenCentral() jcenter() - if (!Libs.AndroidX.Compose.snapshot.isEmpty()) { - maven { - url "https://androidx.dev/snapshots/builds/${Libs.AndroidX.Compose.snapshot}/artifacts/ui/repository/" - } + if (Libs.AndroidX.Compose.version.endsWith("SNAPSHOT")) { + maven { url Libs.AndroidX.Compose.snapshotUrl } } } diff --git a/Jetsurvey/buildSrc/src/main/java/com/example/compose/jetsurvey/buildsrc/dependencies.kt b/Jetsurvey/buildSrc/src/main/java/com/example/compose/jetsurvey/buildsrc/dependencies.kt index db8cd6a04d..eee17e3475 100644 --- a/Jetsurvey/buildSrc/src/main/java/com/example/compose/jetsurvey/buildsrc/dependencies.kt +++ b/Jetsurvey/buildSrc/src/main/java/com/example/compose/jetsurvey/buildsrc/dependencies.kt @@ -29,7 +29,7 @@ object Libs { const val material = "com.google.android.material:material:1.1.0" object Kotlin { - private const val version = "1.4.0" + private const val version = "1.4.10" const val stdlib = "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$version" const val gradlePlugin = "org.jetbrains.kotlin:kotlin-gradle-plugin:$version" const val extensions = "org.jetbrains.kotlin:kotlin-android-extensions:$version" @@ -40,10 +40,13 @@ object Libs { const val coreKtx = "androidx.core:core-ktx:1.5.0-alpha01" object Compose { - const val snapshot = "" - const val version = "1.0.0-alpha04" + const val snapshot = "6901934" + const val version = "1.0.0-SNAPSHOT" + + @get:JvmStatic + val snapshotUrl: String + get() = "https://androidx.dev/snapshots/builds/$snapshot/artifacts/ui/repository/" - const val core = "androidx.compose.ui:ui:$version" const val foundation = "androidx.compose.foundation:foundation:$version" const val layout = "androidx.compose.foundation:foundation-layout:$version" const val material = "androidx.compose.material:material:$version" From 1a0e2cdf6049978d30b63d0e257e5ecc0e5ac79f Mon Sep 17 00:00:00 2001 From: Florina Muntenescu Date: Tue, 13 Oct 2020 10:31:54 +0100 Subject: [PATCH 2/2] [Jetsurvey] Using onSizeChanged to set the branding height --- .../example/compose/jetsurvey/signinsignup/WelcomeScreen.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Jetsurvey/app/src/main/java/com/example/compose/jetsurvey/signinsignup/WelcomeScreen.kt b/Jetsurvey/app/src/main/java/com/example/compose/jetsurvey/signinsignup/WelcomeScreen.kt index 047c8a7da0..b1518b236a 100644 --- a/Jetsurvey/app/src/main/java/com/example/compose/jetsurvey/signinsignup/WelcomeScreen.kt +++ b/Jetsurvey/app/src/main/java/com/example/compose/jetsurvey/signinsignup/WelcomeScreen.kt @@ -40,6 +40,7 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.layout.boundsInParent import androidx.compose.ui.onGloballyPositioned +import androidx.compose.ui.onSizeChanged import androidx.compose.ui.platform.DensityAmbient import androidx.compose.ui.res.stringResource import androidx.compose.ui.res.vectorResource @@ -72,9 +73,9 @@ fun WelcomeScreen(onEvent: (WelcomeEvent) -> Unit) { modifier = Modifier.fillMaxWidth() .brandingPreferredHeight(showBranding, heightDp) .offsetPx(y = currentOffsetHolder) - .onGloballyPositioned { + .onSizeChanged { if (showBranding) { - heightWithBranding = it.size.height + heightWithBranding = it.height } } ) {