blob: bf985c38dab784796a71898538d081904c21b764 [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
19import android.graphics.Bitmap;
20
21/**
22 * Represents an ItemInfo which also holds an icon.
23 */
24public abstract class ItemInfoWithIcon extends ItemInfo {
25
26 /**
27 * A bitmap version of the application icon.
28 */
29 public Bitmap iconBitmap;
30
31 /**
Sunny Goyal179249d2017-12-19 16:49:24 -080032 * Dominant color in the {@link #iconBitmap}.
33 */
34 public int iconColor;
35
36 /**
Sunny Goyal3fe4a142016-12-15 17:40:07 -080037 * Indicates whether we're using a low res icon
38 */
39 public boolean usingLowResIcon;
40
Sunny Goyal076839c2017-10-30 13:52:20 -070041 /**
42 * Indicates that the icon is disabled due to safe mode restrictions.
43 */
44 public static final int FLAG_DISABLED_SAFEMODE = 1 << 0;
45
46 /**
47 * Indicates that the icon is disabled as the app is not available.
48 */
49 public static final int FLAG_DISABLED_NOT_AVAILABLE = 1 << 1;
50
51 /**
52 * Indicates that the icon is disabled as the app is suspended
53 */
54 public static final int FLAG_DISABLED_SUSPENDED = 1 << 2;
55
56 /**
57 * Indicates that the icon is disabled as the user is in quiet mode.
58 */
59 public static final int FLAG_DISABLED_QUIET_USER = 1 << 3;
60
61 /**
62 * Indicates that the icon is disabled as the publisher has disabled the actual shortcut.
63 */
64 public static final int FLAG_DISABLED_BY_PUBLISHER = 1 << 4;
65
66 /**
67 * Indicates that the icon is disabled as the user partition is currently locked.
68 */
69 public static final int FLAG_DISABLED_LOCKED_USER = 1 << 5;
70
71 public static final int FLAG_DISABLED_MASK = FLAG_DISABLED_SAFEMODE |
72 FLAG_DISABLED_NOT_AVAILABLE | FLAG_DISABLED_SUSPENDED |
73 FLAG_DISABLED_QUIET_USER | FLAG_DISABLED_BY_PUBLISHER | FLAG_DISABLED_LOCKED_USER;
74
Sunny Goyal076839c2017-10-30 13:52:20 -070075 /**
76 * The item points to a system app.
77 */
78 public static final int FLAG_SYSTEM_YES = 1 << 6;
79
80 /**
81 * The item points to a non system app.
82 */
83 public static final int FLAG_SYSTEM_NO = 1 << 7;
84
85 public static final int FLAG_SYSTEM_MASK = FLAG_SYSTEM_YES | FLAG_SYSTEM_NO;
86
87 /**
Sunny Goyalea529082017-10-31 13:33:03 -070088 * Flag indicating that the icon is an {@link android.graphics.drawable.AdaptiveIconDrawable}
89 * that can be optimized in various way.
90 */
91 public static final int FLAG_ADAPTIVE_ICON = 1 << 8;
92
93 /**
Sunny Goyal076839c2017-10-30 13:52:20 -070094 * Status associated with the system state of the underlying item. This is calculated every
95 * time a new info is created and not persisted on the disk.
96 */
97 public int runtimeStatusFlags = 0;
98
Sunny Goyal3fe4a142016-12-15 17:40:07 -080099 protected ItemInfoWithIcon() { }
100
Mario Bertschler0fc6f682017-02-17 12:16:13 -0800101 protected ItemInfoWithIcon(ItemInfoWithIcon info) {
Sunny Goyal3fe4a142016-12-15 17:40:07 -0800102 super(info);
Mario Bertschler0fc6f682017-02-17 12:16:13 -0800103 iconBitmap = info.iconBitmap;
Sunny Goyal179249d2017-12-19 16:49:24 -0800104 iconColor = info.iconColor;
Mario Bertschler0fc6f682017-02-17 12:16:13 -0800105 usingLowResIcon = info.usingLowResIcon;
Sunny Goyal076839c2017-10-30 13:52:20 -0700106 runtimeStatusFlags = info.runtimeStatusFlags;
107 }
108
109 @Override
110 public boolean isDisabled() {
111 return (runtimeStatusFlags & FLAG_DISABLED_MASK) != 0;
Sunny Goyal3fe4a142016-12-15 17:40:07 -0800112 }
113}