Fixed
Status Update
Comments
ap...@google.com <ap...@google.com> #2
Project: platform/frameworks/support
Branch: androidx-main
commit 0ae09d3cc524aa70eaefae3ef0ad34426ce43601
Author: Ian Lake <ilake@google.com>
Date: Thu Oct 21 16:09:09 2021
Add ViewTreeOnBackPressedDispatcherOwner
Rather than only being able to cast the Context
to an OnBackPressedDispatcherOwner, use a view tag
via a ViewTree API to allow for a dynamic ability
to look up the appropriate owner.
Relnote: "The `OnBackPressedDispatcherOwner`
associated with a View can now be retrieved via
the `ViewTreeOnBackPressedDispatcherOwner`, rather
than relying on casting the `Context`."
Test: newly added test passes
BUG: 205992875
Change-Id: I74685aabe026659f649eea1b803f499a4def979e
M activity/activity/api/current.txt
M activity/activity/src/main/java/androidx/activity/ComponentActivity.java
A activity/activity/src/androidTest/java/androidx/activity/ViewTreeOnBackPressedDispatcherTest.kt
A activity/activity/src/main/java/androidx/activity/ViewTreeOnBackPressedDispatcherOwner.kt
M activity/activity-compose/src/main/java/androidx/activity/compose/BackHandler.kt
M activity/activity/api/public_plus_experimental_current.txt
A activity/activity/src/main/res/values/ids.xml
M activity/activity/api/restricted_current.txt
https://android-review.googlesource.com/1889237
Branch: androidx-main
commit 0ae09d3cc524aa70eaefae3ef0ad34426ce43601
Author: Ian Lake <ilake@google.com>
Date: Thu Oct 21 16:09:09 2021
Add ViewTreeOnBackPressedDispatcherOwner
Rather than only being able to cast the Context
to an OnBackPressedDispatcherOwner, use a view tag
via a ViewTree API to allow for a dynamic ability
to look up the appropriate owner.
Relnote: "The `OnBackPressedDispatcherOwner`
associated with a View can now be retrieved via
the `ViewTreeOnBackPressedDispatcherOwner`, rather
than relying on casting the `Context`."
Test: newly added test passes
BUG: 205992875
Change-Id: I74685aabe026659f649eea1b803f499a4def979e
M activity/activity/api/current.txt
M activity/activity/src/main/java/androidx/activity/ComponentActivity.java
A activity/activity/src/androidTest/java/androidx/activity/ViewTreeOnBackPressedDispatcherTest.kt
A activity/activity/src/main/java/androidx/activity/ViewTreeOnBackPressedDispatcherOwner.kt
M activity/activity-compose/src/main/java/androidx/activity/compose/BackHandler.kt
M activity/activity/api/public_plus_experimental_current.txt
A activity/activity/src/main/res/values/ids.xml
M activity/activity/api/restricted_current.txt
ap...@google.com <ap...@google.com> #3
Project: platform/frameworks/support
Branch: androidx-main
commit 6c888ef738c01518712ed9ae4cbf32c450aec8dc
Author: Ian Lake <ilake@google.com>
Date: Thu Oct 21 14:52:13 2021
Add ComponentDialog
Provide a stripped down equivalent to
ComponentActivity for a Dialog that implements
LifecycleOwner and OnBackPressedDispatcherOwner.
Importantly, this connects the dialog's
OnBackPressedDispatcher to the Dialog
onBackPressed() API, thus ensuring that it
is called while the dialog is on the screen.
Relnote: "Added `ComponentDialog`, a subclass of
`Dialog` that includes an `OnBackPressedDispatcher`
that will be called when the system back button is
pressed when the dialog is visible. Importantly,
this subclass also sets the
`ViewTreeOnBackPressedDispatcherOwner`, allowing views
a generic way to retrieve the correct dispatcher
whether it exists in a `ComponentActivity` or a
`ComponentDialog`."
Test: ComponentDialogTest suite
BUG: 205992875
Change-Id: I8a1bcd3c4e2b4544d4b4460e2e7fd7424af34452
M activity/activity/api/current.txt
A activity/activity/src/androidTest/java/androidx/activity/ComponentDialogTest.kt
M activity/activity/api/public_plus_experimental_current.txt
A activity/activity/src/main/java/androidx/activity/ComponentDialog.kt
M activity/activity/api/restricted_current.txt
https://android-review.googlesource.com/1889319
Branch: androidx-main
commit 6c888ef738c01518712ed9ae4cbf32c450aec8dc
Author: Ian Lake <ilake@google.com>
Date: Thu Oct 21 14:52:13 2021
Add ComponentDialog
Provide a stripped down equivalent to
ComponentActivity for a Dialog that implements
LifecycleOwner and OnBackPressedDispatcherOwner.
Importantly, this connects the dialog's
OnBackPressedDispatcher to the Dialog
onBackPressed() API, thus ensuring that it
is called while the dialog is on the screen.
Relnote: "Added `ComponentDialog`, a subclass of
`Dialog` that includes an `OnBackPressedDispatcher`
that will be called when the system back button is
pressed when the dialog is visible. Importantly,
this subclass also sets the
`ViewTreeOnBackPressedDispatcherOwner`, allowing views
a generic way to retrieve the correct dispatcher
whether it exists in a `ComponentActivity` or a
`ComponentDialog`."
Test: ComponentDialogTest suite
BUG: 205992875
Change-Id: I8a1bcd3c4e2b4544d4b4460e2e7fd7424af34452
M activity/activity/api/current.txt
A activity/activity/src/androidTest/java/androidx/activity/ComponentDialogTest.kt
M activity/activity/api/public_plus_experimental_current.txt
A activity/activity/src/main/java/androidx/activity/ComponentDialog.kt
M activity/activity/api/restricted_current.txt
il...@google.com <il...@google.com> #4
We've added a new ComponentDialog
that will be available as part of Activity 1.5.0-alpha01.
ComponentDialog
implements LifecycleOwner
and more importantly an OnBackPressedDispatcher
that plugs into the dialog's onBackPressed()
API, thus ensuring that APIs that use ViewTreeOnBackPressedDispatcherOwner
(like Activity Compose's BackHandler
) would work out of the box as soon as Compose switches to ComponentDialog
, which I suspect will be handled as part of
bl...@gmail.com <bl...@gmail.com> #5
Whatever
Description
Component used: Activity
Version used: 1.4.0
Right now the only
OnBackPressedDispatcher
available is the one provided byComponentActivity
and hooked into itsonBackPressed()
. However, when a dialog is visible, the activity'sonBackPressed()
won't be called at all - it is instead theDialog
that intercepts and handles the system back button.It would be nice if all of the
OnBackPressedDispatcher
APIs would also work in these cases, perhaps by also plugging into theDialog
class API ofonBackPressed()
.