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

Commit 56eb0915 authored by Rohan Shah's avatar Rohan Shah
Browse files

[Notif] Fix a11y when guts is open

The content in the back is showing while guts is up since we never make
the content invisible. To avoid making a semi-risky change before the
GAR cutoff, we're listening to guts open/close and toggling the content
views' important for accessibility values.

After guts is closed, this will also re-focus the notification that the
user had long-pressed instead of leaving them without a target/making
them lose track.

Fixes: 75284298
Test: Manually with single and group notif
Change-Id: I57c3ac27e0c134ce04b681717b185eceba19a7a8
parent 47a8ecce
Loading
Loading
Loading
Loading
+39 −0
Original line number Original line Diff line number Diff line
@@ -1651,6 +1651,45 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
        mMenuRow.resetMenu();
        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() {
    public CharSequence getActiveRemoteInputText() {
        return mPrivateLayout.getActiveRemoteInputText();
        return mPrivateLayout.getActiveRemoteInputText();
    }
    }
+2 −1
Original line number Original line Diff line number Diff line
@@ -159,6 +159,7 @@ public class NotificationGutsManager implements Dumpable {
        row.setGutsView(item);
        row.setGutsView(item);
        row.setTag(sbn.getPackageName());
        row.setTag(sbn.getPackageName());
        row.getGuts().setClosedListener((NotificationGuts g) -> {
        row.getGuts().setClosedListener((NotificationGuts g) -> {
            row.onGutsClosed();
            if (!g.willBeRemoved() && !row.isRemoved()) {
            if (!g.willBeRemoved() && !row.isRemoved()) {
                mListContainer.onHeightChanged(
                mListContainer.onHeightChanged(
                        row, !mPresenter.isPresenterFullyCollapsed() /* needsAnimation */);
                        row, !mPresenter.isPresenterFullyCollapsed() /* needsAnimation */);
@@ -390,7 +391,7 @@ public class NotificationGutsManager implements Dumpable {
                        x,
                        x,
                        y,
                        y,
                        needsFalsingProtection,
                        needsFalsingProtection,
                        row::resetTranslation);
                        row::onGutsOpened);


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