Fixed
Status Update
Comments
hu...@littlerobots.nl <hu...@littlerobots.nl> #2
Sorry, but I'm noticing that this complicates the code I need to write in the new API vs the previous API because now I need to keep track of the enabled state in stead of evaluating it when back is pressed. I'm not sure where the requirement described in this issue comes from but it seems a bit philosophical to me :)
il...@google.com <il...@google.com>
hu...@littlerobots.nl <hu...@littlerobots.nl> #3
Revisiting this it turns out that I was already tracking the state needed for enabling the callbacks and I suppose that would be often the case. Also the ktx extensions make it easier to work with the API as such that you don't really have to declare / create the back pressed handlers yourself because they return a handler reference.
ap...@google.com <ap...@google.com> #4
Project: platform/frameworks/support
Branch: androidx-master-dev
commit d339df058031dadca4676524c5c184e559553a2e
Author: Ian Lake <ilake@google.com>
Date: Fri Apr 26 09:57:34 2019
Don't override isEnabled() is NavController's back callback
Update the enabled state of the OnBackPressedCallback
when the back stack changes vs just-in-time in
isEnabled().
Test: tests still pass
BUG: 131416833
Change-Id: I90db47a347f60d4f0886d6d9146b79f14f377269
M navigation/runtime/src/main/java/androidx/navigation/NavController.java
https://android-review.googlesource.com/952421
https://goto.google.com/android-sha1/d339df058031dadca4676524c5c184e559553a2e
Branch: androidx-master-dev
commit d339df058031dadca4676524c5c184e559553a2e
Author: Ian Lake <ilake@google.com>
Date: Fri Apr 26 09:57:34 2019
Don't override isEnabled() is NavController's back callback
Update the enabled state of the OnBackPressedCallback
when the back stack changes vs just-in-time in
isEnabled().
Test: tests still pass
BUG: 131416833
Change-Id: I90db47a347f60d4f0886d6d9146b79f14f377269
M navigation/runtime/src/main/java/androidx/navigation/NavController.java
ap...@google.com <ap...@google.com> #5
Project: platform/frameworks/support
Branch: androidx-master-dev
commit 7039edc63e017c5b9433fe000922eb8f48597799
Author: Ian Lake <ilake@google.com>
Date: Fri Apr 26 11:49:47 2019
Don't override isEnabled() in FragmentManager back
Update the enabled state of the OnBackPressedCallback
when the back stack changes vs just-in-time in
isEnabled().
Test: tests still pass
BUG: 131416833
Change-Id: I40f266429c5dd3e2496decff50bf431d2c52924b
M fragment/src/main/java/androidx/fragment/app/FragmentManagerImpl.java
https://android-review.googlesource.com/952798
https://goto.google.com/android-sha1/7039edc63e017c5b9433fe000922eb8f48597799
Branch: androidx-master-dev
commit 7039edc63e017c5b9433fe000922eb8f48597799
Author: Ian Lake <ilake@google.com>
Date: Fri Apr 26 11:49:47 2019
Don't override isEnabled() in FragmentManager back
Update the enabled state of the OnBackPressedCallback
when the back stack changes vs just-in-time in
isEnabled().
Test: tests still pass
BUG: 131416833
Change-Id: I40f266429c5dd3e2496decff50bf431d2c52924b
M fragment/src/main/java/androidx/fragment/app/FragmentManagerImpl.java
ap...@google.com <ap...@google.com> #6
Project: platform/frameworks/support
Branch: androidx-master-dev
commit 561c9b796f43e1e8c500b856d4ea3726ca9bffd7
Author: Ian Lake <ilake@google.com>
Date: Fri Apr 26 17:52:10 2019
Mark callback isEnabled methods as final
Rather than require 'just in time' checks for
overriden isEnabled() methods, make both the
setter and getter final so that the dispatcher
can know ahead of time which callback is going
to be called when onBackPressed() is actually
triggered.
Test: ./gradlew checkApi
BUG: 131416833
Change-Id: I0d7e84d7d9888f558284cc1719774ccbbdbbc4d6
M activity/api/1.0.0-beta00.txt
M activity/api/current.txt
M activity/src/main/java/androidx/activity/OnBackPressedCallback.java
https://android-review.googlesource.com/952719
https://goto.google.com/android-sha1/561c9b796f43e1e8c500b856d4ea3726ca9bffd7
Branch: androidx-master-dev
commit 561c9b796f43e1e8c500b856d4ea3726ca9bffd7
Author: Ian Lake <ilake@google.com>
Date: Fri Apr 26 17:52:10 2019
Mark callback isEnabled methods as final
Rather than require 'just in time' checks for
overriden isEnabled() methods, make both the
setter and getter final so that the dispatcher
can know ahead of time which callback is going
to be called when onBackPressed() is actually
triggered.
Test: ./gradlew checkApi
BUG: 131416833
Change-Id: I0d7e84d7d9888f558284cc1719774ccbbdbbc4d6
M activity/api/1.0.0-beta00.txt
M activity/api/current.txt
M activity/src/main/java/androidx/activity/OnBackPressedCallback.java
Description
Version used: 1.0.0-alpha07
The OnBackPressedDispatcher should be able to tell at any point what OnBackPressedCallback is enabled or disabled without polling isEnabled() to get a just-in-time answer. This avoids the issue with the current onBackPressed() logic where the system doesn't know what onBackPressed() will do until you actually press the button.
This implies that all callbacks should be calling setEnabled() at the appropriate times to enable or disable them based on their own internal state changing. To enforce this behavior, setEnabled() and isEnabled() should be final.