Yingding Wang
06/07/2022, 10:51 AMcompose-wear
with an AppCompactActivity
on Wear OS, if i want to migrate to wear compose along side my view system code.
The following steps are necessary:
1. the view code need to use Theme.AppCompat.DayNight.NoActionBar
from MDC lib com.google.android.material:material
2. use the AppCompatTheme Adaptor from the Accompanist com.google.accompanist:accompanist-appcompat-theme
to copy over the AppCompat Theme to a MaterialTheme composable
3. Add wear compose dependencies, and also horologist dependencies
I wish there is a codelab for this 🙂
I made an example project to demo this possibility that I can also migrate to compose-wear starting with new features along side view system code (https://github.com/yingding/wear-os-examples/tree/main/Wear3KtxPagerExample), would love to hear your thoughts on this.yschimke
06/07/2022, 12:09 PMyschimke
06/07/2022, 12:10 PMyschimke
06/07/2022, 12:11 PMyschimke
06/07/2022, 12:12 PMyschimke
06/07/2022, 12:13 PMyschimke
06/07/2022, 12:16 PMyschimke
06/07/2022, 12:37 PMYingding Wang
06/07/2022, 12:59 PMyschimke
06/07/2022, 1:00 PMyschimke
06/07/2022, 1:04 PMyschimke
06/07/2022, 1:04 PMyschimke
06/07/2022, 1:06 PMyschimke
06/07/2022, 1:07 PMYingding Wang
06/07/2022, 1:19 PMyschimke
06/07/2022, 1:21 PMyschimke
06/07/2022, 1:34 PMyschimke
06/07/2022, 1:36 PMYingding Wang
06/13/2022, 4:19 PMvalues/styles.xml
<style name="composeWearAppTheme" parent="@android:style/Theme.DeviceDefault" ></style>
2. Apply the migration theme for each activity to migrate in AndroidManifest.xml
<activity
android:name=".migrateToComposeWearActivity"
android:label="ComponentActivity"
android:theme="@style/composeWearAppTheme"
android:exported="false"/>
3. Adopt style to theme/Color.kt
, theme/Theme.kt
,theme/Type.kt
manually and gradually activity by activity
With this approach I can keep my old Theme.AppCompat
and also use Wear Material Theme separately and don’t need to mix them.yschimke
06/13/2022, 4:36 PMyschimke
06/13/2022, 4:47 PM