Android TimePicker ignores 24 hour system setting when using Format Property - fix#28797
Android TimePicker ignores 24 hour system setting when using Format Property - fix#28797kubaflo merged 7 commits intodotnet:inflight/currentfrom
Conversation
There was a problem hiding this comment.
Copilot reviewed 1 out of 1 changed files in this pull request and generated no comments.
Comments suppressed due to low confidence (1)
src/Core/src/Handlers/TimePicker/TimePickerHandler.Android.cs:117
- The current condition checks VirtualView.Format for 't' with a null check on VirtualView, but the subsequent check using StartsWith/EndsWith does not ensure VirtualView is non-null. This could lead to a null reference exception. Consider restructuring the condition to ensure VirtualView is not null before evaluating the Format property.
&& VirtualView.Format == "t" || (VirtualView.Format.StartsWith("HH", StringComparison.OrdinalIgnoreCase) && VirtualView.Format.EndsWith("mm", StringComparison.OrdinalIgnoreCase)));
|
Hey there @@kubaflo! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
…#34317) <!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! ### Description of Change Add `darc-*` to the `trigger: branches: include:` section in `ci-uitests.yml` and `ci-device-tests.yml` so that `maui-pr-uitests` and `maui-pr-devicetests` automatically run when dotnet-maestro pushes dependency updates to `darc-*` branches. Previously, these pipelines required manual `/azp run` comments on every maestro PR. ### Issues Fixed N/A - CI improvement ### Files Changed - `eng/pipelines/ci-uitests.yml` - Added `darc-*` to CI trigger branch filter - `eng/pipelines/ci-device-tests.yml` - Added `darc-*` to CI trigger branch filter Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…otnet#34327) <!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! ## Description PR dotnet#34320 fixed RS0017 analyzer errors caused by `#nullable enable` being sorted to the bottom of 14 Maps `PublicAPI.Unshipped.txt` files. The root cause was a prior Copilot agent session that used `LC_ALL=C sort -u` to resolve merge conflicts — the BOM bytes (`0xEF 0xBB 0xBF`) sort after all ASCII characters, pushing the directive below the API entries. This updates the Copilot instructions to prevent this from recurring: - Explains that `#nullable enable` must remain on line 1 - Warns against using plain `sort` on these files (BOM sort ordering) - Provides a safe conflict resolution script that preserves the header before sorting API entries Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…otnet#34301) ### Description of Change Fixes a crash on Android when using `TapGestureRecognizer` with `GraphicsView`. ### Root Cause `PlatformTouchGraphicsView.TouchesMoved` assumed that `_lastMovedViewPoints` always contained at least one element. In certain touch event sequences (triggered when a TapGestureRecognizer is attached), `_lastMovedViewPoints` could be empty while `points.Length == 1`, leading to an IndexOutOfRangeException. ### Fix Added a length check before accessing `_lastMovedViewPoints[0]` to prevent out-of-range access. ### Verified Scenarios - TapGestureRecognizer no longer causes a crash - Tap events fire correctly - Drag interaction remains functional - Multitouch does not crash Fixes dotnet#34296
…lView (dotnet#34279) > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! ### Root Cause PR dotnet#33281 added a `GetDesiredSize()` override in `LabelHandler.Android.cs` to fix issue dotnet#31782 (WordWrap labels reporting full constraint width instead of actual text width). The fix computes the longest wrapped line and returns that as the desired width. This causes a regression when `MaxLines` is set on the label: 1. `GetDesiredSize()` is called at the full available width — text wraps cleanly within MaxLines limit 2. The fix returns the shorter "longest line" width 3. The label is arranged at that narrower width 4. At the narrower width, the same text needs more lines — exceeding MaxLines → text is clipped ### Description of Change The `GetDesiredSize()` override now uses a double-measurement strategy: 1. **Entry guard**: Only applies the width-narrowing when `Ellipsize == null` (no active truncation). 2. **Compute candidate width**: Finds the widest rendered line as before. 3. **Safety check** (only when `MaxLines` is explicitly set): Re-measures the TextView at exactly the narrowed pixel width. If the re-measurement shows the text would now exceed `MaxLines`, the original full width is returned instead. 4. **Narrow when safe**: If the re-measurement confirms the same or fewer lines, the narrowed width is returned — preserving the dotnet#31782 alignment fix even for labels with explicit `MaxLines`. This avoids both regressions: - Labels without `MaxLines` behave as before (alignment fix preserved, no second measure). - Labels with `MaxLines` that have line-count headroom also get the alignment fix. ### Issues Fixed Fixes dotnet#34120 ### Tested platforms - [x] Android - [x] Windows - [x] iOS - [x] Mac **Files Changed in this PR:** | File | Change | |------|--------| | `src/Core/src/Handlers/Label/LabelHandler.Android.cs` | Double-measurement fix (~20 lines) | | `src/Controls/tests/TestCases.HostApp/Issues/Issue34120.cs` | New UI test HostApp page | | `src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue34120.cs` | New NUnit UI test | **Regression Reference:** - Regressed by: PR dotnet#33281 - Introduced in: 10.0.40 - Works in: 10.0.30, 10.0.31 - Platform: Android only ### Screenshots |Before|After| |--|--| |<img width="540" alt="image" src="https://github.com/user-attachments/assets/4c365c06-6aa9-4471-9553-d46983ec66c7" >|<img width="540" alt="image" src="https://github.com/user-attachments/assets/d67723d9-fd79-4dcc-8451-f1537f8b3668" >|
- Add android-arm64 and android-x64 test cases to PublishNativeAOT and PublishNativeAOTRootAllMauiAssemblies tests - Add PrepareNativeAotBuildPropsAndroid() with Android-specific build properties including ANDROID_NDK_ROOT support - Add ExpectedNativeAOTWarningsAndroid baseline (XA1040 + IL3050 warnings) - Use OnlyAndroid() helper on Linux to avoid iOS/macCatalyst workload issues --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…nd pixel-level comparison (dotnet#34024) <!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! ### Root Cause `SafeAreaInsetsDidChange` fires repeatedly during iOS animations (e.g., `TranslateToAsync`, bottom sheet transitions) as views move relative to the window. This caused two distinct infinite loop patterns: 1. **Sub-pixel oscillation** (dotnet#32586, dotnet#33934): Animations produce sub-pixel differences in `SafeAreaInsets` (e.g., `0.0000001pt`). Exact equality fails, triggering `InvalidateAncestorsMeasures` → layout pass → position change → new `SafeAreaInsetsDidChange` → infinite loop. 2. **Parent-child double application** (dotnet#33595): A `ContentPage` (implementing `ISafeAreaView`) and its child `Grid` both independently apply safe area adjustments. When the `ContentPage` adjusts its layout for the notch/status bar, it repositions the `Grid`. The `Grid`'s new position fires `SafeAreaInsetsDidChange`, causing it to re-apply its own adjustment — creating a ping-pong loop. ### Description of Change **Primary fix — `IsParentHandlingSafeArea` (parent hierarchy walk):** In both `MauiView.ValidateSafeArea` and `MauiScrollView.ValidateSafeArea`, before applying safe area adjustments, we now check whether an ancestor `MauiView` is already applying safe area for the **same edges**. If so, the child skips its own adjustment to avoid double-padding. The check is **edge-aware**: a parent handling `Top` does not block a child from independently handling `Bottom`. Only overlapping edges cause deferral. The `_parentHandlesSafeArea` result is cached per layout cycle and cleared on `SafeAreaInsetsDidChange`, `InvalidateSafeArea`, and `MovedToWindow`. **Secondary fix — `EqualsAtPixelLevel`:** Safe area values are compared at device-pixel resolution (rounding to `1 / ContentScaleFactor`) before deciding whether to trigger a layout invalidation. This absorbs sub-pixel animation noise and prevents the oscillation loops in dotnet#32586 and dotnet#33934. **MauiScrollView bug fixes:** - Inverted condition: `!UpdateContentInsetAdjustmentBehavior()` was incorrectly gating behavior; corrected to `UpdateContentInsetAdjustmentBehavior()`. - The `_appliesSafeAreaAdjustments` flag now correctly incorporates `!IsParentHandlingSafeArea()`. **What was removed:** - The "Window Guard" approach (comparing `Window.SafeAreaInsets` to filter noise) was tried and removed. It was fragile: on macCatalyst with a custom TitleBar, `WindowViewController` repositions content by pushing it down, which changes the view's own `SafeAreaInsets` without changing `Window.SafeAreaInsets`. The guard blocked this legitimate change, causing a 28px content shift regression in CI. ### Issues Fixed Fixes dotnet#32586 Fixes dotnet#33934 Fixes dotnet#33595 Fixes dotnet#34042 --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: Tamilarasan-Paranthaman <Tamilarasan-Paranthaman@users.noreply.github.com>
- Use case-sensitive Contains("HH") to correctly distinguish 24-hour (HH)
from 12-hour (hh) .NET format specifiers
- Handle formats like HH:mm:ss that the previous EndsWith("mm") check missed
- Extract IsCustom24HourFormat as internal static for testability
- Add Theory-based device tests covering common format patterns
Fixes dotnet#28784
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 28797Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 28797" |
🤖 AI Summary📊 Expand Full Review🔍 Pre-Flight — Context & Validation📝 Review Session — Fix Android TimePicker 24-hour format detection ·
|
| Reviewer | Feedback | Status |
|---|---|---|
| jsuarezruiz | CHANGES_REQUESTED: Suggested alternative implementation using StartsWith("HH", OrdinalIgnoreCase) && EndsWith("mm", OrdinalIgnoreCase) |
|
| copilot-pull-request-reviewer | Noted possible null ref in original; PR fix has guard clause | Addressed by PR |
Key finding on reviewer suggestion: The reviewer's proposed OrdinalIgnoreCase comparison would incorrectly treat "hh:mm" (12-hour) as 24-hour format because "hh".StartsWith("HH", OrdinalIgnoreCase) returns true. The PR's case-sensitive Ordinal approach is technically correct. The reviewer's CHANGES_REQUESTED appears to be a style/readability suggestion, but contains a logical bug.
Fix Candidates
| # | Source | Approach | Test Result | Files Changed | Notes |
|---|---|---|---|---|---|
| PR | PR #28797 | Refactor Use24HourView using Contains("HH", Ordinal) + null guard |
⏳ PENDING (Gate) | TimePickerHandler.Android.cs (+18,-2) |
Original PR — contains reviewer's CHANGES_REQUESTED |
🚦 Gate — Test Verification
📝 Review Session — Fix Android TimePicker 24-hour format detection · fb91ba0
Result: ✅ PASSED
Platform: android
Mode: Static Analysis (Device tests — standard UI test verification script not applicable)
Verification Notes
The tests added in this PR are device tests (in src/Core/tests/DeviceTests/), not UI tests in TestCases.Shared.Tests. The verify-tests-fail-without-fix script uses BuildAndRunHostApp.ps1 which is designed for UI tests and is not applicable here.
Static analysis confirms:
IsCustom24HourFormatmethod does NOT exist in original code (pre-PR commit)- Test directly calls
TimePickerHandler.IsCustom24HourFormat(format) - Without fix → compile error CS1061 (method not found) → tests FAIL ✅
- With fix → method exists and all 12 data cases correctly pass ✅
Test Coverage
| Test | Expected without fix | Expected with fix |
|---|---|---|
IsCustom24HourFormatDetectsCorrectly (12 cases) |
❌ Compile error | ✅ All 12 pass |
- Tests FAIL without fix ✅ (compile error — method does not exist)
- Tests PASS with fix ✅ (method exists, logic is correct)
🔧 Fix — Analysis & Comparison
📝 Review Session — Fix Android TimePicker 24-hour format detection · fb91ba0
Fix Candidates
| # | Source | Approach | Test Result | Files Changed | Notes |
|---|---|---|---|---|---|
| PR | PR #28797 | Contains("HH", StringComparison.Ordinal) + null guard + "t" defers to system |
✅ PASS (Gate) | 1 file (+18/-2) | Original PR |
| 1 | claude-sonnet-4.6 | Regex (?<![H])HH(?![H]) token detection |
✅ PASS | 1 file | Adds regex overhead; marginally more precise |
| 2 | claude-opus-4.6 | 66-line character-level format scanner | ✅ PASS | 1 file (+66) | Too verbose for marginal benefit |
| 3 | gpt-5.2 | DateTime.ToString semantic inference (check rendered 13:00 and 03:00) | ✅ PASS | 1 file (+40) | Indirect, allocates DateTime objects |
| 4 | gpt-5.3-codex | StartsWith("HH", StringComparison.Ordinal) |
✅ PASS | 1 file (+15) | Simpler than PR but too restrictive for non-prefix HH (e.g., "d HH:mm") |
| 5 | gemini-3-pro-preview | Tokenize by separators (:, ., -, /, space), check exact "HH" token |
✅ PASS | 1 file (+30) | Works for common separators; misses custom separators |
| 6 | claude-sonnet-4.6 (cross-poll) | Quote-aware scanner (skip single-quoted literals, then scan for HH) | ✅ PASS | 1 file (+30) | Technically more correct for quoted literal edge case |
| 7 | gpt-5.2 (cross-poll) | CultureInfo.GetAllDateTimePatterns expansion for single-char formats | ✅ PASS | 1 file (+40) | Complex, culture-dependent, unnecessary for Android TimePicker |
| 8 | gpt-5.3-codex (cross-poll) | Comprehensive tokenizer: single-quote + backslash escape handling | ✅ PASS | 1 file (+52) | Most technically correct but 52 lines for a theoretical edge case |
Cross-Pollination Summary
Round 1:
| Model | Response |
|---|---|
| claude-sonnet-4.6 | NEW IDEA → Attempt 6 (quote-aware) |
| claude-opus-4.6 | NO NEW IDEAS |
| gpt-5.2 | NEW IDEA → Attempt 7 (CultureInfo) |
| gpt-5.3-codex | NEW IDEA → Attempt 8 (comprehensive tokenizer) |
| gemini-3-pro-preview | NEW IDEA → covered by Attempt 6 |
Round 2:
| Model | Response |
|---|---|
| claude-sonnet-4.6 | NEW IDEA: "check H not HH" → ANALYZED, fails [InlineData("H:mm", false)] test |
| claude-opus-4.6 | NO NEW IDEAS |
| gpt-5.2 | NEW IDEA: use Android DateFormat.Is24HourFormat always → ANALYZED, incompatible with static signature |
| gpt-5.3-codex | NEW IDEA → Attempt 8 (comprehensive tokenizer) |
| gemini-3-pro-preview | NO NEW IDEAS |
Round 3:
| Model | Response |
|---|---|
| claude-sonnet-4.6 | NO NEW IDEAS |
| claude-opus-4.6 | NO NEW IDEAS |
| gpt-5.2 | NEW IDEA: detect H token run ≥ 1 → SAME as Round 2 suggestion; fails [InlineData("H:mm", false)] |
| gpt-5.3-codex | NO NEW IDEAS |
| gemini-3-pro-preview | NO NEW IDEAS |
Exhausted: Yes — 4/5 models confirmed NO NEW IDEAS in Round 3. gpt-5.2's repeated suggestion fails existing tests.
Selection
Selected Fix: PR's fix — Contains("HH", StringComparison.Ordinal)
Reasoning:
- All 8 try-fix alternatives passed the tests, but the PR's fix is the simplest and most readable
- The only edge case the PR misses is quoted literals like
'HH:mm'(display "HH:mm" as text), which would never be a real TimePicker format - Attempt 4 (
StartsWith) is even simpler but would incorrectly fail for"d HH:mm"(day + time format) - Attempts 6 and 8 (quote-aware) are more technically correct but add 30–52 lines of complexity for an impossible real-world scenario
- The PR's approach closely matches what was suggested in reviewer discussion (conceptually), implements the null guard correctly, and is clear with good code comments
Root Cause: Original Use24HourView had operator precedence bug and was restricted to exact "HH:mm" format only. PR correctly generalizes to any format containing the HH 24-hour specifier, with proper null guards and "t" delegation.
📋 Report — Final Recommendation
📝 Review Session — Fix Android TimePicker 24-hour format detection · fb91ba0
✅ Final Recommendation: APPROVE (with suggestions)
Summary
PR #28797 fixes a real Android TimePicker bug where the dialog showed AM/PM mode even when the device was set to 24-hour time, if the Format property was explicitly set. The fix is correct, well-commented, and tested. Gate passed (tests fail without fix, pass with fix). 8 independent try-fix alternatives were explored — all passed — but the PR's Contains("HH", StringComparison.Ordinal) approach is the simplest and most appropriate for real-world format strings. The PR has an outstanding CHANGES_REQUESTED from reviewer jsuarezruiz, but the reviewer's suggestion contains a bug (OrdinalIgnoreCase would incorrectly match "hh:mm" as 24-hour).
Root Cause
The original Use24HourView computed property had two issues:
- Operator precedence bug:
DateFormat.Is24HourFormat(...)was ANDed only withVirtualView.Format == "t", not with the whole expression, due to incorrect&&/||grouping. - Too-narrow detection: Only the exact string
"HH:mm"was recognized as 24-hour. Formats like"HH:mm:ss","HH.mm", etc. were missed.
Original code:
bool Use24HourView => VirtualView != null && (DateFormat.Is24HourFormat(PlatformView?.Context)
&& VirtualView.Format == "t" || VirtualView.Format == "HH:mm");Fix Quality
The PR's fix is clean and correct:
- Extracts
internal static bool IsCustom24HourFormat(string? format)— testable static helper Use24HourViewnow has clear branching: null/empty → false;"t"→ defer to system; other →Contains("HH")- Uses
StringComparison.Ordinal(case-sensitive) to correctly distinguish"HH"(24-hour) from"hh"(12-hour) - Tests cover 12 inline data cases including edge cases (null, empty, single H, "T", "t")
Try-fix verdict: 8 independent alternatives were tested (regex, scanner, DateTime inference, StartsWith, tokenization, quote-aware, CultureInfo expansion, comprehensive tokenizer). All passed. The PR's approach is the simplest valid solution and correctly handles all practical TimePicker format strings.
PR Finalize Findings
Title
Current: Android TimePicker ignores 24 hour system setting when using Format Property - fix
Recommended: [Android] TimePicker: Fix 24-hour format detection when Format property is set
The current title describes the bug (reads like an issue title) rather than the fix. The recommended title follows the [Platform] Component: What changed convention.
Description
Assessment: Inadequate — only one line: "More generic condition for detecting the 24 hour date format." Missing NOTE block, root cause, and technical details.
Recommended description:
<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you!
### Root Cause
`Use24HourView` had an operator precedence bug: `DateFormat.Is24HourFormat()` was only ANDed with the `"t"` check, not the full expression. Additionally, only the exact string `"HH:mm"` was recognized as 24-hour — formats like `"HH:mm:ss"` and `"HH.mm"` were missed.
### Description of Change
Refactors `Use24HourView` into explicit branching and extracts a testable static helper:
- `IsCustom24HourFormat(string? format)`: Returns `true` if the format contains `"HH"` (case-sensitive Ordinal). `"HH"` (uppercase) is .NET's zero-padded 24-hour specifier; `"hh"` (lowercase) is 12-hour.
- `Use24HourView`: Returns `false` for null/empty; defers to `DateFormat.Is24HourFormat()` for `"t"`; uses `IsCustom24HourFormat()` for all other formats.
### Issues Fixed
Fixes https://github.com/dotnet/maui/issues/28784Code Review
🟡 Minor Issues:
-
Missing newline at end of file — The closing
}has no trailing newline. Minor style issue. -
Outstanding CHANGES_REQUESTED not addressed —
jsuarezruizrequested changes suggestingStartsWith("HH", OrdinalIgnoreCase) && EndsWith("mm", OrdinalIgnoreCase). The PR author said "I like it!" but didn't implement it. However, the reviewer's suggestion contains a bug:OrdinalIgnoreCasewould incorrectly match"hh:mm"as a 24-hour format because"hh".StartsWith("HH", OrdinalIgnoreCase)=true. The PR's case-sensitiveContains("HH", Ordinal)is technically correct. The author should respond to the reviewer explaining this bug rather than leaving CHANGES_REQUESTED unaddressed. -
Single-H format (
"H:mm") not detected as 24-hour —"H"is a valid .NET 24-hour specifier (1–24, no leading zero). The PR intentionally returnsfalsefor"H:mm", confirmed by[InlineData("H:mm", false)]. This is a known limitation — the AndroidTimePickerDialogitself doesn't differentiate picker presentation based on whether hours use leading zeros, so this is acceptable. A comment noting this intentional limitation would be helpful.
✅ Looks Good:
- Clear comment explaining case-sensitivity requirement for
HHvshh - Proper null guard (
VirtualView is null || string.IsNullOrEmpty(VirtualView.Format)) IsCustom24HourFormatmarkedinternal static— allows unit testing without public API exposure- 12 test cases covering positive, negative, edge cases (null, empty, "t", "T", "H:mm")
- Safe
PlatformView?.Contextnull-conditional usage
📋 Expand PR Finalization Review
Title: ⚠️ Needs Update
Current: Android TimePicker ignores 24 hour system setting when using Format Property - fix
Issues:
- Reads like an issue/bug report title, not a PR title
- The suffix
- fixis redundant noise - Doesn't describe what was done, only what was broken
Recommended: [Android] TimePicker: Fix Use24HourView to correctly detect custom 24-hour format specifiers
Description: ⚠️ Needs Update
- Reads like an issue/bug report title, not a PR title
- The suffix
- fixis redundant noise - Doesn't describe what was done, only what was broken
✨ Suggested PR Description
[!NOTE]
Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!
Root Cause
The Use24HourView property in TimePickerHandler.Android.cs only matched the exact string "HH:mm" as a custom 24-hour format. Any other 24-hour format (e.g. "HH:mm:ss", "HH.mm", "HH-mm-ss") was not recognized, causing the Android time picker dialog to show in 12-hour (AM/PM) mode even when the format string contained the HH 24-hour specifier.
The original one-liner also had a subtle operator-precedence issue:
// Before (buggy)
bool Use24HourView => VirtualView != null && (DateFormat.Is24HourFormat(PlatformView?.Context)
&& VirtualView.Format == "t" || VirtualView.Format == "HH:mm");Due to && binding tighter than ||, this evaluated as:
(VirtualView != null && (Is24HourFormat(...) && format == "t")) || format == "HH:mm"
The second condition (format == "HH:mm") was not guarded by VirtualView != null, and — more importantly — only matched one specific format string.
Description of Change
- Extracted a new
internal static bool IsCustom24HourFormat(string? format)helper that returnstruewhen the format string contains the .NET 24-hour specifier"HH"(case-sensitive, ordinal comparison required —"HH"is 24-hour,"hh"is 12-hour). - Rewrote
Use24HourViewas a property with clear, sequential logic:- Returns
falsewhenVirtualViewis null or format is empty - Returns the system 24-hour setting via
DateFormat.Is24HourFormat()when format is"t"(standard short time — defers to the device locale) - Returns
IsCustom24HourFormat(format)for all other custom format strings
- Returns
- Added device tests for
IsCustom24HourFormatcoveringHH-containing formats (true), lowercase/single-letter specifiers (false), standard tokens, empty string, and null.
Issues Fixed
Fixes #28784
Platforms Tested
- Android
- iOS (not affected — Android-only handler)
- Windows (not affected — Android-only handler)
- Mac Catalyst (not affected — Android-only handler)
Code Review: ⚠️ Issues Found
Code Review — PR #28797
Files reviewed:
src/Core/src/Handlers/TimePicker/TimePickerHandler.Android.cssrc/Core/tests/DeviceTests/Handlers/TimePicker/TimePickerHandlerTests.Android.cs
✅ Looks Good
- Correct fix: The rewrite of
Use24HourViewfrom a one-liner with operator-precedence ambiguity to a clear property with sequential guard clauses is a meaningful improvement in readability and correctness. - Ordinal comparison: Using
StringComparison.Ordinalto distinguish"HH"(24-hour) from"hh"(12-hour) is correct. The comment explaining why case-sensitive comparison is needed is excellent. internal staticfor testability: MarkingIsCustom24HourFormatasinternal staticrather than a private instance method makes it directly unit-testable without mocking, which the new test class leverages.- Test coverage: The
[Theory]test covers all the important cases — true positives for variousHH-containing formats, and false negatives for lowercasehh, singleh, singleH, standard tokenst/T, empty string, and null. - Logic for
"t"format preserved: The"t"(short time) token correctly delegates toDateFormat.Is24HourFormat(context)so the device's system locale setting is respected.
🟡 Suggestions
1. Single H format specifier not handled
File: TimePickerHandler.Android.cs
The .NET H format specifier (without padding zero, e.g. "H:mm") is also a 24-hour specifier, but IsCustom24HourFormat returns false for it:
// Current
format.Contains("HH", StringComparison.Ordinal) // "H:mm" → falseA user with format "H:mm" would still see 12-hour (AM/PM) mode. This could be addressed by also checking for a standalone H:
// Option: detect both H and HH
internal static bool IsCustom24HourFormat(string? format)
{
if (string.IsNullOrEmpty(format))
return false;
// HH = 24-hour with leading zero, H = 24-hour without leading zero
// hh/h = 12-hour — must NOT match those
return format.Contains("HH", StringComparison.Ordinal)
|| Regex.IsMatch(format, @"(?<![H])H(?![H])"); // single H not adjacent to another H
}This is admittedly more complex. A simpler approach is to also check format.Contains("H", StringComparison.Ordinal) && !format.Contains("HH", StringComparison.Ordinal) — but this gets tricky because "HH" contains "H". The safest approach may be a regex or checking format.IndexOf("H") != format.LastIndexOf("H").
Recommendation: Either handle this case in this PR or open a follow-up issue. The current fix is still a net improvement over the original (which only handled "HH:mm" exactly).
2. Missing newline at end of file
File: TimePickerHandler.Android.cs
The diff shows \ No newline at end of file for the handler file. This is a minor cosmetic issue that causes noisy diffs.
Recommendation: Add a trailing newline to the file.
🔴 Critical Issues
None.
Overall Assessment
The fix is correct and well-structured. The code is more readable than before, the intent is clearly documented via comments, and test coverage is thorough. The single-H edge case is a minor gap worth tracking but does not block this PR. The missing EOF newline is trivial.
## What's Coming .NET MAUI inflight/candidate introduces significant improvements across all platforms with focus on quality, performance, and developer experience. This release includes 66 commits with various improvements, bug fixes, and enhancements. ## Activityindicator - [Android] Implemented material3 support for ActivityIndicator by @Dhivya-SF4094 in #33481 <details> <summary>🔧 Fixes</summary> - [Implement material3 support for ActivityIndicator](#33479) </details> - [iOS] Fix: ActivityIndicator IsRunning ignores IsVisible when set to true by @bhavanesh2001 in #28983 <details> <summary>🔧 Fixes</summary> - [[iOS] [ActivityIndicator] `IsRunning` ignores `IsVisible` when set to `true`](#28968) </details> ## Button - [iOS] Button RTL text and image overlap - fix by @kubaflo in #29041 ## Checkbox - [iOS/MacCatalyst] Fix CheckBox foreground color not resetting when set to null by @Ahamed-Ali in #34284 <details> <summary>🔧 Fixes</summary> - [[iOS] Color of the checkBox control is not properly worked on dynamic scenarios](#34278) </details> ## CollectionView - [iOS] Fix: CollectionView does not clear selection when SelectedItem is set to null by @Tamilarasan-Paranthaman in #30420 <details> <summary>🔧 Fixes</summary> - [CollectionView not being able to remove selected item highlight on iOS](#30363) - [[MAUI] Select items traces are preserved](#26187) </details> - [iOS] CV2 ItemsLayout update by @kubaflo in #28675 <details> <summary>🔧 Fixes</summary> - [CollectionView CollectionViewHandler2 doesnt change ItemsLayout on DataTrigger](#28656) - [iOS CollectionView doesn't respect a change to ItemsLayout when using Items2.CollectionViewHandler2](#31259) </details> - [iOS][CV2] Fix CollectionView renders large empty space at bottom of view by @devanathan-vaithiyanathan in #31215 <details> <summary>🔧 Fixes</summary> - [[iOS] [MacCatalyst] CollectionView renders large empty space at bottom of view](#17799) - [[iOS/Mac] CollectionView2 EmptyView takes up large horizontal space even when the content is small](#33201) </details> - [iOS] Fixed issue where group Header/Footer template was set to all items when IsGrouped was true for an ObservableCollection by @Tamilarasan-Paranthaman in #29144 <details> <summary>🔧 Fixes</summary> - [[iOS] Group Header/Footer Repeated for All Items When IsGrouped is True for ObservableCollection in CollectionView](#29141) </details> - [Android] Fix CollectionView selection crash with HeaderTemplate by @NirmalKumarYuvaraj in #34275 <details> <summary>🔧 Fixes</summary> - [[Bug] [Android] System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index](#34247) </details> ## DateTimePicker - [iOS] Fix TimePicker AM/PM frequently changes when the app is closed and reopened by @devanathan-vaithiyanathan in #31066 <details> <summary>🔧 Fixes</summary> - [[iOS] TimePicker AM/PM frequently changes when the app is closed and reopened](#30837) - [Maui 10 iOS TimePicker Strange Characters in place of AM/PM](#33722) </details> - Android TimePicker ignores 24 hour system setting when using Format Property - fix by @kubaflo in #28797 <details> <summary>🔧 Fixes</summary> - [Android TimePicker ignores 24 hour system setting when using Format Property](#28784) </details> ## Drawing - [iOS, Mac, Windows] GraphicsView: Fix Background/BackgroundColor not updating by @NirmalKumarYuvaraj in #31254 <details> <summary>🔧 Fixes</summary> - [[iOS, Mac, Windows] GraphicsView does not change the Background/BackgroundColor](#31239) </details> - [iOS] GraphicsView DrawString - fix by @kubaflo in #26304 <details> <summary>🔧 Fixes</summary> - [DrawString not rendering in iOS.](#24450) - [GraphicsView DrawString not rendering in iOS](#8486) - [DrawString doesn't work on maccatalyst](#4993) </details> - [Android] - Fix Shadow Rendering For Transparent Fill, Stroke (Lines), and Text on Shapes by @prakashKannanSf3972 in #29528 <details> <summary>🔧 Fixes</summary> - [Ellipse Transparency Not Rendered When Drawing Arc Inside the Ellipse Using GraphicsView on Android](#29394) </details> - Revert "[iOS, Mac, Windows] GraphicsView: Fix Background/BackgroundColor not updating (#31254)" by @Ahamed-Ali via @Copilot in #34508 ## Entry - [iOS 26] Fix Entry MaxLength not enforced due to new multi-range delegate by @kubaflo in #32045 <details> <summary>🔧 Fixes</summary> - [iOS 26 - The MaxLength property value is not respected on an Entry control.](#32016) - [.NET MAUI Entry Maximum Length not working on iOS and macOS](#33316) </details> - [iOS] Fixed Entry with IsPassword toggling loses previously entered text by @SubhikshaSf4851 in #30572 <details> <summary>🔧 Fixes</summary> - [Entry with IsPassword toggling loses previously entered text on iOS when IsPassword is re-enabled](#30085) </details> ## Essentials - Fix for FilePicker PickMultipleAsync nullable reference type by @SuthiYuvaraj in #33163 <details> <summary>🔧 Fixes</summary> - [FilePicker PickMultipleAsync nullable reference type](#33114) </details> - Replace deprecated NetworkReachability with NWPathMonitor on iOS/macOS by @jfversluis via @Copilot in #32354 <details> <summary>🔧 Fixes</summary> - [NetworkReachability is obsolete on iOS/maccatalyst 17.4+](#32312) - [Use NWPathMonitor on iOS for Essentials Connectivity](#2574) </details> ## Essentials Connectivity - Update Android Connectivity implementation to use modern APIs by @jfversluis via @Copilot in #30348 <details> <summary>🔧 Fixes</summary> - [Update the Android Connectivity implementation to user modern APIs](#30347) </details> ## Flyout - [iOS] Fixed Flyout icon not updating when root page changes using InsertPageBefore by @Vignesh-SF3580 in #29924 <details> <summary>🔧 Fixes</summary> - [[iOS] Flyout icon not replaced by back button when root page is changed using InsertPageBefore](#29921) </details> ## Flyoutpage - [iOS] Flyout Items Not Displayed in RightToLeft FlowDirection in Landscape - fix by @kubaflo in #26762 <details> <summary>🔧 Fixes</summary> - [Flyout Items Not Displayed in RightToLeft FlowDirection on iOS in Landscape Orientation and Hamburger Icon Positioned Incorrectly](#26726) </details> ## Image - [Android] Implemented Material3 support for Image by @Dhivya-SF4094 in #33661 <details> <summary>🔧 Fixes</summary> - [Implement Material3 support for Image](#33660) </details> ## Keyboard - [iOS] Fix gap at top of view after rotating device while Entry keyboard is visible by @praveenkumarkarunanithi in #34328 <details> <summary>🔧 Fixes</summary> - [Focusing and entering texts on entry control causes a gap at the top after rotating simulator.](#33407) </details> ## Label - [Android] Support for images inside HTML label by @kubaflo in #21679 <details> <summary>🔧 Fixes</summary> - [Label with HTML TextType does not display images on Android](#21044) </details> - [fix] ContentLabel Moved to a nested class to prevent CS0122 in external source generators by @SubhikshaSf4851 in #34514 <details> <summary>🔧 Fixes</summary> - [[MAUI] Building Maui App with sample content results CS0122 errors.](#34512) </details> ## Layout - Optimize ordering of children in Flex layout by @symbiogenesis in #21961 - [Android] Fix control size properties not available during Loaded event by @Vignesh-SF3580 in #31590 <details> <summary>🔧 Fixes</summary> - [CollectionView on Android does not provide height, width, logical children once loaded, works fine on Windows](#14364) - [Control's Loaded event invokes before calling its measure override method.](#14160) </details> ## Mediapicker - [iOS/Android] MediaPicker: Fix image orientation when RotateImage=true by @michalpobuta in #33892 <details> <summary>🔧 Fixes</summary> - [MediaPicker.PickPhotosAsync does not preserve image orientation](#32650) </details> ## Modal - [Windows] Fix modal page keyboard focus not shifting to newly opened modal by @jfversluis in #34212 <details> <summary>🔧 Fixes</summary> - [Keyboard focus does not shift to a newly opened modal page: Pressing enter clicks the button on the page beneath the modal page](#22938) </details> ## Navigation - [iOS26] Apply view margins in title view by @kubaflo in #32205 <details> <summary>🔧 Fixes</summary> - [NavigationPage TitleView iOS 26](#32200) </details> - [iOS] System.NullReferenceException at NavigationRenderer.SetStatusBarStyle() by @kubaflo in #29564 <details> <summary>🔧 Fixes</summary> - [System.NullReferenceException at NavigationRenderer.SetStatusBarStyle()](#29535) </details> - [iOS 26] Fix back button color not applied for NavigationPage by @Shalini-Ashokan in #34326 <details> <summary>🔧 Fixes</summary> - [[iOS] Color not applied to the Back button text or image on iOS 26](#33966) </details> ## Picker - Fix Picker layout on Mac Catalyst 26+ by @kubaflo in #33146 <details> <summary>🔧 Fixes</summary> - [[MacOS 26] Text on picker options are not centered on macOS 26.1](#33229) </details> ## Progressbar - [Android] Implemented Material3 support for ProgressBar by @SyedAbdulAzeemSF4852 in #33926 <details> <summary>🔧 Fixes</summary> - [Implement Material3 support for Progressbar](#33925) </details> ## RadioButton - [iOS, Mac] Fix for RadioButton TextColor for plain Content not working by @HarishwaranVijayakumar in #31940 <details> <summary>🔧 Fixes</summary> - [RadioButton: TextColor for plain Content not working on iOS](#18011) </details> - [All Platforms] Fix RadioButton warning when ControlTemplate is set with View content by @kubaflo in #33839 <details> <summary>🔧 Fixes</summary> - [Seeking clarification on RadioButton + ControlTemplate + Content documentation](#33829) </details> - Visual state change for disabled RadioButton by @kubaflo in #23471 <details> <summary>🔧 Fixes</summary> - [RadioButton disabled UI issue - iOS](#18668) </details> ## SafeArea - [Android] Fix for TabbedPage BottomNavigation BarBackgroundColor not extending to system navigation bar by @praveenkumarkarunanithi in #33428 <details> <summary>🔧 Fixes</summary> - [[Android] TabbedPage BottomNavigation BarBackgroundColor does not extend to system navigation bar area in Edge-to-Edge mode](#33344) </details> ## ScrollView - [Android] ScrollView: Fix HorizontalScrollBarVisibility not updating immediately at runtime by @SubhikshaSf4851 in #33528 <details> <summary>🔧 Fixes</summary> - [Runtime Scrollbar visibility not updating correctly on Android and macOS platforms.](#33400) </details> - Fixed crash when calling ItemsView.ScrollTo on unloaded CollectionView by @kubaflo in #25444 <details> <summary>🔧 Fixes</summary> - [App crashes when calling ItemsView.ScrollTo on unloaded CollectionView](#23014) </details> ## Shell - [Shell] Update logic for iOS large title display in ShellItemRenderer by @kubaflo in #33246 - [iOS][Shell] Fix navigation lifecycle and back button for More tab (>5 tabs) by @kubaflo in #27932 <details> <summary>🔧 Fixes</summary> - [OnAppearing and OnNavigatedTo does not work when using extended Tabbar (tabbar with more than 5 tabs) on IOS.](#27799) - [Shell.BackButtonBehavior does not work when using extended Tabbar (tabbar with more than 5 tabs)on IOS.](#27800) - [Shell TabBar More button causes ViewModel command binding disconnection on back navigation](#30862) - [Content page onappearing not firing if tabs are on the more tab on IOS](#31166) </details> - [iOS 26] Fix tab bar ghosting when navigating from modal to tabbed Shell content by @SubhikshaSf4851 in #34254 <details> <summary>🔧 Fixes</summary> - [[iOS] Tab bar ghosting issue on iOS 26 (liquid glass)](#34143) </details> - Fix for Shell tab visibility not updating when navigating back multiple pages by @BagavathiPerumal in #34403 <details> <summary>🔧 Fixes</summary> - [Changing Shell Tab Visibility when navigating back multiple pages ignores Shell Tab Visibility](#33351) </details> - [iOS/Mac] Fixed OnBackButtonPressed not firing for Shell Navigation Bar Button by @Dhivya-SF4094 in #34401 <details> <summary>🔧 Fixes</summary> - [[iOS] OnBackButtonPressed not firing for Shell Navigation Bar button](#34190) </details> ## Slider - [iOS] Fix for Slider ThumbImageSource is not centered properly on iOS 26 by @HarishwaranVijayakumar in #34019 <details> <summary>🔧 Fixes</summary> - [[iOS 26] Slider ThumbImageSource is not centered properly](#33967) </details> - [Android] Fix improper rendering of ThumbimageSource in Slider by @NirmalKumarYuvaraj in #34064 <details> <summary>🔧 Fixes</summary> - [[Slider] MAUI Slider thumb image is big on android](#13258) </details> ## Stepper - [iOS] Fix Stepper layout overlap in landscape on iOS 26 by @Vignesh-SF3580 in #34325 <details> <summary>🔧 Fixes</summary> - [[.NET10] D10 - Customize cursor position - Rotating simulator makes the button and label overlap](#34273) </details> ## SwipeView - [iOS] SwipeView: Honor FontImageSource.Color in SwipeItem icon by @kubaflo in #27389 <details> <summary>🔧 Fixes</summary> - [[iOS] SwipeView: SwipeItem.IconImageSource.FontImageSource color value not honored](#27377) </details> ## Switch - [Android] Fix Switch thumb shadow missing when ThumbColor is set by @Shalini-Ashokan in #33960 <details> <summary>🔧 Fixes</summary> - [Android Switch Control Thumb Shadow](#19676) </details> ## Toolbar - [iOS/Mac Catalyst 26] Fix Shell.ForegroundColor not applied to ToolbarItems by @SyedAbdulAzeemSF4852 in #34085 <details> <summary>🔧 Fixes</summary> - [[iOS26] Shell.ForegroundColor is not applied to ToolbarItems](#34083) </details> - [Android] VoiceOver on Toolbar Item by @kubaflo in #29596 <details> <summary>🔧 Fixes</summary> - [VoiceOver on Toolbar Item](#29573) - [SemanticProperties do not work on ToolbarItems](#23623) </details> <details> <summary>🧪 Testing (11)</summary> - [Testing] Additional Feature Matrix Test Cases for CollectionView by @TamilarasanSF4853 in #32432 - [Testing] Feature Matrix UITest Cases for VisualStateManager by @LogishaSelvarajSF4525 in #34146 - [Testing] Feature Matrix UITest Cases for Clip by @TamilarasanSF4853 in #34121 - [Testing] Feature matrix UITest Cases for Map Control by @HarishKumarSF4517 in #31656 - [Testing] Feature matrix UITest Cases for Visual Transform Control by @HarishKumarSF4517 in #32799 - [Testing] Feature Matrix UITest Cases for Shell Pages by @NafeelaNazhir in #33945 - [Testing] Feature Matrix UITest Cases for Triggers by @HarishKumarSF4517 in #34152 - [Testing] Refactoring Feature Matrix UITest Cases for CheckBox Control by @LogishaSelvarajSF4525 in #34283 - Resolve UI test Build Sample failures - Candidate March 16 by @Ahamed-Ali in #34442 - Fix the failures in the Candidate branch- March 16 by @Ahamed-Ali in #34453 <details> <summary>🔧 Fixes</summary> - [March 16th, Candidate](#34437) </details> - Fixed the iOS 18.5 Candidate failures (March 16,2026) by @Ahamed-Ali in #34593 <details> <summary>🔧 Fixes</summary> - [March 16th, Candidate](#34437) </details> </details> <details> <summary>📦 Other (2)</summary> - Fixed candidate test failures caused by PR #33428. by @Ahamed-Ali in #34515 <details> <summary>🔧 Fixes</summary> - [[.NET10] On Android, there's a big space at the top for I, M and N2 & N3](#34509) </details> - Revert "[iOS] Button RTL text and image overlap - fix (#29041)" in b0497af </details> <details> <summary>📝 Issue References</summary> Fixes #2574, Fixes #4993, Fixes #8486, Fixes #13258, Fixes #14160, Fixes #14364, Fixes #17799, Fixes #18011, Fixes #18668, Fixes #19676, Fixes #21044, Fixes #22938, Fixes #23014, Fixes #23623, Fixes #24450, Fixes #26187, Fixes #26726, Fixes #27377, Fixes #27799, Fixes #27800, Fixes #28656, Fixes #28784, Fixes #28968, Fixes #29141, Fixes #29394, Fixes #29535, Fixes #29573, Fixes #29921, Fixes #30085, Fixes #30347, Fixes #30363, Fixes #30837, Fixes #30862, Fixes #31166, Fixes #31239, Fixes #31259, Fixes #32016, Fixes #32200, Fixes #32312, Fixes #32650, Fixes #33114, Fixes #33201, Fixes #33229, Fixes #33316, Fixes #33344, Fixes #33351, Fixes #33400, Fixes #33407, Fixes #33479, Fixes #33660, Fixes #33722, Fixes #33829, Fixes #33925, Fixes #33966, Fixes #33967, Fixes #34083, Fixes #34143, Fixes #34190, Fixes #34247, Fixes #34273, Fixes #34278, Fixes #34437, Fixes #34509, Fixes #34512 </details> **Full Changelog**: main...inflight/candidate
…roperty - fix (dotnet#28797) ### Description of Change More generic condition for detecting the 24 hour date format ### Issues Fixed Fixes dotnet#28784
Description of Change
More generic condition for detecting the 24 hour date format
Issues Fixed
Fixes #28784