Skip to content

feat: calculator v61 redesign#942

Open
ovitrif wants to merge 6 commits into
masterfrom
feat/calculator-widget-v61
Open

feat: calculator v61 redesign#942
ovitrif wants to merge 6 commits into
masterfrom
feat/calculator-widget-v61

Conversation

@ovitrif
Copy link
Copy Markdown
Collaborator

@ovitrif ovitrif commented May 15, 2026

Fixes #937
Related: #950

Refreshes the in-app Bitcoin Calculator widget for the v6.1 widget design, routes its UI logic through the view model, and improves formatting with locale-aware thousands and decimal separator support.

The Android OS home-screen calculator widget has been removed from this PR for now. The extracted work is preserved on ovi/calculator-os-widget-v61-backup and tracked in #950. Non-calculator widget polish was split out to #952.

Description

  • Updates the in-app calculator widget to the v6.1 treatment, matching the current widget surface, spacing, focus, and input patterns used by the other refreshed widgets.
  • Replaces the old calculator text entry behavior with the Bitkit number pad flow: localized decimal entry, stable grouping, delete behavior, cursor styling, fractional zero placeholder, and red invalid-key feedback.
  • Polishes calculator focus and dismissal behavior on the app home screen so the number pad, bottom tab bar, scrolling, layout movement, and navigation bar insets behave together.
  • Keeps the OS calculator widget out of scope for this PR while preserving its branch for a follow-up.
  • Keeps non-calculator widget foundation polish split into fix: polish widget foundation #952.
  • Adds the user-facing changelog fragment for the calculator widget refresh.

Design refs:

Preview

Current In-App Widget Extracted OS Widget Backup
In-app widget, number pad, focus, dismissal, formatting, and tab-bar autohide. Historical recording from the backed-up OS widget branch, now tracked in #950.
calc_app.mp4
calc_os.mp4

QA Notes

Manual Tests

Dev verified locally:

  • Added the calculator widget to the app home screen and verified the v6.1 card renders correctly in idle and focused states.
  • Focused both Bitcoin and fiat inputs and verified Bitkit's number pad opens instead of the Android soft keyboard.
  • Typed multi-digit Bitcoin and fiat values and verified the cursor stays at the end of the visible value.
  • Verified Bitcoin grouping uses the same space-separated style as Bitkit amount views.
  • Verified fiat grouping uses normal amount formatting without the unwanted space after separators.
  • Verified deleting a digit from a grouped fiat value keeps the remaining value and converted Bitcoin value stable.
  • Verified decimal entry uses the localized decimal key and does not show both comma and period options.
  • Verified fiat one-decimal input shows the dimmed trailing zero placeholder without layout jump.
  • Verified invalid number-pad input gives red button-text feedback through the number pad error state.
  • Verified tapping outside the calculator collapses the number pad smoothly.
  • Verified the bottom tab bar hides and returns in sync with the number pad animation.
  • Verified the center scan button does not flash as highlighted while the tab bar moves.
  • Verified the calculator remains visible when the lower fiat input is focused near the bottom of the widget list.
  • Verified focusing the calculator from a lower scroll position animates the layout movement instead of jumping.
  • Verified the number pad leaves room for the Android gesture navigation handle.
  • Verified scrolling gestures around the focused calculator do not unexpectedly dismiss the number pad.
  • Verified tapping the app menu or moving away from the focused calculator dismisses the number pad.

Reviewer / QA requested:

  • 1. Add the calculator widget inside Bitkit and check idle, focused Bitcoin input, and focused fiat input states.
  • 2. Enter and delete large Bitcoin and fiat amounts, especially values above 1,000, to confirm grouping and cursor behavior.
  • 3. Check decimal behavior on Belgium locale for comma decimals and United States locale for period decimals.
  • 4. Focus the bottom input when the calculator is low in the app home widget list and confirm the number pad remains usable above the system navigation handle.
  • 5. Focus the calculator from a lower scroll position and confirm the page/layout movement animates instead of jumping.
  • 6. Tap outside the calculator and confirm the number pad collapse and bottom tab bar return animate together.
  • 7. Repeat focus and dismiss several times and confirm the scan button does not appear highlighted during tab bar movement.

Automated Tests

Added in this PR:

  • CalculatorViewModelTest: covers stored value hydration, legacy value backfill, BTC input sanitization/conversion/persistence, fiat input sanitization/conversion/persistence, fiat conversion storage without grouping, currency refresh, and display-unit changes.
  • CalculatorCardStateTest: covers calculator formatting helpers, money separators, fiat placeholder zero behavior, hydration guards, and number-pad input/delete behavior.

Related test-lane / integration test PRs:

Automated Checks

  • Local after the latest cleanup: ./gradlew compileDevDebugKotlin testDevDebugUnitTest --tests to.bitkit.ui.screens.widgets.calculator.CalculatorViewModelTest --tests to.bitkit.ui.screens.widgets.calculator.components.CalculatorCardStateTest

@ovitrif ovitrif self-assigned this May 16, 2026
@ovitrif ovitrif added this to the 2.3.0 milestone May 16, 2026
@ovitrif ovitrif force-pushed the feat/calculator-widget-v61 branch from 48aa6fa to 2183e5d Compare May 16, 2026 00:42
@ovitrif ovitrif changed the title feat: add calculator v61 app & os widget feat: calculator v61 redesign & os widget May 17, 2026
@ovitrif ovitrif marked this pull request as ready for review May 18, 2026 00:01
@ovitrif ovitrif requested review from jvsena42 and piotr-iohk May 18, 2026 00:01
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: 2183e5d8b3

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread app/src/main/java/to/bitkit/appwidget/ui/calculator/CalculatorGlanceWidget.kt Outdated
@ovitrif ovitrif force-pushed the feat/calculator-widget-v61 branch from 2183e5d to 5178b8d Compare May 18, 2026 01:13
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: 5178b8d985

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread app/src/main/java/to/bitkit/ui/screens/widgets/calculator/CalculatorViewModel.kt Outdated
Comment thread app/src/main/java/to/bitkit/models/widget/CalculatorValues.kt Outdated
@ovitrif ovitrif force-pushed the feat/calculator-widget-v61 branch from 5178b8d to 635084f Compare May 18, 2026 01:24
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: 635084fb43

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ovitrif ovitrif force-pushed the feat/calculator-widget-v61 branch from 635084f to 286c5d5 Compare May 18, 2026 01:36
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: 286c5d5b56

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread app/src/main/java/to/bitkit/appwidget/ui/calculator/CalculatorGlanceContent.kt Outdated
@ovitrif ovitrif force-pushed the feat/calculator-widget-v61 branch from 286c5d5 to 4d16994 Compare May 18, 2026 08:02
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: 4d169946b4

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread app/src/main/java/to/bitkit/appwidget/ui/calculator/CalculatorGlanceWidget.kt Outdated
@piotr-iohk
Copy link
Copy Markdown
Collaborator

Currently tapping the Calculator OS widget just opens Bitkit. For a calculator widget, I believe the users would expect the primary flow to be quick conversion: edit BTC or fiat and see the other value update, without going through the full app.
Otherwise the widget doesn't make a lot of sense I think.

Screen.Recording.2026-05-18.at.12.35.36.mov

@ovitrif
Copy link
Copy Markdown
Collaborator Author

ovitrif commented May 18, 2026

Currently tapping the Calculator OS widget just opens Bitkit. For a calculator widget, I believe the users would expect the primary flow to be quick conversion: edit BTC or fiat and see the other value update, without going through the full app. Otherwise the widget doesn't make a lot of sense I think.

Screen.Recording.2026-05-18.at.12.35.36.mov

It's not something doable in Android, I'll try in iOS, see if the platform supports it.

I agree the widget has very little value…. It still has the value if you want to know, for example what is the equivalent in fiat of your stash, would perhaps keep such a thing on my home or lock screen frankly.

Maybe, at best, we could open a dedicated screen, which maybe could have transparent BG, so it feels more like a modal than an app, and there users could play around with values.

But that requires designer input too.

cc. @aldertnl, to ack that we can't do more than show information in Android OS widgets. Can't add functionality to edit the values, as users would expect.

@ovitrif
Copy link
Copy Markdown
Collaborator Author

ovitrif commented May 18, 2026

@piotr-iohk another option which I actually had implemented 1st time is to open the Bitkit app directly on the calculator widget, focused on 1st input, when tapping it.

I replaced that with a simple "Launch Bitkit" because it was only working when Bitkit app was in background, and then there was a bit too much code to change for it.

@ovitrif
Copy link
Copy Markdown
Collaborator Author

ovitrif commented May 18, 2026

re: platform widgets capabilities:

Android
Android OS widgets support limited click actions and state updates, but they do not support focused text input, soft keyboard entry, overlays, or expanding beyond their launcher-provided bounds. A full calculator interaction would need to open Bitkit, or we would need a fixed-size button-based widget UI with significant UX compromises.

iOS
iOS can support limited button-based widget interactions, but it cannot expand the widget or show a keyboard/numpad outside its fixed widget area. A full calculator interaction still needs to open Bitkit, ideally deep-linked to the Calculator widget focused in-app.

So, a few buttons at most. Adding a numpad, with very small buttons would constrain the size of the widget to some large shapes, and add issues with touch-targets, there's a reason Material Design recommends 48x48 for the smallest buttons.

@piotr-iohk
Copy link
Copy Markdown
Collaborator

@piotr-iohk another option which I actually had implemented 1st time is to open the Bitkit app directly on the calculator widget, focused on 1st input, when tapping it.

I replaced that with a simple "Launch Bitkit" because it was only working when Bitkit app was in background, and then there was a bit too much code to change for it.

That fallback sounds fine to me, with one caveat: it should not depend on the Calculator widget already existing in the in-app widget list. The Calculator widget is not added by default, so opening Bitkit and focusing the existing home widget would fail for many users.

If tapping the OS widget can deep-link into a calculator UI that works independently of whether the in-app Calculator widget is saved, then I think that solves the UX concern well enough. It could be a dedicated calculator screen or a focused calculator preview/editor route. The important part is that users land directly in a usable calculator, not just generic Bitkit home.

@jvsena42
Copy link
Copy Markdown
Member

jvsena42 commented May 18, 2026

The UX for setting a value for OS widget is not good, specially when there is no in-app widget

I suggest to hide this widget to give us time to polish and deploy the others while experimenting the best UX for this one, considering each OS constraints

Edit: hide just the OS widget

Screen_recording_20260518_084055.webm

@piotr-iohk
Copy link
Copy Markdown
Collaborator

I suggest to hide this widget to give us time to polish and deploy the others while experimenting the best UX for this one, considering each OS constraints

I think that is reasonable.

@ovitrif
Copy link
Copy Markdown
Collaborator Author

ovitrif commented May 18, 2026

Hiding OS widget for now, will save to a separate branch on remote for tracking/backref as needed in the future.

@ovitrif
Copy link
Copy Markdown
Collaborator Author

ovitrif commented May 18, 2026

@piotr-iohk Guess we should do the same for iOS?
Not much better support from the platform there either: best way to go would be a re-design exercise from Aldert with this in mind.

@aldertnl:

While redesigning the calculator widget with these constraints in mind, please also incorporate the widget sizes concerns in conformance with the guides provided by Google on grid and sizes enforced by the platform:

On Android (here), I had to center the widget UI elements vertically by myself, thus not implement the FIGMA design, because, that would've meant the widget has a lot of uneven gray space below the fiat "input", and a smaller padding to the remaining sides (top, left, right, gap).

Here are the guides from official android devs docs:

Maybe this is a good practice for iOS too 🤷🏻, to find their official guides on the topic and apply the specifications in design.

@ovitrif ovitrif changed the title feat: calculator v61 redesign & os widget feat: calculator v61 redesign May 18, 2026
@piotr-iohk
Copy link
Copy Markdown
Collaborator

@piotr-iohk Guess we should do the same for iOS?

I believe yes, If you mean hiding OS calc widget for now. Also we should track the further Calc OS widget work under specific ticket(s).

@jvsena42
Copy link
Copy Markdown
Member

@ovitrif can be hidden under dev mode in a stacked PR so we don't lose #946

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: 011c618c42

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread app/src/main/java/to/bitkit/ui/screens/widgets/calculator/CalculatorViewModel.kt Outdated
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: b555c5c3b3

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

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: 801dcf10b4

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +257 to +261
private fun CalculatorValues.resolveSatsValue(): Long {
if (satsValue != null || displayUnit != null || fiatValue.isEmpty()) {
return resolveCalculatorSatsValue()
}
return convertFiatToSats(fiatValue)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve legacy BTC instead of stale fiat

For legacy calculator rows where both satsValue and displayUnit are missing, this makes any non-empty stored fiatValue the canonical source of sats. That corrupts saved Bitcoin amounts whenever the exchange rate or selected fiat currency changed before the upgrade: for example, an old btcValue = "10000" sats with fiatValue = "6.25" is migrated by converting the stale $6.25 at today's rate, so if BTC doubled it becomes 5,000 sats and is then persisted/displayed as such. Prefer the unambiguous BTC value when possible, and only fall back to fiat for the specific ambiguous legacy cases it is meant to recover.

Useful? React with 👍 / 👎.

@ovitrif ovitrif force-pushed the feat/calculator-widget-v61 branch from 801dcf1 to 0d3ed04 Compare May 18, 2026 22:13
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.

Polish Calculator Widget Fiat Input

4 participants