Skip to content

fix: limit blocks widget to 4 fields#956

Open
jvsena42 wants to merge 7 commits into
masterfrom
fix/blocks-widget-948
Open

fix: limit blocks widget to 4 fields#956
jvsena42 wants to merge 7 commits into
masterfrom
fix/blocks-widget-948

Conversation

@jvsena42
Copy link
Copy Markdown
Member

@jvsena42 jvsena42 commented May 20, 2026

Fixes #948

This PR:

  1. Limits the Bitcoin Blocks widget to a maximum of 4 selectable fields, in-app and on the home screen
  2. Removes the "Source" field from the Blocks widget and moves the mempool.space attribution into the widget description
  3. Refactors the Blocks rows display so every renderer and edit screen is driven by a single ordered field definition

Description

Following up on the Blocks widget edit settings, the field selection is now capped at four. An already-selected field can always be turned off, but a fifth selection is ignored once the limit is reached. The section header now reads "DATA (MAX 4)", and the existing Preview and Reset actions are unchanged.

The "Source" field has been removed everywhere — from the in-app edit/preview screens, the home-screen widget configuration, and the rendered cards — and its data is no longer fetched or stored. The mempool.space attribution now lives in the widget description text instead of a toggleable row.

The row-building logic, which was previously duplicated across the in-app wide and compact cards and the home-screen wide and compact layouts, plus repeated as hardcoded toggle rows in both edit screens, is now driven by a single ordered set of fields (Block, Time, Date, Transactions, Size, Fees). Each ViewModel exposes one toggle entry point that enforces the limit, and legacy preferences imported from the React Native app (which had no cap and more fields) are capped on migration.

This mirrors the already-merged iOS v61 implementation.

Preview

os-widget.webm
in-app-widget.webm
migration.webm

QA Notes

Manual Tests

  • 1. Home → add/edit widget → Bitcoin Blocks → Widget Settings: header reads "DATA (MAX 4)", lists Block/Time/Date/Transactions/Size/Fees, no Source row.
  • 2. Blocks edit (4 selected) → tap Size or Fees: stays unselected (no-op).
  • 3a. Blocks edit → unselect Transactions → tap Size: Size becomes selected.
    • 3b. tap Reset: returns to the default 4 (Block, Time, Date, Transactions).
  • 4. Blocks edit → unselect all: Preview disabled; select one field: Preview enabled.
  • 5. Blocks preview: description ends with "Powered by mempool.space.";
  • 6. Save the Blocks widget → Home: widget shows the selected rows, capped at 4.
  • 7. Home screen (OS) → add Bitcoin Blocks widget → config: same MAX 4 behavior and no Source → save: widget renders the selection.
  • **8.**2.2.0 -> Blocks widget with more than 4 items -> install this version -> should only display 4

Automated Checks

  • Unit tests added: cover the MAX-4 toggle guard and limitedToMax migration cap in app/src/test/java/to/bitkit/models/widget/BlocksWidgetFieldTest.kt.
  • Tests modified: rewrite the Block card instrumented tests for the new preferences/block signatures and drop the Source assertions in app/src/androidTest/java/to/bitkit/ui/screens/widgets/blocks/BlockCardTest.kt.
  • Local: compileDevDebugKotlin, testDevDebugUnitTest, detekt, and compileDevDebugAndroidTestKotlin all pass.
  • CI: standard compile, unit test, and detekt checks run by the PR bot.

@jvsena42 jvsena42 self-assigned this May 20, 2026
@jvsena42 jvsena42 added this to the 2.3.0 milestone May 20, 2026
@jvsena42 jvsena42 marked this pull request as ready for review May 21, 2026 09:34
@jvsena42 jvsena42 requested a review from ovitrif May 21, 2026 10:25
@piotr-iohk
Copy link
Copy Markdown
Collaborator

Since we now show max 4 rows, the OS widget has some empty space at the bottom and feels a bit top-heavy. Wondering if we can adjust the row spacing / vertical distribution so the content fills the widget height more naturally?
Other than that LGTM.

Screenshot 2026-05-21 at 14 39 31

@jvsena42 jvsena42 marked this pull request as draft May 21, 2026 13:29
@jvsena42
Copy link
Copy Markdown
Member Author

Draft to test spacing

@jvsena42
Copy link
Copy Markdown
Member Author

jvsena42 commented May 21, 2026

I did some testing with fill-height approach. It got too spaced even with 4 items, because two cells height is too broad

fill-height-tests.webm

as workaround I made the widget resizable for 1 cell height and increased the internal padding

fixed-height-tests.webm

@jvsena42 jvsena42 marked this pull request as ready for review May 21, 2026 14:35
@jvsena42
Copy link
Copy Markdown
Member Author

Another workaround could be allow select 5 items for home widget

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 497272f921

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread app/src/main/java/to/bitkit/ui/screens/widgets/blocks/BlockCard.kt Outdated
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.

Block widget edit settings follow-up

2 participants