Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented predictive back navigation for some screens #14659

Merged

Conversation

lukstbit
Copy link
Member

@lukstbit lukstbit commented Nov 4, 2023

Purpose / Description

Implemented predictive back navigation for Info.kt, ModelFieldEditor.kt and Previewer.kt. These are the simplest screens to change, with a note on Info.kt if we really need to handle the WebView.canGoBack() as we start an outside browser for any url.

Info.kt:

info.mp4

Previewer.kt:

previewer.mp4

ModelFieldEditor.kt:

modelfieldeditor.mp4

Fixes

Related to #14558

How Has This Been Tested?

Enabled the predictive back navigation and manually tested the changed screens

Checklist

  • You have a descriptive commit message with a short title (first line, max 50 chars).
  • You have commented your code, particularly in hard-to-understand areas
  • You have performed a self-review of your own code
  • UI changes: include screenshots of all affected screens (in particular showing any new or changed strings)
  • UI Changes: You have tested your change using the Google Accessibility Scanner

@david-allison david-allison self-assigned this Nov 4, 2023
Copy link
Member

@BrayanDSO BrayanDSO left a comment

Choose a reason for hiding this comment

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

Works for me

@BrayanDSO BrayanDSO added the Needs Second Approval Has one approval, one more approval to merge label Nov 5, 2023
The added back callback is enabled/disabled based on webview status(
can go back or not) to let the system know if it should handle the
back navigation request. The callback is disabled at start, the
WebView it's expected to not have any history yet.

See: https://codelabs.developers.google.com/handling-gesture-back-navigation#5
where this exact scenario is handled.
The previous code was setting the result on back pressed passing the
values of two class properties, the modified code sets an initial
result + updates the returned Intent every time one of the observed
properties is changed.
Simply deleted the onBackPressed() callback as all it did was to close
the activity. Without a back callbak set, the system will handle the
back navigation itself.

The toolbar home button was already handled in the superclass AnkiActivity.
@lukstbit lukstbit force-pushed the feat_predictiveBackNavigation branch from be776c3 to ff873ea Compare November 9, 2023 11:31
@david-allison david-allison merged commit e701cfa into ankidroid:main Nov 9, 2023
7 checks passed
@github-actions github-actions bot added this to the 2.17 release milestone Nov 9, 2023
@github-actions github-actions bot removed the Needs Second Approval Has one approval, one more approval to merge label Nov 9, 2023
@lukstbit lukstbit deleted the feat_predictiveBackNavigation branch November 9, 2023 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants