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

Commit ce90f818 authored by mpodolian's avatar mpodolian
Browse files

Changing system language also updates bubbles

Made bubbles react on language change and re-fetch strings for updated
locale.

Test: Manual
Fix: 242024058
Change-Id: Id98adab79b75002c23245de316fdbdc503de5463
parent af5b892b
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -122,6 +122,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
@@ -247,6 +248,9 @@ public class BubbleController implements ConfigurationChangeListener,
    /** Saved font scale, used to detect font size changes in {@link #onConfigurationChanged}. */
    private float mFontScale = 0;

    /** Saved locale, used to detect local changes in {@link #onConfigurationChanged}. */
    private Locale mLocale = null;

    /** Saved direction, used to detect layout direction changes @link #onConfigChanged}. */
    private int mLayoutDirection = View.LAYOUT_DIRECTION_UNDEFINED;

@@ -1052,6 +1056,11 @@ public class BubbleController implements ConfigurationChangeListener,
                mLayoutDirection = newConfig.getLayoutDirection();
                mStackView.onLayoutDirectionChanged(mLayoutDirection);
            }
            Locale newLocale = newConfig.locale;
            if (newLocale != null && !newLocale.equals(mLocale)) {
                mLocale = newLocale;
                mStackView.updateLocale();
            }
        }
    }

+9 −0
Original line number Diff line number Diff line
@@ -517,6 +517,15 @@ public class BubbleExpandedView extends LinearLayout {
        }
    }

    void updateLocale() {
        if (mManageButton != null) {
            mManageButton.setText(mContext.getString(R.string.manage_bubbles_text));
        }
        if (mOverflowView != null) {
            mOverflowView.updateLocale();
        }
    }

    void applyThemeAttrs() {
        final TypedArray ta = mContext.obtainStyledAttributes(new int[]{
                android.R.attr.dialogCornerRadius,
+5 −0
Original line number Diff line number Diff line
@@ -242,6 +242,11 @@ public class BubbleOverflowContainerView extends LinearLayout {
        mEmptyStateSubtitle.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize);
    }

    public void updateLocale() {
        mEmptyStateTitle.setText(mContext.getString(R.string.bubble_overflow_empty_title));
        mEmptyStateSubtitle.setText(mContext.getString(R.string.bubble_overflow_empty_subtitle));
    }

    private final BubbleData.Listener mDataListener = new BubbleData.Listener() {

        @Override
+6 −0
Original line number Diff line number Diff line
@@ -1447,6 +1447,12 @@ public class BubbleStackView extends FrameLayout
        }
    }

    void updateLocale() {
        if (mBubbleOverflow != null && mBubbleOverflow.getExpandedView() != null) {
            mBubbleOverflow.getExpandedView().updateLocale();
        }
    }

    private void updateOverflow() {
        mBubbleOverflow.update();
        mBubbleContainer.reorderView(mBubbleOverflow.getIconView(),