jetc.dev Newsletter Issue #87

Published: 2021-10-19

1.0.4 and 1.1.0-alpha06 were released, so we take a peek at them!

Also, we look at the impact of composables on garbage collection, where Wear OS is going with its Compose integration, and adding ExoPlayer for video playback. Plus, we explore Clean Architecture, GraphQL, and yet another attempt to make Navigation for Compose easier.

Patch Preview and Alpha Analysis

Reviewing the release notes for the latest Jetpack Compose update!

Compose 1.0.4 was released. The headline is that it works with Kotlin 1.5.31. In fact, that appears to be the only actual change.

We also got Compose 1.1.0-alpha06. Of note:

  • If you have tests that inject input events, note that the default time between those events was raised from 10ms to 16ms. This might affect the timing of your tests.

  • There is a new ExposedDropdownMenu.

  • PopupProperties renamed dismissOnClickOutside to dismissOnOutsideClick and changed the parameter list.

  • Recomposer.state was deprecated. The alternative is a StateFlow named Recomposer.currentState.

  • A ViewConfiguration is now supplied to LayoutInfo and InjectionScope. InjectionScope now also implements Density (for easier px/dp conversions) and has flush() and dispose() functions.

One Off the Stack, One Off the Slack

You’ve got questions. That’s understandable!

How Do I Add Strikethrough to Text?

Sometimes, we want to strike out some text. In Compose UI, Text() handles this via TextStyle and TextDecoration.LineThrough, as we see in this week’s highlighted Stack Overflow question.

When Do Composition Contents Get GC’d?

Migrating from object models to function-centric programming is confusing enough in Compose. The fact that composables hold onto some objects past the function call adds to the confusion. We see what is and what is not retained for recompositions in this week’s highlighted Kotlinlang #compose Slack thread.

Composable Commentary

Posts, videos, and other new information related to Jetpack Compose!

Compose for Wear OS now in Developer Preview!

The Wear Compose / Compose for Wear OS artifacts were bumped up to 1.0.0-alpha08. According to this official blog post, that is a “developer preview”. 🤷 Regardless, Compose for Wear OS is progressing fairly nicely.

Compose for Wear OS: Scaffold

Nikit Bhandari examines some of the core composables in Compose for Wear OS, including Scaffold(), Vignette(), and PositionIndicator().

Learn with code: Jetpack Compose — Playing Media (Part 3)

Ruben Quadros is back, continuing a series of posts examining Compose UI-based app development. This time, Ruben shows how to integrate ExoPlayer via an AndroidView wrapping SimpleExoPlayer, to play back videos within the app.

Medium: Jetpack Compose Side Effects — DisposableEffect: effects that require cleanup

Umair Khalid resumes a tour of Compose effects, looking at DisposableEffect() for cases where you need to do some work to “undo” a side effect when the composition is disposed, such as unregistering a listener.

Medium: Clean Architecture in the flavour of Jetpack Compose

“Clean Architecture” is one of those things that lots of people agree with in principle but not all that many implement fully. Here, Paul Allies explores what it takes to create a fairly faithful implementation of Clean Architecture, complete with use cases, Jetpack’s ViewModel, and more.

Video: Using GraphQL in a KMM project with Jetpack Compose and SwiftUI

John O’Reilly has been exploring Kotlin/Multiplatform, sharing common code while using customized UIs for Android (via Compose UI) and iOS (via SwiftUI). In this presentation to Brighton Kotlin, John talks about those experiences, specifically when using the Apollo client library for accessing GraphQL-based Web services.

Jetpack Compose Hourglass animation on canvas in Android

Rajasekhar walks through what it takes to render custom shapes to a Compose UI Canvas(), in this case drawing a basic hourglass shape.

Jetpack Compose vs Tetris®

Graziano Rizzi did not write a post about Tetris®. Rather, Graziano wrote a post about rendering a game-style UI using Compose UI, where that UI consists of falling blocks that can be rotated. Any resemblance of this to Tetris® is purely coincidental. 😉

Resource Roundup

100% pure code!

GitHub: STAR-ZERO / compose-navgen

Another week, another library to try to simplify the use of Navigation for Compose. In this case, Kenji Abe is working on a KSP-based Gradle plugin to take @NavGen-annotated composables and create routes and helper functions for you, to make navigating to those composables look more like just calling ordinary functions.

GitHub: warting / permissions-ui

Runtime permissions are annoying. Location runtime permissions are even more annoying, particularly for background use and on Android 12+. Stefan Wärting created a LocationInBackgroundTutorialView() composable that aims to hide all of that complexity, while also providing an explanatory UI to help guide the user through the process.