Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Properly calculate alwaysUse24HourFormat on MacOS #53795

Merged
merged 15 commits into from
Aug 1, 2024

Conversation

kpsroka
Copy link
Contributor

@kpsroka kpsroka commented Jul 10, 2024

Moves the implementation if isAlwaysUse24HourFormat from iOS's FlutterViewController internals to common utility, and makes use of it on MacOS in order to return correct value of alwaysUse24HourFormat.

This PR partially resolves #32006.

Note that on iOS 16 and MacOS 13 , there is a new API for obtaining this information: https://developer.apple.com/documentation/foundation/locale/components/3952289-hourcycle. However, to keep things simpler, I wanted to not include changes to the logic.

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide and the C , Objective-C, Java style guides.
  • I listed at least one issue that this PR fixes in the description above.
  • I added new tests to check the change I am making or feature I am adding, or the PR is test-exempt. See testing the engine for instructions on writing and running engine tests.
  • I updated/added relevant documentation (doc comments with ///).
  • I signed the CLA.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@kpsroka kpsroka force-pushed the alwaysUse24Hour-macos-32006 branch from b29181f to 99313d2 Compare July 10, 2024 11:24
@kpsroka kpsroka force-pushed the alwaysUse24Hour-macos-32006 branch from f1ccbb5 to f16f37e Compare July 10, 2024 12:29
@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact "@test-exemption-reviewer" in the #hackers channel in Chat (don't just cc them here, they won't see it! Use Discord!).

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

@knopp knopp self-requested a review July 12, 2024 10:10
Copy link
Member

@knopp knopp left a comment

Choose a reason for hiding this comment

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

LGTM. This seems like a straightforward refactor. Not sure if this needs a test since it only moves things from iOS to darwin embedder. Also I'm not sure how to test this given that the behavior depends on system settings. @cbracken, any ideas?

@cbracken
Copy link
Member

cbracken commented Jul 12, 2024

Also I'm not sure how to test this given that the behavior depends on system settings.

In the usual case, we'd say extract out a thin utility class that wraps the system setting and then write a test of the usage site against a mock. In this case, this is just a refactoring that factors out the thin wrapper that wraps the system setting. Since this also makes use of this in the mac embedding, we should add a test there.

You could write a test against the existing usage that just tests that the value set in the FlutterHourFormat is the value that's used. Probably not too much effort, but I think a case could also be made for requesting a test exemption.

Copy link
Member

@cbracken cbracken left a comment

Choose a reason for hiding this comment

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

LGTM stamp from a Japanese personal seal

Looks great! Thanks for the patch!

@stuartmorgan
Copy link
Contributor

stuartmorgan commented Jul 16, 2024

In this case, this is just a refactoring that factors out the thin wrapper that wraps the system setting.

This isn't just a refactoring though; the purpose of this PR is to change the behavior of the macOS embedding. That's a behavioral change that should not regress, and thus should be tested.

(In this case I would suggest a test that onSettingsChanged: call the channel with expected values, probably using an injected formatter as cbracken suggested.)

@zanderso
Copy link
Member

From PR triage: It looks like this PR is waiting for a test to be added, correct?

@kpsroka
Copy link
Contributor Author

kpsroka commented Jul 18, 2024

From PR triage: It looks like this PR is waiting for a test to be added, correct?

Yes, I will get to that over the weekend.

Copy link
Member

@cbracken cbracken left a comment

Choose a reason for hiding this comment

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

Overall looks good, just a few nits and suggestions.

@kpsroka
Copy link
Contributor Author

kpsroka commented Aug 1, 2024

I think that the PR is ready for merge. @cbracken please merge/add "autosubmit" [if you agree].

@kpsroka
Copy link
Contributor Author

kpsroka commented Aug 1, 2024

Note that flutter/flutter#32006 is best left [re-]opened, and updated to refer only to textScaleFactor

@cbracken cbracken added the autosubmit Merge PR when tree becomes green via auto submit App label Aug 1, 2024
@auto-submit auto-submit bot merged commit 17e3c7d into flutter:main Aug 1, 2024
31 checks passed
@cbracken
Copy link
Member

cbracken commented Aug 1, 2024

Thanks for the fix, @kpsroka! Merged!

engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Aug 1, 2024
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Aug 1, 2024
…152703)

flutter/engine@230879c...17e3c7d

2024-08-01 [email protected] Properly calculate alwaysUse24HourFormat on MacOS (flutter/engine#53795)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-engine-flutter-autoroll
Please CC [email protected],[email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/ doc/main/autoroll/README.md
@kpsroka kpsroka deleted the alwaysUse24Hour-macos-32006 branch August 2, 2024 15:49
TytaniumDev pushed a commit to TytaniumDev/flutter that referenced this pull request Aug 7, 2024
…lutter#152703)

flutter/engine@230879c...17e3c7d

2024-08-01 [email protected] Properly calculate alwaysUse24HourFormat on MacOS (flutter/engine#53795)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-engine-flutter-autoroll
Please CC [email protected],[email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/ doc/main/autoroll/README.md
Buchimi pushed a commit to Buchimi/flutter that referenced this pull request Sep 2, 2024
…lutter#152703)

flutter/engine@230879c...17e3c7d

2024-08-01 [email protected] Properly calculate alwaysUse24HourFormat on MacOS (flutter/engine#53795)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-engine-flutter-autoroll
Please CC [email protected],[email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/ doc/main/autoroll/README.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects: desktop autosubmit Merge PR when tree becomes green via auto submit App platform-ios platform-macos
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Share the alwaysUse24Hour and textScaleFactor heuristics between iOS and macOS
5 participants