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

Fix onBackPressed() deprecation In Card Browser #17594

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Prince-kushwaha
Copy link
Contributor

Purpose / Description

Fix onBackPressed() deprecation In Card Browser

Fixes

How Has This Been Tested?

Physical Device

Checklist

Please, go through these checks before submitting the PR.

  • 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 added the Needs Author Reply Waiting for a reply from the original author label Dec 13, 2024
Copy link
Member

@lukstbit lukstbit left a comment

Choose a reason for hiding this comment

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

The goal of the new predictive back navigation is to have distinct back callbacks for any actions you may want on BACK pressed and to enable/disable those callbacks dynamically so the system knows ahead of time if you are managing the back action or the system should handle it(and show animations).

Using OnBackPressedCallback and permanently have it enabled is equivalent with the current onBackPressed() so the changes in this PR are not an improvement. I would rather keep the deprecated onBackPressed callback present because it stands out as needing to be fixed, instead of the callback which is going to make it harder to see there's an issue.

@Prince-kushwaha
Copy link
Contributor Author

Hi David, I will address the review points

@david-allison david-allison added Needs Review and removed Needs Author Reply Waiting for a reply from the original author labels Dec 24, 2024
Copy link
Member

@david-allison david-allison left a comment

Choose a reason for hiding this comment

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

I don't feel this code matches the logic of the previous implementation. It feels like it should be the following (please disagree, you're closer to the code than I am)

  • If the drawer is open, the drawer should take prioirty
  • If multiselect is open, it should be closed

If neither happen, there shouldn't be an active back dispatcher, and the activity should close normally, with the provided result set somewhere before the back button was pressed (fail + reload required should be the default).

A test here would also be great, regarding the exit + exit intent.

val data = Intent()
// Add reload flag to result intent so that schedule reset when returning to note editor
data.putExtra(NoteEditor.RELOAD_REQUIRED_EXTRA_KEY, reloadRequired)
closeCardBrowser(RESULT_OK, data)
Copy link
Member

Choose a reason for hiding this comment

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

This seems... unusual. It feels like it shouldn't be in the callback and should be the default of pressing 'back', unless there's documentation to disagree.

Comment on lines +483 to +486
updateBackPressedCallBackMethodsStatus(
isDrawerOpen = true,
isInMultiSelectMode = false,
)
Copy link
Member

Choose a reason for hiding this comment

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

I don't get why these are combined. It would make more sense for me that opening the drawer is responsible for the drawer callback, and that opening multiselect is responsible for the multiselect callback

Then the order in which the callbacks are applied affects the action which is reversed first.

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.

Handle "predictive back" / ActivityTransitionAnimation deprecation in API34
3 participants