Skip to content

Commit 195b775

Browse files
Updates all samples to alpha04 (except JetNews and Crane) and to AGP alpha13.
Android Studio 4.2. canary 13 is required to use these samples.
2 parents cbede8b + 2401604 commit 195b775

File tree

82 files changed

+851
-627
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+851
-627
lines changed

Crane/app/build.gradle

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,28 @@ android {
4040

4141
manifestPlaceholders = [ googleMapsKey : properties.getProperty("google.maps.key", "") ]
4242
}
43+
44+
signingConfigs {
45+
// We use a bundled debug keystore, to allow debug builds from CI to be upgradable
46+
debug {
47+
storeFile rootProject.file('debug.keystore')
48+
storePassword 'android'
49+
keyAlias 'androiddebugkey'
50+
keyPassword 'android'
51+
}
52+
}
53+
4354
buildTypes {
55+
debug {
56+
signingConfig signingConfigs.debug
57+
}
58+
4459
release {
4560
minifyEnabled false
4661
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
4762
}
4863
}
64+
4965
compileOptions {
5066
sourceCompatibility JavaVersion.VERSION_1_8
5167
targetCompatibility JavaVersion.VERSION_1_8

Crane/build.gradle

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,18 @@ subprojects {
6969
freeCompilerArgs += '-Xallow-jvm-ir-dependencies'
7070
}
7171
}
72-
}
72+
73+
// Crane uses Compose alpha03 and Android Gradle Plugin 4.2.0-alpha13 which are incompatible
74+
// TODO: Remove this workaround when updating to >alpha04
75+
configurations.configureEach {
76+
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
77+
def group = details.requested.group
78+
def module = details.requested.module.name
79+
def version = details.requested.version
80+
81+
if (group == 'androidx.compose.compiler' && module == 'compiler') {
82+
details.useTarget("androidx.compose:compose-compiler:$version")
83+
}
84+
}
85+
}
86+
}

Crane/buildSrc/src/main/java/com/example/crane/buildsrc/Dependencies.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ object Versions {
2121
}
2222

2323
object Libs {
24-
const val androidGradlePlugin = "com.android.tools.build:gradle:4.2.0-alpha10"
24+
const val androidGradlePlugin = "com.android.tools.build:gradle:4.2.0-alpha13"
2525
const val ktLint = "com.pinterest:ktlint:${Versions.ktLint}"
2626
const val googleMaps = "com.google.android.libraries.maps:maps:3.1.0-beta"
2727

Crane/debug.keystore

2.05 KB
Binary file not shown.

JetNews/app/build.gradle

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,21 @@ android {
2929
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
3030
}
3131

32+
signingConfigs {
33+
// We use a bundled debug keystore, to allow debug builds from CI to be upgradable
34+
debug {
35+
storeFile rootProject.file('debug.keystore')
36+
storePassword 'android'
37+
keyAlias 'androiddebugkey'
38+
keyPassword 'android'
39+
}
40+
}
41+
3242
buildTypes {
43+
debug {
44+
signingConfig signingConfigs.debug
45+
}
46+
3347
release {
3448
minifyEnabled false
3549
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'

JetNews/build.gradle

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616

1717
buildscript {
18-
ext.kotlin_version = '1.4.0'
18+
ext.kotlin_version = '1.4.10'
1919
ext.compose_version = '1.0.0-alpha03'
2020

2121
repositories {
@@ -24,7 +24,7 @@ buildscript {
2424
}
2525

2626
dependencies {
27-
classpath 'com.android.tools.build:gradle:4.2.0-alpha10'
27+
classpath 'com.android.tools.build:gradle:4.2.0-alpha13'
2828
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
2929
}
3030
}
@@ -50,4 +50,20 @@ subprojects {
5050
licenseHeaderFile rootProject.file('spotless/copyright.kt')
5151
}
5252
}
53+
}
54+
55+
// JetNews uses Compose alpha03 and Android Gradle Plugin 4.2.0-alpha13 which are incompatible
56+
// TODO: Remove this workaround when updating to >alpha04
57+
subprojects {
58+
configurations.configureEach {
59+
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
60+
def group = details.requested.group
61+
def module = details.requested.module.name
62+
def version = details.requested.version
63+
64+
if (group == 'androidx.compose.compiler' && module == 'compiler') {
65+
details.useTarget("androidx.compose:compose-compiler:$version")
66+
}
67+
}
68+
}
5369
}

JetNews/debug.keystore

2.05 KB
Binary file not shown.

Jetcaster/app/build.gradle

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,21 @@ android {
5454
exclude "/*.jar"
5555
}
5656

57+
signingConfigs {
58+
// We use a bundled debug keystore, to allow debug builds from CI to be upgradable
59+
debug {
60+
storeFile rootProject.file('debug.keystore')
61+
storePassword 'android'
62+
keyAlias 'androiddebugkey'
63+
keyPassword 'android'
64+
}
65+
}
66+
5767
buildTypes {
68+
debug {
69+
signingConfig signingConfigs.debug
70+
}
71+
5872
release {
5973
minifyEnabled false
6074
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
@@ -84,9 +98,7 @@ dependencies {
8498
implementation Libs.Coroutines.android
8599

86100
implementation Libs.AndroidX.coreKtx
87-
implementation Libs.AndroidX.appcompat
88101
implementation Libs.AndroidX.palette
89-
implementation Libs.material
90102

91103
implementation Libs.AndroidX.Lifecycle.viewmodel
92104

Jetcaster/app/src/main/java/com/example/jetcaster/ui/MainActivity.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@
1717
package com.example.jetcaster.ui
1818

1919
import android.os.Bundle
20-
import androidx.appcompat.app.AppCompatActivity
20+
import androidx.activity.ComponentActivity
2121
import androidx.compose.ui.platform.setContent
2222
import androidx.core.view.WindowCompat
2323
import com.example.jetcaster.ui.theme.JetcasterTheme
2424
import com.example.jetcaster.util.ProvideDisplayInsets
2525

26-
class MainActivity : AppCompatActivity() {
26+
class MainActivity : ComponentActivity() {
2727
override fun onCreate(savedInstanceState: Bundle?) {
2828
super.onCreate(savedInstanceState)
2929

Jetcaster/app/src/main/java/com/example/jetcaster/ui/home/Home.kt

Lines changed: 63 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@
1616

1717
package com.example.jetcaster.ui.home
1818

19-
import androidx.compose.foundation.Box
2019
import androidx.compose.foundation.Icon
20+
import androidx.compose.foundation.Image
2121
import androidx.compose.foundation.Text
2222
import androidx.compose.foundation.background
23+
import androidx.compose.foundation.layout.Box
2324
import androidx.compose.foundation.layout.Column
24-
import androidx.compose.foundation.layout.ColumnScope.align
25+
import androidx.compose.foundation.layout.Row
2526
import androidx.compose.foundation.layout.Spacer
26-
import androidx.compose.foundation.layout.Stack
2727
import androidx.compose.foundation.layout.aspectRatio
2828
import androidx.compose.foundation.layout.fillMaxHeight
2929
import androidx.compose.foundation.layout.fillMaxSize
@@ -32,7 +32,6 @@ import androidx.compose.foundation.layout.height
3232
import androidx.compose.foundation.layout.padding
3333
import androidx.compose.foundation.layout.preferredHeight
3434
import androidx.compose.foundation.layout.preferredHeightIn
35-
import androidx.compose.foundation.layout.preferredWidth
3635
import androidx.compose.foundation.layout.size
3736
import androidx.compose.foundation.shape.RoundedCornerShape
3837
import androidx.compose.material.EmphasisAmbient
@@ -44,6 +43,7 @@ import androidx.compose.material.Tab
4443
import androidx.compose.material.TabConstants.defaultTabIndicatorOffset
4544
import androidx.compose.material.TabPosition
4645
import androidx.compose.material.TabRow
46+
import androidx.compose.material.TopAppBar
4747
import androidx.compose.material.icons.Icons
4848
import androidx.compose.material.icons.filled.AccountCircle
4949
import androidx.compose.material.icons.filled.Search
@@ -76,7 +76,7 @@ import com.example.jetcaster.util.ToggleFollowPodcastIconButton
7676
import com.example.jetcaster.util.constrastAgainst
7777
import com.example.jetcaster.util.quantityStringResource
7878
import com.example.jetcaster.util.rememberDominantColorState
79-
import com.example.jetcaster.util.statusBarsPadding
79+
import com.example.jetcaster.util.statusBarsHeight
8080
import com.example.jetcaster.util.verticalGradientScrim
8181
import dev.chrisbanes.accompanist.coil.CoilImage
8282
import java.time.Duration
@@ -104,36 +104,34 @@ fun Home() {
104104

105105
@Composable
106106
fun HomeAppBar(
107+
backgroundColor: Color,
107108
modifier: Modifier = Modifier
108109
) {
109-
Stack(modifier = modifier) {
110-
ProvideEmphasis(EmphasisAmbient.current.high) {
111-
Icon(
112-
asset = vectorResource(R.drawable.ic_text_logo),
113-
modifier = Modifier.align(Alignment.Center)
114-
.padding(8.dp)
115-
.preferredHeightIn(max = 24.dp)
116-
)
117-
}
118-
119-
ProvideEmphasis(EmphasisAmbient.current.medium) {
120-
IconButton(
121-
onClick = { /* TODO: Open account? */ },
122-
modifier = Modifier.align(Alignment.CenterStart)
123-
.padding(start = 8.dp)
124-
) {
125-
Icon(Icons.Default.AccountCircle)
110+
TopAppBar(
111+
title = {
112+
Row {
113+
Image(asset = vectorResource(R.drawable.ic_logo))
114+
Icon(
115+
asset = vectorResource(R.drawable.ic_text_logo),
116+
modifier = Modifier.padding(start = 4.dp).preferredHeightIn(max = 24.dp)
117+
)
126118
}
127-
128-
IconButton(
129-
onClick = { /* TODO: Open search */ },
130-
modifier = Modifier.align(Alignment.CenterEnd)
131-
.padding(end = 8.dp)
132-
) {
133-
Icon(Icons.Filled.Search)
119+
},
120+
backgroundColor = backgroundColor,
121+
actions = {
122+
ProvideEmphasis(EmphasisAmbient.current.medium) {
123+
IconButton(
124+
onClick = { /* TODO: Open search */ },
125+
icon = { Icon(Icons.Filled.Search) }
126+
)
127+
IconButton(
128+
onClick = { /* TODO: Open account? */ },
129+
icon = { Icon(Icons.Default.AccountCircle) }
130+
)
134131
}
135-
}
136-
}
132+
},
133+
modifier = modifier
134+
)
137135
}
138136

139137
/**
@@ -179,38 +177,38 @@ fun HomeContent(
179177
dominantColorState.reset()
180178
}
181179

182-
Stack(Modifier.fillMaxWidth()) {
183-
Box(
184-
Modifier.matchParentSize()
185-
.verticalGradientScrim(
186-
color = MaterialTheme.colors.primary.copy(alpha = 0.38f),
187-
startYPercentage = 1f,
188-
endYPercentage = 0f
189-
)
180+
Column(
181+
modifier = Modifier.fillMaxWidth()
182+
.verticalGradientScrim(
183+
color = MaterialTheme.colors.primary.copy(alpha = 0.38f),
184+
startYPercentage = 1f,
185+
endYPercentage = 0f
186+
)
187+
) {
188+
val appBarColor = MaterialTheme.colors.surface.copy(alpha = 0.87f)
189+
190+
// Draw a scrim over the status bar which matches the app bar
191+
Spacer(Modifier.background(appBarColor).fillMaxWidth().statusBarsHeight())
192+
193+
HomeAppBar(
194+
backgroundColor = appBarColor,
195+
modifier = Modifier.fillMaxWidth()
190196
)
191197

192-
Column(Modifier.fillMaxWidth()) {
193-
HomeAppBar(
194-
Modifier.fillMaxWidth()
195-
.statusBarsPadding()
196-
.preferredHeight(56.dp) /* TODO: change height to 48.dp in landscape */
198+
if (featuredPodcasts.isNotEmpty()) {
199+
Spacer(Modifier.height(16.dp))
200+
201+
FollowedPodcasts(
202+
items = featuredPodcasts,
203+
pagerState = pagerState,
204+
onPodcastUnfollowed = onPodcastUnfollowed,
205+
modifier = Modifier
206+
.padding(start = Keyline1, top = 16.dp, end = Keyline1)
207+
.fillMaxWidth()
208+
.preferredHeight(200.dp)
197209
)
198210

199-
if (featuredPodcasts.isNotEmpty()) {
200-
Spacer(Modifier.height(16.dp))
201-
202-
FollowedPodcasts(
203-
items = featuredPodcasts,
204-
pagerState = pagerState,
205-
onPodcastUnfollowed = onPodcastUnfollowed,
206-
modifier = Modifier
207-
.padding(start = Keyline1, top = 16.dp, end = Keyline1)
208-
.fillMaxWidth()
209-
.preferredHeight(200.dp)
210-
)
211-
212-
Spacer(Modifier.height(16.dp))
213-
}
211+
Spacer(Modifier.height(16.dp))
214212
}
215213
}
216214
}
@@ -266,7 +264,8 @@ private fun HomeCategoryTabs(
266264
text = when (category) {
267265
HomeCategory.Library -> stringResource(R.string.home_library)
268266
HomeCategory.Discover -> stringResource(R.string.home_discover)
269-
}
267+
},
268+
style = MaterialTheme.typography.body2
270269
)
271270
}
272271
)
@@ -277,12 +276,11 @@ private fun HomeCategoryTabs(
277276
@Composable
278277
fun HomeCategoryTabIndicator(
279278
modifier: Modifier = Modifier,
280-
color: Color = MaterialTheme.colors.primary
279+
color: Color = MaterialTheme.colors.onSurface
281280
) {
282281
Spacer(
283-
modifier.preferredWidth(112.dp)
282+
modifier.padding(horizontal = 24.dp)
284283
.preferredHeight(4.dp)
285-
.align(Alignment.CenterHorizontally)
286284
.background(color, RoundedCornerShape(topLeftPercent = 100, topRightPercent = 100))
287285
)
288286
}
@@ -308,15 +306,11 @@ fun FollowedPodcasts(
308306
podcastImageUrl = podcast.imageUrl,
309307
lastEpisodeDate = lastEpisodeDate,
310308
onUnfollowedClick = { onPodcastUnfollowed(podcast.uri) },
311-
modifier = Modifier.padding(4.dp)
312-
.fillMaxHeight()
313-
.scalePagerItems(unselectedScale = PodcastCarouselUnselectedScale)
309+
modifier = Modifier.padding(4.dp).fillMaxHeight()
314310
)
315311
}
316312
}
317313

318-
private const val PodcastCarouselUnselectedScale = 0.85f
319-
320314
@Composable
321315
private fun FollowedPodcastCarouselItem(
322316
podcastImageUrl: String? = null,
@@ -327,7 +321,7 @@ private fun FollowedPodcastCarouselItem(
327321
Column(
328322
modifier.padding(horizontal = 12.dp, vertical = 8.dp)
329323
) {
330-
Stack(
324+
Box(
331325
Modifier
332326
.weight(1f)
333327
.align(Alignment.CenterHorizontally)

0 commit comments

Comments
 (0)