Navigation Menu

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
  • Loading branch information
dsn5ft committed Sep 20, 2023
1 parent 93660d4 commit 8d83a31
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 @@ -790,10 +790,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 @@ -830,7 +843,6 @@ public void show() {
return;
}
searchViewAnimationHelper.show();
setModalForAccessibility(true);
}

/**
Expand All @@ -845,18 +857,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 8d83a31

Please sign in to comment.