Skip to content

Add Predictive Back support - #665

Merged
gpolak merged 6 commits into
uber:mainfrom
gpolak:predictive_back
Sep 29, 2026
Merged

gpolak merged 6 commits into
uber:mainfrom
gpolak:predictive_back

Conversation

@gpolak

@gpolak gpolak commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

Description:

  • adds support for Predictive Back
  • this is the first Iteration that adds functional support that replicates current pre-PB behavior: swiping back pops to the previous screen on the stack rather than exiting the app when PB is forced
  • future changes will enhance this with support for previous screen "peek" animations

Old RIBs + Predictive Back opt-out

Old RIBs + NO Predictive Back opt-out

This Change + Predictive Back opt-out

This Change + NO Predictive Back opt-out

gpolak and others added 6 commits September 22, 2026 16:07
Opt the intellij demo into the predictive back gesture via
android:enableOnBackInvokedCallback, so the RibActivity
OnBackPressedCallback path is actually exercised on Android 13+.

Drop StackRouterNavigator.peekPreviousRouter(). It was added only to let a
peek animation pre-render the previous screen, and that animation is not
part of this change, so it was unused public API.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Add android:enableOnBackInvokedCallback to the stack-nav manifest, matching
the intellij demo. This demo drives StackRouterNavigator, so it exercises
the RibActivity OnBackPressedCallback path against a real router stack
rather than a single screen.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
RibActivity now handles back via an OnBackPressedCallback instead of an
onBackPressed() override, so the uber#662 regression test has to drive the
dispatcher to reach it. On androidx.activity 1.13 the deprecated
ComponentActivity.onBackPressed() delivers through NavigationEventInput,
which never reaches the dispatcher under Robolectric.

Intent is unchanged: with attachContent overridden to skip attach, a back
press must not crash on the null router and must fall through to super.

Co-Authored-By: Claude Opus 5 (1M context) <ANONYMIZED_EMAIL_ADDRESS_0_6>
RxActivityEvents {
private var router: ViewRouter<*, *>? = null

private val ribBackPressCallback =

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd consider this class implementing this interface to save the object allocation; not sure if that is still relevant on modern android, but it doesn't hurt

@gpolak
gpolak merged commit 64c6ffd into uber:main Sep 29, 2026
4 checks passed
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

Successfully merging this pull request may close these issues.

2 participants