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

Commit 07e440b2 authored by Abodunrinwa Toki's avatar Abodunrinwa Toki Committed by Android (Google) Code Review
Browse files

Merge "Fix FloatingToolbar flickers." into mnc-dev

parents 1b48a643 972ab4f8
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -34575,6 +34575,7 @@ package android.view {
    method public abstract void invalidate();
    method public void invalidateContentRect();
    method public boolean isTitleOptional();
    method public void onWindowFocusChanged(boolean);
    method public abstract void setCustomView(android.view.View);
    method public abstract void setSubtitle(java.lang.CharSequence);
    method public abstract void setSubtitle(int);
+1 −0
Original line number Diff line number Diff line
@@ -36856,6 +36856,7 @@ package android.view {
    method public abstract void invalidate();
    method public void invalidateContentRect();
    method public boolean isTitleOptional();
    method public void onWindowFocusChanged(boolean);
    method public abstract void setCustomView(android.view.View);
    method public abstract void setSubtitle(java.lang.CharSequence);
    method public abstract void setSubtitle(int);
+10 −0
Original line number Diff line number Diff line
@@ -260,6 +260,16 @@ public abstract class ActionMode {
     */
    public abstract MenuInflater getMenuInflater();

    /**
     * Called when the window containing the view that started this action mode gains or loses
     * focus.
     *
     * @param hasWindowFocus True if the window containing the view that started this action mode
     *        now has focus, false otherwise.
     *
     */
    public void onWindowFocusChanged(boolean hasWindowFocus) {}

    /**
     * Returns whether the UI presenting this action mode can take focus or not.
     * This is used by internal components within the framework that would otherwise
+6 −8
Original line number Diff line number Diff line
@@ -3223,12 +3223,11 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
                cb.onWindowFocusChanged(hasWindowFocus);
            }

            if (mFloatingToolbar != null) {
                if (hasWindowFocus) {
                    mFloatingToolbar.show();
                } else {
                    mFloatingToolbar.dismiss();
            if (mPrimaryActionMode != null) {
                mPrimaryActionMode.onWindowFocusChanged(hasWindowFocus);
            }
            if (mFloatingActionMode != null) {
                mFloatingActionMode.onWindowFocusChanged(hasWindowFocus);
            }
        }

@@ -3441,8 +3440,7 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
            mFloatingActionMode = mode;
            mFloatingToolbar = new FloatingToolbar(mContext, PhoneWindow.this);
            ((FloatingActionMode) mFloatingActionMode).setFloatingToolbar(mFloatingToolbar);
            mFloatingActionMode.invalidate();
            mFloatingToolbar.show();
            mFloatingActionMode.invalidate();  // Will show the floating toolbar if necessary.
            mFloatingActionModeOriginatingView.getViewTreeObserver()
                .addOnPreDrawListener(mFloatingToolbarPreDrawListener);
        }
+15 −1
Original line number Diff line number Diff line
@@ -196,6 +196,13 @@ public class FloatingActionMode extends ActionMode {
        }
    }

    @Override
    public void onWindowFocusChanged(boolean hasWindowFocus) {
        checkToolbarInitialized();
        mFloatingToolbarVisibilityHelper.setWindowFocused(hasWindowFocus);
        mFloatingToolbarVisibilityHelper.updateToolbarVisibility();
    }

    @Override
    public void finish() {
        checkToolbarInitialized();
@@ -237,6 +244,7 @@ public class FloatingActionMode extends ActionMode {
    }

    private void reset() {
        mFloatingToolbar.dismiss();
        mFloatingToolbarVisibilityHelper.deactivate();
        mOriginatingView.removeCallbacks(mMovingOff);
        mOriginatingView.removeCallbacks(mHideOff);
@@ -253,6 +261,7 @@ public class FloatingActionMode extends ActionMode {
        private boolean mHideRequested;
        private boolean mMoving;
        private boolean mOutOfBounds;
        private boolean mWindowFocused = true;

        private boolean mActive;

@@ -264,6 +273,7 @@ public class FloatingActionMode extends ActionMode {
            mHideRequested = false;
            mMoving = false;
            mOutOfBounds = false;
            mWindowFocused = true;

            mActive = true;
        }
@@ -285,12 +295,16 @@ public class FloatingActionMode extends ActionMode {
            mOutOfBounds = outOfBounds;
        }

        public void setWindowFocused(boolean windowFocused) {
            mWindowFocused = windowFocused;
        }

        public void updateToolbarVisibility() {
            if (!mActive) {
                return;
            }

            if (mHideRequested || mMoving || mOutOfBounds) {
            if (mHideRequested || mMoving || mOutOfBounds || !mWindowFocused) {
                mToolbar.hide();
            } else {
                mToolbar.show();