Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fcbb637a authored by Rohan Shah's avatar Rohan Shah Committed by android-build-merger
Browse files

Merge "[Notif] Fix a11y when guts is open" into pi-dev am: 888b62d4

am: 0db01a64

Change-Id: Iebd5d47cf5a777f529224c3e5755f963f64fa26f
parents c59a7591 0db01a64
Loading
Loading
Loading
Loading
+39 −0
Original line number Diff line number Diff line
@@ -1651,6 +1651,45 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
        mMenuRow.resetMenu();
    }

    void onGutsOpened() {
        resetTranslation();
        updateContentAccessibilityImportanceForGuts(false /* isEnabled */);
    }

    void onGutsClosed() {
        updateContentAccessibilityImportanceForGuts(true /* isEnabled */);
    }

    /**
     * Updates whether all the non-guts content inside this row is important for accessibility.
     *
     * @param isEnabled whether the content views should be enabled for accessibility
     */
    private void updateContentAccessibilityImportanceForGuts(boolean isEnabled) {
        if (mChildrenContainer != null) {
            updateChildAccessibilityImportance(mChildrenContainer, isEnabled);
        }
        if (mLayouts != null) {
            for (View view : mLayouts) {
                updateChildAccessibilityImportance(view, isEnabled);
            }
        }

        if (isEnabled) {
            this.requestAccessibilityFocus();
        }
    }

    /**
     * Updates whether the given childView is important for accessibility based on
     * {@code isEnabled}.
     */
    private void updateChildAccessibilityImportance(View childView, boolean isEnabled) {
        childView.setImportantForAccessibility(isEnabled
                ? View.IMPORTANT_FOR_ACCESSIBILITY_AUTO
                : View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS);
    }

    public CharSequence getActiveRemoteInputText() {
        return mPrivateLayout.getActiveRemoteInputText();
    }
+2 −1
Original line number Diff line number Diff line
@@ -159,6 +159,7 @@ public class NotificationGutsManager implements Dumpable {
        row.setGutsView(item);
        row.setTag(sbn.getPackageName());
        row.getGuts().setClosedListener((NotificationGuts g) -> {
            row.onGutsClosed();
            if (!g.willBeRemoved() && !row.isRemoved()) {
                mListContainer.onHeightChanged(
                        row, !mPresenter.isPresenterFullyCollapsed() /* needsAnimation */);
@@ -390,7 +391,7 @@ public class NotificationGutsManager implements Dumpable {
                        x,
                        y,
                        needsFalsingProtection,
                        row::resetTranslation);
                        row::onGutsOpened);

                row.closeRemoteInput();
                mListContainer.onHeightChanged(row, true /* needsAnimation */);