Merge "Fix FloatingToolbar flicker in reaction to text cursor blink." into mnc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
1fa8290dbe
@@ -30,6 +30,8 @@ import com.android.internal.util.Preconditions;
|
|||||||
import com.android.internal.view.menu.MenuBuilder;
|
import com.android.internal.view.menu.MenuBuilder;
|
||||||
import com.android.internal.widget.FloatingToolbar;
|
import com.android.internal.widget.FloatingToolbar;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
public class FloatingActionMode extends ActionMode {
|
public class FloatingActionMode extends ActionMode {
|
||||||
|
|
||||||
private static final int MAX_HIDE_DURATION = 3000;
|
private static final int MAX_HIDE_DURATION = 3000;
|
||||||
@@ -42,7 +44,9 @@ public class FloatingActionMode extends ActionMode {
|
|||||||
private final Rect mContentRectOnWindow;
|
private final Rect mContentRectOnWindow;
|
||||||
private final Rect mPreviousContentRectOnWindow;
|
private final Rect mPreviousContentRectOnWindow;
|
||||||
private final int[] mViewPosition;
|
private final int[] mViewPosition;
|
||||||
|
private final int[] mPreviousViewPosition;
|
||||||
private final Rect mViewRect;
|
private final Rect mViewRect;
|
||||||
|
private final Rect mPreviousViewRect;
|
||||||
private final Rect mScreenRect;
|
private final Rect mScreenRect;
|
||||||
private final View mOriginatingView;
|
private final View mOriginatingView;
|
||||||
private final int mBottomAllowance;
|
private final int mBottomAllowance;
|
||||||
@@ -75,7 +79,9 @@ public class FloatingActionMode extends ActionMode {
|
|||||||
mContentRectOnWindow = new Rect();
|
mContentRectOnWindow = new Rect();
|
||||||
mPreviousContentRectOnWindow = new Rect();
|
mPreviousContentRectOnWindow = new Rect();
|
||||||
mViewPosition = new int[2];
|
mViewPosition = new int[2];
|
||||||
|
mPreviousViewPosition = new int[2];
|
||||||
mViewRect = new Rect();
|
mViewRect = new Rect();
|
||||||
|
mPreviousViewRect = new Rect();
|
||||||
mScreenRect = new Rect();
|
mScreenRect = new Rect();
|
||||||
mOriginatingView = Preconditions.checkNotNull(originatingView);
|
mOriginatingView = Preconditions.checkNotNull(originatingView);
|
||||||
mOriginatingView.getLocationInWindow(mViewPosition);
|
mOriginatingView.getLocationInWindow(mViewPosition);
|
||||||
@@ -129,9 +135,17 @@ public class FloatingActionMode extends ActionMode {
|
|||||||
|
|
||||||
public void updateViewLocationInWindow() {
|
public void updateViewLocationInWindow() {
|
||||||
checkToolbarInitialized();
|
checkToolbarInitialized();
|
||||||
|
|
||||||
mOriginatingView.getLocationInWindow(mViewPosition);
|
mOriginatingView.getLocationInWindow(mViewPosition);
|
||||||
mOriginatingView.getGlobalVisibleRect(mViewRect);
|
mOriginatingView.getGlobalVisibleRect(mViewRect);
|
||||||
repositionToolbar();
|
|
||||||
|
if (!Arrays.equals(mViewPosition, mPreviousViewPosition)
|
||||||
|
|| !mViewRect.equals(mPreviousViewRect)) {
|
||||||
|
repositionToolbar();
|
||||||
|
mPreviousViewPosition[0] = mViewPosition[0];
|
||||||
|
mPreviousViewPosition[1] = mViewPosition[1];
|
||||||
|
mPreviousViewRect.set(mViewRect);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void repositionToolbar() {
|
private void repositionToolbar() {
|
||||||
|
|||||||
@@ -85,6 +85,7 @@ public final class FloatingToolbar {
|
|||||||
private final FloatingToolbarPopup mPopup;
|
private final FloatingToolbarPopup mPopup;
|
||||||
|
|
||||||
private final Rect mContentRect = new Rect();
|
private final Rect mContentRect = new Rect();
|
||||||
|
private final Rect mPreviousContentRect = new Rect();
|
||||||
|
|
||||||
private Menu mMenu;
|
private Menu mMenu;
|
||||||
private List<Object> mShowingMenuItems = new ArrayList<Object>();
|
private List<Object> mShowingMenuItems = new ArrayList<Object>();
|
||||||
@@ -178,11 +179,13 @@ public final class FloatingToolbar {
|
|||||||
mPopup.layoutMenuItems(menuItems, mMenuItemClickListener, mSuggestedWidth);
|
mPopup.layoutMenuItems(menuItems, mMenuItemClickListener, mSuggestedWidth);
|
||||||
mShowingMenuItems = getShowingMenuItemsReferences(menuItems);
|
mShowingMenuItems = getShowingMenuItemsReferences(menuItems);
|
||||||
}
|
}
|
||||||
mPopup.updateCoordinates(mContentRect);
|
|
||||||
if (!mPopup.isShowing()) {
|
if (!mPopup.isShowing()) {
|
||||||
mPopup.show(mContentRect);
|
mPopup.show(mContentRect);
|
||||||
|
} else if (!mPreviousContentRect.equals(mContentRect)) {
|
||||||
|
mPopup.updateCoordinates(mContentRect);
|
||||||
}
|
}
|
||||||
mWidthChanged = false;
|
mWidthChanged = false;
|
||||||
|
mPreviousContentRect.set(mContentRect);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -318,24 +321,8 @@ public final class FloatingToolbar {
|
|||||||
};
|
};
|
||||||
private final AnimatorSet mDismissAnimation;
|
private final AnimatorSet mDismissAnimation;
|
||||||
private final AnimatorSet mHideAnimation;
|
private final AnimatorSet mHideAnimation;
|
||||||
private final AnimationSet mOpenOverflowAnimation = new AnimationSet(true) {
|
private final AnimationSet mOpenOverflowAnimation = new AnimationSet(true);
|
||||||
@Override
|
private final AnimationSet mCloseOverflowAnimation = new AnimationSet(true);
|
||||||
public void cancel() {
|
|
||||||
if (hasStarted() && !hasEnded()) {
|
|
||||||
super.cancel();
|
|
||||||
setOverflowPanelAsContent();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
private final AnimationSet mCloseOverflowAnimation = new AnimationSet(true) {
|
|
||||||
@Override
|
|
||||||
public void cancel() {
|
|
||||||
if (hasStarted() && !hasEnded()) {
|
|
||||||
super.cancel();
|
|
||||||
setMainPanelAsContent();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
private final Runnable mOpenOverflow = new Runnable() {
|
private final Runnable mOpenOverflow = new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
@@ -657,8 +644,24 @@ public final class FloatingToolbar {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void cancelOverflowAnimations() {
|
private void cancelOverflowAnimations() {
|
||||||
mOpenOverflowAnimation.cancel();
|
if (mOpenOverflowAnimation.hasStarted()
|
||||||
mCloseOverflowAnimation.cancel();
|
&& !mOpenOverflowAnimation.hasEnded()) {
|
||||||
|
// Remove the animation listener, stop the animation,
|
||||||
|
// then trigger the lister explicitly so it is not posted
|
||||||
|
// to the message queue.
|
||||||
|
mOpenOverflowAnimation.setAnimationListener(null);
|
||||||
|
mContentContainer.clearAnimation();
|
||||||
|
mOnOverflowOpened.onAnimationEnd(null);
|
||||||
|
}
|
||||||
|
if (mCloseOverflowAnimation.hasStarted()
|
||||||
|
&& !mCloseOverflowAnimation.hasEnded()) {
|
||||||
|
// Remove the animation listener, stop the animation,
|
||||||
|
// then trigger the lister explicitly so it is not posted
|
||||||
|
// to the message queue.
|
||||||
|
mCloseOverflowAnimation.setAnimationListener(null);
|
||||||
|
mContentContainer.clearAnimation();
|
||||||
|
mOnOverflowClosed.onAnimationEnd(null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user