Skip to content

Commit 840d92b

Browse files
committedFeb 10, 2021
[Owl] Update to snapshot 7123292.
Change-Id: Icbc31d7b3f3b19e0b77f1b2514aa76e99ea4b531
1 parent f0f9e67 commit 840d92b

File tree

19 files changed

+87
-71
lines changed

19 files changed

+87
-71
lines changed
 

‎Owl/app/build.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ dependencies {
8686

8787
implementation Libs.AndroidX.coreKtx
8888
implementation Libs.AndroidX.navigation
89+
implementation Libs.AndroidX.Activity.activityCompose
8990

9091
implementation Libs.AndroidX.Compose.runtime
9192
implementation Libs.AndroidX.Compose.foundation

‎Owl/app/src/androidTest/java/com/example/owl/ui/NavigationTest.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import androidx.compose.ui.test.performClick
2727
import com.example.owl.R
2828
import com.example.owl.model.courses
2929
import com.example.owl.ui.fakes.ProvideTestImageLoader
30-
import com.example.owl.ui.utils.AmbientBackDispatcher
30+
import com.example.owl.ui.utils.LocalBackDispatcher
3131
import dev.chrisbanes.accompanist.insets.ProvideWindowInsets
3232
import org.junit.Rule
3333
import org.junit.Test
@@ -48,7 +48,7 @@ class NavigationTest {
4848
private fun startActivity(startDestination: String? = null) {
4949
composeTestRule.setContent {
5050
val backDispatcher = composeTestRule.activity.onBackPressedDispatcher
51-
Providers(AmbientBackDispatcher provides backDispatcher) {
51+
Providers(LocalBackDispatcher provides backDispatcher) {
5252
ProvideWindowInsets {
5353
ProvideTestImageLoader {
5454
if (startDestination == null) {

‎Owl/app/src/main/java/com/example/owl/ui/MainActivity.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ package com.example.owl.ui
1818

1919
import android.os.Bundle
2020
import androidx.activity.ComponentActivity
21-
import androidx.compose.ui.platform.setContent
21+
import androidx.activity.compose.setContent
2222
import androidx.core.view.WindowCompat
2323

2424
class MainActivity : ComponentActivity() {

‎Owl/app/src/main/java/com/example/owl/ui/OwlApp.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ package com.example.owl.ui
1919
import androidx.activity.OnBackPressedDispatcher
2020
import androidx.compose.runtime.Composable
2121
import androidx.compose.runtime.Providers
22-
import com.example.owl.ui.utils.AmbientBackDispatcher
22+
import com.example.owl.ui.utils.LocalBackDispatcher
2323
import com.example.owl.ui.utils.ProvideImageLoader
2424
import dev.chrisbanes.accompanist.insets.ProvideWindowInsets
2525

2626
@Composable
2727
fun OwlApp(backDispatcher: OnBackPressedDispatcher) {
2828

29-
Providers(AmbientBackDispatcher provides backDispatcher) {
29+
Providers(LocalBackDispatcher provides backDispatcher) {
3030
ProvideWindowInsets {
3131
ProvideImageLoader {
3232
NavGraph()

‎Owl/app/src/main/java/com/example/owl/ui/course/CourseDetails.kt

+14-14
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@ import androidx.compose.foundation.lazy.LazyRow
3838
import androidx.compose.foundation.lazy.items
3939
import androidx.compose.foundation.lazy.rememberLazyListState
4040
import androidx.compose.foundation.shape.RoundedCornerShape
41-
import androidx.compose.material.AmbientContentAlpha
4241
import androidx.compose.material.ContentAlpha
4342
import androidx.compose.material.Divider
4443
import androidx.compose.material.ExperimentalMaterialApi
4544
import androidx.compose.material.FractionalThreshold
4645
import androidx.compose.material.Icon
4746
import androidx.compose.material.IconButton
47+
import androidx.compose.material.LocalContentAlpha
4848
import androidx.compose.material.MaterialTheme
4949
import androidx.compose.material.Surface
5050
import androidx.compose.material.Text
@@ -67,9 +67,9 @@ import androidx.compose.ui.Modifier
6767
import androidx.compose.ui.gesture.scrollorientationlocking.Orientation
6868
import androidx.compose.ui.graphics.Color
6969
import androidx.compose.ui.graphics.graphicsLayer
70-
import androidx.compose.ui.platform.AmbientDensity
70+
import androidx.compose.ui.platform.LocalDensity
71+
import androidx.compose.ui.res.painterResource
7172
import androidx.compose.ui.res.stringResource
72-
import androidx.compose.ui.res.vectorResource
7373
import androidx.compose.ui.text.style.TextAlign
7474
import androidx.compose.ui.text.style.TextOverflow
7575
import androidx.compose.ui.tooling.preview.Preview
@@ -89,7 +89,7 @@ import com.example.owl.ui.utils.NetworkImage
8989
import com.example.owl.ui.utils.backHandler
9090
import com.example.owl.ui.utils.lerp
9191
import com.example.owl.ui.utils.scrim
92-
import dev.chrisbanes.accompanist.insets.AmbientWindowInsets
92+
import dev.chrisbanes.accompanist.insets.LocalWindowInsets
9393
import dev.chrisbanes.accompanist.insets.navigationBarsPadding
9494
import dev.chrisbanes.accompanist.insets.statusBarsPadding
9595
import dev.chrisbanes.accompanist.insets.toPaddingValues
@@ -119,7 +119,7 @@ fun CourseDetails(
119119
PinkTheme {
120120
BoxWithConstraints {
121121
val sheetState = rememberSwipeableState(SheetState.Closed)
122-
val fabSize = with(AmbientDensity.current) { FabSize.toPx() }
122+
val fabSize = with(LocalDensity.current) { FabSize.toPx() }
123123
val dragRange = constraints.maxHeight - fabSize
124124

125125
backHandler(
@@ -201,7 +201,7 @@ private fun CourseDescriptionHeader(
201201
)
202202
}
203203
Image(
204-
imageVector = vectorResource(id = R.drawable.ic_logo),
204+
painter = painterResource(id = R.drawable.ic_logo),
205205
contentDescription = null,
206206
modifier = Modifier
207207
.padding(bottom = 4.dp)
@@ -245,7 +245,7 @@ private fun CourseDescriptionBody(course: Course) {
245245
.padding(horizontal = 16.dp)
246246
)
247247
Spacer(modifier = Modifier.preferredHeight(16.dp))
248-
Providers(AmbientContentAlpha provides ContentAlpha.medium) {
248+
Providers(LocalContentAlpha provides ContentAlpha.medium) {
249249
Text(
250250
text = stringResource(id = R.string.course_desc),
251251
style = MaterialTheme.typography.body1,
@@ -264,7 +264,7 @@ private fun CourseDescriptionBody(course: Course) {
264264
.fillMaxWidth()
265265
.padding(16.dp)
266266
)
267-
Providers(AmbientContentAlpha provides ContentAlpha.medium) {
267+
Providers(LocalContentAlpha provides ContentAlpha.medium) {
268268
Text(
269269
text = stringResource(id = R.string.needs),
270270
style = MaterialTheme.typography.body1,
@@ -337,8 +337,8 @@ private fun LessonsSheet(
337337
updateSheet: (SheetState) -> Unit
338338
) {
339339
// Use the fraction that the sheet is open to drive the transformation from FAB -> Sheet
340-
val fabSize = with(AmbientDensity.current) { FabSize.toPx() }
341-
val fabSheetHeight = fabSize + AmbientWindowInsets.current.systemBars.bottom
340+
val fabSize = with(LocalDensity.current) { FabSize.toPx() }
341+
val fabSheetHeight = fabSize + LocalWindowInsets.current.systemBars.bottom
342342
val offsetX = lerp(width - fabSize, 0f, 0f, 0.15f, openFraction)
343343
val offsetY = lerp(height - fabSheetHeight, 0f, openFraction)
344344
val tlCorner = lerp(fabSize, 0f, 0f, 0.15f, openFraction)
@@ -351,8 +351,8 @@ private fun LessonsSheet(
351351
)
352352
Surface(
353353
color = surfaceColor,
354-
contentColor = contentColorFor(color = MaterialTheme.colors.primarySurface),
355-
shape = RoundedCornerShape(topLeft = tlCorner),
354+
contentColor = contentColorFor(backgroundColor = MaterialTheme.colors.primarySurface),
355+
shape = RoundedCornerShape(topStart = tlCorner),
356356
modifier = Modifier.graphicsLayer {
357357
translationX = offsetX
358358
translationY = offsetY
@@ -409,7 +409,7 @@ private fun Lessons(
409409
}
410410
LazyColumn(
411411
state = scroll,
412-
contentPadding = AmbientWindowInsets.current.systemBars.toPaddingValues(
412+
contentPadding = LocalWindowInsets.current.systemBars.toPaddingValues(
413413
top = false
414414
)
415415
) {
@@ -465,7 +465,7 @@ private fun Lesson(lesson: Lesson) {
465465
maxLines = 2,
466466
overflow = TextOverflow.Ellipsis
467467
)
468-
Providers(AmbientContentAlpha provides ContentAlpha.medium) {
468+
Providers(LocalContentAlpha provides ContentAlpha.medium) {
469469
Row(
470470
modifier = Modifier.padding(top = 4.dp),
471471
verticalAlignment = Alignment.CenterVertically

‎Owl/app/src/main/java/com/example/owl/ui/courses/Courses.kt

+5-5
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ import androidx.annotation.StringRes
2121
import androidx.compose.foundation.Image
2222
import androidx.compose.foundation.layout.padding
2323
import androidx.compose.foundation.layout.preferredHeight
24-
import androidx.compose.material.AmbientContentColor
2524
import androidx.compose.material.BottomNavigation
2625
import androidx.compose.material.BottomNavigationItem
2726
import androidx.compose.material.Icon
2827
import androidx.compose.material.IconButton
28+
import androidx.compose.material.LocalContentColor
2929
import androidx.compose.material.MaterialTheme
3030
import androidx.compose.material.Scaffold
3131
import androidx.compose.material.Text
@@ -38,8 +38,8 @@ import androidx.compose.runtime.mutableStateOf
3838
import androidx.compose.runtime.remember
3939
import androidx.compose.ui.Alignment
4040
import androidx.compose.ui.Modifier
41+
import androidx.compose.ui.res.painterResource
4142
import androidx.compose.ui.res.stringResource
42-
import androidx.compose.ui.res.vectorResource
4343
import androidx.compose.ui.unit.dp
4444
import com.example.owl.R
4545
import com.example.owl.model.courses
@@ -61,13 +61,13 @@ fun Courses(selectCourse: (Long) -> Unit) {
6161
) {
6262
tabs.forEach { tab ->
6363
BottomNavigationItem(
64-
icon = { Icon(vectorResource(tab.icon), contentDescription = null) },
64+
icon = { Icon(painterResource(tab.icon), contentDescription = null) },
6565
label = { Text(stringResource(tab.title).toUpperCase()) },
6666
selected = tab == selectedTab,
6767
onClick = { setSelectedTab(tab) },
6868
alwaysShowLabels = false,
6969
selectedContentColor = MaterialTheme.colors.secondary,
70-
unselectedContentColor = AmbientContentColor.current,
70+
unselectedContentColor = LocalContentColor.current,
7171
modifier = Modifier.navigationBarsPadding()
7272
)
7373
}
@@ -94,7 +94,7 @@ fun CoursesAppBar() {
9494
modifier = Modifier
9595
.padding(16.dp)
9696
.align(Alignment.CenterVertically),
97-
imageVector = vectorResource(id = R.drawable.ic_lockup_white),
97+
painter = painterResource(id = R.drawable.ic_lockup_white),
9898
contentDescription = null
9999
)
100100
IconButton(

‎Owl/app/src/main/java/com/example/owl/ui/courses/FeaturedCourses.kt

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
* limitations under the License.
1515
*/
1616

17+
@file:Suppress("DEPRECATION") // FIXME move to new ConstraintLayout dep once released
18+
1719
package com.example.owl.ui.courses
1820

1921
import androidx.compose.foundation.clickable

‎Owl/app/src/main/java/com/example/owl/ui/courses/MyCourses.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ fun MyCourse(
6565
CourseListItem(
6666
course = course,
6767
onClick = { selectCourse(course.id) },
68-
shape = RoundedCornerShape(topLeft = 24.dp),
68+
shape = RoundedCornerShape(topStart = 24.dp),
6969
modifier = Modifier.preferredHeight(96.dp)
7070
)
7171
}

‎Owl/app/src/main/java/com/example/owl/ui/courses/SearchCourses.kt

+5-5
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ import androidx.compose.foundation.layout.wrapContentWidth
2525
import androidx.compose.foundation.lazy.LazyColumn
2626
import androidx.compose.foundation.lazy.items
2727
import androidx.compose.foundation.text.BasicTextField
28-
import androidx.compose.material.AmbientContentColor
2928
import androidx.compose.material.Icon
3029
import androidx.compose.material.IconButton
30+
import androidx.compose.material.LocalContentColor
3131
import androidx.compose.material.MaterialTheme
3232
import androidx.compose.material.Text
3333
import androidx.compose.material.TopAppBar
@@ -38,8 +38,8 @@ import androidx.compose.runtime.mutableStateOf
3838
import androidx.compose.runtime.remember
3939
import androidx.compose.ui.Alignment
4040
import androidx.compose.ui.Modifier
41+
import androidx.compose.ui.res.painterResource
4142
import androidx.compose.ui.res.stringResource
42-
import androidx.compose.ui.res.vectorResource
4343
import androidx.compose.ui.text.input.TextFieldValue
4444
import androidx.compose.ui.tooling.preview.Preview
4545
import androidx.compose.ui.unit.dp
@@ -99,7 +99,7 @@ private fun AppBar(
9999
) {
100100
TopAppBar(elevation = 0.dp) {
101101
Image(
102-
imageVector = vectorResource(id = R.drawable.ic_search),
102+
painter = painterResource(id = R.drawable.ic_search),
103103
contentDescription = null,
104104
modifier = Modifier
105105
.padding(16.dp)
@@ -110,10 +110,10 @@ private fun AppBar(
110110
value = searchTerm,
111111
onValueChange = updateSearchTerm,
112112
textStyle = MaterialTheme.typography.subtitle1.copy(
113-
color = AmbientContentColor.current
113+
color = LocalContentColor.current
114114
),
115115
maxLines = 1,
116-
cursorColor = AmbientContentColor.current,
116+
cursorColor = LocalContentColor.current,
117117
modifier = Modifier
118118
.weight(1f)
119119
.align(Alignment.CenterVertically)

‎Owl/app/src/main/java/com/example/owl/ui/onboarding/Onboarding.kt

+10-7
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,15 @@ import androidx.compose.foundation.layout.padding
3232
import androidx.compose.foundation.layout.preferredHeight
3333
import androidx.compose.foundation.layout.preferredSize
3434
import androidx.compose.foundation.layout.wrapContentHeight
35+
import androidx.compose.foundation.layout.wrapContentSize
3536
import androidx.compose.foundation.rememberScrollState
3637
import androidx.compose.foundation.selection.toggleable
3738
import androidx.compose.foundation.shape.CornerSize
38-
import androidx.compose.material.AmbientContentAlpha
3939
import androidx.compose.material.ContentAlpha
4040
import androidx.compose.material.FloatingActionButton
4141
import androidx.compose.material.Icon
4242
import androidx.compose.material.IconButton
43+
import androidx.compose.material.LocalContentAlpha
4344
import androidx.compose.material.MaterialTheme
4445
import androidx.compose.material.Scaffold
4546
import androidx.compose.material.Surface
@@ -58,8 +59,8 @@ import androidx.compose.ui.Alignment
5859
import androidx.compose.ui.Modifier
5960
import androidx.compose.ui.draw.scale
6061
import androidx.compose.ui.layout.Layout
62+
import androidx.compose.ui.res.painterResource
6163
import androidx.compose.ui.res.stringResource
62-
import androidx.compose.ui.res.vectorResource
6364
import androidx.compose.ui.text.style.TextAlign
6465
import androidx.compose.ui.tooling.preview.Preview
6566
import androidx.compose.ui.unit.dp
@@ -129,7 +130,7 @@ private fun AppBar() {
129130
.statusBarsPadding()
130131
) {
131132
Image(
132-
imageVector = vectorResource(id = OwlTheme.images.lockupLogo),
133+
painter = painterResource(id = OwlTheme.images.lockupLogo),
133134
contentDescription = null,
134135
modifier = Modifier.padding(16.dp)
135136
)
@@ -187,7 +188,7 @@ private fun TopicChip(topic: Topic) {
187188
Surface(
188189
modifier = Modifier.padding(4.dp),
189190
elevation = OwlTheme.elevations.card,
190-
shape = MaterialTheme.shapes.medium.copy(topLeft = CornerSize(corerRadius))
191+
shape = MaterialTheme.shapes.medium.copy(topStart = CornerSize(corerRadius))
191192
) {
192193
Row(modifier = Modifier.toggleable(value = selected, onValueChange = onSelected)) {
193194
Box {
@@ -207,7 +208,9 @@ private fun TopicChip(topic: Topic) {
207208
imageVector = Icons.Filled.Done,
208209
contentDescription = null,
209210
tint = MaterialTheme.colors.onPrimary.copy(alpha = selectedAlpha),
210-
modifier = Modifier.scale(checkScale)
211+
modifier = Modifier
212+
.wrapContentSize()
213+
.scale(checkScale)
211214
)
212215
}
213216
}
@@ -224,9 +227,9 @@ private fun TopicChip(topic: Topic) {
224227
)
225228
)
226229
Row(verticalAlignment = Alignment.CenterVertically) {
227-
Providers(AmbientContentAlpha provides ContentAlpha.medium) {
230+
Providers(LocalContentAlpha provides ContentAlpha.medium) {
228231
Icon(
229-
imageVector = vectorResource(R.drawable.ic_grain),
232+
painter = painterResource(R.drawable.ic_grain),
230233
contentDescription = null,
231234
modifier = Modifier
232235
.padding(start = 16.dp)

‎Owl/app/src/main/java/com/example/owl/ui/theme/Elevations.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
package com.example.owl.ui.theme
1818

1919
import androidx.compose.runtime.Immutable
20-
import androidx.compose.runtime.staticAmbientOf
20+
import androidx.compose.runtime.staticCompositionLocalOf
2121
import androidx.compose.ui.unit.Dp
2222
import androidx.compose.ui.unit.dp
2323

@@ -27,4 +27,4 @@ import androidx.compose.ui.unit.dp
2727
@Immutable
2828
data class Elevations(val card: Dp = 0.dp)
2929

30-
internal val AmbientElevations = staticAmbientOf { Elevations() }
30+
internal val LocalElevations = staticCompositionLocalOf { Elevations() }

‎Owl/app/src/main/java/com/example/owl/ui/theme/Images.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ package com.example.owl.ui.theme
1818

1919
import androidx.annotation.DrawableRes
2020
import androidx.compose.runtime.Immutable
21-
import androidx.compose.runtime.staticAmbientOf
21+
import androidx.compose.runtime.staticCompositionLocalOf
2222

2323
/**
2424
* Images that can vary by theme.
2525
*/
2626
@Immutable
2727
data class Images(@DrawableRes val lockupLogo: Int)
2828

29-
internal val AmbientImages = staticAmbientOf<Images>()
29+
internal val AmbientImages = staticCompositionLocalOf<Images>(null)

‎Owl/app/src/main/java/com/example/owl/ui/theme/Shape.kt

+4-4
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ val shapes = Shapes(
2424
small = RoundedCornerShape(percent = 50),
2525
medium = RoundedCornerShape(size = 0f),
2626
large = RoundedCornerShape(
27-
topLeft = 16.dp,
28-
topRight = 0.dp,
29-
bottomRight = 0.dp,
30-
bottomLeft = 16.dp
27+
topStart = 16.dp,
28+
topEnd = 0.dp,
29+
bottomEnd = 0.dp,
30+
bottomStart = 16.dp
3131
)
3232
)

0 commit comments

Comments
 (0)
Please sign in to comment.