Merge "Update overflow, expanded view dimens after dpi change" into rvc-dev am: b92d8d64d5

Change-Id: Ibd8612566171c1a8982fb0be1586c48a4c09ceb2
This commit is contained in:
Lyn Han
2020-05-26 17:54:12 +00:00
committed by Automerger Merge Worker
4 changed files with 30 additions and 13 deletions

View File

@@ -226,8 +226,12 @@ public class BubbleExpandedView extends LinearLayout {
public BubbleExpandedView(Context context, AttributeSet attrs, int defStyleAttr,
int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
updateDimensions();
}
void updateDimensions() {
mDisplaySize = new Point();
mWindowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
mWindowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
// Get the real size -- this includes screen decorations (notches, statusbar, navbar).
mWindowManager.getDefaultDisplay().getRealSize(mDisplaySize);
Resources res = getResources();

View File

@@ -61,9 +61,7 @@ public class BubbleOverflow implements BubbleViewProvider {
}
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);
updateDimensions();
mExpandedView = (BubbleExpandedView) mInflater.inflate(
R.layout.bubble_expanded_view, parentViewGroup /* root */,
@@ -74,6 +72,15 @@ public class BubbleOverflow implements BubbleViewProvider {
updateIcon(mContext, parentViewGroup);
}
void updateDimensions() {
mBitmapSize = mContext.getResources().getDimensionPixelSize(R.dimen.bubble_bitmap_size);
mIconBitmapSize = mContext.getResources().getDimensionPixelSize(
R.dimen.bubble_overflow_icon_bitmap_size);
if (mExpandedView != null) {
mExpandedView.updateDimensions();
}
}
void updateIcon(Context context, ViewGroup parentViewGroup) {
mContext = context;
mInflater = LayoutInflater.from(context);

View File

@@ -92,6 +92,14 @@ public class BubbleOverflowActivity extends Activity {
mRecyclerView = findViewById(R.id.bubble_overflow_recycler);
mEmptyStateImage = findViewById(R.id.bubble_overflow_empty_state_image);
updateDimensions();
onDataChanged(mBubbleController.getOverflowBubbles());
mBubbleController.setOverflowCallback(() -> {
onDataChanged(mBubbleController.getOverflowBubbles());
});
}
void updateDimensions() {
Resources res = getResources();
final int columns = res.getInteger(R.integer.bubbles_overflow_columns);
mRecyclerView.setLayoutManager(
@@ -99,8 +107,9 @@ public class BubbleOverflowActivity extends Activity {
DisplayMetrics displayMetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
final int recyclerViewWidth = (displayMetrics.widthPixels
- res.getDimensionPixelSize(R.dimen.bubble_overflow_padding));
final int overflowPadding = res.getDimensionPixelSize(R.dimen.bubble_overflow_padding);
final int recyclerViewWidth = displayMetrics.widthPixels - (overflowPadding * 2);
final int viewWidth = recyclerViewWidth / columns;
final int maxOverflowBubbles = res.getInteger(R.integer.bubbles_max_overflow);
@@ -112,17 +121,12 @@ public class BubbleOverflowActivity extends Activity {
mAdapter = new BubbleOverflowAdapter(getApplicationContext(), mOverflowBubbles,
mBubbleController::promoteBubbleFromOverflow, viewWidth, viewHeight);
mRecyclerView.setAdapter(mAdapter);
onDataChanged(mBubbleController.getOverflowBubbles());
mBubbleController.setOverflowCallback(() -> {
onDataChanged(mBubbleController.getOverflowBubbles());
});
onThemeChanged();
}
/**
* Handle theme changes.
*/
void onThemeChanged() {
void updateTheme() {
final int mode =
getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
switch (mode) {
@@ -181,7 +185,8 @@ public class BubbleOverflowActivity extends Activity {
@Override
public void onResume() {
super.onResume();
onThemeChanged();
updateDimensions();
updateTheme();
}
@Override

View File

@@ -1033,6 +1033,7 @@ public class BubbleStackView extends FrameLayout
mBubbleOverflow.setUpOverflow(mBubbleContainer, this);
} else {
mBubbleContainer.removeView(mBubbleOverflow.getBtn());
mBubbleOverflow.updateDimensions();
mBubbleOverflow.updateIcon(mContext,this);
overflowBtnIndex = mBubbleContainer.getChildCount();
}