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

Question about the usage of internal APIs in the bottom sheet implementation #36

Closed
StylianosGakis opened this issue Jun 28, 2024 · 1 comment

Comments

@StylianosGakis
Copy link

This is not a feature request nor a bug report, I was mostly curious about the lines I can see inside here in particular

val className = "android.view.WindowManager\$LayoutParams"
val layoutParamsClass = Class.forName(className)
val privateFlags: Field = layoutParamsClass.getField("privateFlags")
val noAnim: Field = layoutParamsClass.getField("PRIVATE_FLAG_NO_MOVE_ANIMATION")
var privateFlagsValue: Int = privateFlags.getInt(this)
val noAnimFlag: Int = noAnim.getInt(this)
privateFlagsValue = privateFlagsValue or noAnimFlag
privateFlags.setInt(this, privateFlagsValue)

I am only asking because I am concerned about what kind of risks you think one would be opting into while using this. And what are the chances that these private APIs will change in the future in a backwards incompatible way making this not work as expected in future Android API levels. If that were to happen, can the library update the code accordingly to keep all of this working as expected?

@StylianosGakis StylianosGakis changed the title Question about the usage of interal APIs in the bottom sheet implementation Question about the usage of internal APIs in the bottom sheet implementation Jun 28, 2024
@skydoves
Copy link
Owner

skydoves commented Aug 7, 2024

Hey @StylianosGakis, sorry for the late response. That's an interesting question. Yes, the FlexibleBottomSheet uses reflection to access private fields in WindowManager. However, you don't need to worry about it, as the code in WindowManager has remained unchanged for 13 years 😄, as you can see in the AOSP:
https://android.googlesource.com/platform/frameworks/base/+log/539ee87/core/java/android/view/WindowManager.java

@skydoves skydoves closed this as completed Aug 7, 2024
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

No branches or pull requests

2 participants