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

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

Provide a method to get the default icon for a type

Bug: 326442408
Test: atest ZenIconLoaderTest
Flag: android.app.modes_ui
Change-Id: I9cdd656b4c5c65f22dd62d6b95964bc6286b4603
parent ec7a3088
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import static com.google.common.util.concurrent.Futures.immediateFuture;

import static java.util.Objects.requireNonNull;

import android.annotation.DrawableRes;
import android.annotation.Nullable;
import android.app.AutomaticZenRule;
import android.content.Context;
@@ -120,7 +121,14 @@ public class ZenIconLoader {
    }

    private static Drawable getFallbackIcon(Context context, int ruleType) {
        int iconResIdFromType = switch (ruleType) {
        int iconResIdFromType = getIconResourceIdFromType(ruleType);
        return requireNonNull(context.getDrawable(iconResIdFromType));
    }

    /** Return the default icon resource associated to a {@link AutomaticZenRule.Type} */
    @DrawableRes
    public static int getIconResourceIdFromType(@AutomaticZenRule.Type int ruleType) {
        return switch (ruleType) {
            case AutomaticZenRule.TYPE_UNKNOWN ->
                    com.android.internal.R.drawable.ic_zen_mode_type_unknown;
            case AutomaticZenRule.TYPE_OTHER ->
@@ -141,7 +149,6 @@ public class ZenIconLoader {
                    com.android.internal.R.drawable.ic_zen_mode_type_managed;
            default -> com.android.internal.R.drawable.ic_zen_mode_type_unknown;
        };
        return requireNonNull(context.getDrawable(iconResIdFromType));
    }

    private static Drawable getMonochromeIconIfPresent(Drawable icon) {