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

Commit 76e803db authored by Lyn Han's avatar Lyn Han
Browse files

Update header color for all bubbles

Bubble stack view - after dark mode change, update expanded view header color for all bubbles

Previously, mContext.getColor(R.attr.colorAccent) updated header color in a hacky way:

colorAccent was *not* a color => ResourcesNotFoundException => all bubbles re-inflated with the correct new color

Bug: 123829494
Test: manual
Change-Id: I526d6f91d032b24424740d93c3eec7776c1e0c44
parent d9ee5557
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -381,10 +381,18 @@ public class BubbleExpandedView extends LinearLayout implements View.OnClickList
    }

    /**
     * Update bubble expanded view header when user toggles dark mode.
     * Update header color when user toggles dark mode.
     */
    void updateHeaderColor() {
        mHeaderView.setBackgroundColor(mContext.getColor(R.attr.colorAccent));
        TypedArray ta = mContext.obtainStyledAttributes(
                new int[] {android.R.attr.colorBackgroundFloating, android.R.attr.colorForeground});
        int bgColor = ta.getColor(0, Color.WHITE /* default */);
        int btnColor = ta.getColor(1, Color.BLACK /* default */);
        ta.recycle();

        mHeaderView.setBackgroundColor(bgColor);
        mSettingsIcon.setColorFilter(btnColor);
        mDeepLinkIcon.setColorFilter(btnColor);
    }

    private void updateHeaderView() {
+2 −3
Original line number Diff line number Diff line
@@ -270,8 +270,8 @@ public class BubbleStackView extends FrameLayout {
     * Handle config changes.
     */
    public void onConfigChanged() {
        if (mExpandedBubble != null) {
            mExpandedBubble.expandedView.updateHeaderColor();
        for (Bubble b: mBubbleData.getBubbles()) {
            b.expandedView.updateHeaderColor();
        }
    }

@@ -856,7 +856,6 @@ public class BubbleStackView extends FrameLayout {

    private void applyCurrentState() {
        Log.d(TAG, "applyCurrentState: mIsExpanded=" + mIsExpanded);

        mExpandedViewContainer.setVisibility(mIsExpanded ? VISIBLE : GONE);
        if (mIsExpanded) {
            // First update the view so that it calculates a new height (ensuring the y position