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

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

Zen: Move zen mode preference to switch bar.

 - Add summary line support to SwitchBar.
 - Remove obsolete strings.
 - Wire up switchbar to zen mode w/ dialog prompt.
 - Remove obsolete callback pref helper.

Bug: 20064962
Change-Id: Ifede00b5d43d441ccd94db96bd2796bc57d1a990
parent c12b1ab2
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -24,6 +24,8 @@
              android:layout_width="0dp"
              android:layout_weight="1"
              android:layout_gravity="center_vertical"
              android:maxLines="2"
              android:ellipsize="end"
              android:textAppearance="@style/TextAppearance.Switch"
              android:textColor="?android:attr/textColorPrimary"
              android:textAlignment="viewStart" />
+6 −12
Original line number Diff line number Diff line
@@ -5692,20 +5692,17 @@
    <!-- Sound & notification > Sound section: Title for the zen mode automation option and associated settings page. [CHAR LIMIT=30] -->
    <string name="zen_mode_automation_settings_title">Automatic rules</string>

    <!-- Sound & notification > Sound section: Title for the zen mode option. [CHAR LIMIT=60] -->
    <string name="zen_mode_option_title">When calls and notifications arrive</string>

    <!-- Sound & notification > Sound section: Zen mode option: Off [CHAR LIMIT=60] -->
    <string name="zen_mode_option_off">Always interrupt</string>

    <!-- Sound & notification > Sound section: Zen mode option: Important interruptions [CHAR LIMIT=60] -->
    <string name="zen_mode_option_important_interruptions">Allow only priority interruptions</string>
    <string name="zen_mode_option_important_interruptions">Priority only</string>

    <!-- Sound & notification > Sound section: Zen mode option: Alarms only [CHAR LIMIT=60] -->
    <string name="zen_mode_option_alarms">Allow only alarms</string>
    <string name="zen_mode_option_alarms">Alarms only</string>

    <!-- Sound & notification > Sound section: Zen mode option: No interruptions [CHAR LIMIT=60] -->
    <string name="zen_mode_option_no_interruptions">Don\'t interrupt</string>
    <string name="zen_mode_option_no_interruptions">No interruptions</string>

    <!-- Sound & notification > Sound section: Zen mode combined summary + condition line [CHAR LIMIT=60] -->
    <string name="zen_mode_summary_combination"><xliff:g id="mode" example="Priority only">%1$s</xliff:g> <xliff:g id="exit condition" example="until you turn this off">%2$s</xliff:g></string>

    <!-- Sound & notification > Sound section: Title for the option defining the phone ringtone. [CHAR LIMIT=30] -->
    <string name="ringtone_title">Phone ringtone</string>
@@ -5875,9 +5872,6 @@
    <!-- [CHAR LIMIT=20] Notification settings: App notifications dialog dismiss button caption -->
    <string name="app_notifications_dialog_done">Done</string>

    <!-- [CHAR LIMIT=30] Zen mode settings: Exit condition selection dialog, default option -->
    <string name="zen_mode_default_option">Until you turn this off</string>

    <!-- [CHAR LIMIT=60] Zen mode settings: Downtime category text -->
    <string name="zen_mode_downtime_category">Downtime</string>

+4 −0
Original line number Diff line number Diff line
@@ -350,4 +350,8 @@
        <item name="android:textColor">@color/fingerprint_message_color</item>
    </style>

    <style name="TextAppearance.Small.SwitchBar">
        <item name="android:textColor">?android:attr/textColorPrimary</item>
        <item name="android:textStyle">normal</item>
    </style>
</resources>
+0 −6
Original line number Diff line number Diff line
@@ -19,12 +19,6 @@
    android:key="zen_mode_settings"
    android:title="@string/zen_mode_settings_title" >

    <!-- When calls and notifications arrive -->
    <com.android.settings.DropDownPreference
            android:key="zen_mode"
            android:title="@string/zen_mode_option_title"
            android:persistent="false" />

    <!-- Priority only allows -->
    <PreferenceScreen
            android:key="priority_settings"
+16 −5
Original line number Diff line number Diff line
@@ -118,7 +118,8 @@ public class ZenModeAutomationSettings extends ZenModeSettingsBase implements In
            removePreference(KEY_DOWNTIME);
            return;
        }
        mDays = root.findPreference(KEY_DAYS);
        final PreferenceCategory downtime = (PreferenceCategory) findPreference(KEY_DOWNTIME);
        mDays = downtime.findPreference(KEY_DAYS);
        mDays.setOnPreferenceClickListener(new OnPreferenceClickListener() {
            @Override
            public boolean onPreferenceClick(Preference preference) {
@@ -168,7 +169,7 @@ public class ZenModeAutomationSettings extends ZenModeSettingsBase implements In
                return setZenModeConfig(newConfig);
            }
        });
        root.addPreference(mStart);
        downtime.addPreference(mStart);
        mStart.setDependency(mDays.getKey());

        mEnd = new TimePickerPreference(mContext, mgr);
@@ -190,10 +191,10 @@ public class ZenModeAutomationSettings extends ZenModeSettingsBase implements In
                return setZenModeConfig(newConfig);
            }
        });
        root.addPreference(mEnd);
        downtime.addPreference(mEnd);
        mEnd.setDependency(mDays.getKey());

        mDowntimeMode = (DropDownPreference) root.findPreference(KEY_DOWNTIME_MODE);
        mDowntimeMode = (DropDownPreference) downtime.findPreference(KEY_DOWNTIME_MODE);
        mDowntimeMode.addItem(R.string.zen_mode_downtime_mode_priority, false);
        mDowntimeMode.addItem(R.string.zen_mode_downtime_mode_none, true);
        mDowntimeMode.setCallback(new DropDownPreference.Callback() {
@@ -265,7 +266,17 @@ public class ZenModeAutomationSettings extends ZenModeSettingsBase implements In
    }

    @Override
    protected void updateControls() {
    protected void onZenModeConfigChanged() {
        updateControls();
    }

    @Override
    public void onResume() {
        super.onResume();
        updateControls();
    }

    private void updateControls() {
        mDisableListeners = true;
        if (mDowntimeSupported) {
            updateDays();
Loading