Skip to content

fix: limit due date input length in SetDueDateDialog (part of #18553)#20459

Merged
BrayanDSO merged 1 commit intoankidroid:mainfrom
vinay-singh-dev:fix/set-due-date-limit
Mar 14, 2026
Merged

fix: limit due date input length in SetDueDateDialog (part of #18553)#20459
BrayanDSO merged 1 commit intoankidroid:mainfrom
vinay-singh-dev:fix/set-due-date-limit

Conversation

@vinay-singh-dev
Copy link
Contributor

@vinay-singh-dev vinay-singh-dev commented Mar 14, 2026

Purpose / Description

Part of issue #18553 highlights that the "Set due date" dialog in the
Browser allows extremely large values (e.g. 1000000000 days).

This PR addresses the checklist item:

Browser → Set due date → Limit the number

An InputFilter is added to restrict the number of digits that can
be entered in the due date input fields.

Fixes

Addresses part of #18553

Specifically fixes the following item:

Browser → Set due date:

  • Limit the number

Approach

Added InputFilter.LengthFilter to the EditText fields in
SetDueDateDialog.kt.

Applied to:

  • Single day input
  • Range start input
  • Range end input

This prevents extremely large values while maintaining
support for large but reasonable intervals.

How Has This Been Tested?

Tested using the debug build on an Android emulator.

Steps:

  1. Open a deck.
  2. Go to Browser → select a card → Set due date.
  3. Enter very large values (e.g. 1000000000).
  4. Confirm the input stops accepting digits after the limit.
  5. Verify normal values (10, 365, 2000) still work.
  6. Confirm due dates update correctly after pressing OK.

Test environment:

  • Android Emulator
  • Android SDK 34

Learning

Reviewed the dialog implementation in SetDueDateDialog.kt
and how input changes are handled using doOnTextChanged.

Checklist

Please, go through these checks before submitting the PR.

  • You have a descriptive commit message with a short title (first line, max 50 chars).
  • You have commented your code, particularly in hard-to-understand areas
  • You have performed a self-review of your own code
  • UI changes: include screenshots of all affected screens (in particular showing any new or changed strings)
  • UI Changes: You have tested your change using the Google Accessibility Scanner

Screenshots

@david-allison
Copy link
Member

Cheers! Got a screenshot?

  • Could you comment a justification for 5 figures:

Anki Default Maximum Interval: 100 years ~= 36,525 days, so 5 digits makes sense

@david-allison david-allison added the Needs Author Reply Waiting for a reply from the original author label Mar 14, 2026
@vinay-singh-dev
Copy link
Contributor Author

Thanks!

I chose a 5-digit limit because Anki’s default maximum interval is around 100 years (~36,525 days).
Allowing 5 digits ensures that valid intervals up to this range can still be entered while preventing extremely large values like 1000000000 days.

Here is a screenshot showing the input field after applying the limit.
WhatsApp Image 2026-03-13 at 12 15 00 PM
WhatsApp Image 2026-03-13 at 12 15 01 PM
WhatsApp Image 2026-03-13 at 12 42 12 PM

@BinaryBhaskar
Copy link
Contributor

It would be great if you directly added the screenshot to the PR description, also a small suggestion to limit the img-width when uploading it so it isn't so big.

@vinay-singh-dev
Copy link
Contributor Author

thanks for your suggestion i will keep that in mind

@david-allison
Copy link
Member

Could you edit the commit message with a brief justification of the number selected, and could I see what the 'invalid state' looks like?

Does the value go to 99999, or just stop allowing more input?

…id#18553)

fix: limit due date input length in SetDueDateDialog (part of ankidroid#18553)

Limit the input to 5 digits because Anki’s default maximum interval
is about 100 years (~36,525 days). Allowing 5 digits supports this
range while preventing extremely large values such as 1000000000 days.
@vinay-singh-dev vinay-singh-dev force-pushed the fix/set-due-date-limit branch from 7dcd2d7 to 2be2069 Compare March 14, 2026 06:00
@vinay-singh-dev
Copy link
Contributor Author

Thanks for the suggestion.

The commit message has been updated with the justification for the
5-digit limit (~36,525 days ≈ 100 years).

For the invalid state: the input does not convert the value to 99999.
Instead, the InputFilter prevents additional characters from being entered.

For example, if the user types 123456, the field remains 12345
and no further input is accepted.

I've attached a screenshot showing this behaviour.

Copy link
Member

@david-allison david-allison left a comment

Choose a reason for hiding this comment

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

Cheers!

@david-allison david-allison added Needs Second Approval Has one approval, one more approval to merge and removed Needs Author Reply Waiting for a reply from the original author Needs Review labels Mar 14, 2026
@BrayanDSO BrayanDSO added this pull request to the merge queue Mar 14, 2026
@BrayanDSO BrayanDSO added Pending Merge Things with approval that are waiting future merge (e.g. targets a future release, CI wait, etc) and removed Needs Second Approval Has one approval, one more approval to merge labels Mar 14, 2026
Merged via the queue into ankidroid:main with commit 7f29cf9 Mar 14, 2026
15 checks passed
@github-actions github-actions bot added this to the 2.24 release milestone Mar 14, 2026
@github-actions github-actions bot removed the Pending Merge Things with approval that are waiting future merge (e.g. targets a future release, CI wait, etc) label Mar 14, 2026
@ZornHadNoChoice
Copy link
Collaborator

Thanks for contributing!

Applied to:

  • Single day input
  • Range start input
  • Range end input

I just want to let you know that the two range inputs are already limited to 5 digits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants