Skip to content

Add local and shared state to Remote Compose Android Pet widget - #508

Merged
yrezgui merged 21 commits into
mainfrom
rc_widget
Oct 15, 2026
Merged

yrezgui merged 21 commits into
mainfrom
rc_widget

Conversation

@ashnohe

@ashnohe ashnohe commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR introduces both local state and shared app state to the Remote Compose AndroidPetWidget sample, along with a companion StoreActivity.

What's New

  • Local Document State (Host-Evaluated):
    • Uses rememberMutableRemoteInt and onTouchDown(valueChange(...)) on the pet container in AndroidPetWidget to track taps locally in the Remote Compose document without waking the app process.
    • After 3 taps, reveals the ClaimCreditButton coin icon on the host.
  • Shared App State (BuddyPreferences):
    • Tapping ClaimCreditButton invokes RemoteModifier.onClick to persist collected coins per widgetId in SharedPreferences.
  • Companion Store:
    • Adds StoreButton to launch StoreActivity for the active widget.
    • Implements StoreActivity using Material 3 dynamic colors, Scaffold + TopAppBar, LazyRow FilterChips to filter by widget instance, and ElevatedCards displaying each buddy's collected credits.

Code Cleanup & Simplifications

After migrating the initial implementation, we did several passes of refactoring reducing the implementation by ~1.3k lines of code bringing the entire commit down to ~700 lines of code.

Note that this isn't the entire Gaming Widget, more PRs are planned.

https://github.com/user-attachments/assets/d122ab04-bd41-4b1d-bdfc-c29e69259298
Shows tapping 3 times to get a gold coin, collecting the gold coin, and seeing the number of gold coins collected per widget in the Store.

- Implement 3-tap local document state for coin button visibility
- Add ClaimCreditButton and StoreButton at BottomEnd matching GamingWidget layout
- Add BuddyPreferences and StoreActivity to persist and display per-widget coin counts
- Import button vector drawables and add Robolectric/CoreDocument unit tests
@ashnohe
ashnohe requested review from MayuriKhinvasara and removed request for madebymozart October 13, 2026 20:26
@android android deleted a comment from alabiaga Oct 13, 2026
@android android deleted a comment from alabiaga Oct 13, 2026
@android android deleted a comment from alabiaga Oct 13, 2026
@ashnohe

ashnohe commented Oct 13, 2026

Copy link
Copy Markdown
Contributor Author

@alabiaga sorry for the churn on that. This PR is safe to review now.

@yrezgui yrezgui left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The README.md of app widgets doesn't mention Remote Compose. It's not clear what Remote Compose is bringing compared to Jetpack Glance from your sample

@ashnohe
ashnohe requested a review from yrezgui October 14, 2026 21:22
@yrezgui
yrezgui merged commit c3e4062 into main Oct 15, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants