blob: fea4ddae8e53687b9a60ffadeabd0e281db0c64b [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 /**
32 * Indicates whether we're using a low res icon
33 */
34 public boolean usingLowResIcon;
35
Sunny Goyal076839c2017-10-30 13:52:20 -070036 /**
37 * Indicates that the icon is disabled due to safe mode restrictions.
38 */
39 public static final int FLAG_DISABLED_SAFEMODE = 1 << 0;
40
41 /**
42 * Indicates that the icon is disabled as the app is not available.
43 */
44 public static final int FLAG_DISABLED_NOT_AVAILABLE = 1 << 1;
45
46 /**
47 * Indicates that the icon is disabled as the app is suspended
48 */
49 public static final int FLAG_DISABLED_SUSPENDED = 1 << 2;
50
51 /**
52 * Indicates that the icon is disabled as the user is in quiet mode.
53 */
54 public static final int FLAG_DISABLED_QUIET_USER = 1 << 3;
55
56 /**
57 * Indicates that the icon is disabled as the publisher has disabled the actual shortcut.
58 */
59 public static final int FLAG_DISABLED_BY_PUBLISHER = 1 << 4;
60
61 /**
62 * Indicates that the icon is disabled as the user partition is currently locked.
63 */
64 public static final int FLAG_DISABLED_LOCKED_USER = 1 << 5;
65
66 public static final int FLAG_DISABLED_MASK = FLAG_DISABLED_SAFEMODE |
67 FLAG_DISABLED_NOT_AVAILABLE | FLAG_DISABLED_SUSPENDED |
68 FLAG_DISABLED_QUIET_USER | FLAG_DISABLED_BY_PUBLISHER | FLAG_DISABLED_LOCKED_USER;
69
Sunny Goyal076839c2017-10-30 13:52:20 -070070 /**
71 * The item points to a system app.
72 */
73 public static final int FLAG_SYSTEM_YES = 1 << 6;
74
75 /**
76 * The item points to a non system app.
77 */
78 public static final int FLAG_SYSTEM_NO = 1 << 7;
79
80 public static final int FLAG_SYSTEM_MASK = FLAG_SYSTEM_YES | FLAG_SYSTEM_NO;
81
82 /**
Sunny Goyalea529082017-10-31 13:33:03 -070083 * Flag indicating that the icon is an {@link android.graphics.drawable.AdaptiveIconDrawable}
84 * that can be optimized in various way.
85 */
86 public static final int FLAG_ADAPTIVE_ICON = 1 << 8;
87
88 /**
Sunny Goyal076839c2017-10-30 13:52:20 -070089 * Status associated with the system state of the underlying item. This is calculated every
90 * time a new info is created and not persisted on the disk.
91 */
92 public int runtimeStatusFlags = 0;
93
Sunny Goyal3fe4a142016-12-15 17:40:07 -080094 protected ItemInfoWithIcon() { }
95
Mario Bertschler0fc6f682017-02-17 12:16:13 -080096 protected ItemInfoWithIcon(ItemInfoWithIcon info) {
Sunny Goyal3fe4a142016-12-15 17:40:07 -080097 super(info);
Mario Bertschler0fc6f682017-02-17 12:16:13 -080098 iconBitmap = info.iconBitmap;
99 usingLowResIcon = info.usingLowResIcon;
Sunny Goyal076839c2017-10-30 13:52:20 -0700100 runtimeStatusFlags = info.runtimeStatusFlags;
101 }
102
103 @Override
104 public boolean isDisabled() {
105 return (runtimeStatusFlags & FLAG_DISABLED_MASK) != 0;
Sunny Goyal3fe4a142016-12-15 17:40:07 -0800106 }
107}