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

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

Supply icon (in addition to name) for addCustomManualMode()

Bug: 326442408
Flag: android.app.modes_ui
Test: atest com.android.settings.notification.modes
Change-Id: I1249fcf52770705c8f899fed9ff1f09587ce301f
parent bd4dca1d
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -27,6 +27,8 @@ import android.service.notification.Condition;
import android.service.notification.ZenModeConfig;
import android.util.Log;

import androidx.annotation.DrawableRes;

import com.android.settingslib.R;

import java.time.Duration;
@@ -184,15 +186,18 @@ public class ZenModesBackend {
     * Creates a new custom mode with the provided {@code name}. The mode will be "manual" (i.e.
     * not have a schedule), this can be later updated by the user in the mode settings page.
     *
     * @param name mode name
     * @param iconResId resource id of the chosen icon, {code 0} if none.
     * @return the created mode. Only {@code null} if creation failed due to an internal error
     */
    @Nullable
    public ZenMode addCustomMode(String name) {
    public ZenMode addCustomManualMode(String name, @DrawableRes int iconResId) {
        AutomaticZenRule rule = new AutomaticZenRule.Builder(name,
                ZenModeConfig.toCustomManualConditionId())
                .setPackage(ZenModeConfig.getCustomManualConditionProvider().getPackageName())
                .setType(AutomaticZenRule.TYPE_OTHER)
                .setOwner(ZenModeConfig.getCustomManualConditionProvider())
                .setIconResId(iconResId)
                .setManualInvocationAllowed(true)
                .build();