Sunny Goyal | 3fe4a14 | 2016-12-15 17:40:07 -0800 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package com.android.launcher3; |
| 18 | |
| 19 | import android.graphics.Bitmap; |
| 20 | |
| 21 | /** |
| 22 | * Represents an ItemInfo which also holds an icon. |
| 23 | */ |
| 24 | public 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 Goyal | 076839c | 2017-10-30 13:52:20 -0700 | [diff] [blame] | 36 | /** |
| 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 Goyal | 076839c | 2017-10-30 13:52:20 -0700 | [diff] [blame] | 70 | /** |
| 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 Goyal | ea52908 | 2017-10-31 13:33:03 -0700 | [diff] [blame^] | 83 | * 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 Goyal | 076839c | 2017-10-30 13:52:20 -0700 | [diff] [blame] | 89 | * 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 Goyal | 3fe4a14 | 2016-12-15 17:40:07 -0800 | [diff] [blame] | 94 | protected ItemInfoWithIcon() { } |
| 95 | |
Mario Bertschler | 0fc6f68 | 2017-02-17 12:16:13 -0800 | [diff] [blame] | 96 | protected ItemInfoWithIcon(ItemInfoWithIcon info) { |
Sunny Goyal | 3fe4a14 | 2016-12-15 17:40:07 -0800 | [diff] [blame] | 97 | super(info); |
Mario Bertschler | 0fc6f68 | 2017-02-17 12:16:13 -0800 | [diff] [blame] | 98 | iconBitmap = info.iconBitmap; |
| 99 | usingLowResIcon = info.usingLowResIcon; |
Sunny Goyal | 076839c | 2017-10-30 13:52:20 -0700 | [diff] [blame] | 100 | runtimeStatusFlags = info.runtimeStatusFlags; |
| 101 | } |
| 102 | |
| 103 | @Override |
| 104 | public boolean isDisabled() { |
| 105 | return (runtimeStatusFlags & FLAG_DISABLED_MASK) != 0; |
Sunny Goyal | 3fe4a14 | 2016-12-15 17:40:07 -0800 | [diff] [blame] | 106 | } |
| 107 | } |