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

Commit dd697854 authored by Phil Weaver's avatar Phil Weaver
Browse files

Clean up popup window titles

Removing the recently-added APIs to adjust the title for
the popup window, and moving setting the title to
preparePopup(), which is guaranteed to have a context.
(The bug is a crash because we didn't have a context.)

Apps wishing to specify their own title can still do so
in the LayoutParams without bothering with the get/set.

Bug: 62675086
Test: With TalkBack running, navigate to Settings->
Network & Internet. Select the more options button and
double-tap to select it. It now announces "Popup Window".

Change-Id: I9735ace42c24ef4977d3f4d5150f768d44aff351
parent 5476da96
Loading
Loading
Loading
Loading
+4 −29
Original line number Diff line number Diff line
@@ -208,9 +208,6 @@ public class PopupWindow {

    private int mGravity = Gravity.NO_GRAVITY;

    // Title provided to accessibility services
    private CharSequence mAccessibilityTitle;

    private static final int[] ABOVE_ANCHOR_STATE_SET = new int[] {
            com.android.internal.R.attr.state_above_anchor
    };
@@ -1134,31 +1131,6 @@ public class PopupWindow {
        return mIsShowing;
    }

    /**
     * Set the title for this window to be reported to accessibility services. If no title is set,
     * a generic default will be reported.
     *
     * @param accessibilityTitle The new title, or {@code null} to specify that the default should
     * be used.
     * @hide
     */
    public void setAccessibilityTitle(@Nullable CharSequence accessibilityTitle) {
        mAccessibilityTitle = accessibilityTitle;
    }

    /**
     * Get the title for this window to be reported to accessibility services.
     *
     * @return The current title.
     * @hide
     */
    public @NonNull CharSequence getAccessibilityTitle() {
        if (mAccessibilityTitle == null) {
            mAccessibilityTitle = mContext.getString(R.string.popup_window_default_title);
        }
        return mAccessibilityTitle;
    }

    /** @hide */
    protected final void setShowing(boolean isShowing) {
        mIsShowing = isShowing;
@@ -1362,6 +1334,10 @@ public class PopupWindow {
                    + "calling setContentView() before attempting to show the popup.");
        }

        if (p.accessibilityTitle == null) {
            p.accessibilityTitle = mContext.getString(R.string.popup_window_default_title);
        }

        // The old decor view may be transitioning out. Make sure it finishes
        // and cleans up before we try to create another one.
        if (mDecorView != null) {
@@ -1524,7 +1500,6 @@ public class PopupWindow {

        // Used for debugging.
        p.setTitle("PopupWindow:" + Integer.toHexString(hashCode()));
        p.accessibilityTitle = getAccessibilityTitle();

        return p;
    }