1 /*
2 * Copyright (C) 2024 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 package com.android.settingslib.notification.modes;
18
19 import static com.google.common.base.Preconditions.checkArgument;
20
21 import android.graphics.drawable.Drawable;
22
23 import androidx.annotation.DrawableRes;
24 import androidx.annotation.NonNull;
25 import androidx.annotation.Nullable;
26
27 /**
28 * Icon of a Zen Mode, already loaded from the owner's resources (if specified) or from a default.
29 */
ZenIcon(@onNull Key key, @NonNull Drawable drawable)30 public record ZenIcon(@NonNull Key key, @NonNull Drawable drawable) {
31
32 /**
33 * Key of a Zen Mode Icon.
34 *
35 * <p>{@link #resPackage()} will be null if the resource belongs to the system, and thus can
36 * be loaded with any {@code Context}.
37 */
38 public record Key(@Nullable String resPackage, @DrawableRes int resId) {
39
40 public Key {
41 checkArgument(resId != 0, "Resource id must be valid");
42 }
43
44 static Key forSystemResource(@DrawableRes int resId) {
45 return new Key(null, resId);
46 }
47 }
48 }
49