Merge "Update resources after display size change" into rvc-dev am: b375d0f628
Change-Id: I9dbcfe7933b2943e3a0cc397cbe9f34f27b2c5eb
This commit is contained in:
@@ -198,6 +198,11 @@ public class BubbleController implements ConfigurationController.ConfigurationLi
|
||||
/** Last known orientation, used to detect orientation changes in {@link #onConfigChanged}. */
|
||||
private int mOrientation = Configuration.ORIENTATION_UNDEFINED;
|
||||
|
||||
/**
|
||||
* Last known screen density, used to detect display size changes in {@link #onConfigChanged}.
|
||||
*/
|
||||
private int mDensityDpi = Configuration.DENSITY_DPI_UNDEFINED;
|
||||
|
||||
private boolean mInflateSynchronously;
|
||||
|
||||
// TODO (b/145659174): allow for multiple callbacks to support the "shadow" new notif pipeline
|
||||
@@ -705,9 +710,16 @@ public class BubbleController implements ConfigurationController.ConfigurationLi
|
||||
|
||||
@Override
|
||||
public void onConfigChanged(Configuration newConfig) {
|
||||
if (mStackView != null && newConfig != null && newConfig.orientation != mOrientation) {
|
||||
mOrientation = newConfig.orientation;
|
||||
mStackView.onOrientationChanged(newConfig.orientation);
|
||||
if (mStackView != null && newConfig != null) {
|
||||
if (newConfig.orientation != mOrientation) {
|
||||
mOrientation = newConfig.orientation;
|
||||
mStackView.onOrientationChanged(newConfig.orientation);
|
||||
}
|
||||
if (newConfig.densityDpi != mDensityDpi) {
|
||||
mDensityDpi = newConfig.densityDpi;
|
||||
mBubbleIconFactory = new BubbleIconFactory(mContext);
|
||||
mStackView.onDisplaySizeChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -58,12 +58,13 @@ public class BubbleOverflow implements BubbleViewProvider {
|
||||
public BubbleOverflow(Context context) {
|
||||
mContext = context;
|
||||
mInflater = LayoutInflater.from(context);
|
||||
mBitmapSize = mContext.getResources().getDimensionPixelSize(R.dimen.bubble_bitmap_size);
|
||||
mIconBitmapSize = mContext.getResources().getDimensionPixelSize(
|
||||
R.dimen.bubble_overflow_icon_bitmap_size);
|
||||
}
|
||||
|
||||
void setUpOverflow(ViewGroup parentViewGroup, BubbleStackView stackView) {
|
||||
mBitmapSize = mContext.getResources().getDimensionPixelSize(R.dimen.bubble_bitmap_size);
|
||||
mIconBitmapSize = mContext.getResources().getDimensionPixelSize(
|
||||
R.dimen.bubble_overflow_icon_bitmap_size);
|
||||
|
||||
mExpandedView = (BubbleExpandedView) mInflater.inflate(
|
||||
R.layout.bubble_expanded_view, parentViewGroup /* root */,
|
||||
false /* attachToRoot */);
|
||||
@@ -74,6 +75,7 @@ public class BubbleOverflow implements BubbleViewProvider {
|
||||
}
|
||||
|
||||
void updateIcon(Context context, ViewGroup parentViewGroup) {
|
||||
mContext = context;
|
||||
mInflater = LayoutInflater.from(context);
|
||||
mOverflowBtn = (BadgedImageView) mInflater.inflate(R.layout.bubble_overflow_button,
|
||||
parentViewGroup /* root */,
|
||||
@@ -87,7 +89,7 @@ public class BubbleOverflow implements BubbleViewProvider {
|
||||
ta.recycle();
|
||||
|
||||
TypedValue typedValue = new TypedValue();
|
||||
context.getTheme().resolveAttribute(android.R.attr.colorAccent, typedValue, true);
|
||||
mContext.getTheme().resolveAttribute(android.R.attr.colorAccent, typedValue, true);
|
||||
int colorAccent = mContext.getColor(typedValue.resourceId);
|
||||
mOverflowBtn.getDrawable().setTint(colorAccent);
|
||||
mDotColor = colorAccent;
|
||||
@@ -97,7 +99,7 @@ public class BubbleOverflow implements BubbleViewProvider {
|
||||
mBitmapSize - mIconBitmapSize /* inset */);
|
||||
AdaptiveIconDrawable adaptiveIconDrawable = new AdaptiveIconDrawable(bg, fg);
|
||||
|
||||
BubbleIconFactory iconFactory = new BubbleIconFactory(context);
|
||||
BubbleIconFactory iconFactory = new BubbleIconFactory(mContext);
|
||||
mIcon = iconFactory.createBadgedIconBitmap(adaptiveIconDrawable,
|
||||
null /* user */,
|
||||
true /* shrinkNonAdaptiveIcons */).icon;
|
||||
@@ -106,7 +108,7 @@ public class BubbleOverflow implements BubbleViewProvider {
|
||||
null /* outBounds */, null /* path */, null /* outMaskShape */);
|
||||
float radius = DEFAULT_PATH_SIZE / 2f;
|
||||
mPath = PathParser.createPathFromPathData(
|
||||
context.getResources().getString(com.android.internal.R.string.config_icon_mask));
|
||||
mContext.getResources().getString(com.android.internal.R.string.config_icon_mask));
|
||||
Matrix matrix = new Matrix();
|
||||
matrix.setScale(scale /* x scale */, scale /* y scale */, radius /* pivot x */,
|
||||
radius /* pivot y */);
|
||||
|
||||
@@ -790,8 +790,8 @@ public class BubbleStackView extends FrameLayout
|
||||
|
||||
mOrientationChangedListener =
|
||||
(v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) -> {
|
||||
mExpandedAnimationController.updateOrientation(mOrientation, mDisplaySize);
|
||||
mStackAnimationController.updateOrientation(mOrientation);
|
||||
mExpandedAnimationController.updateResources(mOrientation, mDisplaySize);
|
||||
mStackAnimationController.updateResources(mOrientation);
|
||||
|
||||
// Reposition & adjust the height for new orientation
|
||||
if (mIsExpanded) {
|
||||
@@ -1007,7 +1007,7 @@ public class BubbleStackView extends FrameLayout
|
||||
mBubbleOverflow.setUpOverflow(mBubbleContainer, this);
|
||||
} else {
|
||||
mBubbleContainer.removeView(mBubbleOverflow.getBtn());
|
||||
mBubbleOverflow.updateIcon(mContext, this);
|
||||
mBubbleOverflow.updateIcon(mContext,this);
|
||||
overflowBtnIndex = mBubbleContainer.getChildCount();
|
||||
}
|
||||
mBubbleContainer.addView(mBubbleOverflow.getBtn(), overflowBtnIndex,
|
||||
@@ -1054,6 +1054,28 @@ public class BubbleStackView extends FrameLayout
|
||||
mShowingManage = false;
|
||||
}
|
||||
|
||||
/** Respond to the display size change by recalculating view size and location. */
|
||||
public void onDisplaySizeChanged() {
|
||||
setUpOverflow();
|
||||
|
||||
WindowManager wm = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE);
|
||||
wm.getDefaultDisplay().getRealSize(mDisplaySize);
|
||||
Resources res = getContext().getResources();
|
||||
mStatusBarHeight = res.getDimensionPixelSize(
|
||||
com.android.internal.R.dimen.status_bar_height);
|
||||
mBubblePaddingTop = res.getDimensionPixelSize(R.dimen.bubble_padding_top);
|
||||
mBubbleSize = getResources().getDimensionPixelSize(R.dimen.individual_bubble_size);
|
||||
for (Bubble b : mBubbleData.getBubbles()) {
|
||||
if (b.getIconView() == null) {
|
||||
Log.d(TAG, "Display size changed. Icon null: " + b);
|
||||
continue;
|
||||
}
|
||||
b.getIconView().setLayoutParams(new LayoutParams(mBubbleSize, mBubbleSize));
|
||||
}
|
||||
mExpandedAnimationController.updateResources(mOrientation, mDisplaySize);
|
||||
mStackAnimationController.updateResources(mOrientation);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComputeInternalInsets(ViewTreeObserver.InternalInsetsInfo inoutInfo) {
|
||||
inoutInfo.setTouchableInsets(ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_REGION);
|
||||
@@ -1294,7 +1316,7 @@ public class BubbleStackView extends FrameLayout
|
||||
Log.d(TAG, "was asked to remove Bubble, but didn't find the view! " + bubble);
|
||||
}
|
||||
|
||||
private void updateOverflowBtnVisibility(boolean apply) {
|
||||
private void updateOverflowBtnVisibility() {
|
||||
if (!BubbleExperimentConfig.allowBubbleOverflow(mContext)) {
|
||||
return;
|
||||
}
|
||||
@@ -1303,11 +1325,6 @@ public class BubbleStackView extends FrameLayout
|
||||
Log.d(TAG, "Show overflow button.");
|
||||
}
|
||||
mBubbleOverflow.setBtnVisible(VISIBLE);
|
||||
if (apply) {
|
||||
mExpandedAnimationController.expandFromStack(() -> {
|
||||
updatePointerPosition();
|
||||
} /* after */);
|
||||
}
|
||||
} else {
|
||||
if (DEBUG_BUBBLE_STACK_VIEW) {
|
||||
Log.d(TAG, "Collapsed. Hide overflow button.");
|
||||
@@ -1567,7 +1584,7 @@ public class BubbleStackView extends FrameLayout
|
||||
Log.d(TAG, BubbleDebugConfig.formatBubblesString(getBubblesOnScreen(),
|
||||
mExpandedBubble));
|
||||
}
|
||||
updateOverflowBtnVisibility(/* apply */ false);
|
||||
updateOverflowBtnVisibility();
|
||||
mBubbleContainer.cancelAllAnimations();
|
||||
mExpandedAnimationController.collapseBackToStack(
|
||||
mStackAnimationController.getStackPositionAlongNearestHorizontalEdge()
|
||||
@@ -1591,7 +1608,7 @@ public class BubbleStackView extends FrameLayout
|
||||
beforeExpandedViewAnimation();
|
||||
|
||||
mBubbleContainer.setActiveController(mExpandedAnimationController);
|
||||
updateOverflowBtnVisibility(/* apply */ false);
|
||||
updateOverflowBtnVisibility();
|
||||
mExpandedAnimationController.expandFromStack(() -> {
|
||||
updatePointerPosition();
|
||||
afterExpandedViewAnimation();
|
||||
|
||||
@@ -118,7 +118,7 @@ public class ExpandedAnimationController
|
||||
|
||||
public ExpandedAnimationController(Point displaySize, int expandedViewPadding,
|
||||
int orientation) {
|
||||
updateOrientation(orientation, displaySize);
|
||||
updateResources(orientation, displaySize);
|
||||
mExpandedViewPadding = expandedViewPadding;
|
||||
}
|
||||
|
||||
@@ -168,7 +168,7 @@ public class ExpandedAnimationController
|
||||
* @param orientation Landscape or portrait.
|
||||
* @param displaySize Updated display size.
|
||||
*/
|
||||
public void updateOrientation(int orientation, Point displaySize) {
|
||||
public void updateResources(int orientation, Point displaySize) {
|
||||
mScreenOrientation = orientation;
|
||||
mDisplaySize = displaySize;
|
||||
if (mLayout != null) {
|
||||
|
||||
@@ -809,7 +809,7 @@ public class StackAnimationController extends
|
||||
* Update effective screen width based on current orientation.
|
||||
* @param orientation Landscape or portrait.
|
||||
*/
|
||||
public void updateOrientation(int orientation) {
|
||||
public void updateResources(int orientation) {
|
||||
if (mLayout != null) {
|
||||
Resources res = mLayout.getContext().getResources();
|
||||
mBubblePaddingTop = res.getDimensionPixelSize(R.dimen.bubble_padding_top);
|
||||
|
||||
Reference in New Issue
Block a user