Skip to content

feat: system widgets foundation + price widget#895

Merged
ovitrif merged 116 commits intomasterfrom
feat/system-widgets-foundation
May 7, 2026
Merged

feat: system widgets foundation + price widget#895
ovitrif merged 116 commits intomasterfrom
feat/system-widgets-foundation

Conversation

@jvsena42
Copy link
Copy Markdown
Member

@jvsena42 jvsena42 commented Apr 9, 2026

This PR:

  1. Adds a Bitcoin Price home screen widget using Jetpack Glance
  2. Implements independent widget preferences stored in a separate DataStore
  3. Uses WorkManager for periodic background data refresh (15-minute intervals)
  4. Includes a configuration Activity for widget settings on click
  5. Renders a sparkline chart via Bitmap using Android Canvas API

Description

Introduces the foundation for Android home screen widgets (AppWidgets) using Jetpack Glance, starting with the Price widget. The widget displays enabled trading pairs with price, change percentage, and a line chart — matching the in-app Price widget layout.

The architecture reuses the existing PriceService for data fetching (via a new fetchData(period) overload) while keeping widget preferences completely independent from the in-app widget system through a dedicated AppWidgetPreferencesStore backed by its own DataStore file.

A Glance design system (GlanceTextStyles, GlanceColors) ports the app's typography and color tokens to Glance equivalents, and shared components (GlanceWidgetScaffold, GlanceDataRow) provide consistent widget layouts.

Preview

Screen_recording_20260421_153032.webm

QA Notes

  1. Long-press the home screen and select "Widgets"
    • Find "Bitcoin Price" in the widget picker
    • Verify the preview shows a price layout with mock data
  2. Add the widget to the home screen
    • Verify the configuration screen opens with trading pair and period options
    • Toggle pairs and period, tap Save
    • Verify the widget updates to show selected pairs with price, change %, and sparkline chart
  3. Wait 15+ minutes or force-stop and reopen
    • Verify the widget refreshes data via WorkManager
  4. Tap the widget
    • Verify it opens the widget settings screen
    • Verify the widget update after saving new preferences
  5. Long-press the widget
    • Verify the widget is resizable
    • Verify the chat is hidden if not enough vertical space
  6. Verify the OS widget settings are independent from internal app widgets

@jvsena42 jvsena42 changed the title feat: add price home screen widget feat: System widgets foundation + price widget Apr 9, 2026
@jvsena42 jvsena42 self-assigned this Apr 10, 2026
Copy link
Copy Markdown
Contributor

@claude claude Bot left a comment

Choose a reason for hiding this comment

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

Code review

Found 2 issues: 1 CLAUDE.md violation and 1 bug.

Comment thread app/src/main/java/to/bitkit/appwidget/config/AppWidgetConfigScreen.kt Outdated
Comment thread app/src/main/java/to/bitkit/appwidget/config/AppWidgetConfigActivity.kt Outdated
@jvsena42 jvsena42 removed request for ovitrif and pwltr May 1, 2026 13:09
@jvsena42 jvsena42 requested review from ovitrif and pwltr May 1, 2026 13:51
@piotr-iohk
Copy link
Copy Markdown
Collaborator

I've approved all individual stacked PRs. I think it looks good functionally. Also e2e tests updated to cover in app redesigned widgets.

There are some outstanding items that I think would be good to address before releasing this feature:

  • behavior described here: feat: headlines widget v61 + OS widget #919 (comment) (seems to concern all OS widgets)
  • if possible consider ordering suggestion of OS widgets on add screen (IMHO price, blocks, weather could be on top if possible)
  • in app small widget support... either support it in app view or remove small preview for now. Otherwise it may be a bit confusing as why only wide version is supported despite saving the small one.

Copy link
Copy Markdown
Collaborator

@ovitrif ovitrif left a comment

Choose a reason for hiding this comment

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

Code LGTM 🎉

Going to test tomorrow.

@Stable
@Serializable
data class HomePricePreferences(
val enabledPairs: List<TradingPair> = listOf(TradingPair.BTC_USD),
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: according to AI, it’s safe to always use ImmutableList, also in business logic. Doing so would remove the need to convert for Compose UI stability.

@jvsena42
Copy link
Copy Markdown
Member Author

jvsena42 commented May 7, 2026

I'll create a branch on top of the stacked with all the fixes, to reduce the work with conflicts

@ovitrif ovitrif mentioned this pull request May 7, 2026
2 tasks
Copy link
Copy Markdown
Collaborator

@ovitrif ovitrif left a comment

Choose a reason for hiding this comment

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

Tested with success on device.

Found a couple of UI nits worth polishing in another PR.
EDIT: Extracted to new issue:


1. Bg Color Issue

Screen in AppWidgetConfigActivity doesn't have same BG color as the bitkit app, apparently.

While that's not the main issue, it leads to these visible differences in bg between system bars and app bg:

Widgets Activity App Activity

Most likely the fix is to enable edge to edge like we do in MainActivity.kt#L89

enableAppEdgeToEdge()
// setContent {
//

2. New Select Option UI Control Jump

There's a slightly visible jump on UI when changing widget options using the new select component, visible on tap:

uiglitch.mp4

@ovitrif ovitrif merged commit d60467a into master May 7, 2026
31 of 33 checks passed
@ovitrif ovitrif deleted the feat/system-widgets-foundation branch May 7, 2026 15:52
@ovitrif
Copy link
Copy Markdown
Collaborator

ovitrif commented May 7, 2026

I've approved all individual stacked PRs. I think it looks good functionally. Also e2e tests updated to cover in app redesigned widgets.

There are some outstanding items that I think would be good to address before releasing this feature:

  • behavior described here: feat: headlines widget v61 + OS widget #919 (comment) (seems to concern all OS widgets)
  • if possible consider ordering suggestion of OS widgets on add screen (IMHO price, blocks, weather could be on top if possible)
  • in app small widget support... either support it in app view or remove small preview for now. Otherwise it may be a bit confusing as why only wide version is supported despite saving the small one.

Copied these over as 'Part 2', into:

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.

4 participants