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

Commit bcc608fb authored by Matías Hernández's avatar Matías Hernández
Browse files

Style priority modes items in aggregator

* Different color if active.
* Trigger description / "ON" / "Paused" / "Tap to set up" depending on enabled and active status (strings may be revised later).

This CL also adds a helper class to create ZenModes, reducing boilerplate in unit tests.

Bug: 346575288
Test: atest com.android.settings.notification.modes
Flag: android.app.modes_ui
Change-Id: Ia0e16b8be5284d13bed4366cbee0f92748bf2f85
parent 3cac4114
Loading
Loading
Loading
Loading
+16 −4
Original line number Diff line number Diff line
@@ -7930,16 +7930,28 @@
    <!-- Zen Modes: Option to add an automatic schedule for a mode. [CHAR_LIMIT=40] -->
    <string name="zen_mode_select_schedule">Select activation type</string>
    <!-- Zen Modes: Option to choose a time-based schedule for a mode. [CHAR_LIMIT=40] -->
    <!-- Priority Modes: Option to choose a time-based schedule for a mode. [CHAR_LIMIT=40] -->
    <string name="zen_mode_select_schedule_time">Time</string>
    <!-- Zen Modes: Example text for the option to choose a time-based schedule for a mode. [CHAR_LIMIT=60] -->
    <!-- Priority Modes: Example text for the option to choose a time-based schedule for a mode. [CHAR_LIMIT=60] -->
    <string name="zen_mode_select_schedule_time_example">Ex. \"9:30 – 5:00 PM\"</string>
    <!-- Zen Modes: Option to choose a calendar-events-based schedule for a mode. [CHAR_LIMIT=40] -->
    <!-- Priority Modes: Option to choose a calendar-events-based schedule for a mode. [CHAR_LIMIT=40] -->
    <string name="zen_mode_select_schedule_calendar">Calendar</string>
    <!-- Zen Modes: Example text for the option to choose a calendar-events-based schedule for a mode. [CHAR_LIMIT=60] -->
    <!-- Priority Modes: Example text for the option to choose a calendar-events-based schedule for a mode. [CHAR_LIMIT=60] -->
    <string name="zen_mode_select_schedule_calendar_example">Ex. \"Personal calendar\"</string>
    <!-- Priority Modes: Short text that indicates that a mode is currently on (active). [CHAR_LIMIT=10] -->
    <string name="zen_mode_active_text">ON</string>
    <!-- Priority Modes: Format string for the "current state + trigger description summary for rules in the list. [CHAR_LIMIT=10] -->
    <string name="zen_mode_format_status_and_trigger" translatable="false"><xliff:g id="current_status" example="ON">%1$s</xliff:g> • <xliff:g id="trigger_description" example="Mon-Fri, 23:00-7:00">%2$s</xliff:g></string>
    <!-- Priority Modes: Call to action for a mode that is disabled and needs to be configured. [CHAR_LIMIT=40] -->
    <string name="zen_mode_disabled_tap_to_set_up">Tap to set up</string>
    <!-- Priority Modes: Indicates that a mode is disabled by the user. [CHAR_LIMIT=40] -->
    <string name="zen_mode_disabled_by_user">Paused</string>
    <!-- Subtitle for the Do not Disturb slice. [CHAR LIMIT=50]-->
    <string name="zen_mode_slice_subtitle">Limit interruptions</string>
+12 −3
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.graphics.drawable.LayerDrawable;
import android.graphics.drawable.ShapeDrawable;
import android.graphics.drawable.shapes.OvalShape;

import androidx.annotation.AttrRes;
import androidx.annotation.DrawableRes;
import androidx.annotation.NonNull;

@@ -32,10 +33,18 @@ import com.android.settingslib.Utils;

class IconUtil {

    static Drawable applyTint(@NonNull Context context, @NonNull Drawable icon) {
    static Drawable applyNormalTint(@NonNull Context context, @NonNull Drawable icon) {
        return applyTint(context, icon, android.R.attr.colorControlNormal);
    }

    static Drawable applyAccentTint(@NonNull Context context, @NonNull Drawable icon) {
        return applyTint(context, icon, android.R.attr.colorAccent);
    }

    private static Drawable applyTint(@NonNull Context context, @NonNull Drawable icon,
            @AttrRes int colorAttr) {
        icon = icon.mutate();
        icon.setTintList(
                Utils.getColorAttr(context, android.R.attr.colorControlNormal));
        icon.setTintList(Utils.getColorAttr(context, colorAttr));
        return icon;
    }

+1 −1
Original line number Diff line number Diff line
@@ -27,7 +27,7 @@ import com.android.settingslib.notification.modes.ZenMode;
import com.android.settingslib.notification.modes.ZenModesBackend;
import com.android.settingslib.widget.LayoutPreference;

public class ZenModeButtonPreferenceController extends AbstractZenModePreferenceController {
class ZenModeButtonPreferenceController extends AbstractZenModePreferenceController {

    private Button mZenButton;

+15 −19
Original line number Diff line number Diff line
@@ -26,7 +26,7 @@ import androidx.preference.TwoStatePreference;
import com.android.settingslib.notification.modes.ZenMode;
import com.android.settingslib.notification.modes.ZenModesBackend;

public class ZenModeDisplayEffectPreferenceController extends AbstractZenModePreferenceController
class ZenModeDisplayEffectPreferenceController extends AbstractZenModePreferenceController
        implements Preference.OnPreferenceChangeListener {

    public ZenModeDisplayEffectPreferenceController(Context context, String key,
@@ -37,10 +37,7 @@ public class ZenModeDisplayEffectPreferenceController extends AbstractZenModePre
    @Override
    public void updateState(Preference preference, @NonNull ZenMode zenMode) {
        TwoStatePreference pref = (TwoStatePreference) preference;
        ZenDeviceEffects effects =  zenMode.getRule().getDeviceEffects();
        if (effects == null) {
            pref.setChecked(false);
        } else {
        ZenDeviceEffects effects =  zenMode.getDeviceEffects();
        switch (getPreferenceKey()) {
            case "effect_greyscale":
                pref.setChecked(effects.shouldDisplayGrayscale());
@@ -56,7 +53,6 @@ public class ZenModeDisplayEffectPreferenceController extends AbstractZenModePre
                break;
        }
    }
    }

    @Override
    public boolean onPreferenceChange(@NonNull Preference preference, Object newValue) {
+1 −1
Original line number Diff line number Diff line
@@ -66,7 +66,7 @@ class ZenModeHeaderController extends AbstractZenModePreferenceController {

        FutureUtil.whenDone(
                zenMode.getIcon(mContext, ZenIconLoader.getInstance()),
                icon -> mHeaderController.setIcon(IconUtil.applyTint(mContext, icon))
                icon -> mHeaderController.setIcon(IconUtil.applyNormalTint(mContext, icon))
                        .done(/* rebindActions= */ false),
                mContext.getMainExecutor());
    }
Loading