Skip to content

Commit

Permalink
[Predictive Back][Search] Fix issue where modal accessibility is not …
Browse files Browse the repository at this point in the history
…reset after collapsing search view predictively, which caused the screen to appear frozen when using TalkBack

PiperOrigin-RevId: 566750080
(cherry picked from commit 8d83a31)
  • Loading branch information
dsn5ft authored and afohrman committed Sep 21, 2023
1 parent 4442635 commit e8af8f9
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions lib/java/com/google/android/material/search/SearchView.java
Expand Up @@ -785,10 +785,23 @@ public TransitionState getCurrentTransitionState() {
}

void setTransitionState(@NonNull TransitionState state) {
setTransitionState(state, /* updateModalForAccessibility= */ true);
}

private void setTransitionState(
@NonNull TransitionState state, boolean updateModalForAccessibility) {
if (currentTransitionState.equals(state)) {
return;
}

if (updateModalForAccessibility) {
if (state == TransitionState.SHOWN) {
setModalForAccessibility(true);
} else if (state == TransitionState.HIDDEN) {
setModalForAccessibility(false);
}
}

TransitionState previousState = currentTransitionState;
currentTransitionState = state;
Set<TransitionListener> listeners = new LinkedHashSet<>(transitionListeners);
Expand Down Expand Up @@ -825,7 +838,6 @@ public void show() {
return;
}
searchViewAnimationHelper.show();
setModalForAccessibility(true);
}

/**
Expand All @@ -840,18 +852,16 @@ public void hide() {
return;
}
searchViewAnimationHelper.hide();
setModalForAccessibility(false);
}

/** Updates the visibility of the {@link SearchView} without an animation. */
public void setVisible(boolean visible) {
boolean wasVisible = rootView.getVisibility() == VISIBLE;
rootView.setVisibility(visible ? VISIBLE : GONE);
updateNavigationIconProgressIfNeeded();
if (wasVisible != visible) {
setModalForAccessibility(visible);
}
setTransitionState(visible ? TransitionState.SHOWN : TransitionState.HIDDEN);
setTransitionState(
visible ? TransitionState.SHOWN : TransitionState.HIDDEN,
/* updateModalForAccessibility= */ wasVisible != visible);
}

private void updateNavigationIconProgressIfNeeded() {
Expand Down

0 comments on commit e8af8f9

Please sign in to comment.