am 3128692f: am 6bc12244: Fix Select All Option is truncated when device goes from landscape to portrait
* commit '3128692fd4a7d9113becc5bfbd0206413b34ebaa': Fix Select All Option is truncated when device goes from landscape to portrait
This commit is contained in:
@@ -20,7 +20,9 @@ import android.animation.Animator;
|
|||||||
import android.animation.AnimatorListenerAdapter;
|
import android.animation.AnimatorListenerAdapter;
|
||||||
import android.animation.AnimatorSet;
|
import android.animation.AnimatorSet;
|
||||||
import android.animation.ObjectAnimator;
|
import android.animation.ObjectAnimator;
|
||||||
|
import android.content.ComponentCallbacks;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.res.Configuration;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.graphics.Point;
|
import android.graphics.Point;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
@@ -89,6 +91,19 @@ public final class FloatingToolbar {
|
|||||||
private int mSuggestedWidth;
|
private int mSuggestedWidth;
|
||||||
private boolean mWidthChanged = true;
|
private boolean mWidthChanged = true;
|
||||||
|
|
||||||
|
private final ComponentCallbacks mOrientationChangeHandler = new ComponentCallbacks() {
|
||||||
|
@Override
|
||||||
|
public void onConfigurationChanged(Configuration newConfig) {
|
||||||
|
if (mPopup.isShowing() && mPopup.viewPortHasChanged()) {
|
||||||
|
mWidthChanged = true;
|
||||||
|
updateLayout();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLowMemory() {}
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes a floating toolbar.
|
* Initializes a floating toolbar.
|
||||||
*/
|
*/
|
||||||
@@ -151,6 +166,8 @@ public final class FloatingToolbar {
|
|||||||
* Shows this floating toolbar.
|
* Shows this floating toolbar.
|
||||||
*/
|
*/
|
||||||
public FloatingToolbar show() {
|
public FloatingToolbar show() {
|
||||||
|
mContext.unregisterComponentCallbacks(mOrientationChangeHandler);
|
||||||
|
mContext.registerComponentCallbacks(mOrientationChangeHandler);
|
||||||
List<MenuItem> menuItems = getVisibleAndEnabledMenuItems(mMenu);
|
List<MenuItem> menuItems = getVisibleAndEnabledMenuItems(mMenu);
|
||||||
if (!isCurrentlyShowing(menuItems) || mWidthChanged) {
|
if (!isCurrentlyShowing(menuItems) || mWidthChanged) {
|
||||||
mPopup.dismiss();
|
mPopup.dismiss();
|
||||||
@@ -181,6 +198,7 @@ public final class FloatingToolbar {
|
|||||||
* Dismisses this floating toolbar.
|
* Dismisses this floating toolbar.
|
||||||
*/
|
*/
|
||||||
public void dismiss() {
|
public void dismiss() {
|
||||||
|
mContext.unregisterComponentCallbacks(mOrientationChangeHandler);
|
||||||
mPopup.dismiss();
|
mPopup.dismiss();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -329,6 +347,7 @@ public final class FloatingToolbar {
|
|||||||
|
|
||||||
private final Rect mViewPort = new Rect();
|
private final Rect mViewPort = new Rect();
|
||||||
private final Point mCoords = new Point();
|
private final Point mCoords = new Point();
|
||||||
|
private final Rect mTmpRect = new Rect();
|
||||||
|
|
||||||
private final Region mTouchableRegion = new Region();
|
private final Region mTouchableRegion = new Region();
|
||||||
private final ViewTreeObserver.OnComputeInternalInsetsListener mInsetsComputer =
|
private final ViewTreeObserver.OnComputeInternalInsetsListener mInsetsComputer =
|
||||||
@@ -873,6 +892,11 @@ public final class FloatingToolbar {
|
|||||||
mParent.getWindowVisibleDisplayFrame(mViewPort);
|
mParent.getWindowVisibleDisplayFrame(mViewPort);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean viewPortHasChanged() {
|
||||||
|
mParent.getWindowVisibleDisplayFrame(mTmpRect);
|
||||||
|
return !mTmpRect.equals(mViewPort);
|
||||||
|
}
|
||||||
|
|
||||||
private int getToolbarWidth(int suggestedWidth) {
|
private int getToolbarWidth(int suggestedWidth) {
|
||||||
int width = suggestedWidth;
|
int width = suggestedWidth;
|
||||||
refreshViewPort();
|
refreshViewPort();
|
||||||
|
|||||||
Reference in New Issue
Block a user