Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

@0xZOne
Copy link
Member

@0xZOne 0xZOne commented Feb 18, 2022

Using invalidateChildInParent for API levels lower than 26.

/cc @blasten @dnfield

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 Hixie said 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.

@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 Hixie on the #hackers channel in Chat (don't just cc him here, he won't see it! He's on 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.

…rnally-calculated area instead. Because of this, clients are encouraged to just call invalidate().
}

/** Used on Android O+, {@link invalidateChildInParent} used for previous versions. */
@SuppressLint("NewApi")
Copy link

Choose a reason for hiding this comment

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

why is this required? Do you set a lower targetSdkVersion?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think we should also consider the API levels lower than 26. :)

Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this be a TargetApi attribute instead of suppress lint?

Copy link
Member Author

Choose a reason for hiding this comment

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

Shouldn't this be a TargetApi attribute instead of suppress lint?

We override this method and call invalidate simply in it. I consider @SuppressLint is fine here.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, but the right way to express this to the linter is via @TargetApi and/or @RequiresApi - see https://stackoverflow.com/questions/40007365/requiresapi-vs-targetapi-android-annotations/45773141. SuppressLint works but it looks like we're ignoring a lint without explaining why. It's not a huge deal either way in this case, especially given the comment - but with those lints you don't need the comments since it's encoded in the attribute :)

Copy link
Member Author

Choose a reason for hiding this comment

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

why is this required? Do you set a lower targetSdkVersion?

I think we should also consider the API levels lower than 26. :)

I misunderstood what @blasten meant earlier. Here @SuppressLint("NewApi") is not required indeed because onDescendantInvalidated is only called by the Android framework.

@dnfield
Copy link
Contributor

dnfield commented Feb 18, 2022

Needs a test.

@0xZOne
Copy link
Member Author

0xZOne commented Feb 18, 2022

Needs a test.

Sorry, I don't know how to write tests for this situation. If there are guidelines, I'd be happy to add them. @dnfield @blasten

@dnfield
Copy link
Contributor

dnfield commented Feb 18, 2022

In shell/platform/android/test/io/flutter/plugin/platform/PlatformViewWrapperTest.java, add a test that verifies invalidate() gets called when you call invalidateChildInParent (which would fail without this patch).

@0xZOne
Copy link
Member Author

0xZOne commented Feb 20, 2022

In shell/platform/android/test/io/flutter/plugin/platform/PlatformViewWrapperTest.java, add a test that verifies invalidate() gets called when you call invalidateChildInParent (which would fail without this patch).

@dnfield Thank you for your patient reply.

@0xZOne 0xZOne requested review from blasten and dnfield February 20, 2022 10:49
Copy link
Contributor

@dnfield dnfield left a comment

Choose a reason for hiding this comment

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

LGTM

@dnfield
Copy link
Contributor

dnfield commented Feb 22, 2022

@blasten can you provide a second review?

Copy link

@blasten blasten left a comment

Choose a reason for hiding this comment

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

LGTM

@dnfield dnfield added waiting for tree to go green This PR is approved and tested, but waiting for the tree to be green to land. and removed needs tests labels Feb 22, 2022
@fluttergithubbot fluttergithubbot merged commit ae3ece3 into flutter:main Feb 23, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Feb 23, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Feb 23, 2022
@0xZOne 0xZOne deleted the task/refactoring branch January 24, 2024 11:17
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

platform-android waiting for tree to go green This PR is approved and tested, but waiting for the tree to be green to land.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants