Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
[Crane] Update to snapshot 6860046
  • Loading branch information
Manuel Vivo committed Oct 9, 2020
commit f26bcc829a044bee40038a51d2247cc39beaf386
18 changes: 17 additions & 1 deletion Crane/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,19 @@ android {
}

buildFeatures {
compose true
// We turn off the Compose feature for now, due to using Compose SNAPSHOTs where the
// Compose compiler artifact has changed artifact group/name.
// Instead we add the compiler manually below in the dependencies {}. Also see
// the root build.gradle for info on how to apply the plugin.
// TODO: remove this once we upgrade to an AGP version which uses the new artifact details

// compose true
// Disable unused AGP features
buildConfig false
aidl false
renderScript false
resValues false
shaders false
}
composeOptions {
kotlinCompilerVersion Libs.Kotlin.version
Expand All @@ -81,6 +93,10 @@ android {
}

dependencies {
// Temporary workaround (see above)
// TODO: remove this once we upgrade to an AGP version which uses the new artifact details
kotlinCompilerPlugin Libs.AndroidX.Compose.compiler

implementation Libs.Kotlin.stdlib
implementation Libs.googleMaps

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ package androidx.compose.samples.crane.base
import androidx.compose.foundation.Image
import androidx.compose.foundation.Text
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.Stack
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.preferredHeight
Expand All @@ -46,7 +46,7 @@ import androidx.compose.ui.graphics.Color
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.res.vectorResource
import androidx.compose.ui.unit.dp
import dev.chrisbanes.accompanist.coil.CoilImageWithCrossfade
import dev.chrisbanes.accompanist.coil.CoilImage

@Composable
fun ExploreSection(
Expand Down Expand Up @@ -89,11 +89,12 @@ private fun ExploreItem(
.padding(top = 12.dp, bottom = 12.dp)
) {
ExploreImageContainer {
CoilImageWithCrossfade(
CoilImage(
data = item.imageUrl,
fadeIn = true,
contentScale = ContentScale.Crop,
loading = {
Stack(Modifier.fillMaxSize()) {
Box(Modifier.fillMaxSize()) {
Image(
modifier = Modifier.preferredSize(36.dp).align(Alignment.Center),
asset = vectorResource(id = R.drawable.ic_crane_logo)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ package androidx.compose.samples.crane.calendar
import androidx.compose.foundation.ScrollableColumn
import androidx.compose.foundation.Text
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.Stack
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
Expand Down Expand Up @@ -210,7 +210,7 @@ private fun DayStatusContainer(
children: @Composable () -> Unit
) {
if (status.isMarked()) {
Stack {
Box {
val color = MaterialTheme.colors.secondary
Circle(color = color)
if (status == DaySelectedStatus.FirstDay) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package androidx.compose.samples.crane.calendar
import android.content.Context
import android.content.Intent
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.activity.ComponentActivity
import androidx.compose.foundation.Image
import androidx.compose.foundation.Text
import androidx.compose.foundation.layout.Column
Expand All @@ -42,7 +42,7 @@ fun launchCalendarActivity(context: Context) {
context.startActivity(intent)
}

class CalendarActivity : AppCompatActivity() {
class CalendarActivity : ComponentActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ package androidx.compose.samples.crane.details
import android.content.Context
import android.content.Intent
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.annotation.VisibleForTesting
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.foundation.Text
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
Expand Down Expand Up @@ -73,7 +73,7 @@ data class DetailsActivityArg(
val longitude: String
)

class DetailsActivity : AppCompatActivity() {
class DetailsActivity : ComponentActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import androidx.compose.material.BackdropValue
import androidx.compose.material.DrawerValue
import androidx.compose.material.ExperimentalMaterialApi
import androidx.compose.material.ModalDrawerLayout
import androidx.compose.material.rememberBackdropState
import androidx.compose.material.rememberBackdropScaffoldState
import androidx.compose.material.rememberDrawerState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
Expand Down Expand Up @@ -82,7 +82,7 @@ fun CraneHomeContent(

BackdropScaffold(
modifier = modifier,
backdropScaffoldState = rememberBackdropState(BackdropValue.Revealed),
scaffoldState = rememberBackdropScaffoldState(BackdropValue.Revealed),
frontLayerScrimColor = Color.Transparent,
appBar = {
HomeTabBar(openDrawer, tabSelected, onTabSelected = { tabSelected = it })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@

package androidx.compose.samples.crane.home

import androidx.compose.foundation.Box
import androidx.compose.foundation.ContentGravity
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.Composable
import androidx.compose.runtime.launchInComposition
import androidx.compose.samples.crane.R
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.vectorResource
import kotlinx.coroutines.delay
Expand All @@ -31,7 +31,7 @@ private const val SplashWaitTime: Long = 2000

@Composable
fun LandingScreen(modifier: Modifier = Modifier, onTimeout: () -> Unit) {
Box(modifier = modifier.fillMaxSize(), gravity = ContentGravity.Center) {
Box(modifier = modifier.fillMaxSize(), alignment = Alignment.Center) {
launchInComposition {
delay(SplashWaitTime)
onTimeout()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@
package androidx.compose.samples.crane.home

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.activity.ComponentActivity
import androidx.compose.animation.DpPropKey
import androidx.compose.animation.core.FloatPropKey
import androidx.compose.animation.core.Spring.StiffnessLow
import androidx.compose.animation.core.spring
import androidx.compose.animation.core.transitionDefinition
import androidx.compose.animation.core.tween
import androidx.compose.animation.transition
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.Stack
import androidx.compose.foundation.layout.padding
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
Expand All @@ -43,7 +43,7 @@ import androidx.compose.ui.platform.setContent
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp

class MainActivity : AppCompatActivity() {
class MainActivity : ComponentActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Expand All @@ -59,7 +59,7 @@ class MainActivity : AppCompatActivity() {

var splashShown by remember { mutableStateOf(SplashState.Shown) }
val transition = transition(splashTransitionDefinition, splashShown)
Stack {
Box {
LandingScreen(
modifier = Modifier.drawOpacity(transition[splashAlphaKey]),
onTimeout = { splashShown = SplashState.Completed }
Expand Down
20 changes: 18 additions & 2 deletions Crane/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import com.example.crane.buildsrc.Libs
import com.example.crane.buildsrc.Urls
import com.example.crane.buildsrc.Versions
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

buildscript {
repositories {
Expand Down Expand Up @@ -57,7 +56,13 @@ subprojects {
}
}

tasks.withType(KotlinCompile).configureEach {
// Create a configuration which allows us to intercept the JARs, and add them to
// Kotlin Compiler freeCompilerArgs. This is needed because we can't currently use the
// built-in `compose` feature in AGP, since it depends on the old Compose Compiler artifacts.
// TODO: Remove this once AGP uses the new Compose Compiler artifact name
def compilerPluginConfig = project.configurations.create("kotlinCompilerPlugin")

tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach { compile ->
kotlinOptions {
// Treat all Kotlin warnings as errors
allWarningsAsErrors = true
Expand All @@ -68,6 +73,17 @@ subprojects {
freeCompilerArgs += '-Xopt-in=kotlin.RequiresOptIn'
freeCompilerArgs += '-Xallow-jvm-ir-dependencies'
}

compile.dependsOn(compilerPluginConfig)
compile.doFirst {
if (!compilerPluginConfig.isEmpty()) {
// Add the compiler plugin JARs using the -Xplugin flag
compile.kotlinOptions.freeCompilerArgs +=
"-Xplugin=${compilerPluginConfig.files.first()}"
// Need to turn on the IR compiler too
compile.kotlinOptions.useIR = true
}
}
}

// Crane uses Compose alpha03 and Android Gradle Plugin 4.2.0-alpha13 which are incompatible
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package com.example.crane.buildsrc

object Versions {
const val ktLint = "0.38.1"
const val ktLint = "0.39.0"
}

object Libs {
Expand All @@ -26,12 +26,12 @@ object Libs {
const val googleMaps = "com.google.android.libraries.maps:maps:3.1.0-beta"

object Accompanist {
private const val version = "0.2.2"
private const val version = "0.2.3.compose-6860046-SNAPSHOT"
const val coil = "dev.chrisbanes.accompanist:accompanist-coil:$version"
}

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"
Expand All @@ -41,9 +41,10 @@ object Libs {
const val appcompat = "androidx.appcompat:appcompat:1.3.0-alpha02"

object Compose {
const val snapshot = ""
const val version = "1.0.0-alpha03"
const val snapshot = "6860046"
const val version = "1.0.0-SNAPSHOT"

const val compiler = "androidx.compose.compiler:compiler:$version"
const val runtime = "androidx.compose.runtime:runtime:$version"
const val runtimeLivedata = "androidx.compose.runtime:runtime-livedata:$version"
const val material = "androidx.compose.material:material:$version"
Expand Down