blob: 19414550f8aa74998d59ffa39fc881909abf83d6 [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 Songcda96a52018-10-18 15:05:45 -070019import com.android.launcher3.icons.BitmapInfo;
20
Sunny Goyal3fe4a142016-12-15 17:40:07 -080021/**
22 * Represents an ItemInfo which also holds an icon.
23 */
24public abstract class ItemInfoWithIcon extends ItemInfo {
25
Samuel Fufa866ff002019-08-09 16:16:06 -070026 public static final String TAG = "ItemInfoDebug";
27
Sunny Goyal3fe4a142016-12-15 17:40:07 -080028 /**
Sunny Goyal3808a692019-10-25 13:41:28 -070029 * The bitmap for the application icon
Sunny Goyal3fe4a142016-12-15 17:40:07 -080030 */
Sunny Goyal3808a692019-10-25 13:41:28 -070031 public BitmapInfo bitmap = BitmapInfo.LOW_RES_INFO;
Sunny Goyal179249d2017-12-19 16:49:24 -080032
33 /**
Sunny Goyal076839c2017-10-30 13:52:20 -070034 * Indicates that the icon is disabled due to safe mode restrictions.
35 */
36 public static final int FLAG_DISABLED_SAFEMODE = 1 << 0;
37
38 /**
39 * Indicates that the icon is disabled as the app is not available.
40 */
41 public static final int FLAG_DISABLED_NOT_AVAILABLE = 1 << 1;
42
43 /**
44 * Indicates that the icon is disabled as the app is suspended
45 */
46 public static final int FLAG_DISABLED_SUSPENDED = 1 << 2;
47
48 /**
49 * Indicates that the icon is disabled as the user is in quiet mode.
50 */
51 public static final int FLAG_DISABLED_QUIET_USER = 1 << 3;
52
53 /**
54 * Indicates that the icon is disabled as the publisher has disabled the actual shortcut.
55 */
56 public static final int FLAG_DISABLED_BY_PUBLISHER = 1 << 4;
57
58 /**
59 * Indicates that the icon is disabled as the user partition is currently locked.
60 */
61 public static final int FLAG_DISABLED_LOCKED_USER = 1 << 5;
62
63 public static final int FLAG_DISABLED_MASK = FLAG_DISABLED_SAFEMODE |
64 FLAG_DISABLED_NOT_AVAILABLE | FLAG_DISABLED_SUSPENDED |
65 FLAG_DISABLED_QUIET_USER | FLAG_DISABLED_BY_PUBLISHER | FLAG_DISABLED_LOCKED_USER;
66
Sunny Goyal076839c2017-10-30 13:52:20 -070067 /**
68 * The item points to a system app.
69 */
70 public static final int FLAG_SYSTEM_YES = 1 << 6;
71
72 /**
73 * The item points to a non system app.
74 */
75 public static final int FLAG_SYSTEM_NO = 1 << 7;
76
77 public static final int FLAG_SYSTEM_MASK = FLAG_SYSTEM_YES | FLAG_SYSTEM_NO;
78
79 /**
Sunny Goyalea529082017-10-31 13:33:03 -070080 * Flag indicating that the icon is an {@link android.graphics.drawable.AdaptiveIconDrawable}
81 * that can be optimized in various way.
82 */
83 public static final int FLAG_ADAPTIVE_ICON = 1 << 8;
84
85 /**
Mario Bertschlerd39148a2018-04-05 22:44:42 +020086 * Flag indicating that the icon is badged.
87 */
88 public static final int FLAG_ICON_BADGED = 1 << 9;
89
90 /**
Sunny Goyal076839c2017-10-30 13:52:20 -070091 * Status associated with the system state of the underlying item. This is calculated every
92 * time a new info is created and not persisted on the disk.
93 */
94 public int runtimeStatusFlags = 0;
95
Sunny Goyal3fe4a142016-12-15 17:40:07 -080096 protected ItemInfoWithIcon() { }
97
Mario Bertschler0fc6f682017-02-17 12:16:13 -080098 protected ItemInfoWithIcon(ItemInfoWithIcon info) {
Sunny Goyal3fe4a142016-12-15 17:40:07 -080099 super(info);
Sunny Goyal3808a692019-10-25 13:41:28 -0700100 bitmap = info.bitmap;
Sunny Goyal076839c2017-10-30 13:52:20 -0700101 runtimeStatusFlags = info.runtimeStatusFlags;
102 }
103
104 @Override
105 public boolean isDisabled() {
106 return (runtimeStatusFlags & FLAG_DISABLED_MASK) != 0;
Sunny Goyal3fe4a142016-12-15 17:40:07 -0800107 }
Sunny Goyal2b787e52018-08-20 15:01:03 -0700108
109 /**
110 * Indicates whether we're using a low res icon
111 */
112 public boolean usingLowResIcon() {
Sunny Goyal3808a692019-10-25 13:41:28 -0700113 return bitmap.isLowRes();
Hyunyoung Songcda96a52018-10-18 15:05:45 -0700114 }
115
Samuel Fufa866ff002019-08-09 16:16:06 -0700116 /**
117 * @return a copy of this
118 */
119 public abstract ItemInfoWithIcon clone();
Sunny Goyal3fe4a142016-12-15 17:40:07 -0800120}