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

Commit bc985c5c authored by Lyn Han's avatar Lyn Han
Browse files

Update overflow, expanded view dimens after dpi change

Fixes: 156693907
Fixes: 156967175
Test: manual - overflow button, overflow, normal bubble expanded views
look proportionally consistent in each display size

Change-Id: I67ccf9402cf7ec17bed258158ca7ca81e63077e8
parent 28c3a34f
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -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();
+10 −3
Original line number Diff line number Diff line
@@ -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);
+14 −9
Original line number Diff line number Diff line
@@ -89,6 +89,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(
@@ -96,8 +104,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);
@@ -109,17 +118,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) {
@@ -178,7 +182,8 @@ public class BubbleOverflowActivity extends Activity {
    @Override
    public void onResume() {
        super.onResume();
        onThemeChanged();
        updateDimensions();
        updateTheme();
    }

    @Override
+1 −0
Original line number Diff line number Diff line
@@ -1027,6 +1027,7 @@ public class BubbleStackView extends FrameLayout
            mBubbleOverflow.setUpOverflow(mBubbleContainer, this);
        } else {
            mBubbleContainer.removeView(mBubbleOverflow.getBtn());
            mBubbleOverflow.updateDimensions();
            mBubbleOverflow.updateIcon(mContext,this);
            overflowBtnIndex = mBubbleContainer.getChildCount();
        }