Status Update
Comments
ca...@google.com <ca...@google.com> #2
We're actually removing instance of constructors not using the window because of
Is there something we can do to ensure we have the right instance of window
?
ro...@google.com <ro...@google.com> #3
mWindow
usages:
mWindow.getCurrentFocus
->mView.getRootView().findFocus()
mWindow.findViewById(android.R.id.content)
->mView.getRootView().findViewById(android.R.id.content)
mWindow.getContext()
->mView.getContext()
mWindow.addFlags()
->mView.getRootView().get/setLayoutParams().flags
mWindow.getDecorView()
->mView.getRootView()
ro...@google.com <ro...@google.com> #4
Ah I see.
Is there something we can do to ensure we have the right instance of window ?
Either pass it in, or reflect on (getRootView() as? DecorView).mWindow
, but that's relying on hidden APIs. When you have a Dialog
attached to an Activity
, looking it up via Context
isn't going to work (because there's simply no Dialog
-specific Context
instance).
Honestly though, I think we should just use the replacements from #3 that avoid interacting with the Window altogether. Added benefit: this also works with decorless windows where there isn't a Window
instance altogether.
ap...@google.com <ap...@google.com> #5
Branch: androidx-main
commit 0d8eb4081585d1be1997cb097f5fd54b41ddf8bb
Author: Alex Vanyo <vanyo@google.com>
Date: Tue Nov 23 01:06:28 2021
Convert WindowInsetsControllerCompat behavior to depend on a View to align behavior
Relnote: Converted WindowInsetsControllerCompat to depend on a View instead of a Window or the platform WindowInsetsController. This improves behavior with Dialogs, showing the IME, and ensures the non-deprecated creation methods workaround
Bug: 207401542,210121779
Test: Updated and new tests
Change-Id: I292640cb4acc39e47a4d2ce0502293d42468ed67
M core/core/api/restricted_current.txt
M core/core/src/androidTest/java/androidx/core/view/WindowInsetsAnimationCompatActivityTest.kt
M core/core/src/main/java/androidx/core/view/ViewCompat.java
M core/core/api/public_plus_experimental_current.txt
M samples/Support4Demos/src/main/java/com/example/android/supportv4/view/WindowInsetsControllerPlayground.kt
M core/core/src/main/java/androidx/core/view/WindowCompat.java
M core/core/src/androidTest/java/androidx/core/view/WindowInsetsControllerCompatActivityTest.kt
M core/core/api/current.txt
M core/core/src/main/java/androidx/core/view/WindowInsetsControllerCompat.java
M core/core/src/androidTest/java/androidx/core/view/WindowInsetsCompatActivityTest.kt
M core/core/src/androidTest/java/androidx/core/view/ViewCompatTest.java
Description
Requiring a Window instance when constructing WindowInsetsControllerCompat hinders composability, and requires unfortunate hacks like casting the Context to Activity to obtain a Window (which won't return the right instance in all cases, e.g. with
Dialog
s).We should look into removing this dependency, or making it optional.