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

Commit 386831dc authored by John Spurlock's avatar John Spurlock Committed by Android (Google) Code Review
Browse files

Merge "Zen: Fix recent regression in mode selection after reboot." into lmp-dev

parents 6663d4f9 4291fb79
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import java.util.Objects;
public class SegmentedButtons extends LinearLayout {
    private static final Typeface MEDIUM = Typeface.create("sans-serif-medium", Typeface.NORMAL);
    private static final Typeface BOLD = Typeface.create("sans-serif", Typeface.BOLD);
    private static final int LABEL_RES_KEY = R.id.label;

    private final Context mContext;
    private final LayoutInflater mInflater;
@@ -69,6 +70,7 @@ public class SegmentedButtons extends LinearLayout {

    public void addButton(int labelResId, Object value) {
        final Button b = (Button) mInflater.inflate(R.layout.segmented_button, this, false);
        b.setTag(LABEL_RES_KEY, labelResId);
        b.setText(labelResId);
        final LayoutParams lp = (LayoutParams) b.getLayoutParams();
        if (getChildCount() == 0) {
@@ -80,6 +82,14 @@ public class SegmentedButtons extends LinearLayout {
        b.setOnClickListener(mClick);
    }

    public void updateLocale() {
        for (int i = 0; i < getChildCount(); i++) {
            final Button b = (Button) getChildAt(i);
            final int labelResId = (Integer) b.getTag(LABEL_RES_KEY);
            b.setText(labelResId);
        }
    }

    private void fireOnSelected() {
        if (mCallback != null) {
            mCallback.onSelected(mSelectedValue);
+5 −10
Original line number Diff line number Diff line
@@ -120,7 +120,10 @@ public class ZenModePanel extends LinearLayout {
        super.onFinishInflate();

        mZenButtons = (SegmentedButtons) findViewById(R.id.zen_buttons);
        addZenButtons();
        mZenButtons.addButton(R.string.interruption_level_none, Global.ZEN_MODE_NO_INTERRUPTIONS);
        mZenButtons.addButton(R.string.interruption_level_priority,
                Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS);
        mZenButtons.addButton(R.string.interruption_level_all, Global.ZEN_MODE_OFF);
        mZenButtons.setCallback(mZenButtonsCallback);

        mZenSubhead = findViewById(R.id.zen_subhead);
@@ -170,13 +173,6 @@ public class ZenModePanel extends LinearLayout {
        setExpanded(false);
    }

    private void addZenButtons() {
        mZenButtons.addButton(R.string.interruption_level_none, Global.ZEN_MODE_NO_INTERRUPTIONS);
        mZenButtons.addButton(R.string.interruption_level_priority,
                Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS);
        mZenButtons.addButton(R.string.interruption_level_all, Global.ZEN_MODE_OFF);
    }

    public void setHidden(boolean hidden) {
        if (mHidden == hidden) return;
        mHidden = hidden;
@@ -238,8 +234,7 @@ public class ZenModePanel extends LinearLayout {
    }

    public void updateLocale() {
        mZenButtons.removeAllViews();
        addZenButtons();
        mZenButtons.updateLocale();
    }

    private void setExitCondition(Condition exitCondition) {