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

Commit 0bd1d0a1 authored by Adam Powell's avatar Adam Powell
Browse files

Fix bug 5060033 - No text-editing toolbar when in a dialog

Fix a bug that caused standalone action mode bars to not appear
properly or account for system insets such as the status bar.

Add public API to View to toggle the fitsSystemWindows attribute.

Change-Id: I5d7669425b930c5d23f9df26a45f544b706e8242
parent 423f0ed4
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -22231,6 +22231,7 @@ package android.view {
    method public final android.view.View findViewWithTag(java.lang.Object);
    method public void findViewsWithText(java.util.ArrayList<android.view.View>, java.lang.CharSequence);
    method protected boolean fitSystemWindows(android.graphics.Rect);
    method public boolean fitsSystemWindows();
    method public android.view.View focusSearch(int);
    method public void forceLayout();
    method public float getAlpha();
@@ -22472,6 +22473,7 @@ package android.view {
    method public void setEnabled(boolean);
    method public void setFadingEdgeLength(int);
    method public void setFilterTouchesWhenObscured(boolean);
    method public void setFitsSystemWindows(boolean);
    method public void setFocusable(boolean);
    method public void setFocusableInTouchMode(boolean);
    method public void setHapticFeedbackEnabled(boolean);
+30 −0
Original line number Diff line number Diff line
@@ -4279,6 +4279,36 @@ public class View implements Drawable.Callback2, KeyEvent.Callback, Accessibilit
        return false;
    }

    /**
     * Set whether or not this view should account for system screen decorations
     * such as the status bar and inset its content. This allows this view to be
     * positioned in absolute screen coordinates and remain visible to the user.
     *
     * <p>This should only be used by top-level window decor views.
     *
     * @param fitSystemWindows true to inset content for system screen decorations, false for
     *                         default behavior.
     *
     * @attr ref android.R.styleable#View_fitsSystemWindows
     */
    public void setFitsSystemWindows(boolean fitSystemWindows) {
        setFlags(fitSystemWindows ? FITS_SYSTEM_WINDOWS : 0, FITS_SYSTEM_WINDOWS);
    }

    /**
     * Check for the FITS_SYSTEM_WINDOWS flag. If this method returns true, this view
     * will account for system screen decorations such as the status bar and inset its
     * content. This allows the view to be positioned in absolute screen coordinates
     * and remain visible to the user.
     *
     * @return true if this view will adjust its content bounds for system screen decorations.
     *
     * @attr ref android.R.styleable#View_fitsSystemWindows
     */
    public boolean fitsSystemWindows() {
        return (mViewFlags & FITS_SYSTEM_WINDOWS) == FITS_SYSTEM_WINDOWS;
    }

    /**
     * Returns the visibility status for this view.
     *
+21 −0
Original line number Diff line number Diff line
@@ -91,6 +91,7 @@ public class PopupWindow {
    private boolean mLayoutInScreen;
    private boolean mClipToScreen;
    private boolean mAllowScrollingAnchorParent = true;
    private boolean mLayoutInsetDecor = false;

    private OnTouchListener mTouchInterceptor;
    
@@ -657,6 +658,22 @@ public class PopupWindow {
        mLayoutInScreen = enabled;
    }

    /**
     * Allows the popup window to force the flag
     * {@link WindowManager.LayoutParams#FLAG_LAYOUT_INSET_DECOR}, overriding default behavior.
     * This will cause the popup to inset its content to account for system windows overlaying
     * the screen, such as the status bar.
     *
     * <p>This will often be combined with {@link #setLayoutInScreenEnabled(boolean)}.
     *
     * @param enabled true if the popup's views should inset content to account for system windows,
     *                the way that decor views behave for full-screen windows.
     * @hide
     */
    public void setLayoutInsetDecor(boolean enabled) {
        mLayoutInsetDecor = enabled;
    }

    /**
     * Set the layout type for this window. Should be one of the TYPE constants defined in
     * {@link WindowManager.LayoutParams}.
@@ -942,6 +959,7 @@ public class PopupWindow {
        if (mContext != null) {
            p.packageName = mContext.getPackageName();
        }
        mPopupView.setFitsSystemWindows(mLayoutInsetDecor);
        mWindowManager.addView(mPopupView, p);
    }

@@ -1012,6 +1030,9 @@ public class PopupWindow {
        if (mLayoutInScreen) {
            curFlags |= WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN;
        }
        if (mLayoutInsetDecor) {
            curFlags |= WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR;
        }
        return curFlags;
    }
    
+2 −1
Original line number Diff line number Diff line
@@ -2040,13 +2040,14 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
                        mActionModePopup = new PopupWindow(mContext, null,
                                com.android.internal.R.attr.actionModePopupWindowStyle);
                        mActionModePopup.setLayoutInScreenEnabled(true);
                        mActionModePopup.setLayoutInsetDecor(true);
                        mActionModePopup.setClippingEnabled(false);
                        mActionModePopup.setContentView(mActionModeView);
                        mActionModePopup.setWidth(MATCH_PARENT);

                        TypedValue heightValue = new TypedValue();
                        mContext.getTheme().resolveAttribute(
                                com.android.internal.R.attr.actionBarSize, heightValue, false);
                                com.android.internal.R.attr.actionBarSize, heightValue, true);
                        final int height = TypedValue.complexToDimensionPixelSize(heightValue.data,
                                mContext.getResources().getDisplayMetrics());
                        mActionModePopup.setHeight(height);