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

Commit de547008 authored by John Spurlock's avatar John Spurlock
Browse files

Wire up SystemUI zen mode config to new settings panel.

Change-Id: I949b31be0b31c02ab736799f9080601fb0fd79d1
parent f87b2248
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -749,6 +749,14 @@ public final class Settings {
    public static final String ACTION_PRINT_SETTINGS =
            "android.settings.ACTION_PRINT_SETTINGS";

    /**
     * Activity Action: Show Zen Mode configuration settings.
     *
     * @hide
     */
    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
    public static final String ACTION_ZEN_MODE_SETTINGS = "android.settings.ZEN_MODE_SETTINGS";

    // End of Intent actions for Settings

    /**
+9 −1
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.content.Context;
import android.content.res.Resources;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.provider.Settings;
import android.util.AttributeSet;
import android.util.EventLog;
import android.view.MotionEvent;
@@ -58,7 +59,14 @@ public class NotificationPanelView extends PanelView {
        mHandleView = findViewById(R.id.handle);
        PanelHeaderView header = (PanelHeaderView) findViewById(R.id.header);
        ZenModeView zenModeView = (ZenModeView) findViewById(R.id.zenmode);
        zenModeView.setAdapter( new ZenModeViewAdapter(mContext));
        zenModeView.setAdapter(new ZenModeViewAdapter(mContext) {
            @Override
            public void configure() {
                if (mStatusBar != null) {
                    mStatusBar.startSettingsActivity(Settings.ACTION_ZEN_MODE_SETTINGS);
                }
            }
        });
        header.setZenModeView(zenModeView);
    }

+6 −0
Original line number Diff line number Diff line
@@ -2739,6 +2739,12 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode {
                || (mDisabled & StatusBarManager.DISABLE_SEARCH) != 0;
    }

    public void startSettingsActivity(String action) {
        if (mQS != null) {
            mQS.startSettingsActivity(action);
        }
    }

    private static class FastColorDrawable extends Drawable {
        private final int mColor;

+1 −1
Original line number Diff line number Diff line
@@ -278,7 +278,7 @@ class QuickSettings {
        mTilesSetUp = true;
    }

    private void startSettingsActivity(String action) {
    public void startSettingsActivity(String action) {
        Intent intent = new Intent(action);
        startSettingsActivity(intent);
    }
+3 −41
Original line number Diff line number Diff line
@@ -66,10 +66,7 @@ public class ZenModeView extends RelativeLayout {
    private static final long BOUNCE_DURATION = DURATION / 3;
    private static final float BOUNCE_SCALE = 0.8f;
    private static final float SETTINGS_ALPHA = 0.6f;
    private static final int INFO_WINDOW_DELAY = 2000;

    private static final String LIMITED_TEXT =
            "New notifications suppressed except calls, alarms & timers.";
    private static final String FULL_TEXT =
            "You won't hear any calls, alarms or timers.";

@@ -79,7 +76,6 @@ public class ZenModeView extends RelativeLayout {
    private final ModeSpinner mModeSpinner;
    private final ImageView mCloseButton;
    private final ImageView mSettingsButton;
    private final InfoWindow mInfoWindow;
    private final Rect mLayoutRect = new Rect();
    private final UntilPager mUntilPager;
    private final AlarmWarning mAlarmWarning;
@@ -133,16 +129,12 @@ public class ZenModeView extends RelativeLayout {
        mSettingsButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (mAdapter == null || mAdapter.getMode() != Adapter.MODE_LIMITED) {
                    return;
                }
                if (!mInfoWindow.isShowing()) {
                    mInfoWindow.show(mUntilPager);
                if (mAdapter != null && mAdapter.getMode() == Adapter.MODE_LIMITED) {
                    mAdapter.configure();
                }
                bounce(mSettingsButton, null);
            }
        });
        mInfoWindow = new InfoWindow(mContext, LIMITED_TEXT);

        mModeSpinner = new ModeSpinner(mContext);
        mModeSpinner.setAlpha(0);
@@ -201,7 +193,6 @@ public class ZenModeView extends RelativeLayout {
        }).start();
        mUntilPager.animate().alpha(0).start();
        mAlarmWarning.animate().alpha(0).start();
        mInfoWindow.dismiss();
    }

    public void setAdapter(Adapter adapter) {
@@ -247,7 +238,6 @@ public class ZenModeView extends RelativeLayout {
                mBottom = getExpandedBottom();
                setExpanded(1);
            }
            mInfoWindow.dismiss();
        }
    }

@@ -597,6 +587,7 @@ public class ZenModeView extends RelativeLayout {
        public static final int MODE_FULL = 2;

        boolean isApplicable();
        void configure();
        int getMode();
        void setMode(int mode);
        void select(ExitCondition ec);
@@ -745,33 +736,4 @@ public class ZenModeView extends RelativeLayout {
            }
        }
    }

    private static class InfoWindow extends PopupWindow implements Runnable {
        private final TextView mText;

        public InfoWindow(Context context, String text) {
            mText = new TextView(context);
            mText.setTypeface(CONDENSED);
            mText.setBackgroundColor(0xbb000000);
            mText.setTextColor(0xffffffff);
            mText.setText(text);
            mText.setGravity(Gravity.CENTER);
            setAnimationStyle(android.R.style.Animation_Toast);
            setContentView(mText);
        }

        @Override
        public void run() {
            dismiss();
        }

        public void show(View over) {
            setWidth(over.getMeasuredWidth());
            setHeight(over.getMeasuredHeight());
            final int[] loc = new int[2];
            over.getLocationInWindow(loc);
            showAtLocation(over, Gravity.NO_GRAVITY, loc[0], loc[1]);
            over.postDelayed(this, INFO_WINDOW_DELAY);
        }
    }
}
Loading