Status Update
Comments
il...@google.com <il...@google.com> #2
Branch: androidx-main
commit c2365dcfeb9064814282304f30f3eb86be71fdc7
Author: Dan Nizri <dniz@google.com>
Date: Wed Dec 20 16:33:08 2023
Fix Popup back handling on Android T/13+ when android:enableOnBackInvokedCallback="true"
Bug: 313702338
Bug: 318537200
Test: tested with android:enableOnBackInvokedCallback="true"
Change-Id: I7c7cef686ed9fbfd2d144c90040b13528f1675ed
M compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/window/AndroidPopup.android.kt
zb...@gmail.com <zb...@gmail.com> #3
Is there remaining work for this feature request. Support for predictive back in Dialogs would allow Material3 to remove some Dialog forks and would be very helpful!
il...@google.com <il...@google.com> #4
Yeah, we probably want to investigate new API shapes here to take advantage of predictive back. No work ongoing yet though, needs prioritization
zb...@gmail.com <zb...@gmail.com> #5
zb...@gmail.com <zb...@gmail.com> #6
(recapping my chat with Ian)
The tricky part is that the onDismissRequest
is really the final signal and a chance for the app to just say 'nope, I don't want the dialog to dismiss' (since they own the state of 'should the dialog be shown or not' simply by either adding the Dialog to composition or leaving out of composition) - that's the just-in-time problem that the comment talks about. It would be very odd to have any kind of progress animation that doesn't actually lead to the dialog being dismissed when it is committed"
so really it needs to be a more holistic look at how to do dialogs and swap from a binary state (shown/not shown) to something that actually has something in between for cases like predictive back
Description
Version used: 1.0.0-alpha02
Devices/Android versions reproduced on: Emulator API 27
Expected result:
When executing a navigation action with Clear Task flag set (either in the editor or in NavOptions) with an activity as a target, the target activity becomes the root (and the sole activity) of the current task and pressing back button shouldn't allow comming back to the source activity.
Before: [A]
Action: A -> B
After: [B]
Actual result:
The target activity is just added to the back stack, so popping navigates back to the source activity.
Before: [A]
Action: A -> B
After: [A, B]
I think this is caused by setting only Intent.FLAG_ACTIVITY_CLEAR_TASK, without Intent.FLAG_ACTIVITY_NEW_TASK.
ActivityNavigator, lines 117-119:
if (navOptions != null && navOptions.shouldClearTask()) {
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
}
According to the docs:
"If set in an Intent passed to Context.startActivity(), this flag will cause any existing task that would be associated with the activity to be cleared before the activity is started. That is, the activity becomes the new root of an otherwise empty task, and any old activities are finished. This can only be used in conjunction with FLAG_ACTIVITY_NEW_TASK."