blob: 6d453c9b38972575a2e5442d9a7b12227a3384ed [file] [log] [blame]
Sunny Goyal3fe4a142016-12-15 17:40:07 -08001/*
2 * Copyright (C) 2017 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
17package com.android.launcher3;
18
Hyunyoung Song48cb7bc2018-09-25 17:03:34 -070019import static com.android.launcher3.icons.BitmapInfo.LOW_RES_ICON;
Sunny Goyal2b787e52018-08-20 15:01:03 -070020
Sunny Goyal3fe4a142016-12-15 17:40:07 -080021import android.graphics.Bitmap;
22
23/**
24 * Represents an ItemInfo which also holds an icon.
25 */
26public abstract class ItemInfoWithIcon extends ItemInfo {
27
28 /**
29 * A bitmap version of the application icon.
30 */
31 public Bitmap iconBitmap;
32
33 /**
Sunny Goyal179249d2017-12-19 16:49:24 -080034 * Dominant color in the {@link #iconBitmap}.
35 */
36 public int iconColor;
37
38 /**
Sunny Goyal076839c2017-10-30 13:52:20 -070039 * Indicates that the icon is disabled due to safe mode restrictions.
40 */
41 public static final int FLAG_DISABLED_SAFEMODE = 1 << 0;
42
43 /**
44 * Indicates that the icon is disabled as the app is not available.
45 */
46 public static final int FLAG_DISABLED_NOT_AVAILABLE = 1 << 1;
47
48 /**
49 * Indicates that the icon is disabled as the app is suspended
50 */
51 public static final int FLAG_DISABLED_SUSPENDED = 1 << 2;
52
53 /**
54 * Indicates that the icon is disabled as the user is in quiet mode.
55 */
56 public static final int FLAG_DISABLED_QUIET_USER = 1 << 3;
57
58 /**
59 * Indicates that the icon is disabled as the publisher has disabled the actual shortcut.
60 */
61 public static final int FLAG_DISABLED_BY_PUBLISHER = 1 << 4;
62
63 /**
64 * Indicates that the icon is disabled as the user partition is currently locked.
65 */
66 public static final int FLAG_DISABLED_LOCKED_USER = 1 << 5;
67
68 public static final int FLAG_DISABLED_MASK = FLAG_DISABLED_SAFEMODE |
69 FLAG_DISABLED_NOT_AVAILABLE | FLAG_DISABLED_SUSPENDED |
70 FLAG_DISABLED_QUIET_USER | FLAG_DISABLED_BY_PUBLISHER | FLAG_DISABLED_LOCKED_USER;
71
Sunny Goyal076839c2017-10-30 13:52:20 -070072 /**
73 * The item points to a system app.
74 */
75 public static final int FLAG_SYSTEM_YES = 1 << 6;
76
77 /**
78 * The item points to a non system app.
79 */
80 public static final int FLAG_SYSTEM_NO = 1 << 7;
81
82 public static final int FLAG_SYSTEM_MASK = FLAG_SYSTEM_YES | FLAG_SYSTEM_NO;
83
84 /**
Sunny Goyalea529082017-10-31 13:33:03 -070085 * Flag indicating that the icon is an {@link android.graphics.drawable.AdaptiveIconDrawable}
86 * that can be optimized in various way.
87 */
88 public static final int FLAG_ADAPTIVE_ICON = 1 << 8;
89
90 /**
Mario Bertschlerd39148a2018-04-05 22:44:42 +020091 * Flag indicating that the icon is badged.
92 */
93 public static final int FLAG_ICON_BADGED = 1 << 9;
94
95 /**
Sunny Goyal076839c2017-10-30 13:52:20 -070096 * Status associated with the system state of the underlying item. This is calculated every
97 * time a new info is created and not persisted on the disk.
98 */
99 public int runtimeStatusFlags = 0;
100
Sunny Goyal3fe4a142016-12-15 17:40:07 -0800101 protected ItemInfoWithIcon() { }
102
Mario Bertschler0fc6f682017-02-17 12:16:13 -0800103 protected ItemInfoWithIcon(ItemInfoWithIcon info) {
Sunny Goyal3fe4a142016-12-15 17:40:07 -0800104 super(info);
Mario Bertschler0fc6f682017-02-17 12:16:13 -0800105 iconBitmap = info.iconBitmap;
Sunny Goyal179249d2017-12-19 16:49:24 -0800106 iconColor = info.iconColor;
Sunny Goyal076839c2017-10-30 13:52:20 -0700107 runtimeStatusFlags = info.runtimeStatusFlags;
108 }
109
110 @Override
111 public boolean isDisabled() {
112 return (runtimeStatusFlags & FLAG_DISABLED_MASK) != 0;
Sunny Goyal3fe4a142016-12-15 17:40:07 -0800113 }
Sunny Goyal2b787e52018-08-20 15:01:03 -0700114
115 /**
116 * Indicates whether we're using a low res icon
117 */
118 public boolean usingLowResIcon() {
119 return iconBitmap == LOW_RES_ICON;
120 }
Sunny Goyal3fe4a142016-12-15 17:40:07 -0800121}