blob: 1c4e88b5b0b456cdf7332c076754b90eb005504d [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
70
71 /**
72 * The item points to a system app.
73 */
74 public static final int FLAG_SYSTEM_YES = 1 << 6;
75
76 /**
77 * The item points to a non system app.
78 */
79 public static final int FLAG_SYSTEM_NO = 1 << 7;
80
81 public static final int FLAG_SYSTEM_MASK = FLAG_SYSTEM_YES | FLAG_SYSTEM_NO;
82
83 /**
84 * Status associated with the system state of the underlying item. This is calculated every
85 * time a new info is created and not persisted on the disk.
86 */
87 public int runtimeStatusFlags = 0;
88
Sunny Goyal3fe4a142016-12-15 17:40:07 -080089 protected ItemInfoWithIcon() { }
90
Mario Bertschler0fc6f682017-02-17 12:16:13 -080091 protected ItemInfoWithIcon(ItemInfoWithIcon info) {
Sunny Goyal3fe4a142016-12-15 17:40:07 -080092 super(info);
Mario Bertschler0fc6f682017-02-17 12:16:13 -080093 iconBitmap = info.iconBitmap;
94 usingLowResIcon = info.usingLowResIcon;
Sunny Goyal076839c2017-10-30 13:52:20 -070095 runtimeStatusFlags = info.runtimeStatusFlags;
96 }
97
98 @Override
99 public boolean isDisabled() {
100 return (runtimeStatusFlags & FLAG_DISABLED_MASK) != 0;
Sunny Goyal3fe4a142016-12-15 17:40:07 -0800101 }
102}